fix ambiguous/wrong origins for calls from bridge methods #714
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Originally we assumed that comparing declaring class, method name and parameter type names would be good enough to identify the caller of a method, since the compiler does not allow to declare two methods with the same name and parameter types inside the same class. However, the compiler might add methods with the same name and parameter types in certain cases (bridge methods).
Consider
To implement covariant return types (the child overriding the method using a subtype as return type) the compiler transparently adds a so-called "bridge method" that has the original type as return type (i.e. overrides 1-2-1) and simply forwards to the one with the subtype as return type.
We now take the full descriptor (containing parameter types and return types) to match the origin of a caller. By that the ambiguity is resolved, since the descriptor/full signature actually has to be unique.
Resolves: #513