1+ // nopos-error
2+ package crash
3+
4+ import scala .quoted .*
5+
6+ class IRDFType
7+ class IRDFBoolOrBit extends IRDFType
8+ class IRDFDecimal extends IRDFType
9+ class IRDFBits extends IRDFType
10+
11+ final class DFType [+ T <: IRDFType , + A ]
12+ type DFTypeAny = DFType [IRDFType , Any ]
13+
14+ trait Baz
15+
16+ trait Width [T ]:
17+ type Out <: Int
18+ object Width :
19+ given fromDFBoolOrBit [T <: DFBoolOrBit ]: Width [T ] with
20+ type Out = 1
21+ transparent inline given [T ]: Width [T ] = $ { getWidthMacro[T ] }
22+ def getWidthMacro [T ](using Quotes , Type [T ]): Expr [Width [T ]] =
23+ ' {
24+ new Width [T ]:
25+ type Out = 1
26+ }
27+ end Width
28+
29+ extension [T ](t : T )(using baz : Baz ) def width : 1 = ???
30+
31+ trait Check [T1 <: Int , T2 <: Int ]
32+
33+ type DFBits [W <: Int ] = DFType [IRDFBits , Tuple1 [W ]]
34+
35+ private object CompanionsDFBits :
36+ object Val :
37+ trait Candidate [R ]:
38+ type OutW <: Int
39+ def apply (value : R ): DFValOf [DFBits [OutW ]]
40+ object Candidate :
41+ given fromDFUInt [W <: Int , R <: DFValOf [DFDecimal ]]: Candidate [R ] with
42+ type OutW = W
43+ def apply (value : R ): DFValOf [DFBits [W ]] =
44+ import DFVal .Ops .bits
45+ value.bits
46+ ???
47+ end Candidate
48+
49+ object TC :
50+ import DFVal .TC
51+ given DFBitsFromCandidate [
52+ LW <: Int ,
53+ V
54+ ](using candidate : Candidate [V ])(using
55+ check : Check [LW , candidate.OutW ]
56+ ): TC [DFBits [LW ], V ] with
57+ def conv (dfType : DFBits [LW ], value : V ): DFValOf [DFBits [LW ]] =
58+ val dfVal = candidate(value)
59+ ???
60+ end TC
61+ end Val
62+
63+ end CompanionsDFBits
64+
65+ type DFBoolOrBit = DFType [IRDFBoolOrBit , Any ]
66+ type DFDecimal = DFType [IRDFDecimal , Any ]
67+ object DFDecimal :
68+ def foo (arg1 : Int , arg2 : Int ): Unit = ???
69+
70+ object Val :
71+ object TC :
72+ import DFVal .TC
73+ given [R ]: TC [DFDecimal , R ] = ???
74+ def apply (
75+ dfType : DFDecimal ,
76+ dfVal : DFValOf [DFDecimal ]
77+ ): DFValOf [DFDecimal ] =
78+ foo(dfType.width, dfVal.width)
79+ dfVal
80+ end TC
81+ end Val
82+ end DFDecimal
0 commit comments