Skip to content

A more flexible scheme for handling the universal capability #18699

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

Merged
merged 85 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
fce355e
Refine "cannot have inferred type" test
odersky Sep 13, 2023
1f94a68
Run Setup code one phase before CheckCaptures
odersky Sep 18, 2023
5c6a7fd
Don't shorten local roots when printing
odersky Sep 18, 2023
434f455
Drop rhsClosure from CCState
odersky Sep 18, 2023
1164d55
Fix computation of level owners
odersky Sep 19, 2023
2397cd7
Setup newScheme mechanism
odersky Sep 19, 2023
bf9a0b0
Introduce rootTarget for mapRoots customization
odersky Sep 19, 2023
62120fb
Change result type inference of vals and defs
odersky Sep 19, 2023
f550272
Make RecheckDef return a type
odersky Sep 19, 2023
aa29559
Use a separate phase to add try owners
odersky Sep 19, 2023
1a65114
Transform infos of all symbols defined in current run in SymTransformer
odersky Sep 20, 2023
f9d8b74
Fix bug when restoring denotations in Recheck.
odersky Sep 20, 2023
eb8457b
Do fluidify when transforming symbols instead of on access
odersky Sep 20, 2023
174ccb4
Align rechecking ValDefs and DefDefs
odersky Sep 20, 2023
e6c43c1
Revise inferred type checking
odersky Sep 20, 2023
ba1e919
Take singleton types into account when instantiating local roots
odersky Sep 21, 2023
622c73c
Replace some uses of CaptureSet universal to account for local roots
odersky Sep 21, 2023
baf530f
Less forcing of info when printing
odersky Sep 21, 2023
8a332f7
Also set CaptureChecked status for unpickled roots
odersky Sep 23, 2023
d8f8c5a
Let vals be lever owners
odersky Sep 23, 2023
4323b5b
Refactor wellformed checks
odersky Sep 23, 2023
99e3fe3
Drop boxedUnlessFun and boxedIfTypeParam operations
odersky Sep 23, 2023
3544db4
Fix followAlias
odersky Sep 25, 2023
c1f198e
Also interpolate root variables in non-variable capture sets.
odersky Sep 26, 2023
19a1fa7
Refactor addNewElems
odersky Sep 27, 2023
c933a74
Refactor level error reporting
odersky Sep 27, 2023
764302d
Make CompareResult an enum
odersky Sep 29, 2023
70ffa24
Add takesCappedParam criterion to isLevelOwner
odersky Sep 29, 2023
8a8765d
Decorate inferred type aliases as inferred types
odersky Sep 29, 2023
bbde15f
Setup correct environment when completing definitions
odersky Oct 1, 2023
cbd0e0c
Treat classes with universal self types as level owners
odersky Oct 1, 2023
f79e6ae
Revamp capture roots and captureset vars
odersky Oct 1, 2023
d38c7bd
Make RefiningVars level polymorphic
odersky Oct 1, 2023
8394962
Enable takesCappedParam criterion for level ownership
odersky Oct 1, 2023
fdabd8a
Use LooseCaptureRoot checking for checking bounds of applied types
odersky Oct 1, 2023
6da11f7
Update tests can check files
odersky Oct 1, 2023
568867a
Revert "Use LooseCaptureRoot checking for checking bounds of applied …
odersky Oct 1, 2023
4e67d95
Simplification: drop ccNestingLevel
odersky Oct 1, 2023
b8b94d3
Add @sharable annotation to global counter
odersky Oct 1, 2023
7b04b70
Handle outer class roots when instantiating class members
odersky Oct 3, 2023
c0b8fb5
Simplifications
odersky Oct 5, 2023
3fc63fc
Make constructors level owners
odersky Oct 5, 2023
a4e47b1
Work capture root determination into AsSeenFrom
odersky Oct 6, 2023
dac35e1
Keep track of failure traces when subCapturing fails under -Ycc-debug
odersky Oct 7, 2023
c769305
Keep track of enclosing capture sets when comparing refined types
odersky Oct 7, 2023
5423541
Change owner of computed capture set for constructor applications
odersky Oct 7, 2023
8a679aa
Treat added class refinements as inferred types for further processing
odersky Oct 7, 2023
b62e550
A first attempt at level checking for classes
odersky Oct 7, 2023
71f7478
Drop instantiateOuterClassRoots
odersky Oct 8, 2023
0fbd6b8
Disable some special cases about RefiningVars
odersky Oct 8, 2023
09f00bb
Introduce isCaptureChecking test
odersky Oct 8, 2023
c9a02c8
Restrict isUncachable
odersky Oct 8, 2023
c78df14
Move most of self type setup to transformSym
odersky Oct 9, 2023
388349a
Make non-final impure classes level owners
odersky Oct 9, 2023
9be0f6f
Translate local roots when doing override checks
odersky Oct 9, 2023
b3c4717
Map parents of classes with the class as owner.
odersky Oct 9, 2023
dd80312
Fix CC asSeenFrom when prefix is `this`
odersky Oct 9, 2023
6f9e565
Drop unnecessary code in transformSym
odersky Oct 10, 2023
ad43c66
Revert "Revert "Implement sealed type variables""
odersky Oct 12, 2023
c2b805a
Add adapation to convert global to local root
odersky Oct 13, 2023
1df49f1
Make cap a supercapture of local roots
odersky Oct 13, 2023
2be1b41
New scheme
odersky Oct 15, 2023
32f240d
Drop CaptureRoot and AddTryOwners
odersky Oct 15, 2023
16a2216
Drop redundant elements of Setup
odersky Oct 15, 2023
f786979
Drop BoxedTypeCache
odersky Oct 15, 2023
6a21e5f
Drop LooseRootCapturing
odersky Oct 15, 2023
2981ae7
Simplify TypeComparer
odersky Oct 15, 2023
9f82e69
Drop RefiningVar
odersky Oct 15, 2023
202445d
Captureset refactoring
odersky Oct 16, 2023
fc20b42
Failing test
odersky Oct 16, 2023
035786d
Add dropped test
odersky Oct 16, 2023
f6056ae
Drop other disabled tests
odersky Oct 16, 2023
88b328c
Merge AssignProto and LhProto
odersky Oct 16, 2023
2ae29fb
Fix box adaptation
Linyxus Oct 16, 2023
4ffbda9
Polish box adaptation for better legibility
odersky Oct 16, 2023
54aea78
Don't dealias TypeRefs when transforming explicit types
odersky Oct 17, 2023
ac8971e
Move all disallowRootCapabilitiesIn calls to checkCaptures
odersky Oct 17, 2023
d29d5e3
Simplify expandAliases
odersky Oct 18, 2023
c3b2f8a
Drop user-defined local roots
odersky Oct 18, 2023
a6624de
Polishing and change printing options
odersky Oct 18, 2023
eaccea3
Don't treat non-capturechecked classes are pure.
odersky Oct 19, 2023
8883176
In a BiMap variable, propagate backwards before trying to add the ele…
odersky Oct 20, 2023
20a9b96
Add captDebug printer
odersky Oct 20, 2023
2043885
Better error messages in healTypeParam
odersky Oct 21, 2023
181d96e
A more realistic test case
odersky Oct 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package dotc
import core._
import Contexts._
import typer.{TyperPhase, RefChecks}
import cc.CheckCaptures
import parsing.Parser
import Phases.Phase
import transform._
Expand Down Expand Up @@ -84,8 +83,8 @@ class Compiler {
new PatternMatcher) :: // Compile pattern matches
List(new TestRecheck.Pre) :: // Test only: run rechecker, enabled under -Yrecheck-test
List(new TestRecheck) :: // Test only: run rechecker, enabled under -Yrecheck-test
List(new CheckCaptures.Pre) :: // Preparations for check captures phase, enabled under captureChecking
List(new CheckCaptures) :: // Check captures, enabled under captureChecking
List(new cc.Setup) :: // Preparations for check captures phase, enabled under captureChecking
List(new cc.CheckCaptures) :: // Check captures, enabled under captureChecking
List(new ElimOpaque, // Turn opaque into normal aliases
new sjs.ExplicitJSClasses, // Make all JS classes explicit (Scala.js only)
new ExplicitOuter, // Add accessors to outer classes from nested ones.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ object desugar {
private def toDefParam(tparam: TypeDef, keepAnnotations: Boolean): TypeDef = {
var mods = tparam.rawMods
if (!keepAnnotations) mods = mods.withAnnotations(Nil)
tparam.withMods(mods & EmptyFlags | Param)
tparam.withMods(mods & (EmptyFlags | Sealed) | Param)
}
private def toDefParam(vparam: ValDef, keepAnnotations: Boolean, keepDefault: Boolean): ValDef = {
var mods = vparam.rawMods
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
}
}

