summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-10-03 13:42:39 +0000
committerMartin Odersky <odersky@gmail.com>2005-10-03 13:42:39 +0000
commit2994973970bcba6ff90d7788e79f2042cc11deaf (patch)
treeb90fbfc9d5b12b01f2815edabb2f0eeb17655a94 /sources
parent159a3633b593bf2b0a10f4f4e218489b2bba03bc (diff)
downloadscala-2994973970bcba6ff90d7788e79f2042cc11deaf.tar.gz
scala-2994973970bcba6ff90d7788e79f2042cc11deaf.tar.bz2
scala-2994973970bcba6ff90d7788e79f2042cc11deaf.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/Predef.scala4
-rwxr-xr-xsources/scala/tools/nsc/Global.scala9
-rw-r--r--sources/scala/tools/nsc/ast/TreePrinters.scala2
-rw-r--r--sources/scala/tools/nsc/ast/Trees.scala7
-rwxr-xr-xsources/scala/tools/nsc/ast/parser/Parsers.scala1
-rw-r--r--sources/scala/tools/nsc/backend/icode/TypeStacks.scala3
-rwxr-xr-xsources/scala/tools/nsc/symtab/Types.scala58
-rwxr-xr-xsources/scala/tools/nsc/transform/AddInterfaces.scala12
-rwxr-xr-xsources/scala/tools/nsc/transform/Constructors.scala7
-rwxr-xr-xsources/scala/tools/nsc/transform/Flatten.scala2
-rwxr-xr-xsources/scala/tools/nsc/transform/Mixin.scala20
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Infer.scala19
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Namers.scala12
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Typers.scala70
14 files changed, 154 insertions, 72 deletions
diff --git a/sources/scala/Predef.scala b/sources/scala/Predef.scala
index d3214f9fd3..f8e62aa12b 100644
--- a/sources/scala/Predef.scala
+++ b/sources/scala/Predef.scala
@@ -141,6 +141,8 @@ object Predef {
// views -------------------------------------------------------------
+ implicit def identity[a](x: a): a = x;
+
implicit def int2ordered(x: int): Ordered[int] = new Ordered[int] with Proxy {
def self: Any = x;
def compareTo [b >: int <% Ordered[b]](y: b): int = y match {
@@ -295,8 +297,6 @@ object Predef {
}
def view(x: String): Ordered[String] = string2ordered(x);
- implicit def ordered2ordered[a <: Ordered[a]](x: a): Ordered[a] = x;
-
implicit def array2seq[A](xs: Array[A]): Seq[A] = new Seq[A] {
def length = xs.length;
def elements = Iterator.fromArray(xs);
diff --git a/sources/scala/tools/nsc/Global.scala b/sources/scala/tools/nsc/Global.scala
index 0648bd3c4e..e82af18eb9 100755
--- a/sources/scala/tools/nsc/Global.scala
+++ b/sources/scala/tools/nsc/Global.scala
@@ -360,6 +360,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
symData -= sym.linkedSym;
writeSymblFile(sym, pickled)
}
+ resetPackageClass(sym.owner);
}
} else {
for (val Pair(sym, file) <- symSource.elements) {
@@ -396,6 +397,14 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
} catch {
case ex: IOException => error(ex.getMessage());
}
+
+ private def resetPackageClass(pclazz: Symbol): unit = {
+ assert(pclazz.isPackageClass, pclazz);
+ atPhase(firstPhase) {
+ pclazz.setInfo(atPhase(typerPhase)(pclazz.info))
+ }
+ if (!pclazz.isRoot) resetPackageClass(pclazz.owner);
+ }
}
def showDef(name: Name, module: boolean): unit = {
diff --git a/sources/scala/tools/nsc/ast/TreePrinters.scala b/sources/scala/tools/nsc/ast/TreePrinters.scala
index 509ad67d62..f8891766ed 100644
--- a/sources/scala/tools/nsc/ast/TreePrinters.scala
+++ b/sources/scala/tools/nsc/ast/TreePrinters.scala
@@ -260,7 +260,7 @@ abstract class TreePrinters {
def print(tree: Tree): unit =
printRaw(
- if (tree.isDef && tree.symbol != NoSymbol && !tree.symbol.isInitialized) {
+ if (tree.isDef && tree.symbol != NoSymbol) {
tree match {
case ClassDef(_, _, _, _, impl) => ClassDef(tree.symbol, impl)
case ModuleDef(_, _, impl) => ModuleDef(tree.symbol, impl)
diff --git a/sources/scala/tools/nsc/ast/Trees.scala b/sources/scala/tools/nsc/ast/Trees.scala
index 357aeae666..84e297afbf 100644
--- a/sources/scala/tools/nsc/ast/Trees.scala
+++ b/sources/scala/tools/nsc/ast/Trees.scala
@@ -50,7 +50,7 @@ import symtab.Flags._;
case _ => false
}
- def duplicate: Tree = duplicator transform this;
+ def duplicate: this.type = (duplicator transform this).asInstanceOf[this.type];
def copyAttrs(tree: Tree): this.type = {
pos = tree.pos;
@@ -1047,6 +1047,7 @@ import symtab.Flags._;
stats foreach (stat =>
if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(traverse(stat))
else traverse(stat));
+ def apply[T <: Tree](tree: T): T = { traverse(tree); tree }
def atOwner(owner: Symbol)(traverse: => unit): unit = {
val prevOwner = currentOwner;
@@ -1062,7 +1063,7 @@ import symtab.Flags._;
if (tree.tpe != null) tree.tpe = typeSubst(tree.tpe);
super.traverse(tree)
}
- def apply(tree: Tree): Tree = { val tree1 = tree.duplicate; traverse(tree1); tree1 }
+ override def apply[T <: Tree](tree: T): T = super.apply(tree.duplicate)
}
class TreeSymSubstituter(from: List[Symbol], to: List[Symbol]) extends Traverser {
@@ -1077,7 +1078,7 @@ import symtab.Flags._;
if (tree.hasSymbol) subst(from, to);
super.traverse(tree)
}
- def apply(tree: Tree): Tree = { val tree1 = tree.duplicate; traverse(tree1); tree1 }
+ override def apply[T <: Tree](tree: T): T = super.apply(tree.duplicate)
}
class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser {
diff --git a/sources/scala/tools/nsc/ast/parser/Parsers.scala b/sources/scala/tools/nsc/ast/parser/Parsers.scala
index 90b383f59c..59eaa4eb47 100755
--- a/sources/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/sources/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1746,6 +1746,7 @@ import Tokens._;
accept(LBRACE);
val t = makePackaging(pkg, topStatSeq());
accept(RBRACE);
+ if (in.token == SEMI) in.nextToken();
t
}
} else {
diff --git a/sources/scala/tools/nsc/backend/icode/TypeStacks.scala b/sources/scala/tools/nsc/backend/icode/TypeStacks.scala
index d155399483..5d2267f2ec 100644
--- a/sources/scala/tools/nsc/backend/icode/TypeStacks.scala
+++ b/sources/scala/tools/nsc/backend/icode/TypeStacks.scala
@@ -16,8 +16,9 @@ trait TypeStacks: ICodes {
/* This class simulates the type of the opperand
* stack of the ICode.
*/
+ type Rep = List[TypeKind];
+
class TypeStack {
- type Rep = List[TypeKind];
var types: Rep = Nil;
diff --git a/sources/scala/tools/nsc/symtab/Types.scala b/sources/scala/tools/nsc/symtab/Types.scala
index 2d89000518..f326e58fd4 100755
--- a/sources/scala/tools/nsc/symtab/Types.scala
+++ b/sources/scala/tools/nsc/symtab/Types.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.symtab;
import scala.tools.util.Position;
+import nsc.util.ListBuffer;
import Flags._;
/* A standard type pattern match:
@@ -551,7 +552,62 @@ import Flags._;
try {
if (util.Statistics.enabled) compoundClosureCount = compoundClosureCount + 1;
//System.out.println("computing closure of " + symbol.tpe + " " + parents);//DEBUG
- addClosure(symbol.tpe, glbArray(parents map (.closure)));
+ val buf = new ListBuffer[Type];
+ buf += symbol.tpe;
+ var clSize = 1;
+ val nparents = parents.length;
+ if (nparents != 0) {
+ val pclosure = new Array[Array[Type]](nparents);
+ val index = new Array[int](nparents);
+ var i = 0;
+ for (val p <- parents) {
+ pclosure(i) = p.closure;
+ index(i) = 0;
+ i = i + 1
+ }
+ val limit = pclosure(0).length;
+ while (index(0) != limit) {
+ var minSym: Symbol = pclosure(0)(index(0)).symbol;
+ i = 1;
+ while (i < nparents) {
+ if (pclosure(i)(index(i)).symbol isLess minSym)
+ minSym = pclosure(i)(index(i)).symbol;
+ i = i + 1
+ }
+ var minTypes: List[Type] = List();
+ i = 0;
+ while (i < nparents) {
+ val tp = pclosure(i)(index(i));
+ if (tp.symbol == minSym) {
+ if (!(minTypes exists (tp =:=))) minTypes = tp :: minTypes;
+ index(i) = index(i) + 1
+ }
+ i = i + 1
+ }
+ buf += intersectionType(minTypes);
+ clSize = clSize + 1;
+ }
+ i = 0;
+ while (i < nparents) {
+ assert(index(i) == pclosure(i).length);
+ i = i + 1
+ }
+ }
+ closureCache = new Array[Type](clSize);
+ buf.copyToArray(closureCache, 0);
+ //System.out.println("closureCache of " + symbol.tpe + " = " + List.fromArray(closureCache));//DEBUG
+ var j = 0;
+ while (j < clSize) {
+ closureCache(j) match {
+ case RefinedType(parents, decls) =>
+ assert(decls.isEmpty);
+ closureCache(j) = glb(parents)
+ case _ =>
+ }
+ j = j + 1
+ }
+ //System.out.println("closure of " + symbol.tpe + " = " + List.fromArray(closureCache));//DEBUG
+ closureCache
} catch {
case ex: MalformedClosure =>
throw new MalformedType(
diff --git a/sources/scala/tools/nsc/transform/AddInterfaces.scala b/sources/scala/tools/nsc/transform/AddInterfaces.scala
index 00fe47c7ca..2319346f8b 100755
--- a/sources/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/sources/scala/tools/nsc/transform/AddInterfaces.scala
@@ -45,7 +45,7 @@ abstract class AddInterfaces extends InfoTransform {
case None =>
atPhase(currentRun.erasurePhase) {
val implName = nme.implClassName(iface.name);
- var impl = if (iface.owner.isClass) iface.owner.info.decls.lookup(implName) else NoSymbol;
+ var impl = if (iface.owner.isClass) iface.owner.info.decl(implName) else NoSymbol;
if (impl == NoSymbol) {
impl = iface.cloneSymbolImpl(iface.owner);
impl.name = implName;
@@ -55,7 +55,7 @@ abstract class AddInterfaces extends InfoTransform {
impl.flags = iface.flags & ~(INTERFACE | lateINTERFACE);
impl setInfo new LazyImplClassType(iface);
implClassMap(iface) = impl;
- if (settings.debug.value) log("generating impl class " + impl);
+ if (settings.debug.value) log("generating impl class " + impl + " in " + iface.owner);//debug
impl
}
}
@@ -154,8 +154,7 @@ abstract class AddInterfaces extends InfoTransform {
implMethodMap.get(ifaceMethod) match {
case Some(implMethod) =>
tree.symbol = implMethod;
- new ChangeOwnerAndReturnTraverser(ifaceMethod, implMethod).traverse(tree);
- tree
+ new ChangeOwnerAndReturnTraverser(ifaceMethod, implMethod)(tree)
case None =>
throw new Error("implMethod missing for " + ifaceMethod)
}
@@ -169,9 +168,8 @@ abstract class AddInterfaces extends InfoTransform {
val templ1 = Template(templ.parents, templ.body map implMemberDef)
setPos templ.pos
setSymbol clazz.newLocalDummy(templ.pos);
- new ChangeOwnerTraverser(templ.symbol.owner, clazz).traverse(templ1);
- new ChangeOwnerTraverser(templ.symbol, templ1.symbol).traverse(templ1);
- templ1
+ new ChangeOwnerTraverser(templ.symbol.owner, clazz)(
+ new ChangeOwnerTraverser(templ.symbol, templ1.symbol)(templ1))
}
def implClassDefs(trees: List[Tree]): List[Tree] = {
diff --git a/sources/scala/tools/nsc/transform/Constructors.scala b/sources/scala/tools/nsc/transform/Constructors.scala
index 9d9230719c..38c260264f 100755
--- a/sources/scala/tools/nsc/transform/Constructors.scala
+++ b/sources/scala/tools/nsc/transform/Constructors.scala
@@ -62,10 +62,9 @@ abstract class Constructors extends Transform {
}
}
- def intoConstructor(oldowner: Symbol, tree: Tree) = {
- new ChangeOwnerTraverser(oldowner, constr.symbol).traverse(tree);
- intoConstructorTransformer.transform(tree)
- }
+ def intoConstructor(oldowner: Symbol, tree: Tree) =
+ intoConstructorTransformer.transform(
+ new ChangeOwnerTraverser(oldowner, constr.symbol)(tree));
def mkAssign(to: Symbol, from: Tree): Tree =
atPos(to.pos) {
diff --git a/sources/scala/tools/nsc/transform/Flatten.scala b/sources/scala/tools/nsc/transform/Flatten.scala
index 0af811cf3f..6632e50e09 100755
--- a/sources/scala/tools/nsc/transform/Flatten.scala
+++ b/sources/scala/tools/nsc/transform/Flatten.scala
@@ -40,7 +40,7 @@ abstract class Flatten extends InfoTransform {
var parents1 = parents;
val decls1 = new Scope();
if (clazz.isPackageClass) {
- atPhase(phase.next)(decls.toList foreach (decls1 enter))
+ atPhase(phase.next)(decls.toList foreach (decls1 enter));
} else {
val oldowner = clazz.owner;
atPhase(phase.next)(oldowner.info);
diff --git a/sources/scala/tools/nsc/transform/Mixin.scala b/sources/scala/tools/nsc/transform/Mixin.scala
index 6e70bfc31a..90e55f77de 100755
--- a/sources/scala/tools/nsc/transform/Mixin.scala
+++ b/sources/scala/tools/nsc/transform/Mixin.scala
@@ -237,17 +237,12 @@ abstract class Mixin extends InfoTransform {
case DefDef(mods, name, tparams, List(vparams), tpt, EmptyTree)
if (stat.symbol hasFlag SUPERACCESSOR) =>
assert(stat.symbol hasFlag MIXEDIN, stat);
- val rhs1 =
- postTransform {
- localTyper.typed {
- atPos(stat.pos) {
- Apply(Select(Super(clazz, nme.EMPTY.toTypeName), stat.symbol.alias),
- vparams map (vparam => Ident(vparam.symbol)))
- }
- }
- }
- //System.out.println("complete super acc " + stat.symbol + stat.symbol.locationString + " " + rhs1 + " " + stat.symbol.alias + stat.symbol.alias.locationString);//DEBUG
- copy.DefDef(stat, mods, name, tparams, List(vparams), tpt, localTyper.typed(rhs1))
+ val rhs0 =
+ Apply(Select(Super(clazz, nme.EMPTY.toTypeName), stat.symbol.alias),
+ vparams map (vparam => Ident(vparam.symbol)));
+ if (settings.debug.value) log("complete super acc " + stat.symbol + stat.symbol.locationString + " " + rhs0 + " " + stat.symbol.alias + stat.symbol.alias.locationString);//debug
+ val rhs1 = postTransform(localTyper.typed(atPos(stat.pos)(rhs0)));
+ copy.DefDef(stat, mods, name, tparams, List(vparams), tpt, rhs1)
case _ =>
stat
}
@@ -306,7 +301,8 @@ abstract class Mixin extends InfoTransform {
}
} else if (qual.isInstanceOf[Super] && (sym.owner hasFlag lateINTERFACE)) {
val sym1 = atPhase(phase.prev)(sym.overridingSymbol(sym.owner.implClass));
- assert(sym1 != NoSymbol, sym);
+ if (sym1 == NoSymbol)
+ assert(false, "" + sym + " " + sym.owner + " " + sym.owner.implClass + " " + sym.owner.owner + atPhase(phase.prev)(sym.owner.owner.info.decls.toList));//debug
localTyper.typed {
atPos(tree.pos) {
Apply(staticRef(sym1), gen.This(currentOwner.enclClass) :: args)
diff --git a/sources/scala/tools/nsc/typechecker/Infer.scala b/sources/scala/tools/nsc/typechecker/Infer.scala
index 1b0ca1097f..71ebf56512 100755
--- a/sources/scala/tools/nsc/typechecker/Infer.scala
+++ b/sources/scala/tools/nsc/typechecker/Infer.scala
@@ -56,6 +56,7 @@ package scala.tools.nsc.typechecker;
case WildcardType | NoType =>
throw new NoInstance("undetermined type");
case TypeVar(origin, constr) =>
+ assert(constr.inst != null);//debug
if (constr.inst != NoType) instantiate(constr.inst)
else throw new DeferredNoInstance(() =>
"no unique instantiation of type variable " + origin + " could be found");
@@ -108,23 +109,23 @@ package scala.tools.nsc.typechecker;
if (bound.symbol != AnyClass) {
tvar.constr.hibounds =
bound.subst(tparams, tvars) :: tvar.constr.hibounds;
- for (val tparam2 <- tparams)
- if (tparam2.info.bounds.lo =:= tparam.tpe)
- tvar.constr.hibounds =
- tparam2.tpe.subst(tparams, tvars) :: tvar.constr.hibounds;
}
+ for (val tparam2 <- tparams)
+ if (tparam2.info.bounds.lo =:= tparam.tpe)
+ tvar.constr.hibounds =
+ tparam2.tpe.subst(tparams, tvars) :: tvar.constr.hibounds;
} else {
if (bound.symbol != AllClass && bound.symbol != tparam) {
tvar.constr.lobounds =
bound.subst(tparams, tvars) :: tvar.constr.lobounds;
- for (val tparam2 <- tparams)
- if (tparam2.info.bounds.hi =:= tparam.tpe)
- tvar.constr.lobounds =
- tparam2.tpe.subst(tparams, tvars) :: tvar.constr.lobounds;
}
+ for (val tparam2 <- tparams)
+ if (tparam2.info.bounds.hi =:= tparam.tpe)
+ tvar.constr.lobounds =
+ tparam2.tpe.subst(tparams, tvars) :: tvar.constr.lobounds;
}
- tvar.constr.inst = if (up) glb(tvar.constr.hibounds) else lub(tvar.constr.lobounds)
}
+ tvar.constr.inst = if (up) glb(tvar.constr.hibounds) else lub(tvar.constr.lobounds)
}
}
for (val Pair(tvar, Pair(tparam, variance)) <- config) solveOne(tvar, tparam, variance);
diff --git a/sources/scala/tools/nsc/typechecker/Namers.scala b/sources/scala/tools/nsc/typechecker/Namers.scala
index 9219ae330a..11944187aa 100755
--- a/sources/scala/tools/nsc/typechecker/Namers.scala
+++ b/sources/scala/tools/nsc/typechecker/Namers.scala
@@ -16,8 +16,10 @@ trait Namers: Analyzer {
def updatePosFlags(sym: Symbol, pos: int, mods: int): Symbol = {
if (settings.debug.value) log("overwriting " + sym);
+ val lockedFlag = sym.flags & LOCKED;
+ sym.reset(NoType);
sym setPos pos;
- sym.flags = mods | sym.flags & LOCKED;
+ sym.flags = mods | lockedFlag;
if (sym.isModule)
updatePosFlags(sym.moduleClass, pos, (mods & ModuleToClassFlags) | MODULE | FINAL);
if (sym.owner.isPackageClass && sym.linkedSym.rawInfo.isInstanceOf[loaders.SymbolLoader])
@@ -352,11 +354,15 @@ trait Namers: Analyzer {
case ModuleDef(_, _, impl) =>
val clazz = sym.moduleClass;
clazz.setInfo(new Namer(context.make(tree, clazz)).templateSig(impl));
+ //clazz.typeOfThis = singleType(sym.owner.thisType, sym);
clazz.tpe;
case DefDef(_, _, tparams, vparamss, tpt, rhs) =>
- checkContractive(sym,
- new Namer(context.makeNewScope(tree, sym)).methodSig(tparams, vparamss, tpt, rhs))
+ if (sym.isConstructor) sym.owner.setFlag(INCONSTRUCTOR);
+ val result =
+ new Namer(context.makeNewScope(tree, sym)).methodSig(tparams, vparamss, tpt, rhs);
+ if (sym.isConstructor) sym.owner.resetFlag(INCONSTRUCTOR);
+ checkContractive(sym, result)
case ValDef(_, _, tpt, rhs) =>
if (tpt.isEmpty)
diff --git a/sources/scala/tools/nsc/typechecker/Typers.scala b/sources/scala/tools/nsc/typechecker/Typers.scala
index 867c8d6b43..b4a585ed65 100755
--- a/sources/scala/tools/nsc/typechecker/Typers.scala
+++ b/sources/scala/tools/nsc/typechecker/Typers.scala
@@ -33,6 +33,17 @@ import collection.mutable.HashMap;
superDefs.clear;
}
+ val resetAttrs = new Traverser {
+ override def traverse(tree: Tree): unit = tree match {
+ case EmptyTree | TypeTree() =>
+ ;
+ case _ =>
+ if (tree.hasSymbol) tree.symbol = NoSymbol;
+ tree.tpe = null;
+ super.traverse(tree)
+ }
+ }
+
def newTyper(context: Context): Typer = new Typer(context);
class Typer(context0: Context) {
@@ -291,7 +302,6 @@ import collection.mutable.HashMap;
if ((mode & EXPRmode) != 0 && sym == ByNameParamClass) => // (2)
adapt(tree setType arg, mode, pt);
case PolyType(tparams, restpe) if ((mode & TAPPmode) == 0) => // (3)
- if (settings.debug.value && tree.symbol != null) log("adapting " + tree + " " + tree.symbol.tpe + " " + tree.symbol.getClass() + " " + tree.symbol.hasFlag(CASE));//debug
val tparams1 = cloneSymbols(tparams);
val tree1 = if (tree.isType) tree
else TypeApply(tree, tparams1 map (tparam =>
@@ -303,7 +313,9 @@ import collection.mutable.HashMap;
case mt: MethodType if ((mode & (EXPRmode | FUNmode)) == EXPRmode &&
isCompatible(tree.tpe, pt)) => // (4.2)
if (tree.symbol.isConstructor) errorTree(tree, "missing arguments for " + tree.symbol)
- else typed(etaExpand(tree), mode, pt)
+ else {
+ typed(etaExpand(tree), mode, pt)
+ }
case _ =>
if (tree.isType) {
val clazz = tree.tpe.symbol;
@@ -348,7 +360,7 @@ import collection.mutable.HashMap;
val tparams = context.undetparams;
context.undetparams = List();
inferExprInstance(tree, tparams, pt);
- tree
+ adapt(tree, mode, pt)
} else if (tree.tpe <:< pt) {
tree
} else {
@@ -366,8 +378,10 @@ import collection.mutable.HashMap;
}
if (context.reportGeneralErrors) { // (13); the condition prevents chains of views
val coercion = inferView(tree.pos, tree.tpe, pt, true);
- if (coercion != EmptyTree)
+ if (coercion != EmptyTree) {
+ if (settings.debug.value) log("inferred view from " + tree.tpe + " to " + pt + " = " + coercion + ":" + coercion.tpe);
return typed(Apply(coercion, List(tree)) setPos tree.pos, mode, pt);
+ }
}
}
if (settings.debug.value) log("error tree = " + tree);
@@ -676,9 +690,12 @@ import collection.mutable.HashMap;
val expr1 = typed(block.expr, mode & ~(FUNmode | QUALmode), pt);
val block1 = copy.Block(block, stats1, expr1)
setType (if (treeInfo.isPureExpr(block)) expr1.tpe else expr1.tpe.deconst);
- if (block1.tpe.symbol.isAnonymousClass)
- block1 setType intersectionType(block1.tpe.parents, block1.tpe.symbol.owner);
- if (isFullyDefined(pt)) block1 else checkNoEscaping.locals(context.scope, block1)
+ if (isFullyDefined(pt)) block1
+ else {
+ if (block1.tpe.symbol.isAnonymousClass)
+ block1 setType intersectionType(block1.tpe.parents, block1.tpe.symbol.owner);
+ checkNoEscaping.locals(context.scope, block1)
+ }
}
def typedCase(cdef: CaseDef, pattpe: Type, pt: Type): CaseDef = {
@@ -762,18 +779,13 @@ import collection.mutable.HashMap;
case Match(_, cases) =>
val substParam = new TreeSymSubstituter(List(vparams.head.symbol), List(idparam));
def transformCase(cdef: CaseDef): CaseDef =
- CaseDef(substParam(cdef.pat.duplicate),
- substParam(cdef.guard.duplicate),
- Literal(true));
- val result =
- if (cases exists treeInfo.isDefaultCase) Literal(true)
- else
- Match(
- Ident(idparam),
- (cases map transformCase) :::
- List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false))));
- new ChangeOwnerTraverser(applyMethod, isDefinedAtMethod).traverse(result);
- result
+ resetAttrs(CaseDef(cdef.pat.duplicate, cdef.guard.duplicate, Literal(true)));
+ if (cases exists treeInfo.isDefaultCase) Literal(true)
+ else
+ Match(
+ Ident(idparam),
+ (cases map transformCase) :::
+ List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false))))
}
members = DefDef(isDefinedAtMethod, vparamss => idbody(vparamss.head.head)) :: members;
}
@@ -820,7 +832,6 @@ import collection.mutable.HashMap;
if (tparams.length == args.length) {
val targs = args map (.tpe);
checkBounds(tree.pos, tparams, targs, "");
- if (settings.debug.value) log("type app " + tparams + " => " + targs + " = " + restpe.subst(tparams, targs));//debug
copy.TypeApply(tree, fun, args) setType restpe.subst(tparams, targs);
} else {
errorTree(tree, "wrong number of type parameters for " + treeSymTypeMsg(fun))
@@ -935,10 +946,12 @@ import collection.mutable.HashMap;
}
if (sym.info == NoType) {
if (settings.debug.value) log("qual = " + qual + ":" + qual.tpe + "\nSymbol=" + qual.tpe.symbol + "\nsymbol-info = " + qual.tpe.symbol.info + "\nscope-id = " + qual.tpe.symbol.info.decls.hashCode() + "\nmembers = " + qual.tpe.members + "\nfound = " + sym);
- errorTree(tree,
- decode(name) + " is not a member of " + qual.tpe.widen +
- (if (Position.line(tree.pos) > Position.line(qual.pos))
- "\npossible cause: maybe a semicolon is missing before `" + name + "'?" else ""))
+ if (!qual.tpe.isError)
+ error(tree.pos,
+ decode(name) + " is not a member of " + qual.tpe.widen +
+ (if (Position.line(tree.pos) > Position.line(qual.pos))
+ "\npossible cause: maybe a semicolon is missing before `" + name + "'?" else ""));
+ setError(tree)
} else {
val tree1 = tree match {
case Select(_, _) => copy.Select(tree, qual, name)
@@ -1417,7 +1430,7 @@ import collection.mutable.HashMap;
tree = typed1(tree, EXPRmode, pt);
if (settings.debug.value) log("typed implicit " + tree + ":" + tree.tpe + ", pt = " + pt);//debug
val tree1 = adapt(tree, EXPRmode, pt);
- if (settings.debug.value) log("adapted implicit " + tree.symbol + ":" + info.sym);//debug
+ if (settings.debug.value) log("adapted implicit " + tree.symbol + ":" + tree1.tpe + " to " + pt);//debug
if (info.sym == tree.symbol) tree1
else fail("syms differ: " + tree.symbol + " " + info.sym)
} catch {
@@ -1430,10 +1443,11 @@ import collection.mutable.HashMap;
if (util.Statistics.enabled) implcnt = implcnt + 1;
val startTime = if (util.Statistics.enabled) System.currentTimeMillis() else 0l;
- def isBetter(sym1: Symbol, tpe1: Type, sym2: Symbol, tpe2: Type): boolean =
+ def isBetter(sym1: Symbol, tpe1: Type, sym2: Symbol, tpe2: Type): boolean = {
+ System.out.println("is better " + sym1 + ":" + tpe1 + " than " + sym2 + ":" + tpe2);
sym2.isError ||
(sym1.owner != sym2.owner) && (sym1.owner isSubClass sym2.owner) && (tpe1 matches tpe2);
-
+ }
val tc = newTyper(context.makeImplicit(reportAmbiguous));
def searchImplicit(implicitInfoss: List[List[ImplicitInfo]], local: boolean): Tree = {
@@ -1458,7 +1472,7 @@ import collection.mutable.HashMap;
pos,
"ambiguous implicit value:\n" +
" both " + is0.head.sym + is0.head.sym.locationString + " of type " + tree.tpe +
- "\n and" + is.head.sym + is.head.sym.locationString + " of type " + tree1.tpe +
+ "\n and " + is.head.sym + is.head.sym.locationString + " of type " + tree1.tpe +
(if (isView)
"\n are possible conversion functions from " +
pt.typeArgs(0) + " to " + pt.typeArgs(1)