-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Method in trait not a legal implementation in inheriting class #4819
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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
trait IterableOps[+A, +CC[_], +C] {
def concat[B >: A](suffix: Iterable[B]): CC[B] = ???
} ends up with a def concat(suffix: Iterable): Object whereas with: trait SetOps[A, +CC[X], +C <: SetOps[A, CC, C]] {
def concat(that: Iterable[A]): C = ???
} the erasure of def concat(that: Iterable): SetOps So in |
Sorry I was too quick and hopeful and misunderstood this completely... |
cc/ @julienrf Is is intended to be an overload in the standard library? Dotty was happy before |
Here's a minimization: trait One[X] {
def concat(suffix: Int): X = ???
}
trait Two[Y <: Foo] {
def concat[Dummy](suffix: Int): Y = ???
}
class Foo extends One[Foo] with Two[Foo] Any attempt at simplifying this further (avoiding f-bounded polymorphism, removing the parameter lists from the methods, ...) compiles properly, so there's probably a subtle bug somewhere. |
@allanrenucci Yes, since |
The problem is in @odersky Does it really ever makes sense to merge a denotation with a MethodType and a denotation with a PolyType? Why not always return a MultiDenotation in these cases? |
When merging a denotation with a PolyType and a denotation with a MethodType, `infoMeet` will return the MethodType info, but the symbol that is then used to create the `JointRefDenotation` can come from either denotation, if it comes from the PolyType one, the resulting denotation is inconsistent, this resulted in RefChecks errors. We fix this by simply returning either of the denotation when `infoMeet` returning either of their info. This is only a workaround and not a proper fix for scala#4819 as it doesn't allow tests/neg/i4819.scala to compile, see the comments in the file.
When merging a denotation with a PolyType and a denotation with a MethodType, `infoMeet` will return the MethodType info, but the symbol that is then used to create the `JointRefDenotation` can come from either denotation, if it comes from the PolyType one, the resulting denotation is inconsistent, this resulted in RefChecks errors. We fix this by making `preferSym` consistent with `infoMeet`. This is only a workaround and not a proper fix for scala#4819 as it doesn't allow tests/neg/i4819.scala to compile, see the comments in the file.
Workaround #4819: Avoid creating incorrect JointRefDenotations
…ations" This partially reverts 4e695fb which is no longer needed after this PR (we no longer try to merge in a single denotation a PolyType and a MethodType).
…ations" This partially reverts 4e695fb which is no longer needed after this PR (scala#5622), because we no longer try to merge in a single denotation a PolyType and a MethodType.
Uh oh!
There was an error while loading. Please reload this page.
The text was updated successfully, but these errors were encountered: