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

Two fixes to handling of abstract types with cap bounds #22838

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 19, 2025

  1. Strip implied cap.rd sets from Capability types in extends and bounds

    I.e. We do not add an implicit cap.rd in

    class C extends Capability
    type T <: C

  2. Don't map CapSet^ to CapSet^{fresh}. Assume ^ is root in some comparisons with CapSet.

# Conflicts:
#	compiler/src/dotty/tools/dotc/cc/Setup.scala
@odersky odersky force-pushed the capability-bounds branch from ff6f4b8 to a94efa4 Compare March 19, 2025 17:33
Copy link
Contributor

@natsukagami natsukagami left a comment

Choose a reason for hiding this comment

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

Just some comment about new withCapAsRoot calls

@@ -426,7 +426,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
if (tp1.prefix.isStable) return tryLiftedToThis1
case _ =>
if isCaptureVarComparison then
return subCaptures(tp1.captureSet, tp2.captureSet).isOK
return CCState.withCapAsRoot:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should leave a comment to make sure we don't introduce unsoundness

@@ -575,7 +576,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
&& (isBottom(tp1) || GADTusage(tp2.symbol))

if isCaptureVarComparison then
return subCaptures(tp1.captureSet, tp2.captureSet).isOK
return CCState.withCapAsRoot:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should leave a comment to make sure we don't introduce unsoundness

@@ -1875,7 +1904,9 @@ class CheckCaptures extends Recheck, SymTransformer:
def traverse(t: Tree)(using Context) = t match
case tree: InferredTypeTree =>
case tree: New =>
case tree: TypeTree => checkAppliedTypesIn(tree.withType(tree.nuType))
case tree: TypeTree =>
CCState.withCapAsRoot:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should leave a comment to make sure we don't introduce unsoundness

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.

2 participants