Skip to content

Commit f8893e5

Browse files
committed
Drop syntax sugar for capture set member
1 parent 5a901f4 commit f8893e5

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ trait CaptureRef extends TypeProxy, ValueType:
143143
|| viaInfo(y.info)(subsumingRefs(this, _))
144144
case MaybeCapability(y1) => this.stripMaybe.subsumes(y1)
145145
case y: TypeRef if y.derivesFrom(defn.Caps_CapSet) =>
146+
// The upper and lower bounds don't have to be in the form of `CapSet^{...}`.
147+
// They can be other capture set variables, which are bounded by `CapSet`,
148+
// like `def test[X^, Y^, Z >: X <: Y]`.
146149
y.info match
147150
case TypeBounds(_, hi: CaptureRef) => this.subsumes(hi)
148151
case _ => y.captureSetOfInfo.elems.forall(this.subsumes)

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4057,11 +4057,8 @@ object Parsers {
40574057
|| sourceVersion.isAtLeast(`3.6`) && in.isColon =>
40584058
makeTypeDef(typeAndCtxBounds(tname))
40594059
case _ =>
4060-
if in.isIdent(nme.UPARROW) && Feature.ccEnabled then
4061-
makeTypeDef(typeAndCtxBounds(tname))
4062-
else
4063-
syntaxErrorOrIncomplete(ExpectedTypeBoundOrEquals(in.token))
4064-
return EmptyTree // return to avoid setting the span to EmptyTree
4060+
syntaxErrorOrIncomplete(ExpectedTypeBoundOrEquals(in.token))
4061+
return EmptyTree // return to avoid setting the span to EmptyTree
40654062
}
40664063
}
40674064
}

tests/neg-custom-args/captures/capture-poly.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import caps.*
33
trait Foo extends Capability
44

55
trait CaptureSet:
6-
type C^
6+
type C >: CapSet <: CapSet^
77

88
def capturePoly[C^](a: Foo^{C^}): Foo^{C^} = a
99
def capturePoly2(c: CaptureSet)(a: Foo^{c.C^}): Foo^{c.C^} = a

tests/neg-custom-args/captures/i21614.check

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:9:33 ----------------------------------------
2-
9 | files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)?
3-
| ^
4-
| Found: (f : F^)
5-
| Required: File^
6-
|
7-
| longer explanation available when compiling with `-explain`
8-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:12:12 ---------------------------------------
9-
12 | files.map(new Logger(_)) // error, Q: can we improve the error message?
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:12:33 ---------------------------------------
2+
12 | files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)?
3+
| ^
4+
| Found: (f : F^)
5+
| Required: File^
6+
|
7+
| longer explanation available when compiling with `-explain`
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:15:12 ---------------------------------------
9+
15 | files.map(new Logger(_)) // error, Q: can we improve the error message?
1010
| ^^^^^^^^^^^^^
11-
| Found: (_$1: box File^{files*}) ->{files*} (ex$13: caps.Exists) -> box Logger{val f: File^{_$1}}^{ex$13}
12-
| Required: (_$1: box File^{files*}) -><fluid> box Logger{val f: File^?}^?
11+
| Found: (_$1: box File^{files*}) ->{files*} (ex$16: caps.Exists) -> box Logger{val f: File^{_$1}}^{ex$16}
12+
| Required: (_$1: box File^{files*}) => box Logger{val f: File^?}^?
1313
|
1414
| Note that the universal capability `cap`
1515
| cannot be included in capture set ?

tests/neg-custom-args/captures/i21614.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import language.experimental.captureChecking
22
import caps.Capability
33
import caps.use
44

5+
trait List[+T]:
6+
def map[U](f: T => U): List[U]
7+
58
trait File extends Capability
69
class Logger(f: File^) extends Capability // <- will work if we remove the extends clause
710

tests/neg-custom-args/captures/i21868.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ trait AbstractWrong:
55
def f(): Unit^{C^} // error
66

77
trait Abstract1:
8-
type C^
8+
type C >: CapSet <: CapSet^
99
def f(): Unit^{C^}
1010

11-
class Abstract2:
12-
type C >: CapSet <: CapSet^
13-
def f(): Unit^{C^}
11+
// class Abstract2:
12+
// type C^
13+
// def f(): Unit^{C^}

0 commit comments

Comments
 (0)