Skip to content

Passing an instance of a value class to a method accessed structurall via reflection #16995

@prolativ

Description

@prolativ

Compiler version

3.3.1-RC1-bin-20230221-847eccc-NIGHTLY and before

Minimized code

class Foo(val i: Int) extends AnyVal
class Reflective extends reflect.Selectable

@main def run() =
  val reflective = new Reflective {
    def bar(foo: Foo) = foo.i
  }
  val i = reflective.bar(Foo(1))

Output

Exception in thread "main" java.lang.NoSuchMethodException: Reflect$package$$anon$1.bar(Foo)
        at java.lang.Class.getMethod(Class.java:1786)
        at scala.reflect.Selectable.applyDynamic(Selectable.scala:38)
        at scala.reflect.Selectable.applyDynamic$(Selectable.scala:11)
        at Reflective.applyDynamic(Reflect.scala:2)
        at Reflect$package$.run(Reflect.scala:8)
        at run.main(Reflect.scala:4)

Expectation

No exception should be thrown.

This is related to #14340 (with fix available here #16286) but the problem here is in the parameters of methods rather than in returned values

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