Skip to content

Commit 53679ac

Browse files
committed
Fix issue with certain polyfunctions not properly matching in macros
1 parent 95b37a7 commit 53679ac

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,10 @@ class QuoteMatcher(debug: Boolean) {
460460
*/
461461
def matchTypeDef(sctypedef: TypeDef, pttypedef: TypeDef): MatchingExprs = sctypedef match
462462
case TypeDef(_, TypeBoundsTree(sclo, schi, EmptyTree))
463-
if sclo.tpe == defn.NothingType && schi.tpe == defn.AnyType =>
463+
if sclo.tpe.isNothingType && schi.tpe.isAny =>
464464
pttypedef match
465465
case TypeDef(_, TypeBoundsTree(ptlo, pthi, EmptyTree))
466-
if sclo.tpe == defn.NothingType && schi.tpe == defn.AnyType =>
466+
if sclo.tpe.isNothingType && schi.tpe.isAny =>
467467
matched
468468
case _ => notMatched
469469
case _ => notMatched

tests/pos-macros/i23589/Macro_1.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted.*
2+
import scala.language.experimental.quotedPatternsWithPolymorphicFunctions
3+
4+
inline def testMacro(inline body: Any) = ${test('body)}
5+
def test(outsideBody: Expr[Any])(using Quotes): Expr[Unit] =
6+
val insideBody = '{[B] => (a : B, b : B) => (a, b)}
7+
outsideBody match
8+
case '{ [A] => (x : A, y : A) => $b[A](x, y): (A, A) } => ()
9+
insideBody match
10+
case '{ [A] => (x : A, y : A) => $b[A](x, y): (A, A) } => ()
11+
'{()}

tests/pos-macros/i23589/Main_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//> using options -experimental
2+
@main def main() =
3+
testMacro([B] => (a : B, b : B) => (a, b))

0 commit comments

Comments
 (0)