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

Existential capabilities design draft #20470

Closed
wants to merge 14 commits into from
Closed
Prev Previous commit
Next Next commit
Add fewer parameter refinements.
Only enrich classes with capture refinements for a parameter if the deep capture set of the parameter's type is nonempty.
  • Loading branch information
odersky committed May 29, 2024
commit d49b314fcaf96bc6a1e67198abdb66eb7ef56910
15 changes: 14 additions & 1 deletion compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,20 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
private val toBeUpdated = new mutable.HashSet[Symbol]

private def newFlagsFor(symd: SymDenotation)(using Context): FlagSet =
if symd.isAllOf(PrivateParamAccessor) && symd.owner.is(CaptureChecked) && !symd.hasAnnotation(defn.ConstructorOnlyAnnot)

object containsCovarRetains extends TypeAccumulator[Boolean]:
def apply(x: Boolean, tp: Type): Boolean =
if x then true
else if tp.derivesFromCapability && variance >= 0 then true
else tp match
case AnnotatedType(_, ann) if ann.symbol.isRetains && variance >= 0 => true
case _ => foldOver(x, tp)
def apply(tp: Type): Boolean = apply(false, tp)

if symd.isAllOf(PrivateParamAccessor)
&& symd.owner.is(CaptureChecked)
&& !symd.hasAnnotation(defn.ConstructorOnlyAnnot)
//&& containsCovarRetains(symd.symbol.originDenotation.info)
then symd.flags &~ Private | Recheck.ResetPrivate
else symd.flags

Expand Down