Skip to content

Commit b1f070e

Browse files
committed
Plug loophole for "no inlines with opaques" rule
Fixes #12814
1 parent fcd837a commit b1f070e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,7 @@ object SymDenotations {
651651
def containsOpaques(using Context): Boolean = is(Opaque) && isClass
652652

653653
def seesOpaques(using Context): Boolean =
654-
containsOpaques ||
655-
is(Module, butNot = Package) && owner.seesOpaques
654+
containsOpaques || isClass && !is(Package) && owner.seesOpaques
656655

657656
/** Is this the denotation of a self symbol of some class?
658657
* This is the case if one of two conditions holds:

tests/neg/opaque-inline.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
object refined:
3+
opaque type Positive = Int
4+
5+
object Positive extends PositiveFactory
6+
7+
trait PositiveFactory:
8+
inline def apply(value: Int): Positive = f(value) // error: implementation restriction
9+
def f(x: Positive): Positive = x
10+
11+
@main def run: Unit =
12+
import refined.*
13+
val x = 9
14+
val nine = Positive.apply(x)

0 commit comments

Comments
 (0)