File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments