Skip to content

Commit

Permalink
Backport "add regression test for issue #13021" to LTS (#21050)
Browse files Browse the repository at this point in the history
Backports #20104 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 5, 2024
2 parents 66981bc + c1f32d3 commit 550497c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/pos-macros/i13021/DFBits.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object DFBits:
opaque type Token[W <: Int] <: DFToken.Of[Int] = DFToken.Of[Int]
extension [W <: Int](token: Token[W])
def data: Int =
token.asIR
1
14 changes: 14 additions & 0 deletions tests/pos-macros/i13021/DFToken.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trait Token:
val data: Any

opaque type DFToken = Token
object DFToken:
extension (of: DFToken) def asIR: Token = ???

opaque type Of[D] <: DFToken = DFToken
object Of:
extension [D](token: Of[D]) def width(using w: Width[?]): Int = ???

def getWidth[W <: Int](token: DFBits.Token[W]): Int = token.width
def getData[W <: Int](token: DFBits.Token[W]): Int =
token.data //error here
12 changes: 12 additions & 0 deletions tests/pos-macros/i13021/Width.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import scala.quoted.*

trait Width[T]:
type Out <: Int
object Width:
transparent inline given [T]: Width[T] = ${ getWidthMacro[T] }
def getWidthMacro[T](using Quotes, Type[T]): Expr[Width[T]] =
'{
new Width[T] {
type Out = Int
}
}

0 comments on commit 550497c

Please sign in to comment.