Skip to content

Commit ab19081

Browse files
authored
Fix reflect.LambdaType type test (#16972)
Fixes #16961
2 parents a2da1a6 + 4386f3f commit ab19081

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,11 +2167,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
21672167
end extension
21682168
end PolyTypeMethods
21692169

2170-
type TypeLambda = dotc.core.Types.TypeLambda
2170+
type TypeLambda = dotc.core.Types.HKTypeLambda
21712171

21722172
object TypeLambdaTypeTest extends TypeTest[TypeRepr, TypeLambda]:
21732173
def unapply(x: TypeRepr): Option[TypeLambda & x.type] = x match
2174-
case tpe: (Types.TypeLambda & x.type) => Some(tpe)
2174+
case tpe: (Types.HKTypeLambda & x.type) => Some(tpe)
21752175
case _ => None
21762176
end TypeLambdaTypeTest
21772177

scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ trait TypesSupport:
290290
}
291291
inner(sc) ++ keyword(" match ").l ++ plain("{\n").l ++ casesTexts ++ plain(spaces + "}").l
292292

293-
case ParamRef(TypeLambda(names, _, _), i) => tpe(names.apply(i)).l
294-
295293
case ParamRef(m: MethodType, i) => tpe(m.paramNames(i)).l ++ plain(".type").l
296294

295+
case ParamRef(binder: LambdaType, i) => tpe(binder.paramNames(i)).l
296+
297297
case RecursiveType(tp) => inner(tp)
298298

299299
case MatchCase(pattern, rhs) =>

tests/pos-macros/i16961/Macro_1.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import scala.quoted.*
2+
3+
inline def myMacro = ${ myMacroImpl }
4+
5+
def myMacroImpl(using Quotes) =
6+
import quotes.reflect.*
7+
8+
PolyType(List("arg"))(_ => List(TypeBounds.empty), _ => TypeRepr.of[Any]) match
9+
case _: TypeLambda => quotes.reflect.report.errorAndAbort("PolyType should not be a TypeLambda")
10+
case _ => '{ () } // Ok

tests/pos-macros/i16961/Test_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def test = myMacro

0 commit comments

Comments
 (0)