Skip to content

Commit 3dd4f10

Browse files
committed
Refactor: move ccConfig into separate file
1 parent d674405 commit 3dd4f10

File tree

2 files changed

+57
-53
lines changed

2 files changed

+57
-53
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import Types.*, Symbols.*, Contexts.*, Annotations.*, Flags.*
77
import Names.TermName
88
import ast.{tpd, untpd}
99
import Decorators.*, NameOps.*
10-
import config.SourceVersion
1110
import config.Printers.capt
1211
import util.Property.Key
1312
import tpd.*
1413
import StdNames.nme
15-
import config.Feature
1614
import collection.mutable
1715
import CCState.*
1816
import reporting.Message
@@ -24,57 +22,6 @@ private val Captures: Key[CaptureSet] = Key()
2422
/** Context property to print root.Fresh(...) as "fresh" instead of "cap" */
2523
val PrintFresh: Key[Unit] = Key()
2624

27-
object ccConfig:
28-
29-
/** If enabled, use a special path in recheckClosure for closures
30-
* to compare the result tpt of the anonymous functon with the expected
31-
* result type. This can narrow the scope of error messages.
32-
*/
33-
inline val preTypeClosureResults = false
34-
35-
/** If this and `preTypeClosureResults` are both enabled, disable `preTypeClosureResults`
36-
* for eta expansions. This can improve some error messages.
37-
*/
38-
inline val handleEtaExpansionsSpecially = true
39-
40-
/** Don't require @use for reach capabilities that are accessed
41-
* only in a nested closure. This is unsound without additional
42-
* mitigation measures, as shown by unsound-reach-5.scala.
43-
*/
44-
inline val deferredReaches = false
45-
46-
/** Check that if a type map (which is not a BiTypeMap) maps initial capture
47-
* set variable elements to themselves it will not map any elements added in
48-
* the future to something else. That is, we can safely use a capture set
49-
* variable itself as the image under the map. By default this is off since it
50-
* is a bit expensive to check.
51-
*/
52-
inline val checkSkippedMaps = false
53-
54-
/** Always repeat a capture checking run at least once if there are no errors
55-
* yet. Used for stress-testing the logic for when a new capture checking run needs
56-
* to be scheduled because a provisionally solved capture set was later extended.
57-
* So far this happens only in very few tests. With the flag on, the logic is
58-
* tested for all tests except neg tests.
59-
*/
60-
inline val alwaysRepeatRun = false
61-
62-
/** After capture checking, check that no capture set contains ParamRefs that are outside
63-
* its scope. This used to occur and was fixed by healTypeParam. It should no longer
64-
* occur now.
65-
*/
66-
inline val postCheckCapturesets = false
67-
68-
/** If true, turn on separation checking */
69-
def useSepChecks(using Context): Boolean =
70-
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.7`)
71-
72-
/** Not used currently. Handy for trying out new features */
73-
def newScheme(using Context): Boolean =
74-
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.8`)
75-
76-
end ccConfig
77-
7825
/** Are we at checkCaptures phase? */
7926
def isCaptureChecking(using Context): Boolean =
8027
ctx.phaseId == Phases.checkCapturesPhase.id
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package dotty.tools
2+
package dotc
3+
package cc
4+
5+
import core.Contexts.Context
6+
import config.{Feature, SourceVersion}
7+
8+
object ccConfig:
9+
10+
/** If enabled, use a special path in recheckClosure for closures
11+
* to compare the result tpt of the anonymous functon with the expected
12+
* result type. This can narrow the scope of error messages.
13+
*/
14+
inline val preTypeClosureResults = false
15+
16+
/** If this and `preTypeClosureResults` are both enabled, disable `preTypeClosureResults`
17+
* for eta expansions. This can improve some error messages.
18+
*/
19+
inline val handleEtaExpansionsSpecially = true
20+
21+
/** Don't require @use for reach capabilities that are accessed
22+
* only in a nested closure. This is unsound without additional
23+
* mitigation measures, as shown by unsound-reach-5.scala.
24+
*/
25+
inline val deferredReaches = false
26+
27+
/** Check that if a type map (which is not a BiTypeMap) maps initial capture
28+
* set variable elements to themselves it will not map any elements added in
29+
* the future to something else. That is, we can safely use a capture set
30+
* variable itself as the image under the map. By default this is off since it
31+
* is a bit expensive to check.
32+
*/
33+
inline val checkSkippedMaps = false
34+
35+
/** Always repeat a capture checking run at least once if there are no errors
36+
* yet. Used for stress-testing the logic for when a new capture checking run needs
37+
* to be scheduled because a provisionally solved capture set was later extended.
38+
* So far this happens only in very few tests. With the flag on, the logic is
39+
* tested for all tests except neg tests.
40+
*/
41+
inline val alwaysRepeatRun = false
42+
43+
/** After capture checking, check that no capture set contains ParamRefs that are outside
44+
* its scope. This used to occur and was fixed by healTypeParam. It should no longer
45+
* occur now.
46+
*/
47+
inline val postCheckCapturesets = false
48+
49+
/** If true, turn on separation checking */
50+
def useSepChecks(using Context): Boolean =
51+
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.7`)
52+
53+
/** Not used currently. Handy for trying out new features */
54+
def newScheme(using Context): Boolean =
55+
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.8`)
56+
57+
end ccConfig

0 commit comments

Comments
 (0)