Skip to content

Expr.betaReduce does not correctly handle inlining function literals type-ascribed to subclasses of Function #8290

Closed
@fhackett

Description

@fhackett

minimized code

abstract class Test extends (Int => Int) {
  def impl(i: Int): Int
  def apply(i: Int): Int = -1
}
// ...
object Macros {
  inline def dummy : Test =
    (i: Int) => i + 1

  inline def test : Int =
    ${ testImpl }
  def testImpl(using: QuoteContext): Expr[Int]
    Expr.betaReduce('{ dummy })('{ 5 })
}
// ...
object Test {
  def main(argv: Array[String]): Unit =
    println(s"${ Macros.test }")
}

Runtime output

6

expectation

-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions