Skip to content

Workaround #4819: Avoid creating incorrect JointRefDenotations #4829

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

Merged
merged 1 commit into from
Jul 25, 2018

Conversation

smarter
Copy link
Member

@smarter smarter commented Jul 23, 2018

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 #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.
@smarter smarter force-pushed the workaround-overload-merge branch from 30718d8 to 4e695fb Compare July 23, 2018 21:37
@smarter smarter requested a review from odersky July 23, 2018 22:03
@allanrenucci
Copy link
Contributor

allanrenucci commented Jul 25, 2018

With this patch, while compiling the standard library I get:

[error] -- Error: /Users/renucci/workspace/scala/src/library/scala/collection/immutable/TreeMap.scala:28:12 
[error] 28 |final class TreeMap[K, +V] private (tree: RB.Tree[K, V])(implicit val ordering: Ordering[K])
[error]    |            ^
[error]    |method collect in trait StrictOptimizedMapOps is not a legal implementation of `collect` in class TreeMap
[error]    |  its type             [K2, V2](pf: PartialFunction[(K, V), (K2, V2)]): scala.collection.Map[K2, V2]
[error]    |  does not conform to  [K2, V2](pf: PartialFunction[(K, V), (K2, V2)]): Map[K2, V2]

I'll try to minimise

Edit: Actually, I think it is another issue. It also happen on master. I opened #4839

@smarter smarter merged commit ec94614 into scala:master Jul 25, 2018
@allanrenucci allanrenucci deleted the workaround-overload-merge branch July 25, 2018 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants