File tree 5 files changed +24
-4
lines changed
compiler/src/dotty/tools/dotc/transform
pos-macros/tasty-constant-type
5 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,10 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
177
177
case prefix : ThisType if ! tp.symbol.isStatic && level > levelOf(prefix.cls) =>
178
178
tryHeal(tp.symbol, tp, pos)
179
179
case prefix : TermRef if tp.symbol.isSplice =>
180
+ prefix.symbol.info.argInfos match
181
+ case (tb : TypeBounds ) :: _ =>
182
+ ctx.error(em " Cannot splice $tp because it is a wildcard type " , pos)
183
+ case _ =>
180
184
// Heal explicit type splice in the code
181
185
if level > 0 then getQuoteTypeTags.getTagRef(prefix) else tp
182
186
case prefix : TermRef if ! prefix.symbol.isStatic && level > levelOf(prefix.symbol) =>
Original file line number Diff line number Diff line change 2
2
import scala .quoted ._
3
3
class Foo {
4
4
def mcrImpl (body : Expr [Any ])(using t : Type [_ <: Any ])(using ctx : QuoteContext ): Expr [Any ] = ' {
5
- val tmp = ??? .asInstanceOf [$t]
5
+ val tmp = ??? .asInstanceOf [$t] // error // error
6
6
tmp
7
7
}
8
8
}
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+ object Macro {
3
+ def impl [A : Type ](using qctx : QuoteContext ): Unit = {
4
+ import qctx .tasty ._
5
+ val tpe = typeOf[A ].seal.asInstanceOf [quoted.Type [_ <: AnyRef ]]
6
+ ' { (a : $ {tpe}) => ??? } // error
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+ object Macro {
3
+ def impl [A : Type ](using qctx : QuoteContext ): Unit = {
4
+ import qctx .tasty ._
5
+ val tpe /* : quoted.Type[? <: AnyKind]*/ = typeOf[A ].seal
6
+ ' { f[$tpe] } // error
7
+ }
8
+ def f [T <: AnyKind ]: Unit = ()
9
+ }
Original file line number Diff line number Diff line change @@ -12,8 +12,7 @@ object Macro {
12
12
val ConstantType (Constant (v1 : Int )) = a.unseal.tpe
13
13
val ConstantType (Constant (v2 : Int )) = b.unseal.tpe
14
14
15
- val t = Literal (Constant ((v1 + v2): Int )).tpe.seal
16
-
17
- ' { null : AddInt [$a, $b] { type Out = $t } }
15
+ Literal (Constant ((v1 + v2): Int )).tpe.seal match
16
+ case ' [$t] => ' { null : AddInt [$a, $b] { type Out = $t } }
18
17
}
19
18
}
You can’t perform that action at this time.
0 commit comments