Skip to content

Avoid necessaryEither because it could constrain too much #12316

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

Closed
wants to merge 1 commit into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 3, 2021

In a comparison A & B <: C { x: D, y: E }

we cannot reduce the problem in a sound way to necessaryEither. Example:

A = C { x: D }
B is a constrainable type variable

Here, the strongest constraint that follows from A & B <: C { x: D, y: E } is

B <: C { y: E }

But necessaryEither would give in this case

B <: C { x: D, y: E }

Fixes #12306

But a better fix could be to decompose the refinement type on the right into its constituents and
run a necessaryEither for both A & B <: C { x: D } and A & B <: C { y: E }

In a comparison A & B <: C { x: D, y: E }

we cannot reduce the problem in a sound way to necessaryEither. Example:

    A = C { x: D }
    B is a constrainable type variable

Here, the strongest constraint that follows from `A & B <: C { x: D, y: E }` is

    B <: C { y: E }

But necessaryEither would give in this case

    B <: C { x: D, y: E }

Fixes scala#12306

But a better fix could be to decompose the refinement type on the right into its constituents and
run a necessaryEither for both `A & B <: C { x: D }` and `A & B <: C { y: E }`
@odersky
Copy link
Contributor Author

odersky commented May 3, 2021

It turns out that the problem is specific to refinements on the right. It does not come up with AndType/AndType comparisons. So
#12317 is a superior fix.

@odersky odersky closed this May 3, 2021
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.

Bug at type inference for structural types.
1 participant