@@ -348,7 +348,7 @@ object Erasure {
348
348
tree.symbol.getAnnotation(defn.CompileTimeOnlyAnnot ) match {
349
349
case Some (annot) =>
350
350
def defaultMsg =
351
- s """ Reference to ${tree.symbol.showLocated} should not have survived,
351
+ i """ Reference to ${tree.symbol.showLocated} should not have survived,
352
352
|it should have been processed and eliminated during expansion of an enclosing macro or term erasure. """
353
353
val message = annot.argumentConstant(0 ).fold(defaultMsg)(_.stringValue)
354
354
ctx.error(message, tree.sourcePos)
@@ -750,8 +750,11 @@ object Erasure {
750
750
751
751
override def adapt (tree : Tree , pt : Type , locked : TypeVars )(implicit ctx : Context ): Tree =
752
752
trace(i " adapting ${tree.showSummary}: ${tree.tpe} to $pt" , show = true ) {
753
- assert(ctx.phase == ctx.erasurePhase || ctx.phase == ctx.erasurePhase.next, ctx.phase)
754
- if (tree.isEmpty) tree
753
+ if ctx.phase != ctx.erasurePhase && ctx.phase != ctx.erasurePhase.next then
754
+ // this can happen when reading annotations loaded during erasure,
755
+ // since these are loaded at phase typer.
756
+ adapt(tree, pt, locked)(given ctx .withPhase(ctx.erasurePhase.next))
757
+ else if (tree.isEmpty) tree
755
758
else if (ctx.mode is Mode .Pattern ) tree // TODO: replace with assertion once pattern matcher is active
756
759
else adaptToType(tree, pt)
757
760
}
0 commit comments