Skip to content

Commit

Permalink
Regression test for extension nullification
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Feb 4, 2025
1 parent 85ab75f commit 67a2534
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/warn/i21190.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

//> using options -Werror

opaque type FromEnd = Int
object FromEnd:
inline def apply(i: Int): FromEnd = i
extension (fe: FromEnd)
inline def value: Int = fe

// Warning appears when extension is in same namespace as opaque type
extension [A](a: Array[A])
inline def apply(fe: FromEnd): A =
a(a.length - 1 - FromEnd.value(fe))

class R:
def run(): String =
val xs = Array(1, 2, 3)

s"""First element = ${xs(0)}
|Last element = ${xs(FromEnd(0))}""".stripMargin

@main def test = println:
R().run()

0 comments on commit 67a2534

Please sign in to comment.