diff --git a/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala b/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala index 70123ddd77a3..47eb70cb46d4 100644 --- a/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala +++ b/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala @@ -52,7 +52,17 @@ class PruneErasedDefs extends MiniPhase with SymTransformer { thisTransform => else cpy.ValDef(tree)(rhs = trivialErasedTree(tree.rhs)) override def transformDefDef(tree: DefDef)(using Context): Tree = - RefChecks.checkNoInlineAnnoClasses(tree) + def checkNoInlineAnnoClasses(tree: DefDef)(using Context): Unit = + if tree.symbol.is(Inline) then + new TreeTraverser { + def traverse(tree: Tree)(using Context): Unit = + tree match + case tree: TypeDef if tree.symbol.isAnonymousClass => + report.warning(new InlinedAnonClassWarning(), tree.symbol.sourcePos) + case _ => traverseChildren(tree) + }.traverse(tree) + + checkNoInlineAnnoClasses(tree) checkErasedInExperimental(tree.symbol) if !tree.symbol.isEffectivelyErased || tree.rhs.isEmpty then tree else cpy.DefDef(tree)(rhs = trivialErasedTree(tree.rhs)) diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index e075405b5035..cdfd137e5661 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -33,16 +33,6 @@ object RefChecks { def isStable = true } - def checkNoInlineAnnoClasses(tree: DefDef)(using Context): Unit = - if tree.symbol.is(Inline) then - new TreeTraverser { - def traverse(tree: Tree)(using Context): Unit = - tree match - case tree: TypeDef if tree.symbol.isAnonymousClass => - report.warning(new InlinedAnonClassWarning(), tree.symbol.sourcePos) - case _ => traverseChildren(tree) - }.traverse(tree) - /** Only one overloaded alternative is allowed to define default arguments */ private def checkOverloadedRestrictions(clazz: Symbol)(using Context): Unit = { // Using the default getters (such as methodName$default$1) as a cheap way of