diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-04-24 18:40:12 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-04-24 18:54:21 +0200 |
commit | a47acbc36d312cc12ab02f4564edff1deb93d941 (patch) | |
tree | c433d551cb69e7d26f7f291e4659a45c4f569c08 /src | |
parent | 2890714d7bcdd55b7a62091dcdf031cc3efe0822 (diff) | |
download | scala-a47acbc36d312cc12ab02f4564edff1deb93d941.tar.gz scala-a47acbc36d312cc12ab02f4564edff1deb93d941.tar.bz2 scala-a47acbc36d312cc12ab02f4564edff1deb93d941.zip |
copy BackQuotedIdent trees (don't copy as Ident)
typer synthesized the wrong isDefinedAt method in typedMatchAnon
because a BackQuotedIdent was copied as an Ident, so that the equality check
was performed in applyOrElse (since it operates on the original tree),
but not in isDefinedAt (since it operates on the copy, which collapsed Ident and BackQuotedIdent)
Diffstat (limited to 'src')
4 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/internal/TreePrinters.scala b/src/compiler/scala/reflect/internal/TreePrinters.scala index 486a3d3567..3093bb049a 100644 --- a/src/compiler/scala/reflect/internal/TreePrinters.scala +++ b/src/compiler/scala/reflect/internal/TreePrinters.scala @@ -373,6 +373,9 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable => case Select(qualifier, name) => print(backquotedPath(qualifier), ".", symName(tree, name)) + case bqid: BackQuotedIdent => + print("`%s`" format symName(tree, bqid.name)) + case Ident(name) => print(symName(tree, name)) diff --git a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala index 3be8397a9c..96d92e0609 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala @@ -136,7 +136,7 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => // (that would require more sophistication when generating trees, // and the only place that emits Matches after typers is for exception handling anyway) if(phase.id >= currentRun.uncurryPhase.id) debugwarn("running translateMatch at "+ phase +" on "+ scrut +" match "+ cases) - + // println("translating "+ cases.mkString("{", "\n", "}")) val scrutSym = freshSym(scrut.pos, pureType(scrutType)) setFlag SYNTH_CASE // pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental combineCases(scrut, scrutSym, cases map translateCase(scrutSym, pt), pt, matchOwner, matchFailGenOverride) @@ -987,6 +987,7 @@ class Foo(x: Other) { x._1 } // no error in this order fixerUpper(owner, scrut.pos){ val ptDefined = if (isFullyDefined(pt)) pt else NoType def matchFailGen = (matchFailGenOverride orElse Some(CODE.MATCHERROR(_: Tree))) + // println("combining cases: "+ (casesNoSubstOnly.map(_.mkString(" >> ")).mkString("{", "\n", "}"))) emitSwitch(scrut, scrutSym, casesNoSubstOnly, pt, matchFailGenOverride).getOrElse{ if (casesNoSubstOnly nonEmpty) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index ba6a363095..1414424a0b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2288,6 +2288,7 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser // need to duplicate the cases before typing them to generate the apply method, or the symbols will be all messed up val casesTrue = if (isPartial) cases map (c => deriveCaseDef(c)(x => TRUE_typed).duplicate) else Nil + // println("casesTrue "+ casesTrue) def parentsPartial(targs: List[Type]) = List(appliedType(AbstractPartialFunctionClass.typeConstructor, targs), SerializableClass.tpe) def applyMethod = { @@ -2373,6 +2374,7 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser } val members = if (isPartial) { + // TODO: don't check for MarkerCPSTypes -- check whether all targs are subtype of any (which they are not under CPS) if ((MarkerCPSTypes ne NoSymbol) && (targs exists (_ hasAnnotation MarkerCPSTypes))) List(applyMethod, isDefinedAtMethod) else List(applyOrElseMethodDef, isDefinedAtMethod) } else List(applyMethod) diff --git a/src/library/scala/reflect/api/Trees.scala b/src/library/scala/reflect/api/Trees.scala index 6e2e8261e7..2f6dc820a5 100644 --- a/src/library/scala/reflect/api/Trees.scala +++ b/src/library/scala/reflect/api/Trees.scala @@ -1171,7 +1171,10 @@ trait Trees { self: Universe => def Select(tree: Tree, qualifier: Tree, selector: Name) = new Select(qualifier, selector).copyAttrs(tree) def Ident(tree: Tree, name: Name) = - new Ident(name).copyAttrs(tree) + (tree match { + case _ : BackQuotedIdent => new BackQuotedIdent(name) + case _ => new Ident(name) + }).copyAttrs(tree) def ReferenceToBoxed(tree: Tree, idt: Ident) = new ReferenceToBoxed(idt).copyAttrs(tree) def Literal(tree: Tree, value: Constant) = |