Skip to content

Trivial inline identity function causes runtime NoClassDefFound error in resulting code #23279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
neko-kai opened this issue May 28, 2025 · 1 comment

Comments

@neko-kai
Copy link
Contributor

neko-kai commented May 28, 2025

Compiler version

3.3.6, 3.7.0 and 3.7.1-RC2

Minimized code

inline def simpleInlineWrap(f: => Any): Unit = f

@main def main(): Unit = {
  simpleInlineWrap {
    object lifecycle {
      object Lifecycle {
        trait FromZIO
      }
    }
    object defn {
      val Lifecycle: lifecycle.Lifecycle.type = lifecycle.Lifecycle
    }
    val xa: defn.Lifecycle.type = defn.Lifecycle
  }
}

https://scastie.scala-lang.org/fcE9r7cwQBSw7m5XwrrR1w - Scastie running on 3.7.1-RC2

Output

java.lang.NoClassDefFoundError: main$package$_$lifecycle$Lifecycle$
	at main$package$.f$proxy1$1(main.scala:13)
	at main$package$.main(main.scala:4)
	at main.main(main.scala:3)

Expectation

Expected not to throw NoClassDefFound error. Removing inline from simpleInlineWrap causes the code to work as expected.

NB: encountered when using ScalaTest, which at some point started wrapping all user tests via inline functions

@neko-kai neko-kai added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 28, 2025
neko-kai added a commit to zio/izumi-reflect that referenced this issue May 28, 2025
@som-snytt
Copy link
Contributor

The working case at flatten has

        val xa:
          i23279$package$lifecycle$2.this.i23279$package$lifecycle$2$Lifecycle
           = this.defn$1(defn$lzy1, lifecycle$lzy1).Lifecycle()

before flatten

        val xa: lifecycle$2.this.Lifecycle =
          this.defn$1(defn$lzy1, lifecycle$lzy1).Lifecycle()

The broken proxy has

        val xa: i23279$package.lifecycle.i23279$package$_$lifecycle$Lifecycle =
          this.defn$1(defn$lzy1, lifecycle$lzy1).Lifecycle().asInstanceOf[
            i23279$package.lifecycle.i23279$package$_$lifecycle$Lifecycle]

before flatten

        val xa: i23279$package.lifecycle.Lifecycle =
          this.defn$1(defn$lzy1, lifecycle$lzy1).Lifecycle().asInstanceOf[
            i23279$package.lifecycle.Lifecycle]

where it should be lifecycle$2 after lambdalift.

neko-kai added a commit to zio/izumi-reflect that referenced this issue May 29, 2025
#541)

* Fix regression in 3.0.0: properly dealias nested singletons on Scala 2

Regression was introduced in #504

* Fix Scala 3 build by working around a newly found scala/scala3#23279
@Gedochao Gedochao added area:inline and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 29, 2025
@som-snytt som-snytt self-assigned this Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants