Skip to content

class cast exception with inline defs in nested objects #15317

Closed
@rmgk

Description

@rmgk

Compiler version

3.1.2, 3.2.0-RC1-bin-20220528-23c0825-NIGHTLY

Minimized code

class Outer {
  val outer = 1
  object Inner {
    def forwarder: Int   = inlined
    inline def inlined: Int = outer
  }
}

@main def run() = (new Outer).Inner.forwarder

Output

Exception in thread "main" java.lang.ClassCastException: class Outer$Inner$ cannot be cast to class Outer (Outer$Inner$ and Outer are in unnamed module of loader java.net.URLClassLoader @36e409e0)
	at Outer$Inner$.forwarder(bits.scala:4)
	at bits$package$.run(bits.scala:10)
	at run.main(bits.scala:10)

Expectation

Runs without exception.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions