aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-13 14:08:17 +0200
committerMartin Odersky <odersky@gmail.com>2014-07-17 11:02:03 +0200
commit65a85700146674d64f02aed1f2ec185a8ff41c7a (patch)
tree48abd526256e20bdfa8c4c8384b86bd4d87e7c05 /src/dotty/tools/dotc/typer/Typer.scala
parent8a0ce6dda986ce149982e102e6962ac7d1e70784 (diff)
downloaddotty-65a85700146674d64f02aed1f2ec185a8ff41c7a.tar.gz
dotty-65a85700146674d64f02aed1f2ec185a8ff41c7a.tar.bz2
dotty-65a85700146674d64f02aed1f2ec185a8ff41c7a.zip
Fixes to ReTyper
1) Disabled insertApplyOrImplicit - it leads to untyped trees which cause assertion errors down the road. In any case, neither apply methods nor implicits can be inserted when retyping. 2) Avoid copying tree annotations into symbols when retyping.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index c01cf714f..6dc9a49b1 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -744,9 +744,14 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
assignType(cpy.Alternative(tree, trees1), trees1)
}
+ def addTypedModifiersAnnotations(mods: untpd.Modifiers, sym: Symbol)(implicit ctx: Context): Modifiers = {
+ val mods1 = typedModifiers(mods, sym)
+ for (tree <- mods1.annotations) sym.addAnnotation(Annotation(tree))
+ mods1
+ }
+
def typedModifiers(mods: untpd.Modifiers, sym: Symbol)(implicit ctx: Context): Modifiers = track("typedModifiers") {
val annotations1 = mods.annotations mapconserve typedAnnotation
- for (tree <- annotations1) sym.addAnnotation(Annotation(tree))
if (annotations1 eq mods.annotations) mods.asInstanceOf[Modifiers]
else Modifiers(mods.flags, mods.privateWithin, annotations1)
}
@@ -757,7 +762,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedValDef(vdef: untpd.ValDef, sym: Symbol)(implicit ctx: Context) = track("typedValDef") {
val ValDef(mods, name, tpt, rhs) = vdef
- val mods1 = typedModifiers(mods, sym)
+ val mods1 = addTypedModifiersAnnotations(mods, sym)
val tpt1 = typedType(tpt)
val rhs1 = rhs match {
case Ident(nme.WILDCARD) => rhs withType tpt1.tpe
@@ -768,7 +773,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedDefDef(ddef: untpd.DefDef, sym: Symbol)(implicit ctx: Context) = track("typedDefDef") {
val DefDef(mods, name, tparams, vparamss, tpt, rhs) = ddef
- val mods1 = typedModifiers(mods, sym)
+ val mods1 = addTypedModifiersAnnotations(mods, sym)
val tparams1 = tparams mapconserve (typed(_).asInstanceOf[TypeDef])
val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf[ValDef])
if (sym is Implicit) checkImplicitParamsNotSingletons(vparamss1)
@@ -780,7 +785,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedTypeDef(tdef: untpd.TypeDef, sym: Symbol)(implicit ctx: Context): Tree = track("typedTypeDef") {
val TypeDef(mods, name, rhs) = tdef
- val mods1 = typedModifiers(mods, sym)
+ val mods1 = addTypedModifiersAnnotations(mods, sym)
val _ = typedType(rhs) // unused, typecheck only to remove from typedTree
assignType(cpy.TypeDef(tdef, mods1, name, TypeTree(sym.info)), sym)
}
@@ -807,7 +812,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
val TypeDef(mods, name, impl @ Template(constr, parents, self, body)) = cdef
- val mods1 = typedModifiers(mods, cls)
+ val mods1 = addTypedModifiersAnnotations(mods, cls)
val constr1 = typed(constr).asInstanceOf[DefDef]
val parents1 = ensureConstrCall(ensureFirstIsClass(
parents mapconserve typedParent, cdef.pos.toSynthetic))