Skip to content
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

Reject all explicitly written type references with bad bounds #15577

Merged
merged 8 commits into from
Jul 9, 2022

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 4, 2022

Reject type definitions or bound types in patterns that have possibly conflicting bounds.
However, we can suppress checks for type parameters, since these will need to be instantiated
with good types themselves. We can also suppress checks for members of abstract classes
or traits or types in refinements since in each case these can be accessed only by selecting
from a concrete value, and bounds are checked when such a value is created.

Fixes further unsoundness examples added to neg/i15569.scala.

Fixes #15578
Fixes #15575
Fixes #15609

... except for type parameters, since these will need to be instantiated
with good types themselves. Fixes further unsoundness examples added to
neg/i15569.scala.
tests/neg/i13820.scala Outdated Show resolved Hide resolved
Flag already creations of type that have possibly conflicting bounds.
Creation sites are

 - type declarations other than type parameters
 - bindings in type patterns
Don't check bounds for type definitions in abstract classes, traits, or refinements.
Bounds violations will be detected when values of these types are created.
and fix two other tests
@odersky
Copy link
Contributor Author

odersky commented Jul 9, 2022

@dwijnand @Linyxus ping for review

Copy link
Contributor

@Linyxus Linyxus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM!

compiler/src/dotty/tools/dotc/typer/Checking.scala Outdated Show resolved Hide resolved
tests/semanticdb/expect/i5854.scala Show resolved Hide resolved
tests/semanticdb/metac.expect Outdated Show resolved Hide resolved
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those minor details aside, LGTM

@odersky odersky merged commit ef6ec75 into scala:main Jul 9, 2022
@odersky odersky deleted the fix-15569-2 branch July 9, 2022 22:27
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants