Skip to content

Commit 2dd8436

Browse files
oderskytanishiking
authored andcommitted
Test case for scala#12950
1 parent d341dcc commit 2dd8436

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/pos/i12950/repro_1.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package repro
2+
object repro:
3+
object opq:
4+
opaque type Lift[T] = Int
5+
extension(v: Int)
6+
def lift[T]: Lift[T] = v
7+
extension[T](l: Lift[T])
8+
def value: Int = l
9+
10+
export opq.Lift as Lift
11+
export opq.lift as lift
12+
13+
final type Two
14+
15+
extension[TL](l: Lift[TL])
16+
def repro[TR](using m: Mul[TL, TR]): Int = l.value + m.value
17+
18+
abstract class Mul[TL, TR]:
19+
val value: Int
20+
21+
transparent inline given mulGivenInt[TL <: Int & Singleton, TR <: Int & Singleton]: Mul[TL, TR] =
22+
val m: Int = scala.compiletime.constValue[TL] * scala.compiletime.constValue[TR]
23+
new Mul[TL, TR] { val value: Int = m }
24+
25+
transparent inline given mulGivenTwo[TR <: Int & Singleton]: Mul[Two, TR] =
26+
val m: Int = 2 * scala.compiletime.constValue[TR]
27+
new Mul[Two, TR] { val value: Int = m }

tests/pos/i12950/test_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import repro.repro.{*, given}
2+
3+
val x = 1.lift[Two]
4+
val _ = x.repro[2]
5+
val y = 1.lift[2]
6+
val _ = y.repro[2]

0 commit comments

Comments
 (0)