Skip to content

Underlying fields enumerated when inspecting opaque type #22143

Open
@OndrejSpanel

Description

@OndrejSpanel

Compiler version

3.5.2, 3.6.2-RC3

Minimized code

import scala.quoted.*

inline def debug[A]: String = ${ debugImpl[A] }

def debugImpl[A: Type](using quotes: Quotes): Expr[String] = {
  import quotes.reflect.*
  val a = TypeRepr.of[A]
  val sym = a.typeSymbol
  val xMem = sym.fieldMember("x")
  if (xMem != Symbol.noSymbol)
    Expr(s"${sym.name}.${xMem.name}, flags ${xMem.flags.show}")
  else
    Expr("No symbol")
}
object T {
  case class V(x: Double)

  opaque type Vec = V
}

import T.*

object Main {

  def main(args: Array[String]): Unit = {
    println(debug[Vec])
    println(debug[V])
  }
}

Output

Vec.x, flags Flags.CaseAccessor | Flags.ParamAccessor
V.x, flags Flags.CaseAccessor | Flags.ParamAccessor

Expectation

When inspecting opaque type field members, members of the underlying type should not be revealed.

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