We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f6115b5 + ca77d84 commit 0fcd897Copy full SHA for 0fcd897
tests/warn/i21190.scala
@@ -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