Skip to content

Consolidate CC #21863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f5c9eab
Recognize double annotated capabilities such as x*?
odersky Oct 5, 2024
bbafb09
Refactor narrowCaps
odersky Oct 11, 2024
d33c89a
Make sure dcs includes cs
odersky Oct 11, 2024
cdd03b7
Align deep capture sets with reach capabilities
odersky Oct 12, 2024
822550d
Refactor handling of applications
odersky Oct 29, 2024
e7c018b
Handle reach capabilities correctly in markFree
odersky Oct 30, 2024
fcf4045
Rename @unbox to @use
odersky Oct 30, 2024
7c2a76b
Make sure we don't lose `erased` in method types on Setup
odersky Oct 30, 2024
2747f03
Drop curried use scheme
odersky Oct 30, 2024
17a4a8c
Stop markFree at nested methods
odersky Oct 31, 2024
02cd565
Allow reach capabilities from within a nested closure
odersky Oct 31, 2024
e6b08de
Drop code supporting previous unsound scheme for curried lambdas
odersky Oct 31, 2024
fd9e895
Re-enable handleEtaExpansionsSpecially setting
odersky Oct 31, 2024
4226a33
Disable reach capabilities in nested closures appearing without @use
odersky Oct 31, 2024
8f8a15f
Go back to sealed checking
odersky Nov 1, 2024
62b2f1c
Follow upper bounds of type variables when computing dcs
odersky Nov 2, 2024
0676450
Check that @use annotations only appear for method and class parameters
odersky Nov 2, 2024
96d1610
Refactorings and drop useExistential Config option
odersky Nov 2, 2024
adf6a25
Refactoring: Use common code for all markFree variants
odersky Nov 2, 2024
496c866
Fix dcs for invariant type parameters
odersky Nov 3, 2024
f4c09e3
Fix toFunctionType for methods containing reach capabilities in the r…
odersky Nov 3, 2024
c4c69b0
Expand criterion when to not check inferred types a bit
odersky Nov 5, 2024
91da9fb
Be more careful computing underlying types of reach capabilities
odersky Nov 5, 2024
34e947a
Polish code of markFree
odersky Nov 5, 2024
eb0577f
Revert change to Iterator
odersky Nov 8, 2024
2b51ee9
Document and polish CheckCaptures
odersky Nov 8, 2024
b9d485a
Drop legacy caps.unsafe operations
odersky Nov 8, 2024
1e79a2d
Don't show redudundant existental wrappers
odersky Nov 8, 2024
ff73a2f
Use unsafeAssumePure instead of asInstanceOf in stdlib-cc
odersky Nov 8, 2024
a98903c
Treat by-name closures specially in recheck
odersky Nov 11, 2024
d8ea08d
Polish and comment Setup class
odersky Nov 12, 2024
e309d5a
Some tweaks after code walkthrough
odersky Nov 15, 2024
6f51fc0
Address review comments
odersky Nov 21, 2024
da14277
Fix rebase breakage
odersky Nov 21, 2024
353f80b
Fix more rebase breakage
odersky Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix toFunctionType for methods containing reach capabilities in the r…
…esult type
  • Loading branch information
odersky committed Nov 22, 2024
commit f4c09e3891005c5d404ef68dfb01afe965c68ac1
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import config.Printers.{core, typr, matchTypes}
import reporting.{trace, Message}
import java.lang.ref.WeakReference
import compiletime.uninitialized
import cc.{CapturingType, CaptureRef, CaptureSet, SingletonCaptureRef, isTrackableRef,
derivedCapturingType, isBoxedCapturing, isCaptureChecking, isRetains, isRetainsLike}
import cc.*
import CaptureSet.{CompareResult, IdempotentCaptRefMap, IdentityCaptRefMap}

import scala.annotation.internal.sharable
Expand Down Expand Up @@ -4070,6 +4069,10 @@ object Types extends TypeUtils {
range(defn.NothingType, atVariance(1)(apply(tp.underlying)))
case CapturingType(_, _) =>
mapOver(tp)
case ReachCapability(tp1) =>
apply(tp1) match
case tp1a: CaptureRef if tp1a.isTrackableRef => tp1a.reach
case _ => defn.captureRoot.termRef
case AnnotatedType(parent, ann) if ann.refersToParamOf(thisLambdaType) =>
val parent1 = mapOver(parent)
if ann.symbol.isRetainsLike then
Expand Down
14 changes: 14 additions & 0 deletions tests/neg-custom-args/captures/depfun-reach.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/depfun-reach.scala:13:4 ----------------------------------
13 | op // error
| ^^
| Found: (xs: List[(X, box () ->{io} Unit)]) ->{op} List[box () ->{xs*} Unit]
| Required: (xs: List[(X, box () ->{io} Unit)]) => List[() -> Unit]
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/depfun-reach.scala:20:60 ---------------------------------
20 | val b: (xs: List[() ->{io} Unit]) => List[() ->{} Unit] = a // error
| ^
| Found: (xs: List[box () ->{io} Unit]) ->{a} List[box () ->{xs*} Unit]
| Required: (xs: List[box () ->{io} Unit]) => List[() -> Unit]
|
| longer explanation available when compiling with `-explain`
20 changes: 20 additions & 0 deletions tests/neg-custom-args/captures/depfun-reach.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import language.experimental.captureChecking
import caps.cap

def test(io: Object^, async: Object^) =
def compose(op: List[(() ->{cap} Unit, () ->{cap} Unit)]): List[() ->{op*} Unit] =
List(() => op.foreach((f,g) => { f(); g() }))

def compose1(op: List[(() ->{async} Unit, () ->{io} Unit)]): List[() ->{op*} Unit] =
compose(op)

def foo[X](op: (xs: List[(X, () ->{io} Unit)]) => List[() ->{xs*} Unit])
: (xs: List[(X, () ->{io} Unit)]) => List[() ->{} Unit] =
op // error

def boom(op: List[(() ->{async} Unit, () ->{io} Unit)]): List[() ->{} Unit] =
foo(compose1)(op)

def test2(io: Object^) =
val a: (xs: List[() ->{io} Unit]) => List[() ->{xs*} Unit] = ???
val b: (xs: List[() ->{io} Unit]) => List[() ->{} Unit] = a // error
7 changes: 6 additions & 1 deletion tests/pos-custom-args/captures/gears-problem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ extension [T](@use fs: Seq[Future[T]^])
val collector: Collector[T]{val futures: Seq[Future[T]^{fs*}]}
= Collector(fs)
// val ch = collector.results // also errors
val fut: Future[T]^{fs*} = collector.results.read().right.get // found ...^{caps.cap}
val fut: Future[T]^{fs*} = collector.results.read().right.get // found ...^{caps.cap}

val ch = collector.results
val item = ch.read()
val r = item.right
val fut2: Future[T]^{fs*} = r.get