-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add regression test for issue #13021
[Cherry-picked 93674c5]
- Loading branch information
1 parent
11feb72
commit c1f32d3
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |