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

Ignore capture sets in certain cases of subtyping #22183

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bracevac
Copy link
Contributor

@bracevac bracevac commented Dec 10, 2024

Fixes #22103

If C is a capture-set variable, then a comparison C <: CapSet^{C^} would previously fail in the TypeComparer due to a level mismatch resulting in the test CapSet^ <: CapSet.

For such cases, we now ignore the LHS capture annotation. This is controlled by a new bit in the ApproxState of the TypeComparer.

@bracevac bracevac requested review from noti0na1 and odersky December 10, 2024 16:22
@@ -12,8 +12,4 @@ def either[T1, T2, Cap^](
src2: Source[T2, Cap]^{Cap^}): Source[Either[T1, T2], Cap]^{Cap^} =
val left = src1.transformValuesWith(Left(_))
val right = src2.transformValuesWith(Right(_))
race[Either[T1, T2], Cap](left, right)
Copy link
Member

@noti0na1 noti0na1 Dec 11, 2024

Choose a reason for hiding this comment

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

The extension methods above can be tested as well. I remember they have similar issues.

@noti0na1
Copy link
Member

noti0na1 commented Dec 11, 2024

We should have standalone file to test the subtyping:

def test[C^] = 
  val a: C = ???
  val b: CapSet^{C^} = a
  val c: C = b
  val d: CapSet^{C^, ...} = a
  ...

We also want to test nested types are still working:

def test[C^, D^] = 
  A[C] <:< A[CapSet^{C^}] // ok
  A[C] <:< A[CapSet^{D^}] // error
  A[C]^{D^} <:< A[CapSet^{D^}]^{D^} // error

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.

Improve Subtyping and Normalization of Capture Sets
2 participants