summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/Array.java2
-rw-r--r--sources/scala/Iterator.scala6
-rw-r--r--sources/scalac/ast/parser/Scanner.java36
-rw-r--r--sources/scalac/ast/parser/Scanner.scala7
-rw-r--r--sources/scalac/typechecker/Analyzer.java26
5 files changed, 48 insertions, 29 deletions
diff --git a/sources/scala/Array.java b/sources/scala/Array.java
index 53ee7c242c..0ff31e9acb 100644
--- a/sources/scala/Array.java
+++ b/sources/scala/Array.java
@@ -11,7 +11,7 @@
package scala;
-/** @meta class [?T] extends scala.Function1[scala.Int, ?T];
+/** @meta class [+ ?T] extends scala.Function1[scala.Int, ?T];
*/
public abstract class Array
extends scala.Object
diff --git a/sources/scala/Iterator.scala b/sources/scala/Iterator.scala
index 1d5e505ee7..1f7a437b5f 100644
--- a/sources/scala/Iterator.scala
+++ b/sources/scala/Iterator.scala
@@ -34,12 +34,12 @@ object Iterator {
else error("next on empty iterator");
}
- def range(lo: Int, hi: Int) = new Iterator[Int] {
+ def range(lo: Int, end: Int) = new Iterator[Int] {
private var i = 0;
def hasNext: Boolean =
- i <= hi;
+ i < end;
def next: Int =
- if (i <= hi) { i = i + 1 ; i - 1 }
+ if (i < end) { i = i + 1 ; i - 1 }
else error("next on empty iterator");
}
diff --git a/sources/scalac/ast/parser/Scanner.java b/sources/scalac/ast/parser/Scanner.java
index 46b00d98d6..7d5910588b 100644
--- a/sources/scalac/ast/parser/Scanner.java
+++ b/sources/scalac/ast/parser/Scanner.java
@@ -226,6 +226,16 @@ public class Scanner extends TokenData {
nextch();
getOperatorRest(index);
return;
+ case '\\':
+ nextch();
+ if (ch == '"') {
+ getStringLit();
+ token = IDENTIFIER;
+ } else {
+ syntaxError(pos, "illegal character");
+ }
+ return;
+
case '/':
nextch();
if (!skipComment()) {
@@ -250,17 +260,7 @@ public class Scanner extends TokenData {
getNumber(index, 10);
return;
case '\"':
- nextch();
- litlen = 0;
- while (ch != '\"' && ch != CR && ch != LF && ch != SU)
- getlitch();
- if (ch == '\"') {
- token = STRINGLIT;
- name = Name.fromSource(lit, 0, litlen);
- nextch();
- }
- else
- syntaxError("unclosed character literal");
+ getStringLit();
return;
case '\'':
nextch();
@@ -497,6 +497,20 @@ public class Scanner extends TokenData {
}
}
+ private void getStringLit() {
+ nextch();
+ litlen = 0;
+ while (ch != '\"' && ch != CR && ch != LF && ch != SU)
+ getlitch();
+ if (ch == '\"') {
+ token = STRINGLIT;
+ name = Name.fromSource(lit, 0, litlen);
+ nextch();
+ }
+ else
+ syntaxError("unclosed character literal");
+ }
+
/** returns true if argument corresponds to a keyword.
* Used in dtd2scala tool.
*/
diff --git a/sources/scalac/ast/parser/Scanner.scala b/sources/scalac/ast/parser/Scanner.scala
index 5181812b9c..f36eec7f82 100644
--- a/sources/scalac/ast/parser/Scanner.scala
+++ b/sources/scalac/ast/parser/Scanner.scala
@@ -202,11 +202,12 @@ class Scanner(unit: Unit) extends TokenData {
nextch();
getOperatorRest(index);
return;
- case `\\' =>
+ case '\\' =>
nextch();
- if (ch == '"')//"
+ if (ch == '"') { //"
getStringLit();
- else
+ token = IDENTIFIER;
+ } else
syntaxError(pos, "illegal character");
return;
case '/' =>
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index d4c0674a2e..64181df003 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -1400,15 +1400,19 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
break;
}
if ((mode & EXPRmode) != 0) {
- Symbol coerceMeth = tree.type.lookup(Names.coerce);
- if (coerceMeth != Symbol.NONE) {
- Type coerceType = checkAccessible(
- tree.pos, coerceMeth, tree.type.memberType(coerceMeth),
- tree);
- tree = make.Select(tree.pos, tree, Names.coerce)
- .setSymbol(coerceMeth)
- .setType(coerceType);
- return adapt(tree, mode, pt);
+ if (pt.symbol() == definitions.UNIT_CLASS) {
+ return gen.Block(new Tree[]{tree, gen.mkUnitLit(tree.pos)});
+ } else {
+ Symbol coerceMeth = tree.type.lookup(Names.coerce);
+ if (coerceMeth != Symbol.NONE) {
+ Type coerceType = checkAccessible(
+ tree.pos, coerceMeth, tree.type.memberType(coerceMeth),
+ tree);
+ tree = make.Select(tree.pos, tree, Names.coerce)
+ .setSymbol(coerceMeth)
+ .setType(coerceType);
+ return adapt(tree, mode, pt);
+ }
}
}
if ((mode & CONSTRmode) == 0) {
@@ -2068,7 +2072,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
pattype, definitions.BOOLEAN_TYPE());
Tree applyVisitor = transformVisitor(tree, pattype, restype);
if (!infer.isFullyDefined(restype))
- restype = applyVisitor.type;
+ restype = applyVisitor.type.deconst();
if (definitions.PARTIALFUNCTION_CLASS.isExternal())
// need to load tree for mixins
new SourceCompleter(global).complete(
@@ -2234,7 +2238,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
enterParams(vparams);
Tree.ValDef[] vparams1 = transform(vparams);
Tree body1 = transform(body, EXPRmode, restype);
- if (!infer.isFullyDefined(restype)) restype = body1.type;
+ if (!infer.isFullyDefined(restype)) restype = body1.type.deconst();
popContext();
return gen.mkFunction(
tree.pos, vparams1, body1, restype, context.owner);