Skip to content

Fix issue with certain polyfunctions not properly matching in macros #23614

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

Merged
merged 1 commit into from
Jul 29, 2025
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/QuoteMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ class QuoteMatcher(debug: Boolean) {
*/
def matchTypeDef(sctypedef: TypeDef, pttypedef: TypeDef): MatchingExprs = sctypedef match
case TypeDef(_, TypeBoundsTree(sclo, schi, EmptyTree))
if sclo.tpe == defn.NothingType && schi.tpe == defn.AnyType =>
if sclo.tpe.isNothingType && schi.tpe.isAny =>
pttypedef match
case TypeDef(_, TypeBoundsTree(ptlo, pthi, EmptyTree))
if sclo.tpe == defn.NothingType && schi.tpe == defn.AnyType =>
if sclo.tpe.isNothingType && schi.tpe.isAny =>
matched
case _ => notMatched
case _ => notMatched
Expand Down
11 changes: 11 additions & 0 deletions tests/pos-macros/i23589/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import scala.quoted.*
import scala.language.experimental.quotedPatternsWithPolymorphicFunctions

inline def testMacro(inline body: Any) = ${test('body)}
def test(outsideBody: Expr[Any])(using Quotes): Expr[Unit] =
val insideBody = '{[B] => (a : B, b : B) => (a, b)}
outsideBody match
case '{ [A] => (x : A, y : A) => $b[A](x, y): (A, A) } => ()
insideBody match
case '{ [A] => (x : A, y : A) => $b[A](x, y): (A, A) } => ()
'{()}
3 changes: 3 additions & 0 deletions tests/pos-macros/i23589/Main_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//> using options -experimental
@main def main() =
testMacro([B] => (a : B, b : B) => (a, b))
Loading