-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Incorrect bridge gen for method that has value class with underlying Object type as result type #1169
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
Comments
Here is the diagnosis of this bug. It has nothing to do with class X(val underlying: Object) extends AnyVal
trait Producer[T] {
def produce: T
}
class XProducer extends Producer[X] {
def produce = new X(null)
} Consider the method Producer.produce. I has erased signature: This will lead to fact that we would have 2 methods with same signature but different semantics. One returns an This problem is not specific to class VC(u: UT) extends UT is able to break bridge generation for methods that return The solution that I propose to this problem, is to have |
Note, Scalac had similar bugs: The fix that was deployed in Note, that in https://issues.scala-lang.org/browse/SI-9166 @retronym proposes the same change that I'm proposing here. |
I think name mangling is a can of worms, so would like to avoid it. The way I see it there are two options:
The easiest route is probably to do what scalac does. |
Currently scalac rejects this example (2.11 and 2.12) with:
|
OK, I think that is acceptable. On Fri, Mar 18, 2016 at 5:45 PM, Vladimir Nikolaev <[email protected]
Martin Odersky |
We have agreed in private discussion that we may reconsider. |
Related: #1905. We might come back to the idea of mangling, after all. |
We already generate an error message for i1169.scala, but it looked weird: |bridge generated for member method produce=> X in class XProducer |which overrides method produce=> T in trait Producer |clashes with definition of the member itself; both have erased type (): Object. The fix changes how ExprTypes in method signatures are handled. We now get: |bridge generated for member method produce: X in class XProducer |which overrides method produce: T in trait Producer |clashes with definition of the member itself; both have erased type (): Object."
We already generate an error message for i1169.scala, but it looked weird: |bridge generated for member method produce=> X in class XProducer |which overrides method produce=> T in trait Producer |clashes with definition of the member itself; both have erased type (): Object. The fix changes how ExprTypes in method signatures are handled. We now get: |bridge generated for member method produce: X in class XProducer |which overrides method produce: T in trait Producer |clashes with definition of the member itself; both have erased type (): Object."
Fix #1169: Fix strange type formatting in error message
Incorrect bridge generation for method that has value class with the underlying Object type as result type.
The compilation of this code with -Ycheck:all:
results in:
The problem is that there is a bridge generation during Erasure for
def yyyy(x: Object): A = ...
.This bridge has the same signature as original
def yyyy(x: Object): A = ...
:The text was updated successfully, but these errors were encountered: