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

Disallow covariant caps in the lower bound of type members #19624

Merged
merged 4 commits into from
Feb 15, 2024

Conversation

Linyxus
Copy link
Contributor

@Linyxus Linyxus commented Feb 6, 2024

Fixes #19330.

Since when instantiating a type member we do not disallow covariant caps in the instance, a check is added at the application site to check for covariant caps in the lower bound of type members to maintain soundness. This check is elided for type parameters since their instances are always checked at the instantiation site.

@Linyxus Linyxus requested a review from odersky February 6, 2024 06:05
@Linyxus Linyxus added the area:experimental:cc Capture checking related label Feb 6, 2024
Copy link
Contributor

@odersky odersky 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


// Check the lower bound of path dependent types.
// See issue #19330.
val isTypeParam = t.prefix eq NoPrefix
Copy link
Contributor

Choose a reason for hiding this comment

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

isTypeParam is misleading as a name. It could also be a local type definition, that also will lead to a NoPrefix. I'd turn it around and define:

val isMember = t.prefix ne NoPrefix

@odersky odersky assigned Linyxus and unassigned odersky Feb 15, 2024
@odersky odersky assigned Linyxus and unassigned odersky Feb 15, 2024
@Linyxus Linyxus enabled auto-merge February 15, 2024 17:46
@Linyxus Linyxus merged commit 0800dec into scala:main Feb 15, 2024
17 checks passed
@Linyxus Linyxus deleted the fix-19330 branch February 15, 2024 20:35
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:cc Capture checking related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scoped capabilities can leak through path-dependent types
3 participants