Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reflect.LambdaType type test #16972

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ trait TypesSupport:
}
inner(sc) ++ keyword(" match ").l ++ plain("{\n").l ++ casesTexts ++ plain(spaces + "}").l

case ParamRef(TypeLambda(names, _, _), i) => tpe(names.apply(i)).l

case ParamRef(m: MethodType, i) => tpe(m.paramNames(i)).l ++ plain(".type").l

case ParamRef(binder: LambdaType, i) => tpe(binder.paramNames(i)).l
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case ParamRef(TypeLambda(names, _, _), i) was accidentally matching TypeLambda and PolyType here. Replaced with LambdaType that matches TypeLambda, PolyType, and MethodType.


case RecursiveType(tp) => inner(tp)

case MatchCase(pattern, rhs) =>
Expand Down
10 changes: 10 additions & 0 deletions tests/pos-macros/i16961/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/pos-macros/i16961/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def test = myMacro