Skip to content

Structural types with "primitive" methods throw NoSuchMethodException #24859

@xuwei-k

Description

@xuwei-k

Compiler version

  • 3.8.0-RC4
  • 3.7.4
  • 3.3.7

Minimized code

//> using scala 3.8.0-RC4

import scala.reflect.Selectable.reflectiveSelectable

def x(y: Any{def +(z: Int): Int}): Int = y + 5
 
@main def test = print(x(2))

Output

java.lang.NoSuchMethodException: java.lang.Integer.$plus(int)
	at java.base/java.lang.Class.getMethod(Class.java:2397)
	at scala.reflect.Selectable.applyDynamic(Selectable.scala:40)
	at scala.reflect.Selectable.applyDynamic$(Selectable.scala:13)
	at scala.reflect.Selectable$DefaultSelectable.applyDynamic(Selectable.scala:53)
	at A$package$.x(A.scala:5)
	at A$package$.test(A.scala:7)
	at test.main(A.scala:7)

Expectation

compile error or success. not runtime error

Note

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