Skip to content
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

Structural types + value types + method subtyping = NoSuchMethodException #10175

Closed
scabug opened this Issue Feb 8, 2017 · 4 comments

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented Feb 8, 2017

scala> val oops: Any { def +(a: Int): Any } = 42
oops: Any{def +(a: Int): Any} = 42

This works because Int has a method def +(a: Int): Int and Int <: Any.
But when you try to use it, you get a NoSuchMethodException:

scala> import scala.language.reflectiveCalls
import scala.language.reflectiveCalls

scala> oops + 5
java.lang.NoSuchMethodException: java.lang.Integer.$plus(int)
  at java.lang.Class.getMethod(Class.java:1786)
  at .reflMethod$Method1(<console>:14)
  ... 39 elided
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Feb 8, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10175?orig=1
Reporter: Jasper-M
Affected Versions: 2.12.1
See #9919, #192

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Feb 11, 2017

@SethTisue said:
Is this not a duplicate of SI-9919?

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Feb 11, 2017

Jasper-M said:
I wasn't sure. It's at least very strongly related.

@scabug scabug closed this Feb 11, 2017

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Feb 11, 2017

@SethTisue said:
(Let's assume they're basically the same thing unless we're pretty sure they're not.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.