diff options
author | Burak Emir <emir@epfl.ch> | 2007-08-07 09:15:34 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-08-07 09:15:34 +0000 |
commit | d50a0095915c1d86edec691fdd187163037be7cb (patch) | |
tree | a95997977223b0239d8a463cf674257e5eb3ff6d /src | |
parent | a19af644d2a04ddaaa93252b33795debdcda7057 (diff) | |
download | scala-d50a0095915c1d86edec691fdd187163037be7cb.tar.gz scala-d50a0095915c1d86edec691fdd187163037be7cb.tar.bz2 scala-d50a0095915c1d86edec691fdd187163037be7cb.zip |
fixed #1215 unapply typing bug
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 96238bd76e..e8a52e9b2f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1654,11 +1654,25 @@ trait Typers { self: Analyzer => arg.tpe = typer1.infer.inferTypedPattern(tree.pos, unappFormal, arg.tpe) //todo: replace arg with arg.asInstanceOf[inferTypedPattern(unappFormal, arg.tpe)] instead. } - // Console.println("unapply "+fun.tpe) + val funPrefix = fun.tpe.prefix match { + case tt @ ThisType(sym) => + //Console.println(" sym="+sym+" "+" .isPackageClass="+sym.isPackageClass+" .isModuleClass="+sym.isModuleClass); + //Console.println(" funsymown="+fun.symbol.owner+" .isClass+"+fun.symbol.owner.isClass); + //Console.println(" contains?"+sym.tpe.decls.lookup(fun.symbol.name)); + if(sym != fun.symbol.owner && sym.isPackageClass /*(1)*/ ) { // (1) see 'files/pos/unapplyVal.scala' + if(fun.symbol.owner.isClass) { + mkThisType(fun.symbol.owner) + } else { + NoPrefix // see 'files/run/unapplyComplex.scala' + } + } else tt + case st @ SingleType(pre, sym) => st + case xx => xx // cannot happen? + } val fun1untyped = atPos(fun.pos) { Apply( Select( - gen.mkAttributedRef(fun.tpe.prefix, fun.symbol) setType null, + gen.mkAttributedRef(funPrefix, fun.symbol) setType null, // setType null is necessary so that ref will be stabilized; see bug 881 unapp), List(arg)) |