Skip to content

Commit

Permalink
Plug loophole for "no inlines with opaques" rule
Browse files Browse the repository at this point in the history
Fixes #12814
  • Loading branch information
odersky committed Jun 13, 2021
1 parent fcd837a commit b1f070e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions tests/neg/opaque-inline.scala
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b1f070e

Please sign in to comment.