Skip to content

Signature is different if method compiled by Scala 2 #11949

Closed
@bishabosha

Description

@bishabosha

Compiler version

3.0.0-RC2

Minimized code

// reflection.scala (scala-reflect shim), compiled with Scala 2.13.5
package reflectshims

abstract class Universe {
  type Tree >: Null <: AnyRef with TreeApi
  trait TreeApi extends Product { this: Tree => }
}

trait Context {

  type Tree = universe.Tree

  val universe: Universe

}
// Scala2Macros.scala
package example

object Scala2Macro {
  def fooImpl(c: reflectshims.Context)(code: c.Tree): c.Tree = code
}

class Scala2Bundle(val c: reflectshims.Context) {
  def fooImpl(code: c.Tree): c.Tree = code
}
// MacroDefs.scala, compile with 3.0.0-RC2
package example

object MacroDefs {
  // here we simulate code generated for Scala 2 macro implementations

  def foo(code: String): String = Scala2Macro.fooImpl(??? : reflectshims.Context)(???).asInstanceOf[String]

  def foo2(code: String): String = {
    val bundle = new Scala2Bundle(null)
    bundle.fooImpl(???).asInstanceOf[String]
  }

}

Output

  • compile Scala2Macros.scala with 2.13.5
  • compile MacroDefs.scala
  • the signature in TASTy for calling Scala2Macro.fooImpl is
fooImpl[Signed Signature(List(reflectshims.Context, reflectshims.Universe.TreeApi),reflectshims.Universe.TreeApi) @fooImpl]
  • compile Scala2Macros.scala with 3.0.0-RC2
  • compile MacroDefs.scala
  • the signature in TASTy for calling Scala2Macro.fooImpl is
fooImpl[Signed Signature(List(reflectshims.Context, java.lang.Object),java.lang.Object) @fooImpl]

Expectation

I expect the signature to be the same

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions