File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
compiler/src/dotty/tools/dotc/cc Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -871,12 +871,13 @@ class CheckCaptures extends Recheck, SymTransformer:
871
871
val isLocal =
872
872
sym.owner.ownersIterator.exists(_.isTerm)
873
873
|| sym.accessBoundary(defn.RootClass ).isContainedIn(sym.topLevelClass)
874
-
875
- // The following classes of definitions need explicit capture types ...
876
- if ! isLocal // ... since external capture types are not inferred
877
- || sym.owner.is(Trait ) // ... since we do OverridingPairs checking before capture inference
878
- || sym.allOverriddenSymbols.nonEmpty // ... since we do override checking before capture inference
879
- then
874
+ def canUseInferred = // If canUseInferred is false, all capturing types in the type of `sym` need to be given explicitly
875
+ sym.is(Private ) // private symbols can always have inferred types
876
+ || // non-local symbols cannot have inferred types since external capture types are not inferred
877
+ isLocal // local symbols still need an explicit types if
878
+ && ! sym.owner.is(Trait ) // - they are defined in a trait, since we do OverridingPairs checking before capture inference
879
+ && ! sym.allOverriddenSymbols.nonEmpty // - they override some other symbol, since we do override checking before capture inference
880
+ if ! canUseInferred then
880
881
val inferred = t.tpt.knownType
881
882
def checkPure (tp : Type ) = tp match
882
883
case CapturingType (_, refs) if ! refs.elems.isEmpty =>
You can’t perform that action at this time.
0 commit comments