From a32af5e0ae3040c307df7678eb7bf93b1a383d2f Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 20 Feb 2023 11:15:33 +0100 Subject: [PATCH] Fix reflect.LambdaType type test Fixes #16961 --- .../src/scala/quoted/runtime/impl/QuotesImpl.scala | 4 ++-- tests/pos-macros/i16961/Macro_1.scala | 10 ++++++++++ tests/pos-macros/i16961/Test_2.scala | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/pos-macros/i16961/Macro_1.scala create mode 100644 tests/pos-macros/i16961/Test_2.scala diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index 1501b07c6bde..cac0335177d9 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -2167,11 +2167,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler end extension end PolyTypeMethods - type TypeLambda = dotc.core.Types.TypeLambda + type TypeLambda = dotc.core.Types.HKTypeLambda object TypeLambdaTypeTest extends TypeTest[TypeRepr, TypeLambda]: def unapply(x: TypeRepr): Option[TypeLambda & x.type] = x match - case tpe: (Types.TypeLambda & x.type) => Some(tpe) + case tpe: (Types.HKTypeLambda & x.type) => Some(tpe) case _ => None end TypeLambdaTypeTest diff --git a/tests/pos-macros/i16961/Macro_1.scala b/tests/pos-macros/i16961/Macro_1.scala new file mode 100644 index 000000000000..20ec6b439ec8 --- /dev/null +++ b/tests/pos-macros/i16961/Macro_1.scala @@ -0,0 +1,10 @@ +import scala.quoted.* + +inline def myMacro = ${ myMacroImpl } + +def myMacroImpl(using Quotes) = + import quotes.reflect.* + + PolyType(List("arg"))(_ => List(TypeBounds.empty), _ => TypeRepr.of[Any]) match + case _: TypeLambda => quotes.reflect.report.errorAndAbort("PolyType should not be a TypeLambda") + case _ => '{ () } // Ok diff --git a/tests/pos-macros/i16961/Test_2.scala b/tests/pos-macros/i16961/Test_2.scala new file mode 100644 index 000000000000..76a9e17659db --- /dev/null +++ b/tests/pos-macros/i16961/Test_2.scala @@ -0,0 +1 @@ +def test = myMacro