File tree Expand file tree Collapse file tree 5 files changed +24
-4
lines changed
compiler/src/dotty/tools/dotc/transform
pos-macros/tasty-constant-type Expand file tree Collapse file tree 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(
177177 case prefix : ThisType if ! tp.symbol.isStatic && level > levelOf(prefix.cls) =>
178178 tryHeal(tp.symbol, tp, pos)
179179 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 _ =>
180184 // Heal explicit type splice in the code
181185 if level > 0 then getQuoteTypeTags.getTagRef(prefix) else tp
182186 case prefix : TermRef if ! prefix.symbol.isStatic && level > levelOf(prefix.symbol) =>
Original file line number Diff line number Diff line change 22import scala .quoted ._
33class Foo {
44 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
66 tmp
77 }
88}
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 {
1212 val ConstantType (Constant (v1 : Int )) = a.unseal.tpe
1313 val ConstantType (Constant (v2 : Int )) = b.unseal.tpe
1414
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 } }
1817 }
1918}
You can’t perform that action at this time.
0 commit comments