Skip to content

Commit 0bda95a

Browse files
add regression test for issue scala#13021 (scala#20104)
fixes scala#13021
2 parents 4ea930b + 93674c5 commit 0bda95a

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

tests/pos-macros/i13021/DFBits.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object DFBits:
2+
opaque type Token[W <: Int] <: DFToken.Of[Int] = DFToken.Of[Int]
3+
extension [W <: Int](token: Token[W])
4+
def data: Int =
5+
token.asIR
6+
1

tests/pos-macros/i13021/DFToken.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
trait Token:
2+
val data: Any
3+
4+
opaque type DFToken = Token
5+
object DFToken:
6+
extension (of: DFToken) def asIR: Token = ???
7+
8+
opaque type Of[D] <: DFToken = DFToken
9+
object Of:
10+
extension [D](token: Of[D]) def width(using w: Width[?]): Int = ???
11+
12+
def getWidth[W <: Int](token: DFBits.Token[W]): Int = token.width
13+
def getData[W <: Int](token: DFBits.Token[W]): Int =
14+
token.data //error here

tests/pos-macros/i13021/Width.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.quoted.*
2+
3+
trait Width[T]:
4+
type Out <: Int
5+
object Width:
6+
transparent inline given [T]: Width[T] = ${ getWidthMacro[T] }
7+
def getWidthMacro[T](using Quotes, Type[T]): Expr[Width[T]] =
8+
'{
9+
new Width[T] {
10+
type Out = Int
11+
}
12+
}

0 commit comments

Comments
 (0)