Skip to content

Commit

Permalink
Drop syntax sugar for capture set member
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Dec 1, 2024
1 parent 1ed08de commit c1a0835
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/cc/CaptureRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ trait CaptureRef extends TypeProxy, ValueType:
|| viaInfo(y.info)(subsumingRefs(this, _))
case MaybeCapability(y1) => this.stripMaybe.subsumes(y1)
case y: TypeRef if y.derivesFrom(defn.Caps_CapSet) =>
// The upper and lower bounds don't have to be in the form of `CapSet^{...}`.
// They can be other capture set variables, which are bounded by `CapSet`,
// like `def test[X^, Y^, Z >: X <: Y]`.
y.info match
case TypeBounds(_, hi: CaptureRef) => this.subsumes(hi)
case _ => y.captureSetOfInfo.elems.forall(this.subsumes)
Expand Down
7 changes: 2 additions & 5 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4057,11 +4057,8 @@ object Parsers {
|| sourceVersion.isAtLeast(`3.6`) && in.isColon =>
makeTypeDef(typeAndCtxBounds(tname))
case _ =>
if in.isIdent(nme.UPARROW) && Feature.ccEnabled then
makeTypeDef(typeAndCtxBounds(tname))
else
syntaxErrorOrIncomplete(ExpectedTypeBoundOrEquals(in.token))
return EmptyTree // return to avoid setting the span to EmptyTree
syntaxErrorOrIncomplete(ExpectedTypeBoundOrEquals(in.token))
return EmptyTree // return to avoid setting the span to EmptyTree
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/capture-poly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import caps.*
trait Foo extends Capability

trait CaptureSet:
type C^
type C >: CapSet <: CapSet^

def capturePoly[C^](a: Foo^{C^}): Foo^{C^} = a
def capturePoly2(c: CaptureSet)(a: Foo^{c.C^}): Foo^{c.C^} = a
Expand Down
8 changes: 4 additions & 4 deletions tests/neg-custom-args/captures/i21868.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ trait AbstractWrong:
def f(): Unit^{C^} // error

trait Abstract1:
type C^
type C >: CapSet <: CapSet^
def f(): Unit^{C^}

class Abstract2:
type C >: CapSet <: CapSet^
def f(): Unit^{C^}
// class Abstract2:
// type C^
// def f(): Unit^{C^}

0 comments on commit c1a0835

Please sign in to comment.