/** An extractor for def of a closure contained the block of the closure,
/** An extractor for the method of a closure contained the block of the closure,
* possibly with type ascriptions.
*/
object possiblyTypedClosureDef:
Expand Down
15 changes: 15 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,21 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
!(sym.is(Method) && sym.info.isInstanceOf[MethodOrPoly]) // if is a method it is parameterless
}

/** A tree traverser that generates the the same import contexts as original typer for statements.
* TODO: Should we align TreeMapWithPreciseStatContexts and also keep track of exprOwners?
*/
abstract class TreeTraverserWithPreciseImportContexts extends TreeTraverser:
override def apply(x: Unit, trees: List[Tree])(using Context): Unit =
def recur(trees: List[Tree]): Unit = trees match
case (imp: Import) :: rest =>
traverse(rest)(using ctx.importContext(imp, imp.symbol))
case tree :: rest =>
traverse(tree)
traverse(rest)
case Nil =>
recur(trees)
end TreeTraverserWithPreciseImportContexts

extension (xs: List[tpd.Tree])
def tpes: List[Type] = xs match {
case x :: xs1 => x.tpe :: xs1.tpes
Expand Down
19 changes: 0 additions & 19 deletions compiler/src/dotty/tools/dotc/cc/BoxedTypeCache.scala

This file was deleted.

13 changes: 11 additions & 2 deletions compiler/src/dotty/tools/dotc/cc/CaptureAnnotation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ case class CaptureAnnotation(refs: CaptureSet, boxed: Boolean)(cls: Symbol) exte
import CaptureAnnotation.*
import tpd.*

/** A cache for boxed version of a capturing type with this annotation */
val boxedType = BoxedTypeCache()
/** A cache for the version of this annotation which differs in its boxed status. */
var boxDual: CaptureAnnotation | Null = null

/** A boxed annotation which is either the same annotation or its boxDual */
def boxedAnnot(using Context): CaptureAnnotation =
if boxed then this
else if boxDual != null then boxDual.nn
else
val dual = CaptureAnnotation(refs, boxed = true)(cls)
dual.boxDual = this
dual

/** Reconstitute annotation tree from capture set */
override def tree(using Context) =
Expand Down
Loading