diff options
author | Martin Odersky <odersky@gmail.com> | 2007-11-11 17:08:02 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-11-11 17:08:02 +0000 |
commit | 5bd7d8413a47d8c0806e42a1dc8de2bdde507bc5 (patch) | |
tree | 4a3d42d9bbdf5d2f90ea9755fb69446212b7e735 /src | |
parent | 6c52710e5669d4740819b7713529f00efb11ab8e (diff) | |
download | scala-5bd7d8413a47d8c0806e42a1dc8de2bdde507bc5.tar.gz scala-5bd7d8413a47d8c0806e42a1dc8de2bdde507bc5.tar.bz2 scala-5bd7d8413a47d8c0806e42a1dc8de2bdde507bc5.zip |
Fixed #180 and #189
Diffstat (limited to 'src')
4 files changed, 22 insertions, 39 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index b8a789d9cb..a04461a568 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -884,41 +884,6 @@ trait Parsers extends NewScanners with MarkupParsers { //////// EXPRESSIONS //////////////////////////////////////////////////////// -/* - // XX_LIFTED - var liftedGenerators = new collection.mutable.ListBuffer[ValFrom] - - // XX_LIFTED - def wrapLiftedGenerators(t: Tree): Tree = - if (liftedGenerators.isEmpty) t - else { - val t1 = makeLifted(liftedGenerators.toList, t) - liftedGenerators.clear - t1 - } - - // XX_LIFTED - def noLifting(op: => Tree): Tree = { - val savedLiftedGenerators = liftedGenerators - if (!savedLiftedGenerators.isEmpty) // optimization to avoid buffer allocation - liftedGenerators = new collection.mutable.ListBuffer - val t = op - if (!liftedGenerators.isEmpty) - syntaxError(liftedGenerators.toList.head.pos, "no lifted expression allowed here", false) - liftedGenerators = savedLiftedGenerators - t - } - - // XX_LIFTED - def liftingScope(op: => Tree): Tree = { - val savedLiftedGenerators = liftedGenerators - if (!savedLiftedGenerators.isEmpty) // optimization to avoid buffer allocation - liftedGenerators = new collection.mutable.ListBuffer - val t = wrapLiftedGenerators(op) - liftedGenerators = savedLiftedGenerators - t - } -*/ /** EqualsExpr ::= `=' Expr */ def equalsExpr(): Tree = { diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index c735c953bf..8014881cf2 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -43,7 +43,7 @@ trait Symbols { var rawflags: Long = 0 private var rawpos = initPos val id = { ids += 1; ids } -// assert(id != 4699, initName+"/"+initOwner) +// assert(id != 5413, initName+"/"+initOwner) var validTo: Period = NoPeriod diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 14c805254a..c939ab9979 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -25,6 +25,8 @@ trait Infer { var normP = 0 var normO = 0 + private final val inferInfo = false + /* -- Type parameter inference utility functions --------------------------- */ def assertNonCyclic(tvar: TypeVar) = @@ -735,12 +737,19 @@ trait Infer { */ def inferArgumentInstance(tree: Tree, undetparams: List[Symbol], strictPt: Type, lenientPt: Type) { + if (inferInfo) + println("infer argument instance "+tree+":"+tree.tpe+"\n"+ + " undetparams = "+undetparams+"\n"+ + " strict pt = "+strictPt+"\n"+ + " lenient pt = "+lenientPt) var targs = exprTypeArgs(undetparams, tree.tpe, strictPt) - if (targs eq null) targs = exprTypeArgs(undetparams, tree.tpe, lenientPt) + if ((targs eq null) || !(tree.tpe.subst(undetparams, targs) <:< strictPt)) { + targs = exprTypeArgs(undetparams, tree.tpe, lenientPt) + } substExpr(tree, undetparams, targs, lenientPt) } - /** Substitite free type variables `undetparams; of polymorphic expression + /** Substitute free type variables `undetparams; of polymorphic expression * <code>tree</code>, given prototype <code>pt</code>. * * @param tree ... @@ -748,6 +757,10 @@ trait Infer { * @param pt ... */ def inferExprInstance(tree: Tree, undetparams: List[Symbol], pt: Type) { + if (inferInfo) + println("infer expr instance "+tree+"\n"+ + " undetparams = "+undetparams+"\n"+ + " pt = "+pt) substExpr(tree, undetparams, exprTypeArgs(undetparams, tree.tpe, pt), pt) } @@ -782,6 +795,11 @@ trait Infer { def inferMethodInstance(fn: Tree, undetparams: List[Symbol], args: List[Tree], pt: Type): List[Symbol] = fn.tpe match { case MethodType(formals0, _) => + if (inferInfo) + println("infer method instance "+fn+"\n"+ + " undetparams = "+undetparams+"\n"+ + " args = "+args+"\n"+ + " pt = "+pt) try { val formals = formalTypes(formals0, args.length) val argtpes = actualTypes(args map (_.tpe.deconst), formals.length) diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 5d42e79a18..963aab557c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -150,8 +150,8 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT superAcc = clazz.newMethod(tree.pos, supername) .setFlag(SUPERACCESSOR | PRIVATE) - .setInfo(clazz.thisType.memberType(sym)) .setAlias(sym) + superAcc.setInfo(clazz.thisType.memberType(sym).cloneInfo(superAcc)) clazz.info.decls enter superAcc; accDefBuf(clazz) += typed(DefDef(superAcc, vparamss => EmptyTree)) } |