From abbc707f3aafad5e2f7bf4be486e6783da31508e Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 19 Jun 2015 12:53:33 +0200 Subject: Remove dead code and rename addTypedModifiersAnnotations --- src/dotty/tools/dotc/typer/Typer.scala | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index db3ae9319..a372bb121 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -859,15 +859,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit assignType(cpy.Alternative(tree)(trees1), trees1) } - def addTypedModifiersAnnotations(mdef: untpd.MemberDef, sym: Symbol)(implicit ctx: Context): Unit = { - val mods1 = typedModifiers(untpd.modsDeco(mdef).mods, sym) - sym.annotations.foreach(_.tree) // force trees to be computed - } - - def typedModifiers(mods: untpd.Modifiers, sym: Symbol)(implicit ctx: Context): Modifiers = track("typedModifiers") { - val annotations1 = mods.annotations mapconserve typedAnnotation - if (annotations1 eq mods.annotations) mods.asInstanceOf[Modifiers] - else Modifiers(mods.flags, mods.privateWithin, annotations1) + def completeAnnotations(mdef: untpd.MemberDef, sym: Symbol)(implicit ctx: Context): Unit = { + // necessary to force annotation trees to be computed. + sym.annotations.foreach(_.tree) + // necessary in order to mark the typed ahead annotations as definitiely typed: + untpd.modsDeco(mdef).mods.annotations.mapconserve(typedAnnotation) } def typedAnnotation(annot: untpd.Tree)(implicit ctx: Context): Tree = track("typedAnnotation") { @@ -876,7 +872,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(name, tpt, _) = vdef - addTypedModifiersAnnotations(vdef, sym) + completeAnnotations(vdef, sym) val tpt1 = typedType(tpt) val rhs1 = vdef.rhs match { case rhs @ Ident(nme.WILDCARD) => rhs withType tpt1.tpe @@ -887,7 +883,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(name, tparams, vparamss, tpt, _) = ddef - addTypedModifiersAnnotations(ddef, sym) + completeAnnotations(ddef, sym) val tparams1 = tparams mapconserve (typed(_).asInstanceOf[TypeDef]) val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf[ValDef]) if (sym is Implicit) checkImplicitParamsNotSingletons(vparamss1) @@ -899,7 +895,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(name, rhs) = tdef - addTypedModifiersAnnotations(tdef, sym) + completeAnnotations(tdef, sym) val _ = typedType(rhs) // unused, typecheck only to remove from typedTree assignType(cpy.TypeDef(tdef)(name, TypeTree(sym.info), Nil), sym) } @@ -916,7 +912,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit result } - addTypedModifiersAnnotations(cdef, cls) + completeAnnotations(cdef, cls) val constr1 = typed(constr).asInstanceOf[DefDef] val parentsWithClass = ensureFirstIsClass(parents mapconserve typedParent, cdef.pos.toSynthetic) val parents1 = ensureConstrCall(cls, parentsWithClass)(superCtx) -- cgit v1.2.3