diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2013-02-12 12:32:20 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2013-02-12 14:25:24 +0100 |
commit | 8206e26f7b04b028b6a81cf7008d9b49169341fd (patch) | |
tree | b9dec24a2a091e25058ce277b0bca73e35a3c7df /src/compiler | |
parent | f51ed74aa3aa142c8aa9d5f9d03e0c244737f66e (diff) | |
download | scala-8206e26f7b04b028b6a81cf7008d9b49169341fd.tar.gz scala-8206e26f7b04b028b6a81cf7008d9b49169341fd.tar.bz2 scala-8206e26f7b04b028b6a81cf7008d9b49169341fd.zip |
Fix typing idempotency bug with Annotated trees
typedAnnotated transforms an Annotated tree into a Typed tree. The
original field of the result is set to the Annotated tree.
The bug was that typedAnnotated was using the untyped Annotated tree
as original, but also set its type. When re-typing later on the same
Annotated tree, the typer would consider it as alreadyTyped. This
is incorrect, the typer needs to convert Annotated trees to Typed.
Also, the Annotated tree only had its type field set, but its children
were still untyped. This crashed the compiler lateron, non-typed trees
would get out of the typing phase.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f97582f45c..9dde952d25 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4153,15 +4153,11 @@ trait Typers extends Modes with Adaptations with Tags { def resultingTypeTree(tpe: Type) = { // we need symbol-ful originals for reification // hence we go the extra mile to hand-craft tis guy - val original = - if (arg1.isType) - arg1 match { - case tt @ TypeTree() => Annotated(ann, tt.original) - // this clause is needed to correctly compile stuff like "new C @D" or "@(inline @getter)" - case _ => Annotated(ann, arg1) - } - else - tree + val original = arg1 match { + case tt @ TypeTree() => Annotated(ann, tt.original) + // this clause is needed to correctly compile stuff like "new C @D" or "@(inline @getter)" + case _ => Annotated(ann, arg1) + } original setType ann.tpe TypeTree(tpe) setOriginal original setPos tree.pos.focus } |