wvlet / airframe

Essential Building Blocks for Scala
https://wvlet.org/airframe
Apache License 2.0
632 stars 66 forks source link

`Surface.methodsOf` for `Enumeration` fails in Scala 3 #3411

Open OndrejSpanel opened 8 months ago

OndrejSpanel commented 8 months ago

Another one discovered thanks to using the workaround suggested in #3367. Tested with Scala 3.4.1-RC1 and surface 24.2.2, works fine in Scala 2:

build.sbt:

version := "0.1.0-SNAPSHOT"

scalaVersion := "3.4.1-RC1"

name := "airframe-surface-test"

libraryDependencies += "org.wvlet.airframe" %% "airframe-surface" % "24.2.2"

Main.scala:

import wvlet.airframe.surface.Surface

object Main {

  object ScalaEnum extends Enumeration {
    val EnumA, EnumB = Value

    type ScalaEnum = Value
  }

  def main(args: Array[String]): Unit = {
    Surface.methodsOf[ScalaEnum.ScalaEnum]
  }
}

produces following error:

C:\Dev\airframe-surface-test\src\main\scala\Main.scala:12:22
constructor ValueSet cannot be accessed as a member of Enumeration.this.ValueSet from object Main.
  private[ValueSet] constructor ValueSet can only be accessed from class ValueSet in class Enumeration.
    Surface.methodsOf[ScalaEnum.ScalaEnum]
OndrejSpanel commented 8 months ago

I guess with #3423 the behaviour will change, as private[ValueSet] should be handled gracefully. It might be worth checking what is the current behaviour with Scala 2 and make sure with Scala 3 it behaves the same way.