-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix compatibility of Java with value classes #532
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
Conversation
ec9cfce to
656c248
Compare
|
@smarter can you add a testcase? |
|
Otherwise LGTM |
This avoids getting a runtime error when calling a Java-defined method whose signature contains value classes. It happened because we erased the value classes in this signature even though it comes from a classfile. Amusingly, this problem also exists in scalac: <https://issues.scala-lang.org/browse/SI-9298>
656c248 to
e8f3224
Compare
|
Test added. |
Fix compatibility of Java with value classes
|
Probably worth a look at scala/scala@44b9cf0 which introduced nuanced erasure to Scala based on whether the symbol was Java/Scala, or constructor/non-constructor. |
|
@retronym we already have different erasure for java-defined symbol, with different glb. |
|
I was echoing a comment in that commit. Looking back a bit further, I think it refers to the special case that the result type of a value class constructor should not erase to the underlying: scala/scala@e171d6d I guess you have that covered already. |
scala> case class C(val i: Int) extends AnyVal
defined class C
scala> :power
scala> val constructor = symbolOf[C].primaryConstructor
constructor: $r.intp.global.Symbol = constructor C
scala> erasure.specialErasure(constructor)(constructor.info)
res5: $r.intp.global.erasure.global.Type = (i: Int)C
scala> erasure.specialErasure(NoSymbol)(constructor.info)
res6: $r.intp.global.erasure.global.Type = (i: Int)ErasedValueType(class C, Int) |
Backport "Check OrType in interpolated toString lint" to 3.3 LTS
Review by @odersky.