diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 7e4ee3c3dbb9..4300139c1f1b 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -177,6 +177,10 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( case prefix: ThisType if !tp.symbol.isStatic && level > levelOf(prefix.cls) => tryHeal(tp.symbol, tp, pos) case prefix: TermRef if tp.symbol.isSplice => + prefix.symbol.info.argInfos match + case (tb: TypeBounds) :: _ => + ctx.error(em"Cannot splice $tp because it is a wildcard type", pos) + case _ => // Heal explicit type splice in the code if level > 0 then getQuoteTypeTags.getTagRef(prefix) else tp case prefix: TermRef if !prefix.symbol.isStatic && level > levelOf(prefix.symbol) => diff --git a/tests/pos/i6997.scala b/tests/neg/i6997.scala similarity index 73% rename from tests/pos/i6997.scala rename to tests/neg/i6997.scala index fb8f8e6d1aa4..c90239ef986a 100644 --- a/tests/pos/i6997.scala +++ b/tests/neg/i6997.scala @@ -2,7 +2,7 @@ import scala.quoted._ class Foo { def mcrImpl(body: Expr[Any])(using t: Type[_ <: Any])(using ctx: QuoteContext): Expr[Any] = '{ - val tmp = ???.asInstanceOf[$t] + val tmp = ???.asInstanceOf[$t] // error // error tmp } } diff --git a/tests/neg/i8871.scala b/tests/neg/i8871.scala new file mode 100644 index 000000000000..4fa1bd3af936 --- /dev/null +++ b/tests/neg/i8871.scala @@ -0,0 +1,8 @@ +import scala.quoted._ +object Macro { + def impl[A : Type](using qctx: QuoteContext): Unit = { + import qctx.tasty._ + val tpe = typeOf[A].seal.asInstanceOf[quoted.Type[_ <: AnyRef]] + '{ (a: ${tpe}) => ???} // error + } +} diff --git a/tests/neg/i8871b.scala b/tests/neg/i8871b.scala new file mode 100644 index 000000000000..bb363e90f29e --- /dev/null +++ b/tests/neg/i8871b.scala @@ -0,0 +1,9 @@ +import scala.quoted._ +object Macro { + def impl[A : Type](using qctx: QuoteContext): Unit = { + import qctx.tasty._ + val tpe/*: quoted.Type[? <: AnyKind]*/ = typeOf[A].seal + '{ f[$tpe] } // error + } + def f[T <: AnyKind]: Unit = () +} diff --git a/tests/pos-macros/tasty-constant-type/Macro_1.scala b/tests/pos-macros/tasty-constant-type/Macro_1.scala index ee564610f299..effb2252a56b 100644 --- a/tests/pos-macros/tasty-constant-type/Macro_1.scala +++ b/tests/pos-macros/tasty-constant-type/Macro_1.scala @@ -12,8 +12,7 @@ object Macro { val ConstantType(Constant(v1: Int)) = a.unseal.tpe val ConstantType(Constant(v2: Int)) = b.unseal.tpe - val t = Literal(Constant((v1 + v2): Int)).tpe.seal - - '{ null: AddInt[$a, $b] { type Out = $t } } + Literal(Constant((v1 + v2): Int)).tpe.seal match + case '[$t] => '{ null: AddInt[$a, $b] { type Out = $t } } } }