summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-10-05 09:10:59 +0000
committerMartin Odersky <odersky@gmail.com>2005-10-05 09:10:59 +0000
commitadd8bf8d68f06468e9bd07f1a6cb4146dd5fd843 (patch)
treed557dddb4bc55d4da20e1237a0176e8d95d52555 /sources
parent85218bf8a66bc8807f57cf5225728ac9f748ca40 (diff)
downloadscala-add8bf8d68f06468e9bd07f1a6cb4146dd5fd843.tar.gz
scala-add8bf8d68f06468e9bd07f1a6cb4146dd5fd843.tar.bz2
scala-add8bf8d68f06468e9bd07f1a6cb4146dd5fd843.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rwxr-xr-xsources/scala/tools/nsc/ast/parser/Scanners.scala17
-rwxr-xr-xsources/scala/tools/nsc/symtab/Types.scala10
-rwxr-xr-xsources/scala/tools/nsc/symtab/classfile/ClassfileParser.scala2
-rwxr-xr-xsources/scala/tools/nsc/transform/Mixin.scala11
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Infer.scala6
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Typers.scala21
-rw-r--r--sources/scala/tools/nsc/util/CharArrayReader.scala5
-rw-r--r--sources/scala/tools/scalac/ast/parser/Scanner.scala3
8 files changed, 51 insertions, 24 deletions
diff --git a/sources/scala/tools/nsc/ast/parser/Scanners.scala b/sources/scala/tools/nsc/ast/parser/Scanners.scala
index 3cda4e3a83..31508fc1e5 100755
--- a/sources/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/sources/scala/tools/nsc/ast/parser/Scanners.scala
@@ -289,7 +289,10 @@ import scala.tools.nsc.util.CharArrayReader;
return;
case SU =>
if (!in.hasNext) token = EOF;
- else syntaxError("illegal character");
+ else {
+ syntaxError("illegal character");
+ in.next
+ }
return;
case _ =>
if (Character.isUnicodeIdentifierStart(in.ch)) {
@@ -448,7 +451,7 @@ import scala.tools.nsc.util.CharArrayReader;
private def getStringLit(delimiter: char): unit = {
in.next;
- while (in.ch != delimiter && in.ch != CR && in.ch != LF && in.ch != SU) {
+ while (in.ch != delimiter && (in.isUnicode || in.ch != CR && in.ch != LF && in.ch != SU)) {
getlitch();
}
if (in.ch == delimiter) {
@@ -505,10 +508,10 @@ import scala.tools.nsc.util.CharArrayReader;
* if one is present.
*/
protected def getFraction = {
+ token = DOUBLELIT;
while ('0' <= in.ch && in.ch <= '9') {
putChar(in.ch);
in.next;
- token = DOUBLELIT;
}
if (in.ch == 'e' || in.ch == 'E') {
val lookahead = in.copy;
@@ -607,11 +610,17 @@ import scala.tools.nsc.util.CharArrayReader;
val lookahead = in.copy;
lookahead.next;
lookahead.ch match {
- case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'd' | 'D' | 'e' | 'E' | 'f' | 'F' =>
+ case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' |
+ '8' | '9' | 'd' | 'D' | 'e' | 'E' | 'f' | 'F' =>
putChar(in.ch);
in.next;
return getFraction
case _ =>
+ if (!isIdentStart(lookahead.ch)) {
+ putChar(in.ch);
+ in.next;
+ return getFraction
+ }
}
}
if (base <= 10 &&
diff --git a/sources/scala/tools/nsc/symtab/Types.scala b/sources/scala/tools/nsc/symtab/Types.scala
index f326e58fd4..5bf8dd7c0f 100755
--- a/sources/scala/tools/nsc/symtab/Types.scala
+++ b/sources/scala/tools/nsc/symtab/Types.scala
@@ -362,17 +362,19 @@ import Flags._;
member = sym
} else if (members == null) {
if (member.name != sym.name ||
- member != sym && {
- if (self == null) self = this.narrow;
- !self.memberType(member).matches(self.memberType(sym))})
+ member != sym &&
+ (member.owner == sym.owner || {
+ if (self == null) self = this.narrow;
+ !self.memberType(member).matches(self.memberType(sym))}))
members = new Scope(List(member, sym));
} else {
var prevEntry = members lookupEntry sym.name;
while (prevEntry != null &&
!(prevEntry.sym == sym
||
+ prevEntry.sym.owner != sym.owner &&
!prevEntry.sym.hasFlag(PRIVATE) &&
- !entry.sym.hasFlag(PRIVATE) && {
+ !sym.hasFlag(PRIVATE) && {
if (self == null) self = this.narrow;
(self.memberType(prevEntry.sym) matches self.memberType(sym))}))
prevEntry = members lookupNextEntry prevEntry;
diff --git a/sources/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/sources/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index ff61c0cb9f..0173338df8 100755
--- a/sources/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/sources/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -247,6 +247,8 @@ abstract class ClassfileParser {
}
statics.setInfo(staticInfo);
staticModule.setInfo(statics.tpe);
+ staticModule.setFlag(JAVA);
+ staticModule.moduleClass.setFlag(JAVA);
in.bp = curbp;
val fieldCount = in.nextChar();
for (val i <- Iterator.range(0, fieldCount)) parseField();
diff --git a/sources/scala/tools/nsc/transform/Mixin.scala b/sources/scala/tools/nsc/transform/Mixin.scala
index 1c88f8c66c..7b6a1ed71f 100755
--- a/sources/scala/tools/nsc/transform/Mixin.scala
+++ b/sources/scala/tools/nsc/transform/Mixin.scala
@@ -201,6 +201,14 @@ abstract class Mixin extends InfoTransform {
} else {
EmptyTree
}
+ case Apply(tapp @ TypeApply(fn, List(arg)), List()) =>
+ if (arg.tpe.symbol.isImplClass) {
+ val ifacetpe = toInterface(arg.tpe);
+ arg.tpe = ifacetpe;
+ tapp.tpe = MethodType(List(), ifacetpe);
+ tree.tpe = ifacetpe
+ }
+ tree
case ValDef(_, _, _, _) if (currentOwner.isImplClass) =>
EmptyTree
case _ =>
@@ -363,9 +371,6 @@ abstract class Mixin extends InfoTransform {
Apply(Select(qual, lhs.symbol.setter(enclInterface)) setPos lhs.pos, List(rhs))
}
}
- case TypeApply(fn, List(arg)) =>
- if (arg.tpe.symbol.isImplClass) arg.tpe = toInterface(arg.tpe);
- tree
case _ =>
tree
}
diff --git a/sources/scala/tools/nsc/typechecker/Infer.scala b/sources/scala/tools/nsc/typechecker/Infer.scala
index 71ebf56512..fc45a72425 100755
--- a/sources/scala/tools/nsc/typechecker/Infer.scala
+++ b/sources/scala/tools/nsc/typechecker/Infer.scala
@@ -365,8 +365,10 @@ package scala.tools.nsc.typechecker;
try {
val uninstantiated = new ListBuffer[Symbol];
val targs = methTypeArgs(undetparams, formals, restpe, argtpes, pt, uninstantiated);
- isWithinBounds(undetparams, targs) &&
- exprTypeArgs(uninstantiated.toList, restpe.subst(undetparams, targs), pt) != null
+ val result =
+ exprTypeArgs(uninstantiated.toList, restpe.subst(undetparams, targs), pt) != null &&
+ isWithinBounds(undetparams, targs);
+ result
} catch {
case ex: NoInstance => false
}
diff --git a/sources/scala/tools/nsc/typechecker/Typers.scala b/sources/scala/tools/nsc/typechecker/Typers.scala
index b4a585ed65..d53bd9049f 100755
--- a/sources/scala/tools/nsc/typechecker/Typers.scala
+++ b/sources/scala/tools/nsc/typechecker/Typers.scala
@@ -1295,7 +1295,7 @@ import collection.mutable.HashMap;
if (name == nme.WILDCARD && (mode & (PATTERNmode | FUNmode)) == PATTERNmode)
tree setType pt
else
- typedIdent(name);
+ typedIdent(name)
// todo: try with case Literal(Constant(()))
case Literal(value) =>
@@ -1321,17 +1321,20 @@ import collection.mutable.HashMap;
}
case AppliedTypeTree(tpt, args) =>
- val tpt1 = typed(tpt, mode | FUNmode | TAPPmode, WildcardType);
- val tparams = tpt1.tpe.symbol.typeParams;
+ val tpt1 = typed1(tpt, mode | FUNmode | TAPPmode, WildcardType);
+ val tparams = tpt1.symbol.typeParams;
val args1 = List.mapConserve(args)(typedType);
- if (tpt1.tpe.isError)
+ if (tpt1.tpe.isError) {
setError(tree)
- else if (tparams.length == args1.length)
- TypeTree() setPos tree.pos setType appliedType(tpt1.tpe, args1 map (.tpe))
- else if (tparams.length == 0)
+ } else if (tparams.length == args1.length) {
+ val argtypes = args1 map (.tpe);
+ val owntype = if (tpt1.symbol.isClass) appliedType(tpt1.tpe, argtypes)
+ else tpt1.tpe.subst(tparams, argtypes);
+ TypeTree() setPos tree.pos setType owntype
+ } else if (tparams.length == 0) {
errorTree(tree, "" + tpt1.tpe + " does not take type parameters")
- else {
- System.out.println(tpt1.tpe.symbol.rawInfo);//debug
+ } else {
+ System.out.println("" + tpt1 + ":" + tpt1.symbol + ":" + tpt1.symbol.info);//debug
errorTree(tree, "wrong number of type arguments for " + tpt1.tpe + ", should be " + tparams.length)
}
}
diff --git a/sources/scala/tools/nsc/util/CharArrayReader.scala b/sources/scala/tools/nsc/util/CharArrayReader.scala
index 465a2e08fa..cf7e66a2ff 100644
--- a/sources/scala/tools/nsc/util/CharArrayReader.scala
+++ b/sources/scala/tools/nsc/util/CharArrayReader.scala
@@ -23,6 +23,7 @@ class CharArrayReader(buf: Array[char], start: int, startline: int, startcol: in
var bp = start;
var cline: int = _;
var ccol: int = _;
+ var isUnicode: boolean = _;
private var nextline = startline;
private var nextcol = startcol;
@@ -32,6 +33,7 @@ class CharArrayReader(buf: Array[char], start: int, startline: int, startcol: in
cline = nextline;
ccol = nextcol;
ch = buf(bp);
+ isUnicode = false;
bp = bp + 1;
ch match {
case '\t' =>
@@ -64,7 +66,8 @@ class CharArrayReader(buf: Array[char], start: int, startline: int, startcol: in
bp = bp + 1; nextcol = nextcol + 1;
} while (buf(bp) == 'u');
val code = udigit << 12 | udigit << 8 | udigit << 4 | udigit;
- ch = code.asInstanceOf[char]
+ ch = code.asInstanceOf[char];
+ isUnicode = true
}
case _ =>
nextcol = nextcol + 1
diff --git a/sources/scala/tools/scalac/ast/parser/Scanner.scala b/sources/scala/tools/scalac/ast/parser/Scanner.scala
index f9240de01d..43d7710926 100644
--- a/sources/scala/tools/scalac/ast/parser/Scanner.scala
+++ b/sources/scala/tools/scalac/ast/parser/Scanner.scala
@@ -442,6 +442,7 @@ class Scanner(_unit: CompilationUnit) extends TokenData {
token = EOF;
else
syntaxError("illegal character");
+ nextch();
return;
case _ =>
@@ -452,8 +453,8 @@ class Scanner(_unit: CompilationUnit) extends TokenData {
putChar(ch);
getOperatorRest;
} else {
- nextch();
syntaxError("illegal character");
+ nextch();
};
return;
}