diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index ba094c587038..7f81fcf72597 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -651,8 +651,7 @@ object SymDenotations { def containsOpaques(using Context): Boolean = is(Opaque) && isClass def seesOpaques(using Context): Boolean = - containsOpaques || - is(Module, butNot = Package) && owner.seesOpaques + containsOpaques || isClass && !is(Package) && owner.seesOpaques /** Is this the denotation of a self symbol of some class? * This is the case if one of two conditions holds: diff --git a/tests/neg/opaque-inline.scala b/tests/neg/opaque-inline.scala new file mode 100644 index 000000000000..5507484231dd --- /dev/null +++ b/tests/neg/opaque-inline.scala @@ -0,0 +1,14 @@ + +object refined: + opaque type Positive = Int + + object Positive extends PositiveFactory + + trait PositiveFactory: + inline def apply(value: Int): Positive = f(value) // error: implementation restriction + def f(x: Positive): Positive = x + +@main def run: Unit = + import refined.* + val x = 9 + val nine = Positive.apply(x)