diff options
author | Martin Odersky <odersky@gmail.com> | 2007-08-20 10:57:43 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-08-20 10:57:43 +0000 |
commit | 102aadc5f56f6f297b8643563eeb49557e36dd41 (patch) | |
tree | d5be00898604457f1145e2a44bbbcf6c005fbe90 /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 5eadca1408d20df1484459309206f97aefc1688d (diff) | |
download | scala-102aadc5f56f6f297b8643563eeb49557e36dd41.tar.gz scala-102aadc5f56f6f297b8643563eeb49557e36dd41.tar.bz2 scala-102aadc5f56f6f297b8643563eeb49557e36dd41.zip |
fixed some bugs related to existentials.
fixed unboxing bug
fixed ByNameFunction problem
some cleanups in parser
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 4b6e3ce9db..6794c9d58b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -603,6 +603,12 @@ trait Typers { self: Analyzer => case TypeRef(_, sym, List(arg)) if ((mode & EXPRmode) != 0 && sym == ByNameParamClass) => // (2) adapt(tree setType arg, mode, pt) + case tr @ TypeRef(_, sym, _) + if sym.isAliasType && tr.normalize.isInstanceOf[ExistentialType] && + ((mode & (EXPRmode | LHSmode)) == EXPRmode) => + adapt(tree setType tr.normalize.skolemizeExistential(context.owner, tree), mode, pt) + case et @ ExistentialType(_, _) if ((mode & (EXPRmode | LHSmode)) == EXPRmode) => + adapt(tree setType et.skolemizeExistential(context.owner, tree), mode, pt) case PolyType(tparams, restpe) if ((mode & (TAPPmode | PATTERNmode)) == 0) => // (3) assert((mode & HKmode) == 0) //@M val tparams1 = cloneSymbols(tparams) @@ -1874,7 +1880,7 @@ trait Typers { self: Analyzer => } } // add all local symbols of `tp' to `localSyms' - // expanding higher-kinded types into individual copies for esach instance. + // expanding higher-kinded types into individual copies for each instance. def addLocals(tp: Type) { def addIfLocal(sym: Symbol, tp: Type) { if (sym != NoSymbol && !sym.isRefinementClass && isLocal(sym) && @@ -2651,7 +2657,7 @@ trait Typers { self: Analyzer => val sym: Symbol = tree.symbol if (sym ne null) sym.initialize //if (settings.debug.value && tree.isDef) log("typing definition of "+sym);//DEBUG - val result = tree match { + tree match { case PackageDef(name, stats) => val stats1 = newTyper(context.make(tree, sym.moduleClass, sym.info.decls)) .typedStats(stats, NoSymbol) @@ -2898,10 +2904,6 @@ trait Typers { self: Analyzer => case _ => throw new Error("unexpected tree: " + tree.getClass + "\n" + tree)//debug } - if ((mode & (EXPRmode | LHSmode)) == EXPRmode && result.tpe.isInstanceOf[ExistentialType]) - result setType result.tpe.skolemizeExistential(context.owner, result) - else - result } /** @@ -2924,8 +2926,10 @@ trait Typers { self: Analyzer => case ExistentialType(tparams, tpe) => if (settings.debug.value) println("drop ex "+tree+" "+tp) new SubstWildcardMap(tparams).apply(tp) - case TypeRef(_, sym, _)if sym.isAliasType => - dropExistential(tp.normalize) + case TypeRef(_, sym, _) if sym.isAliasType => + val tp0 = tp.normalize + val tp1 = dropExistential(tp0) + if (tp1 eq tp0) tp else tp1 case _ => tp } var tree1 = if (tree.tpe ne null) tree else typed1(tree, mode, dropExistential(pt)) |