Skip to content

Typer regression for macros using class with default parameters list under separete compilation units #26623

Description

@WojciechMazur

Based on the OpenCB failure in greenfossil/data-mapping - build logs

Compiler version

3.9.0-RC4
Bisect points to 80517e5 / #26063

Last good release: 3.9.0-RC1-bin-20260515-ed18d94-NIGHTLY
First bad release: 3.9.0-RC1-bin-20260517-80517e5-NIGHTLY

Minimized code

// macro.scala 

trait Binder[T]

object Binder:
  def foo(s: String): Binder[Int] = new Binder[Int] {}
  val foo: Binder[Int] = foo("x")

// Named `binder =` skips the defaulted `name` parameter.
case class Box[A](tpe: String, name: String = "", binder: Binder[A] = null)

object Mapping:
  inline def localDate: Box[Int] =
    Box("LocalDate", binder = Binder.foo)
// test.test.scala - requires separate compilation unit
//> using file macro.scala

@main def Test = Mapping.localDate

Requires seperate compilation unit, reproductible the easiest under scala-cli --test target scope

scala compile --test test.test.scala -S 3.nightly  

Output

Checked https://repo1.maven.org/maven2/org/scala-lang/scala3-library_3/maven-metadata.xml
-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/community-build3/test.test.scala:3:25 
 3 |@main def Test = Mapping.localDate
   |                 ^^^^^^^^^^^^^^^^^
   |                 Found:    (Binder.foo : Binder[Int])
   |                 Required: <overloaded Binder.foo>
   |----------------------------------------------------------------------------
   |Inline stack trace
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   |This location contains code that was inlined from test-macro.scala:12
12 |    Box("LocalDate", binder = Binder.foo)
   |                              ^^^^^^^^^^
    ----------------------------------------------------------------------------
   |
   | longer explanation available when compiling with `-explain`
1 error found
Compilation failed

Expectation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions