Skip to content

Commit 67a2534

Browse files
committed
Regression test for extension nullification
1 parent 85ab75f commit 67a2534

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/warn/i21190.scala

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
//> using options -Werror
3+
4+
opaque type FromEnd = Int
5+
object FromEnd:
6+
inline def apply(i: Int): FromEnd = i
7+
extension (fe: FromEnd)
8+
inline def value: Int = fe
9+
10+
// Warning appears when extension is in same namespace as opaque type
11+
extension [A](a: Array[A])
12+
inline def apply(fe: FromEnd): A =
13+
a(a.length - 1 - FromEnd.value(fe))
14+
15+
class R:
16+
def run(): String =
17+
val xs = Array(1, 2, 3)
18+
19+
s"""First element = ${xs(0)}
20+
|Last element = ${xs(FromEnd(0))}""".stripMargin
21+
22+
@main def test = println:
23+
R().run()

0 commit comments

Comments
 (0)