@@ -348,7 +348,7 @@ object Erasure {
348348 tree.symbol.getAnnotation(defn.CompileTimeOnlyAnnot ) match {
349349 case Some (annot) =>
350350 def defaultMsg =
351- s """ Reference to ${tree.symbol.showLocated} should not have survived,
351+ i """ Reference to ${tree.symbol.showLocated} should not have survived,
352352 |it should have been processed and eliminated during expansion of an enclosing macro or term erasure. """
353353 val message = annot.argumentConstant(0 ).fold(defaultMsg)(_.stringValue)
354354 ctx.error(message, tree.sourcePos)
@@ -750,8 +750,11 @@ object Erasure {
750750
751751 override def adapt (tree : Tree , pt : Type , locked : TypeVars )(implicit ctx : Context ): Tree =
752752 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
755758 else if (ctx.mode is Mode .Pattern ) tree // TODO: replace with assertion once pattern matcher is active
756759 else adaptToType(tree, pt)
757760 }
0 commit comments