@@ -860,15 +860,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
860
860
assignType(cpy.Alternative (tree)(trees1), trees1)
861
861
}
862
862
863
- def addTypedModifiersAnnotations (mdef : untpd.MemberDef , sym : Symbol )(implicit ctx : Context ): Unit = {
864
- val mods1 = typedModifiers(untpd.modsDeco(mdef).mods, sym)
865
- for (tree <- mods1.annotations) sym.addAnnotation(Annotation (tree))
866
- }
867
-
868
- def typedModifiers (mods : untpd.Modifiers , sym : Symbol )(implicit ctx : Context ): Modifiers = track(" typedModifiers" ) {
869
- val annotations1 = mods.annotations mapconserve typedAnnotation
870
- if (annotations1 eq mods.annotations) mods.asInstanceOf [Modifiers ]
871
- else Modifiers (mods.flags, mods.privateWithin, annotations1)
863
+ def completeAnnotations (mdef : untpd.MemberDef , sym : Symbol )(implicit ctx : Context ): Unit = {
864
+ // necessary to force annotation trees to be computed.
865
+ sym.annotations.foreach(_.tree)
866
+ // necessary in order to mark the typed ahead annotations as definitiely typed:
867
+ untpd.modsDeco(mdef).mods.annotations.mapconserve(typedAnnotation)
872
868
}
873
869
874
870
def typedAnnotation (annot : untpd.Tree )(implicit ctx : Context ): Tree = track(" typedAnnotation" ) {
@@ -877,7 +873,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
877
873
878
874
def typedValDef (vdef : untpd.ValDef , sym : Symbol )(implicit ctx : Context ) = track(" typedValDef" ) {
879
875
val ValDef (name, tpt, _) = vdef
880
- addTypedModifiersAnnotations (vdef, sym)
876
+ completeAnnotations (vdef, sym)
881
877
val tpt1 = typedType(tpt)
882
878
val rhs1 = vdef.rhs match {
883
879
case rhs @ Ident (nme.WILDCARD ) => rhs withType tpt1.tpe
@@ -888,7 +884,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
888
884
889
885
def typedDefDef (ddef : untpd.DefDef , sym : Symbol )(implicit ctx : Context ) = track(" typedDefDef" ) {
890
886
val DefDef (name, tparams, vparamss, tpt, _) = ddef
891
- addTypedModifiersAnnotations (ddef, sym)
887
+ completeAnnotations (ddef, sym)
892
888
val tparams1 = tparams mapconserve (typed(_).asInstanceOf [TypeDef ])
893
889
val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf [ValDef ])
894
890
if (sym is Implicit ) checkImplicitParamsNotSingletons(vparamss1)
@@ -900,7 +896,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
900
896
901
897
def typedTypeDef (tdef : untpd.TypeDef , sym : Symbol )(implicit ctx : Context ): Tree = track(" typedTypeDef" ) {
902
898
val TypeDef (name, rhs) = tdef
903
- addTypedModifiersAnnotations (tdef, sym)
899
+ completeAnnotations (tdef, sym)
904
900
val _ = typedType(rhs) // unused, typecheck only to remove from typedTree
905
901
assignType(cpy.TypeDef (tdef)(name, TypeTree (sym.info), Nil ), sym)
906
902
}
@@ -916,7 +912,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
916
912
result
917
913
}
918
914
919
- addTypedModifiersAnnotations (cdef, cls)
915
+ completeAnnotations (cdef, cls)
920
916
val constr1 = typed(constr).asInstanceOf [DefDef ]
921
917
val parentsWithClass = ensureFirstIsClass(parents mapconserve typedParent, cdef.pos.toSynthetic)
922
918
val parents1 = ensureConstrCall(cls, parentsWithClass)(superCtx)
0 commit comments