diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/ReTyper.scala | 15 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 15 |
2 files changed, 21 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/typer/ReTyper.scala b/src/dotty/tools/dotc/typer/ReTyper.scala index 76817fd16..6adfa3052 100644 --- a/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/src/dotty/tools/dotc/typer/ReTyper.scala @@ -1,10 +1,11 @@ package dotty.tools.dotc package typer -import core.Contexts._ -import core.Types._ -import core.Symbols._ -import core.Decorators._ +import core._ +import Contexts._ +import Types._ +import Symbols._ +import Decorators._ import typer.ProtoTypes._ import ast.{tpd, untpd} import ast.Trees._ @@ -59,4 +60,10 @@ class ReTyper extends Typer { override def localTyper(sym: Symbol) = this override def index(trees: List[untpd.Tree])(implicit ctx: Context) = ctx + + override def tryInsertApplyOrImplicit(tree: Tree, pt: ProtoType)(fallBack: (Tree, TyperState) => Tree)(implicit ctx: Context): Tree = + fallBack(tree, ctx.typerState) + + override def addTypedModifiersAnnotations(mods: untpd.Modifiers, sym: Symbol)(implicit ctx: Context): Modifiers = + typedModifiers(mods, sym) }
\ No newline at end of file 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)) |