aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
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))