Open
Description
Compiler version
3.7.1, 3.7.3-RC1-bin-20250620-d6b74fa-NIGHTLY
Minimized code
//> using scala 3.7.1
// file: Repro2.scala
import NamedTuple.*
import scala.quoted.*
class ReproClass {
def methodCallWithNamedTuple[Names <: Tuple, Values <: Tuple](tup: NamedTuple[Names, Values]): Int = 1
def methodCallWithAnyNamedTuple[Tup <: AnyNamedTuple](tup: Tup): Int = 1
}
object Repro2 {
// works correctly if this is defined as just `inline`
transparent inline def run(inline expr: Int) = ${ runMacro('expr) }
def runMacro(expr: Expr[Int])(using Quotes) = {
import quotes.reflect.*
expr match {
case '{
type names <: Tuple
type values <: Tuple
($reproClass: ReproClass).methodCallWithNamedTuple[names, values]($tup)
} => report.errorAndAbort("Matched methodCallWithNamedTuple")
case '{
type tup <: AnyNamedTuple
($reproClass: ReproClass).methodCallWithAnyNamedTuple[tup]($tup)
} => report.errorAndAbort("Matched methodCallWithAnyNamedTuple")
case _ => report.errorAndAbort("didn't match anything :c")
}
}
}
//file test2.scala
object test2 {
val reproClass = new ReproClass
Repro2.run(reproClass.methodCallWithNamedTuple((field1 = 123, field2 = "123"))) // didn't match anything :c
Repro2.run(reproClass.methodCallWithAnyNamedTuple((field1 = 123, field2 = "123"))) // Matched methodWithAnyNamedTuple
}
Output
Compiling project (Scala 3.7.3-RC1-bin-20250620-d6b74fa-NIGHTLY, JVM (21))
[error] ./unableToMatchExprsThatEvenMentionNamedTuple/test2.scala:3:3
[error] didn't match anything :c
[error] Repro2.run(reproClass.methodCallWithNamedTuple((field1 = 123, field2 = "123"))) // didn't match anything :c
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] ./unableToMatchExprsThatEvenMentionNamedTuple/test2.scala:4:3
[error] Matched methodCallWithAnyNamedTuple
[error] Repro2.run(reproClass.methodCallWithAnyNamedTuple((field1 = 123, field2 = "123"))) // Matched methodWithAnyNamedTuple
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error compiling project (Scala 3.7.3-RC1-bin-20250620-d6b74fa-NIGHTLY, JVM (21))
Compilation failed
Expectation
Repro2.run(reproClass.methodCallWithNamedTuple((field1 = 123, field2 = "123")))
outputs Matched methodCallWithNamedTuple
when Repro2.run
is defined as inline
or transparent inline