diff --git a/compiler/src/dotty/tools/dotc/transform/Mixin.scala b/compiler/src/dotty/tools/dotc/transform/Mixin.scala index d223566a208c..52c7b6420acc 100644 --- a/compiler/src/dotty/tools/dotc/transform/Mixin.scala +++ b/compiler/src/dotty/tools/dotc/transform/Mixin.scala @@ -10,6 +10,7 @@ import SymUtils._ import Symbols._ import SymDenotations._ import Types._ +import Periods._ import Decorators._ import DenotTransformers._ import StdNames._ @@ -146,6 +147,7 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase => // !decl.isClass avoids forcing nested traits, preventing cycles if !decl.isClass && needsTraitSetter(decl) then val setter = makeTraitSetter(decl.asTerm) + setter.validFor = thisPhase.validFor // validity of setter = next phase up to next transformer afterwards decls1.enter(setter) modified = true if modified then diff --git a/tests/pos/i12140/Test.scala b/tests/pos/i12140/Test.scala new file mode 100644 index 000000000000..073d096e8490 --- /dev/null +++ b/tests/pos/i12140/Test.scala @@ -0,0 +1 @@ +@main def Test = println(example.Trait.get) \ No newline at end of file diff --git a/tests/pos/i12140/Trait.scala b/tests/pos/i12140/Trait.scala new file mode 100644 index 000000000000..23d5cde613a0 --- /dev/null +++ b/tests/pos/i12140/Trait.scala @@ -0,0 +1,14 @@ +// Trait.scala +package example + +import quoted._ + +trait Trait { + implicit val foo: Int = 23 +} + +object Trait { + inline def get: Trait = ${ getImpl } + + def getImpl(using Quotes): Expr[Trait] = '{ new Trait {} } +}