Skip to content

Enum values are not properly reused due to underlyingArgument in macros #14510

Closed
@Atry

Description

@Atry

Compiler version

3.1.1

Minimized code

import scala.quoted.*

given staging.Compiler = staging.Compiler.make(getClass.getClassLoader)

def underlyingArgumentImpl[A](expr: Expr[A])(using Quotes, Type[A]) =
  import scala.quoted.quotes.reflect.*
  expr.asTerm.underlyingArgument.asExprOf[A]

inline def underlyingArgument[A](inline a: A): A = ${
  underlyingArgumentImpl('a)
}

val b: Boolean = staging.run[Boolean] {
  '{
    def f() = {
      enum E:
        case V
      underlyingArgument(E.V == E.V)
    }
    f()
  }
}

println(b)

https://scastie.scala-lang.org/82665kkpQ3KIBESu0jMnTg

Output

false

Expectation

true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions