Skip to content

Commit f78648b

Browse files
committed
Drop "Global capability will not be tracked" warning
1 parent 8e29192 commit f78648b

File tree

5 files changed

+0
-47
lines changed

5 files changed

+0
-47
lines changed

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,23 +1262,6 @@ class CheckCaptures extends Recheck, SymTransformer:
12621262

12631263
if runInConstructor && savedEnv.owner.isClass then
12641264
markFree(declaredCaptures, tree, addUseInfo = false)
1265-
1266-
if sym.owner.isStaticOwner
1267-
&& !declaredCaptures.elems.isEmpty
1268-
&& sym != defn.captureRoot
1269-
&& !(sym.is(ModuleVal) && sym.owner.is(Package))
1270-
// global modules that don't derive from capability can have captures
1271-
// only if their fields have them, and then the field was already reported.
1272-
&& !CaptureSet.isAssumedPure(sym.termRef)
1273-
then
1274-
def where =
1275-
if sym.effectiveOwner.is(Package) then "top-level definition"
1276-
else i"member of static ${sym.owner}"
1277-
report.warning(
1278-
em"""$sym has a non-empty capture set but will not be added as
1279-
|a capability to computed capture sets since it is globally accessible
1280-
|as a $where. Global values cannot be capabilities.""",
1281-
tree.namePos)
12821265
end recheckValDef
12831266

12841267
/** Recheck method definitions:

tests/neg-custom-args/captures/class-caps.check

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
30 | a + b
2323
|
2424
| longer explanation available when compiling with `-explain`
25-
-- Warning: tests/neg-custom-args/captures/class-caps.scala:35:6 -------------------------------------------------------
26-
35 | val console: Console^ = Console() // provide capability locally
27-
| ^^^^^^^
28-
| value console has a non-empty capture set but will not be added as
29-
| a capability to computed capture sets since it is globally accessible
30-
| as a member of static object Test2. Global values cannot be capabilities.
3125
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/class-caps.scala:37:46 -----------------------------------
3226
37 | def addWritesToConsole: (Int, Int) -> Int = (a, b) => // error
3327
| ^

tests/neg-custom-args/captures/indirect-avoid.check

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
| Note that capability nll is not included in capture set {ll}.
88
|
99
| longer explanation available when compiling with `-explain`
10-
-- Warning: tests/neg-custom-args/captures/indirect-avoid.scala:24:6 ---------------------------------------------------
11-
24 | val x1 = filterImpl1(LL())
12-
| ^^
13-
| value x1 has a non-empty capture set but will not be added as
14-
| a capability to computed capture sets since it is globally accessible
15-
| as a member of static object Test. Global values cannot be capabilities.
16-
-- Warning: tests/neg-custom-args/captures/indirect-avoid.scala:25:6 ---------------------------------------------------
17-
25 | val _: LL^{cap.rd}= x1
18-
| ^
19-
| value _$1 has a non-empty capture set but will not be added as
20-
| a capability to computed capture sets since it is globally accessible
21-
| as a member of static object Test. Global values cannot be capabilities.
2210
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/indirect-avoid.scala:26:14 -------------------------------
2311
26 | val _: LL = x1 // error
2412
| ^^

tests/neg-custom-args/captures/nonsensical-for-pure.check

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,3 @@
22
1 |val x: Int^ = 2 // error
33
| ^^^^
44
| Int is a pure type, it makes no sense to add a capture set to it
5-
-- Warning: tests/neg-custom-args/captures/nonsensical-for-pure.scala:1:4 ----------------------------------------------
6-
1 |val x: Int^ = 2 // error
7-
| ^
8-
| value x has a non-empty capture set but will not be added as
9-
| a capability to computed capture sets since it is globally accessible
10-
| as a top-level definition. Global values cannot be capabilities.

tests/neg/mixed_cc.check

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
-- Warning: tests/neg/mixed_cc/B.scala:4:4 -----------------------------------------------------------------------------
2-
4 |val x: Object^{A.B} = ??? // error
3-
| ^
4-
| value x has a non-empty capture set but will not be added as
5-
| a capability to computed capture sets since it is globally accessible
6-
| as a top-level definition. Global values cannot be capabilities.
71
-- Error: tests/neg/mixed_cc/B.scala:4:7 -------------------------------------------------------------------------------
82
4 |val x: Object^{A.B} = ??? // error
93
| ^^^^^^^^^^^^

0 commit comments

Comments
 (0)