From 899e2056ad9311eb4c49998045bfb6d8ac978799 Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 8 Jan 2026 17:25:06 +0100 Subject: [PATCH 1/3] Internally rename FreshCap to LocalCap Also, LocalCaps are no longer described as "fresh" in error messages. --- .../src/dotty/tools/dotc/cc/CCState.scala | 32 +-- .../src/dotty/tools/dotc/cc/Capability.scala | 248 +++++++++--------- .../src/dotty/tools/dotc/cc/CaptureOps.scala | 18 +- .../src/dotty/tools/dotc/cc/CaptureSet.scala | 81 +++--- .../dotty/tools/dotc/cc/CheckCaptures.scala | 112 ++++---- .../tools/dotc/cc/RetainingAnnotation.scala | 5 +- .../src/dotty/tools/dotc/cc/SepCheck.scala | 26 +- compiler/src/dotty/tools/dotc/cc/Setup.scala | 12 +- .../src/dotty/tools/dotc/cc/ccConfig.scala | 4 +- .../dotty/tools/dotc/core/Definitions.scala | 2 +- .../dotty/tools/dotc/core/TypeComparer.scala | 4 +- .../src/dotty/tools/dotc/core/Types.scala | 10 +- .../tools/dotc/printing/PlainPrinter.scala | 8 +- .../dotty/tools/dotc/typer/RefChecks.scala | 4 +- .../captures/apply-fresh.check | 4 +- .../captures/boundary-homebrew.check | 4 +- tests/neg-custom-args/captures/boundary.check | 10 +- .../captures/boundschecks3.check | 4 +- .../captures/boxed-consume.check | 2 +- tests/neg-custom-args/captures/byname.check | 2 +- .../captures/capt-depfun.check | 4 +- tests/neg-custom-args/captures/capt1.check | 24 +- .../captures/cc-existential-conformance.check | 4 +- .../neg-custom-args/captures/cc-poly-2.check | 2 +- .../captures/check-inferred.check | 12 +- .../captures/class-level-attack.check | 12 +- .../captures/classified-inheritance2.check | 2 +- .../captures/classifiers-secondclass.check | 6 +- .../captures/closure-result-typing.check | 2 +- .../captures/consume-in-constructor.check | 8 +- .../captures/consume-tvar-bound.check | 6 +- tests/neg-custom-args/captures/dcs-tvar.check | 4 +- .../captures/depfun-reach.check | 16 +- .../captures/effect-swaps-explicit.check | 4 +- .../captures/effect-swaps.check | 4 +- .../captures/existential-mapping.check | 24 +- .../captures/extending-cap-classes.check | 2 +- .../captures/filevar-expanded.check | 4 +- .../captures/freeze-boxes.check | 10 +- .../captures/fresh-counter.check | 4 +- .../captures/fresh-fields.check | 16 +- .../captures/heal-tparam-cs.check | 2 +- tests/neg-custom-args/captures/i15116.check | 8 +- tests/neg-custom-args/captures/i15772.check | 10 +- tests/neg-custom-args/captures/i15923a.check | 2 +- tests/neg-custom-args/captures/i15923b.check | 2 +- tests/neg-custom-args/captures/i16226.check | 6 +- tests/neg-custom-args/captures/i20481.check | 4 +- tests/neg-custom-args/captures/i21313.check | 2 +- tests/neg-custom-args/captures/i21401.check | 6 +- tests/neg-custom-args/captures/i21614.check | 6 +- tests/neg-custom-args/captures/i21920.check | 2 +- tests/neg-custom-args/captures/i23431.check | 14 +- tests/neg-custom-args/captures/i23582.check | 2 +- tests/neg-custom-args/captures/i23726.check | 12 +- tests/neg-custom-args/captures/i23746.check | 2 +- tests/neg-custom-args/captures/i24310.check | 2 +- tests/neg-custom-args/captures/i24335.check | 2 +- tests/neg-custom-args/captures/i24373.check | 6 +- tests/neg-custom-args/captures/i24373a.check | 8 +- .../neg-custom-args/captures/implied-ro.check | 8 +- .../captures/indirect-avoid.check | 4 +- .../captures/lazyListState.check | 2 +- tests/neg-custom-args/captures/lazyref.check | 4 +- .../captures/lazyvals-sep.check | 4 +- .../captures/leaking-iterators.check | 2 +- .../captures/linear-buffer-2.check | 10 +- .../captures/linear-buffer.check | 28 +- .../captures/local-mutables-2.check | 18 +- .../captures/local-mutables.check | 12 +- tests/neg-custom-args/captures/matrix.check | 4 +- .../captures/mut-iterator.check | 4 +- .../captures/mut-iterator4.check | 2 +- .../captures/mut-widen-empty.check | 20 +- .../neg-custom-args/captures/mutability.check | 50 ++-- tests/neg-custom-args/captures/mutvars.check | 44 ++-- .../neg-custom-args/captures/outer-var.check | 8 +- tests/neg-custom-args/captures/reaches.check | 24 +- tests/neg-custom-args/captures/real-try.check | 2 +- .../captures/ref-with-file.check | 12 +- .../captures/reference-cc.check | 6 +- .../captures/ro-mut-conformance.check | 14 +- .../captures/scope-extrude-mut.check | 4 +- .../captures/scope-extrusions.check | 56 ++-- .../captures/scoped-caps.check | 12 +- .../captures/scoped-caps2.check | 50 ++-- tests/neg-custom-args/captures/sep-box.check | 2 +- .../captures/sep-compose.check | 16 +- .../captures/sep-consume.check | 4 +- .../captures/sep-counter.check | 16 +- .../captures/sep-curried-par.check | 10 +- .../captures/sep-curried.check | 20 +- tests/neg-custom-args/captures/sep-list.check | 2 +- .../captures/sep-pairs-unboxed.check | 20 +- .../neg-custom-args/captures/sep-pairs.check | 32 +-- tests/neg-custom-args/captures/sep-use.check | 8 +- tests/neg-custom-args/captures/sep-use2.check | 16 +- .../neg-custom-args/captures/sepchecks2.check | 10 +- .../neg-custom-args/captures/sepchecks4.check | 2 +- .../neg-custom-args/captures/sepchecks5.check | 2 +- .../captures/simple-using.check | 2 +- tests/neg-custom-args/captures/try.check | 10 +- .../captures/unbox-overrides.check | 12 +- .../captures/unscoped-classifier.check | 6 +- .../captures/unscoped-extrude.check | 2 +- .../captures/unsound-reach-4.check | 6 +- .../captures/unsound-reach.check | 24 +- .../captures/usingLogFile.check | 8 +- .../captures/vars-simple.check | 2 +- .../captures/widen-reach.check | 4 +- tests/neg-custom-args/captures/withFile.check | 14 +- 111 files changed, 753 insertions(+), 761 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/cc/CCState.scala b/compiler/src/dotty/tools/dotc/cc/CCState.scala index 248ebb944e33..a0accb8c5653 100644 --- a/compiler/src/dotty/tools/dotc/cc/CCState.scala +++ b/compiler/src/dotty/tools/dotc/cc/CCState.scala @@ -88,9 +88,9 @@ class CCState: private var openExistentialScopes: List[MethodType] = Nil - private var capIsRoot: Boolean = false + private var globalAnyIsRoot: Boolean = false - private var collapseFresh: Boolean = false + private var collapseLocalCaps: Boolean = false private var discardUses: Boolean = false @@ -112,37 +112,37 @@ object CCState: /** The currently opened existential scopes */ def openExistentialScopes(using Context): List[MethodType] = ccState.openExistentialScopes - /** Run `op` under the assumption that `cap` can subsume all other capabilties + /** Run `op` under the assumption that `caps.any` can subsume all other capabilties * except Result capabilities. Every use of this method should be scrutinized * for whether it introduces an unsoundness hole. */ - inline def withCapAsRoot[T](op: => T)(using Context): T = + inline def withGlobalCapAsRoot[T](op: => T)(using Context): T = if isCaptureCheckingOrSetup then val ccs = ccState - val saved = ccs.capIsRoot - ccs.capIsRoot = true - try op finally ccs.capIsRoot = saved + val saved = ccs.globalAnyIsRoot + ccs.globalAnyIsRoot = true + try op finally ccs.globalAnyIsRoot = saved else op /** Is `caps.cap` a root capability that is allowed to subsume other capabilities? */ - def capIsRoot(using Context): Boolean = ccState.capIsRoot + def globalAnyIsRoot(using Context): Boolean = ccState.globalAnyIsRoot - /** Run `op` under the assumption that all FreshCap instances are equal + /** Run `op` under the assumption that all LocalCap instances are equal * to each other and to GlobalCap. - * Needed to make override checking of types containing fresh work. + * Needed to make override checking work for types containing LocalCaps. * Asserted in override checking, tested in maxSubsumes. * Is this sound? Test case is neg-custom-args/captures/leaked-curried.scala. */ - inline def withCollapsedFresh[T](op: => T)(using Context): T = + inline def withCollapsedLocalCaps[T](op: => T)(using Context): T = if isCaptureCheckingOrSetup then val ccs = ccState - val saved = ccs.collapseFresh - ccs.collapseFresh = true - try op finally ccs.collapseFresh = saved + val saved = ccs.collapseLocalCaps + ccs.collapseLocalCaps = true + try op finally ccs.collapseLocalCaps = saved else op - /** Should all FreshCap instances be treated as equal to GlobalCap? */ - def collapseFresh(using Context): Boolean = ccState.collapseFresh + /** Should all LocalCap instances be treated as equal to GlobalCap? */ + def collapseLocalCaps(using Context): Boolean = ccState.collapseLocalCaps /** Run `op` but suppress all recording of uses in `markFree` */ inline def withDiscardedUses[T](op: => T)(using Context): T = diff --git a/compiler/src/dotty/tools/dotc/cc/Capability.scala b/compiler/src/dotty/tools/dotc/cc/Capability.scala index f45c6d579ebb..f8f1ae3379b7 100644 --- a/compiler/src/dotty/tools/dotc/cc/Capability.scala +++ b/compiler/src/dotty/tools/dotc/cc/Capability.scala @@ -27,9 +27,10 @@ import collection.immutable /** Capabilities are members of capture sets. They partially overlap with types * as shown in the trait hierarchy below. * - * Capability --+-- RootCapability -----+-- GlobalCap - * | +-- FreshCap - * | +-- ResultCap + * Capability --+-- RootCapabilty -----+-- GlobalCap --------+-- GlobalAny + * | | +-- GlobalFresh + * | +-- LocalCap + * | +-- ResultCap * | * +-- CoreCapability ----+-- ObjectCapability --+-- TermRef * | | +-- ThisType @@ -124,9 +125,8 @@ object Capabilities: */ case class Reach(underlying: ObjectCapability) extends DerivedCapability - /** The global root capability referenced as `caps.cap` - * `cap` does not subsume other capabilities, except in arguments of - * `withCapAsRoot` calls. + /** The global root capability referenced as `caps.any`. It does not subsume + * other capabilities, except in arguments of `withCapAsRoot` calls. */ @sharable // We override below all operations that access internal capability state object GlobalCap extends RootCapability: @@ -134,20 +134,20 @@ object Capabilities: override val maybe = Maybe(this) override val readOnly = ReadOnly(this) override def restrict(cls: ClassSymbol)(using Context) = Restricted(this, cls) - override def reach = unsupported("cap.reach") + override def reach = unsupported("caps.any.reach") override def singletonCaptureSet(using Context) = CaptureSet.universal override def captureSetOfInfo(using Context) = singletonCaptureSet override def cached[C <: DerivedCapability](newRef: C): C = unsupported("cached") override def invalidateCaches() = () - /** The class of "fresh" roots. These do subsume other capabilities in scope. + /** The class of local roots named "any". These do subsume other capabilities in scope. * They track with hidden sets which other capabilities were subsumed. * Hidden sets are inspected by separation checking. - * @param owner the owner of the context in which the FreshCap was created - * @param origin an indication where and why the FreshCap was created, used + * @param owner the owner of the context in which the LocalCap was created + * @param origin an indication where and why the LocalCap was created, used * for diagnostics */ - case class FreshCap(val prefix: Type) + case class LocalCap(val prefix: Type) (val owner: Symbol, val origin: Origin, origHidden: CaptureSet.HiddenSet | Null) (using @constructorOnly ctx: Context) extends RootCapability: @@ -156,40 +156,40 @@ object Capabilities: else origHidden // fails initialization check without the @unchecked - def derivedFreshCap(newPrefix: Type)(using Context): FreshCap = + def derivedLocalCap(newPrefix: Type)(using Context): LocalCap = if newPrefix eq prefix then this else if newPrefix eq hiddenSet.owningCap.prefix then hiddenSet.owningCap else hiddenSet.derivedCaps - .getOrElseUpdate(newPrefix, FreshCap(newPrefix)(owner, origin, hiddenSet)) + .getOrElseUpdate(newPrefix, LocalCap(newPrefix)(owner, origin, hiddenSet)) /** A map from context owners to skolem TermRefs that were created by ensurePath * TypeMap's mapCapability. */ var skolems: immutable.Map[Symbol, TermRef] = immutable.HashMap.empty - //assert(rootId != 4, i"fresh $prefix, $origin, ${ctx.owner}") + //assert(rootId != 4, i"any $prefix, $origin, ${ctx.owner}") - /** Is this fresh cap (definitely) classified? If that's the case, the + /** Is this LocalCap (definitely) classified? If that's the case, the * classifier cannot be changed anymore. - * We need to distinguish `FreshCap`s that can still be classified from - * ones that cannot. Once a `FreshCap` is part of a constant capture set, + * We need to distinguish LocalCaps that can still be classified from + * ones that cannot. Once a LocalCap is part of a constant capture set, * it gets classified by the type that prefixes the set and that classification - * cannot be changed anymore. But other `FreshCap`s are created as members of + * cannot be changed anymore. But other LocalCaps are created as members of * variable sets and then their classification status is open and can be * constrained further. */ private[Capabilities] var isClassified = false override def equals(that: Any) = that match - case that: FreshCap => this eq that + case that: LocalCap => this eq that case _ => false - /** Is this fresh cap at the right level to be able to subsume `ref`? + /** Is this LocalCap at the right level to be able to subsume `ref`? */ def acceptsLevelOf(ref: Capability)(using Context): Boolean = - if ccConfig.useFreshLevels && !CCState.collapseFresh then + if ccConfig.useLocalCapLevels && !CCState.collapseLocalCaps then val refOwner = ref.levelOwner ccOwner.isContainedIn(refOwner) || classifier.derivesFrom(defn.Caps_Unscoped) @@ -197,7 +197,7 @@ object Capabilities: case ResultCap(_) | _: ParamRef => false case _ => true - /** Classify this FreshCap as `cls`, provided `isClassified` is still false. + /** Classify this LocalCap as `cls`, provided `isClassified` is still false. * @param freeze Determines future `isClassified` state. */ def adoptClassifier(cls: ClassSymbol, freeze: Boolean)(using Context): Unit = @@ -220,14 +220,14 @@ object Capabilities: if hiddenSet.classifier != defn.AnyClass then i" classified as ${hiddenSet.classifier.name}" else "" - i"a fresh root capability$classifierStr$originStr" + i"a root capability$classifierStr$originStr" - object FreshCap: - def apply(owner: Symbol, prefix: Type, origin: Origin)(using Context): FreshCap = - new FreshCap(prefix)(owner, origin, null) - def apply(owner: Symbol, origin: Origin)(using Context): FreshCap = + object LocalCap: + def apply(owner: Symbol, prefix: Type, origin: Origin)(using Context): LocalCap = + new LocalCap(prefix)(owner, origin, null) + def apply(owner: Symbol, origin: Origin)(using Context): LocalCap = apply(owner, owner.skipWeakOwner.thisType, origin) - def apply(origin: Origin)(using Context): FreshCap = + def apply(origin: Origin)(using Context): LocalCap = apply(ctx.owner, origin) /** A root capability associated with a function type. These are conceptually @@ -235,28 +235,25 @@ object Capabilities: * @param binder The function type with which the capability is associated. * It is a MethodicType since we also have ResultCaps that are * associated with the ExprTypes of parameterless functions. - * Currently we never create results over PolyTypes. TODO change this? + * Currently we never create results over PolyTypes since a PolyType + * used as a type (not a method info) is always followed by a MethodType. * Setup: * - * In the setup phase, `cap` instances in the result of a dependent function type - * or method type such as `(x: T): C^{cap}` are converted to `ResultCap(binder)` instances, - * where `binder` refers to the method type. Most other cap instances are mapped to - * Fresh instances instead. For example the `cap` in the result of `T => C^{cap}` - * is mapped to a Fresh instance. + * In the setup phase, `fresh` instances in the result of a dependent function type + * or method type such as `(x: T): C^{fresh}` are converted to `ResultCap(binder)` instances, + * where `binder` refers to the immediately enclosing method type. * - * If one needs to use a dependent function type yet one still want to map `cap` to - * a fresh instance instead an existential root, one can achieve that by the use - * of a type alias. For instance, the following type creates an existential for `^`: + * If one needs to refer to an outer method type as the binder instead, one can achieve that + * by using a type alias. For instance: * - * (x: A) => (C^{x}, D^) + * type F[X^] = (x: A) => C^{X} + * () => F[{fresh}] * - * By contrast, this variant creates a fresh instance instead: + * With explicit quantification, this would be equivalent to * - * type F[X] = (x: A) => (C^{x}, X) - * F[D^] + * () => \exists fresh. (x: A) => C^{fresh} * - * The trick is that the argument D^ is mapped to D^{fresh} before the `F` alias - * is expanded. + * The trick is that the argument `fresh` is bound before the `F` alias is expanded. */ case class ResultCap(binder: MethodicType) extends RootCapability: @@ -264,7 +261,7 @@ object Capabilities: private var variants: SimpleIdentitySet[ResultCap] = SimpleIdentitySet.empty /** Every ResultCap capability has an origin. This is - * - A FreshCap capability `f`, if the current capability was created as a mirror + * - A LocalCap capability `f`, if the current capability was created as a mirror * of `f` in the ToResult map. * - Another ResultCap capability `r`, if the current capability was created * via a chain of `derivedResult` calls from an original ResultCap `r` @@ -273,13 +270,13 @@ object Capabilities: */ def origin: RootCapability = myOrigin - /** Initialize origin of this capability to a FreshCap instance (or to GlobalCap + /** Initialize origin of this capability to a LocalCap instance (or to GlobalCap * if separation checks are turned off). * @pre The capability's origin was not yet set. */ - def setOrigin(freshOrigin: FreshCap | GlobalCap.type): this.type = + def setOrigin(localCapOrigin: LocalCap | GlobalCap.type): this.type = assert(myOrigin eq GlobalCap) - myOrigin = freshOrigin + myOrigin = localCapOrigin this /** If the current capability was created via a chain of `derivedResult` calls @@ -380,14 +377,14 @@ object Capabilities: case _ => this ne stripReadOnly /** The classifier, either given in an explicit `.only` or assumed for a - * FreshCap. AnyRef for unclassified FreshCaps. Otherwise NoSymbol if no + * LocalCap. AnyRef for unclassified LocalCaps. Otherwise NoSymbol if no * classifier is given. */ final def classifier(using Context): Symbol = this match case Restricted(_, cls) => cls case ReadOnly(ref1) => ref1.classifier case Maybe(ref1) => ref1.classifier - case self: FreshCap => self.hiddenSet.classifier + case self: LocalCap => self.hiddenSet.classifier case _ => NoSymbol /** Is this a reach reference of the form `x*` or a readOnly or maybe variant @@ -421,9 +418,9 @@ object Capabilities: case Maybe(ref1) => ref1.stripReach.maybe case _ => this - /** Is this reference the generic root capability `cap` or a Fresh instance? */ - final def isCapOrFresh(using Context): Boolean = this match - case GlobalCap | _: FreshCap => true + /** Is this reference the global root capability `caps.any` or a LocalCap instance? */ + final def isGlobalOrLocalCap(using Context): Boolean = this match + case GlobalCap | _: LocalCap => true case _ => false /** Is this reference a root capability or a derived version of one? @@ -494,7 +491,7 @@ object Capabilities: * the form this.C but their pathroot is still this.C, not this. */ final def pathRoot(using Context): Capability = this match - case FreshCap(pre: Capability) => pre.pathRoot + case LocalCap(pre: Capability) => pre.pathRoot case _: RootCapability => this case self: DerivedCapability => self.underlying.pathRoot case self: CoreCapability => self.dealias match @@ -510,15 +507,15 @@ object Capabilities: /** The logical owner of the root of this class: * - If this path starts with `C.this`, the class `C`. * - If it starts with a reference `r`, `r`'s owner. - * - If it starts with cap, the `scala.caps` package class. - * - If it starts with a fresh instance, its owner. + * - If it starts with caps.any, the `scala.caps` package class. + * - If it starts with a LocalCap instance, its owner. * - If it starts with a ParamRef or a ResultCap, NoSymbol. */ final def pathOwner(using Context): Symbol = pathRoot match case tp1: ThisType => tp1.cls case tp1: NamedType => tp1.symbol.owner case GlobalCap => defn.CapsModule.moduleClass - case tp1: FreshCap => tp1.ccOwner + case tp1: LocalCap => tp1.ccOwner case _ => NoSymbol final def paramPathRoot(using Context): Type = core match @@ -535,7 +532,7 @@ object Capabilities: final def isParamPath(using Context): Boolean = paramPathRoot.exists /** Compute ccOwner or (part of level owner). - * @param mapUnscoped if true, return the nclosing toplevel class for FreshCaps + * @param mapUnscoped if true, return the enclosing toplevel class for LocalCaps * classified as Unscoped that don't have a prefix */ private def computeOwner(mapUnscoped: Boolean)(using Context): Symbol = this match @@ -543,7 +540,7 @@ object Capabilities: case TermRef(prefix: Capability, _) => prefix.computeOwner(mapUnscoped) case self: NamedType => self.symbol case self: DerivedCapability => self.underlying.computeOwner(mapUnscoped) - case self: FreshCap => + case self: LocalCap => val setOwner = self.hiddenSet.owner self.prefix match case prefix: ThisType if setOwner.isTerm && setOwner.owner == prefix.cls => @@ -560,7 +557,7 @@ object Capabilities: final def ccOwner(using Context): Symbol = computeOwner(mapUnscoped = false) final def visibility(using Context): Symbol = this match - case self: FreshCap => adjustOwner(computeOwner(mapUnscoped = true)) + case self: LocalCap => adjustOwner(computeOwner(mapUnscoped = true)) case _ => val vis = computeOwner(mapUnscoped = true) if vis.is(Param) then vis.owner else vis @@ -569,7 +566,7 @@ object Capabilities: * Symbols representing levels are * - class symbols, but not inner (non-static) module classes * - method symbols, but not accessors or constructors - * For Unscoped FreshCaps the level owner is the top-level class. + * For Unscoped LocalCaps the level owner is the top-level class. */ final def levelOwner(using Context): Symbol = adjustOwner(computeOwner(mapUnscoped = true)) @@ -620,7 +617,7 @@ object Capabilities: captureSetValid = currentId computed - /** The elements hidden by this capability, if this is a FreshCap + /** The elements hidden by this capability, if this is a LocalCap * or a derived version of one. Read-only status and restrictions * are transferred from the capability to its hidden set. */ @@ -632,7 +629,7 @@ object Capabilities: * @param f a function that gets applied to all detected hidden sets */ def computeHiddenSet(f: Refs => Refs)(using Context): Refs = this match - case self: FreshCap => f(self.hiddenSet.elems) + case self: LocalCap => f(self.hiddenSet.elems) case Restricted(elem1, cls) => elem1.computeHiddenSet(f).map(_.restrict(cls)) case ReadOnly(elem1) => elem1.computeHiddenSet(f).map(_.readOnly) case _ => emptyRefs @@ -644,7 +641,7 @@ object Capabilities: else ClassifiedAs(cls :: Nil) if classifiersValid != currentId then myClassifiers = this match - case self: FreshCap => + case self: LocalCap => toClassifiers(self.hiddenSet.classifier) case self: RootCapability => Unclassified @@ -669,7 +666,7 @@ object Capabilities: def tryClassifyAs(cls: ClassSymbol)(using Context): Boolean = cls == defn.AnyClass || this.match - case self: FreshCap => + case self: LocalCap => if self.isClassified then self.hiddenSet.classifier.derivesFrom(cls) else self.hiddenSet.tryClassifyAs(cls) case self: RootCapability => @@ -795,9 +792,9 @@ object Capabilities: /** This is a maximal capability that subsumes `y` in given context and VarState. * @param canAddHidden If true we allow maximal capabilities to subsume all other capabilities. - * We add those capabilities to the hidden set if this is a Fresh instance. + * We add those capabilities to the hidden set if this is a LocalCap instance. * If false we only accept `y` elements that are already in the - * hidden set of this Fresh instance. The idea is that in a VarState that + * hidden set of this LocalCap instance. The idea is that in a VarState that * accepts additions we first run `maxSubsumes` with `canAddHidden = false` * so that new variables get added to the sets. If that fails, we run * the test again with canAddHidden = true as a last effort before we @@ -806,7 +803,7 @@ object Capabilities: def maxSubsumes(y: Capability, canAddHidden: Boolean)(using ctx: Context)(using vs: VarState = VarState.Separate): Boolean = (this eq y) || this.match - case x: FreshCap => + case x: LocalCap => def classifierOK = if y.tryClassifyAs(x.hiddenSet.classifier) then true else @@ -814,15 +811,15 @@ object Capabilities: false def prefixAllowsAddHidden: Boolean = - CCState.collapseFresh || x.prefix.match + CCState.collapseLocalCaps || x.prefix.match case NoPrefix => true case pre: ThisType => x.ccOwner.isContainedIn(pre.cls) case pre => - capt.println(i"fresh not open $x, ${x.rootId}, $pre, ${x.ccOwner.skipWeakOwner.thisType}") + capt.println(i"LocalCap not open $x, ${x.rootId}, $pre, ${x.ccOwner.skipWeakOwner.thisType}") false vs.ifNotSeen(this)(x.hiddenSet.elems.exists(_.subsumes(y))) - || x.coversFresh(y) + || x.coversLocalCap(y) || x.acceptsLevelOf(y) && classifierOK && canAddHidden @@ -836,10 +833,10 @@ object Capabilities: y match case GlobalCap => true case _: ResultCap => false - case _: FreshCap if CCState.collapseFresh => true + case _: LocalCap if CCState.collapseLocalCaps => true case _ => y.derivesFromShared - || canAddHidden && vs != VarState.HardSeparate && CCState.capIsRoot + || canAddHidden && vs != VarState.HardSeparate && CCState.globalAnyIsRoot case Restricted(x1, cls) => y.isKnownClassifiedAs(cls) && x1.maxSubsumes(y, canAddHidden) case _ => @@ -856,7 +853,7 @@ object Capabilities: * x covers x * x covers y ==> x covers y.f * x covers y ==> x* covers y*, x? covers y? - * x covers y ==> covers y + * x covers y ==> covers y * x covers y ==> x.only[C] covers y, x covers y.only[C] * * TODO what other clauses from subsumes do we need to port here? @@ -866,7 +863,7 @@ object Capabilities: * the clause to make the test pass. */ final def covers(y: Capability)(using Context): Boolean = - val seen: util.EqHashSet[FreshCap] = new util.EqHashSet + val seen: util.EqHashSet[LocalCap] = new util.EqHashSet def recur(x: Capability, y: Capability): Boolean = (x eq y) @@ -886,8 +883,8 @@ object Capabilities: case _ => false || x.match - case x: FreshCap => - if x.coversFresh(y) then true + case x: LocalCap => + if x.coversLocalCap(y) then true else if !seen.contains(x) then seen.add(x) x.hiddenSet.exists(recur(_, y)) @@ -898,14 +895,14 @@ object Capabilities: recur(this, y) end covers - /** `x eq y` or `x` is a fresh cap, `y` is a fresh cap with prefix + /** `x eq y` or `x` is a LocalCap, `y` is a LocalCap with prefix * `p`, and there is a prefix of `p` that contains `x` in its * capture set. */ - final def coversFresh(y: Capability)(using Context): Boolean = + final def coversLocalCap(y: Capability)(using Context): Boolean = (this eq y) || this.match - case x: FreshCap => y match - case y: FreshCap => + case x: LocalCap => y match + case y: LocalCap => x.origin match case Origin.InDecl(sym) => def occursInPrefix(pre: Type): Boolean = pre match @@ -988,7 +985,7 @@ object Capabilities: case (ClassifiedAs(cs1), ClassifiedAs(cs2)) => ClassifiedAs(dominators(cs1, cs2)) - /** The place of - and cause for - creating a fresh capability. Used for + /** The place of - and cause for - creating a LocalCap capability. Used for * error diagnostics */ enum Origin derives CanEqual: @@ -1047,10 +1044,10 @@ object Capabilities: // ---------- Maps between different kinds of root capabilities ----------------- - /** Map each occurrence of cap to a different Fresh instance + /** Map each occurrence of `caps.any` to a different LocalCap instance * Exception: CapSet^ stays as it is. */ - class CapToFresh(origin: Origin)(using Context) extends BiTypeMap, FollowAliasesMap: + class GlobalToLocalCap(origin: Origin)(using Context) extends BiTypeMap, FollowAliasesMap: thisMap => override def apply(t: Type) = @@ -1059,7 +1056,7 @@ object Capabilities: case t @ CapturingType(_, _) => mapOver(t) case t @ AnnotatedType(parent, ann: RetainingAnnotation) - if ann.isStrict && ann.toCaptureSet.containsCap => + if ann.isStrict && ann.toCaptureSet.containsGlobalCapDerivs => // Applying `this` can cause infinite recursion in some cases during printing. // scalac -Xprint:all tests/pos/i23885/S_1.scala tests/pos/i23885/S_2.scala mapOver(CapturingType(this(parent), ann.toCaptureSet)) @@ -1071,14 +1068,14 @@ object Capabilities: mapFollowingAliases(t) override def mapCapability(c: Capability, deep: Boolean): Capability = c match - case GlobalCap => FreshCap(origin) + case GlobalCap => LocalCap(origin) case _ => super.mapCapability(c, deep) override def fuse(next: BiTypeMap)(using Context) = next match case next: Inverse => assert(false); Some(IdentityTypeMap) case _ => None - override def toString = "CapToFresh" + override def toString = "GlobalToLocalCap" class Inverse extends BiTypeMap, FollowAliasesMap: def apply(t: Type): Type = t match @@ -1086,7 +1083,7 @@ object Capabilities: case _ => mapFollowingAliases(t) override def mapCapability(c: Capability, deep: Boolean): Capability = c match - case _: FreshCap => GlobalCap + case _: LocalCap => GlobalCap case _ => super.mapCapability(c, deep) def inverse = thisMap @@ -1094,21 +1091,21 @@ object Capabilities: lazy val inverse = Inverse() - end CapToFresh + end GlobalToLocalCap - /** Maps cap to fresh. CapToFresh is a BiTypeMap since we don't want to - * freeze a set when it is mapped. On the other hand, we do not want Fresh - * values to flow back to cap since that would fail disallowRootCapability + /** Maps caps.any to LocalCap instances. GlobalToLocalCap is a BiTypeMap since we don't want to + * freeze a set when it is mapped. On the other hand, we do not want LocalCap + * values to flow back to caps.any since that would fail disallowRootCapability * tests elsewhere. We therefore use `withoutMappedFutureElems` to prevent * the map being installed for future use. */ - def capToFresh(tp: Type, origin: Origin)(using Context): Type = + def globalToLocalCap(tp: Type, origin: Origin)(using Context): Type = ccState.withoutMappedFutureElems: - CapToFresh(origin)(tp) + GlobalToLocalCap(origin)(tp) - /** Maps fresh to cap */ - def freshToCap(param: Symbol, tp: Type)(using Context): Type = - CapToFresh(Origin.Parameter(param)).inverse(tp) + /** Maps all LocalCap instances to caps.any */ + def localCapToGlobal(param: Symbol, tp: Type)(using Context): Type = + GlobalToLocalCap(Origin.Parameter(param)).inverse(tp) /** The local dual of a result type of a closure type. * @param binder the method type of the anonymous function whose result is mapped @@ -1124,8 +1121,8 @@ object Capabilities: // The result of Internalize is used to se the result type of an anonymous function, and // the new info of that function is built with the result. sym.paramSymss.head - val resultToFresh = EqHashMap[ResultCap, FreshCap]() - val freshToResult = EqHashMap[FreshCap, ResultCap]() + val resultToAny = EqHashMap[ResultCap, LocalCap]() + val anyToResult = EqHashMap[LocalCap, ResultCap]() override def apply(t: Type) = if variance < 0 then t @@ -1136,12 +1133,12 @@ object Capabilities: override def mapCapability(c: Capability, deep: Boolean): Capability = c match case r: ResultCap if r.binder == this.binder => - resultToFresh.get(r) match + resultToAny.get(r) match case Some(f) => f case None => - val f = FreshCap(Origin.LocalInstance(binder.resType)) - resultToFresh(r) = f - freshToResult(f) = r + val f = LocalCap(Origin.LocalInstance(binder.resType)) + resultToAny(r) = f + anyToResult(f) = r f case _ => super.mapCapability(c, deep) @@ -1155,13 +1152,13 @@ object Capabilities: case _ => mapOver(t) override def mapCapability(c: Capability, deep: Boolean): Capability = c match - case f: FreshCap if f.owner == sym => - freshToResult.get(f) match + case f: LocalCap if f.owner == sym => + anyToResult.get(f) match case Some(r) => r case None => val r = ResultCap(binder) - resultToFresh(r) = f - freshToResult(f) = r + resultToAny(r) = f + anyToResult(f) = r r case _ => super.mapCapability(c, deep) @@ -1173,10 +1170,10 @@ object Capabilities: def inverse = Inverse() end Internalize - /** Map top-level free existential variables one-to-one to Fresh instances */ - def resultToFresh(tp: Type, origin: Origin)(using Context): Type = + /** Map top-level free ResultCaps one-to-one to LocalCap instances */ + def resultToAny(tp: Type, origin: Origin)(using Context): Type = val subst = new TypeMap: - val seen = EqHashMap[ResultCap, FreshCap | GlobalCap.type]() + val seen = EqHashMap[ResultCap, LocalCap | GlobalCap.type]() var localBinders: SimpleIdentitySet[MethodType] = SimpleIdentitySet.empty def apply(t: Type): Type = t match @@ -1196,17 +1193,17 @@ object Capabilities: case c @ ResultCap(binder) => if localBinders.contains(binder) then c // keep bound references else - // Create a fresh skolem that does not subsume anything - def freshSkolem = - val c = FreshCap(origin) + // Create a LocalCap skolem that does not subsume anything + def localCapSkolem = + val c = LocalCap(origin) c.hiddenSet.markSolved(provisional = false) c - seen.getOrElseUpdate(c, freshSkolem) // map free references to FreshCap + seen.getOrElseUpdate(c, localCapSkolem) // map free references to LocalCap case _ => super.mapCapability(c, deep) end subst subst(tp) - end resultToFresh + end resultToAny abstract class CapMap(using Context) extends BiTypeMap: override def mapOver(t: Type): Type = t match @@ -1230,10 +1227,10 @@ object Capabilities: mapOver(t) override def mapCapability(c: Capability, deep: Boolean) = c match - case c: (FreshCap | GlobalCap.type) => + case c: (LocalCap | GlobalCap.type) => if variance > 0 then c match - case c: FreshCap => + case c: LocalCap => if sym.isAnonymousFunction && c.classifier.derivesFrom(defn.Caps_Unscoped) then c else ResultCap(mt).setOrigin(c) @@ -1242,7 +1239,7 @@ object Capabilities: if variance == 0 then fail(em"""$localResType captures the root capability `cap` in invariant position. |This capability cannot be converted to an existential in the result type of a function.""") - // we accept variance < 0, and leave the cap as it is + // we accept variance < 0, and leave the `any` as it is c case _ => super.mapCapability(c, deep) @@ -1255,15 +1252,13 @@ object Capabilities: override def mapCapability(c: Capability, deep: Boolean) = c match case c @ ResultCap(`mt`) => - // do a reverse getOrElseUpdate on `seen` to produce the - // `Fresh` assosicated with `t` val primary = c.primaryResultCap primary.origin match case GlobalCap => - val fresh = FreshCap(Origin.LocalInstance(mt.resType)) - primary.setOrigin(fresh) - fresh - case origin: FreshCap => + val localCap = LocalCap(Origin.LocalInstance(mt.resType)) + primary.setOrigin(localCap) + localCap + case origin: LocalCap => origin case _ => super.mapCapability(c, deep) @@ -1273,9 +1268,8 @@ object Capabilities: end inverse end ToResult - /** Replace all occurrences of `cap` (or fresh) in parts of this type by an existentially bound - * variable bound by `mt`. - * Stop at function or method types since these have been mapped before. + /** Replace all occurrences of `caps.any` or LocalCap in parts of this type by an existentially bound + * variable bound by `mt`. Stop at function or method types since these have been mapped before. */ def toResult(tp: Type, mt: MethodicType, sym: Symbol, fail: Message => Unit)(using Context): Type = ToResult(tp, mt, sym, fail)(tp) @@ -1317,7 +1311,7 @@ object Capabilities: // object Buffer: // def empty[T]: Buffer[T]^ // ``` - // This is more desirable than interpreting `^` as a `Fresh` at the level of `Buffer.empty` + // This is more desirable than interpreting `^` as a `^{any}` at the level of `Buffer.empty` // in most cases. tp1.derivedLambdaType(resType = toResult(tp1.resType, tp1, sym, fail)) case tp1 => tp1 diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala index 6394b11971cb..b4c6bb4e8247 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala @@ -70,7 +70,7 @@ extension (tp: Type) tp1.toCapability.readOnly case OnlyCapability(tp1, cls) => tp1.toCapability.restrict(cls) - case ref: TermRef if ref.isCapRef => + case ref: TermRef if ref.isCapsAnyRef => GlobalCap case ref: Capability if ref.isTrackableRef => ref @@ -145,7 +145,7 @@ extension (tp: Type) * `CaptureSet.ofTypeDeeply`. If that set is nonempty, and the type is * a singleton capability `x` or a reach capability `x*`, the deep capture * set can be narrowed to`{x*}`. - * @param includeTypevars if true, return a new FreshCap for every type parameter + * @param includeTypevars if true, return a new LocalCap for every type parameter * or abstract type with an Any upper bound. Types with * defined upper bound are always mapped to the dcs of their bound * @param includeBoxed if true, include capture sets found in boxed parts of this type @@ -343,8 +343,8 @@ extension (tp: Type) case _ => false - /** Is this a reference to caps.cap? Note this is _not_ the GlobalCap capability. */ - def isCapRef(using Context): Boolean = tp match + /** Is this a reference to caps.any? Note this is _not_ the GlobalCap capability. */ + def isCapsAnyRef(using Context): Boolean = tp match case tp: TermRef => tp.name == nme.CAPTURE_ROOT && tp.symbol == defn.captureRoot case _ => false @@ -409,7 +409,7 @@ extension (tp: Type) mapOver(t) tm(tp) - /** If `x` is a capability, replace all no-flip covariant occurrences of `cap` + /** If `x` is a capability, replace all no-flip covariant occurrences of `any` * in type `tp` with `x*`. */ def withReachCaptures(ref: Type)(using Context): Type = ref match @@ -419,7 +419,7 @@ extension (tp: Type) def apply(t: Type) = if variance <= 0 then t else t.dealias match - case t @ CapturingType(p, cs) if cs.containsCapOrFresh => + case t @ CapturingType(p, cs) if cs.containsGlobalOrLocalCap => val reachRef = if cs.isReadOnly then ref.reach.readOnly else ref.reach if reachRef.singletonCaptureSet.mightSubcapture(cs) then change = true @@ -444,13 +444,13 @@ extension (tp: Type) tp end withReachCaptures - /** Does this type contain no-flip covariant occurrences of `cap`? */ + /** Does this type contain no-flip covariant occurrences of `any`? */ def containsCap(using Context): Boolean = val acc = new TypeAccumulator[Boolean]: def apply(x: Boolean, t: Type) = x || variance > 0 && t.dealiasKeepAnnots.match - case t @ CapturingType(p, cs) if cs.containsCap => + case t @ CapturingType(p, cs) if cs.containsGlobalCapDerivs => true case t @ AnnotatedType(parent, ann) => // Don't traverse annotations, which includes capture sets @@ -682,7 +682,7 @@ extension (sym: Symbol) sym.copy( flags = Flags.EmptyFlags, info = defn.Caps_Var.typeRef.appliedTo(sym.info) - .capturing(FreshCap(sym, Origin.InDecl(sym))))) + .capturing(LocalCap(sym, Origin.InDecl(sym))))) extension (tp: AnnotatedType) /** Is this a boxed capturing type? */ diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala index 5a36b9a878d3..4dff4a8019ef 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala @@ -118,7 +118,7 @@ sealed abstract class CaptureSet extends Showable: case c: Const => c case v: Var => Const(v.elems) - /** Does this capture set contain the root reference `cap` as element? */ + /** Does this capture set contain the root reference `caps.any` as element? */ final def isUniversal(using Context) = elems.contains(GlobalCap) @@ -130,18 +130,18 @@ sealed abstract class CaptureSet extends Showable: final def containsResultCapability(using Context) = elems.exists(_.core.isInstanceOf[ResultCap]) - /** Does this capture set contain a GlobalCap or FreshCap, and at the same time + /** Does this capture set contain a GlobalCap or LocalCap, and at the same time * does not contain a ResultCap? */ - final def containsCapOrFresh(using Context) = + final def containsGlobalOrLocalCap(using Context) = !containsResultCapability && elems.exists: elem => elem.core match case GlobalCap => true - case _: FreshCap => true + case _: LocalCap => true case _ => false - final def containsCap(using Context) = + final def containsGlobalCapDerivs(using Context) = elems.exists(_.core eq GlobalCap) final def isReadOnly(using Context): Boolean = @@ -279,13 +279,9 @@ sealed abstract class CaptureSet extends Showable: */ def mightAccountFor(x: Capability)(using Context): Boolean = reporting.trace(i"$this mightAccountFor $x, ${x.captureSetOfInfo}?", show = true): - CCState.withCollapsedFresh: - // withCollapsedFresh should be dropped. The problem is that since our level checking - // does not deal with classes well, we get false negatives here. Observed in the line - // - // stateFromIteratorConcatSuffix(it)(flatMapImpl(rest, f).state)))) - // - // in cc-lib's LazyListIterable.scala. + CCState.withCollapsedLocalCaps: + // TODO Can we drop withCollapsedLocalCaps?. Without it we get errors in + // LazyListIterable.scala. TypeComparer.noNotes: elems.exists(_.subsumes(x)(using ctx)(using VarState.ClosedUnrecorded)) || !x.isTerminalCapability @@ -464,10 +460,10 @@ sealed abstract class CaptureSet extends Showable: def adoptClassifier(cls: ClassSymbol)(using Context): Unit = for elem <- elems do elem.stripReadOnly match - case fresh: FreshCap => fresh.adoptClassifier(cls, freeze = isConst) + case localCap: LocalCap => localCap.adoptClassifier(cls, freeze = isConst) case _ => - /** All capabilities of this set except those Termrefs and FreshCaps that + /** All capabilities of this set except those Termrefs and LocalCaps that * are bound by `mt`. */ def freeInResult(mt: MethodicType)(using Context): CaptureSet = @@ -487,7 +483,7 @@ sealed abstract class CaptureSet extends Showable: if rootLimit == null then false else elem.core match case GlobalCap | _: ResultCap => true - case elem: FreshCap => elem.ccOwner.isContainedIn(rootLimit) + case elem: LocalCap => elem.ccOwner.isContainedIn(rootLimit) case _ => false /** Invoke `handler` if this set has (or later aquires) a bad root capability. @@ -592,11 +588,6 @@ object CaptureSet: def universal(using Context): Const = Const(SimpleIdentitySet(GlobalCap)) - def fresh(owner: Symbol, prefix: Type, origin: Origin)(using Context): Const = - FreshCap(owner, prefix, origin).singletonCaptureSet - def fresh(origin: Origin)(using Context): Const = - fresh(ctx.owner, ctx.owner.thisType, origin) - /** The shared capture set `{cap.rd}` */ def shared(using Context): Const = GlobalCap.readOnly.singletonCaptureSet @@ -929,7 +920,7 @@ object CaptureSet: this else if isUniversal || computingApprox then universal - else if containsCap && isReadOnly then + else if containsGlobalCapDerivs && isReadOnly then shared else computingApprox = true @@ -952,9 +943,9 @@ object CaptureSet: * in the results of defs and vals. */ def solve()(using Context): Unit = - CCState.withCapAsRoot: // // OK here since we infer parameter types that get checked later + CCState.withGlobalCapAsRoot: // OK here since we infer parameter types that get checked later val approx = upperApprox(empty) - .map(CapToFresh(Origin.Unknown).inverse) // Fresh --> cap + .map(GlobalToLocalCap(Origin.Unknown).inverse) // Fresh --> cap .showing(i"solve $this = $result", capt) //println(i"solving var $this $approx ${approx.isConst} deps = ${deps.toList}") val newElems = approx.elems -- elems @@ -1008,43 +999,43 @@ object CaptureSet: extends Var(owner, initialElems, nestedOK): /** Make sure that capset variables in types of vals and result types of - * non-anonymous functions contain only a single FreshCap, and furthermore - * that that FreshCap has as origin InDecl(owner), where owner is the val + * non-anonymous functions contain only a single LocalCap, and furthermore + * that that LocalCap has as origin InDecl(owner), where owner is the val * or def for which the type is defined. - * Note: This currently does not apply to classified or read-only fresh caps. + * Note: This currently does not apply to classified or read-only LocalCaps. */ override def includeElem(elem: Capability)(using ctx: Context, vs: VarState): Unit = elem match - case elem: FreshCap + case elem: LocalCap if !nestedOK && !elems.contains(elem) && !owner.isAnonymousFunction => def fail = i"attempting to add $elem to $this" - def hideIn(fc: FreshCap): Boolean = - assert(elem.tryClassifyAs(fc.hiddenSet.classifier), fail) + def hideIn(ac: LocalCap): Boolean = + assert(elem.tryClassifyAs(ac.hiddenSet.classifier), fail) if isRefining then // If a variable is added by addCaptureRefinements in a synthetic // refinement of a class type, don't do level checking. The problem is // that the variable might be matched against a type that does not have - // a refinement, in which case FreshCaps of the class definition would + // a refinement, in which case LocalCaps of the class definition would // leak out in the corresponding places. This will fail level checking. // The disallowBadRoots override below has a similar reason. // TODO: We should instead mark the variable as impossible to instantiate // and drop the refinement later in the inferred type. // Test case is drop-refinement.scala. true - else if fc.acceptsLevelOf(elem) then - fc.hiddenSet.add(elem) + else if ac.acceptsLevelOf(elem) then + ac.hiddenSet.add(elem) true else - capt.println(i"level failure when subsuming fresh caps, cannot add $elem with ${elem.levelOwner} to $owner / $fail") + capt.println(i"level failure when subsuming in a LocalCap, cannot add $elem with ${elem.levelOwner} to $owner / $fail") false val isSubsumed = (false /: elems): (isSubsumed, prev) => prev match - case prev: FreshCap => hideIn(prev) + case prev: LocalCap => hideIn(prev) case _ => isSubsumed if !isSubsumed then if elem.origin != Origin.InDecl(owner) || elem.hiddenSet.isConst then - val fc = FreshCap(owner, Origin.InDecl(owner)) + val fc = LocalCap(owner, Origin.InDecl(owner)) assert(fc.tryClassifyAs(elem.hiddenSet.classifier), fail) hideIn(fc) super.includeElem(fc) @@ -1272,7 +1263,7 @@ object CaptureSet: * which are already subject through snapshotting and rollbacks in VarState. * It's advantageous if we don't need to deal with other pieces of state there. */ - class HiddenSet(initialOwner: Symbol, val owningCap: FreshCap)(using @constructorOnly ictx: Context) + class HiddenSet(initialOwner: Symbol, val owningCap: LocalCap)(using @constructorOnly ictx: Context) extends Var(initialOwner): // Updated by anchorCaps in CheckCaptures, but owner can be changed only @@ -1281,12 +1272,12 @@ object CaptureSet: override def owner = givenOwner - /** The FreshCaps generated by derivedFreshCap, indexed by prefix */ - val derivedCaps = new EqHashMap[Type, FreshCap]() + /** The LocalCaps generated by derivedLocalCap, indexed by prefix */ + val derivedCaps = new EqHashMap[Type, LocalCap]() //assert(id != 3) - description = i"of elements subsumed by a fresh cap in $initialOwner" + description = i"of elements subsumed by an `any` in $initialOwner" /** Add element to hidden set. */ def add(elem: Capability)(using ctx: Context, vs: VarState): Unit = @@ -1359,7 +1350,7 @@ object CaptureSet: override def showAsPrefix(using Context) = cs match case cs: Var => !cs.levelOK(elem) - || cs.isBadRoot(elem) && elem.isInstanceOf[FreshCap] + || cs.isBadRoot(elem) && elem.isInstanceOf[LocalCap] case _ => false @@ -1406,7 +1397,7 @@ object CaptureSet: |cannot be included in capture set $cs of ${cs.classifier.name} elements""" else if cs.isBadRoot(elem) then elem match - case elem: FreshCap => + case elem: LocalCap => leading: i"""Local capability ${elem.showAsCapability} created in ${elem.ccOwner} outlives its scope: |It leaks into outer capture set $cs$ownerStr""" @@ -1424,9 +1415,9 @@ object CaptureSet: case _ => def why = val reasons = cs.elems.toList.collect: - case c: FreshCap if !c.acceptsLevelOf(elem) => + case c: LocalCap if !c.acceptsLevelOf(elem) => i"$elem${elem.levelOwner.qualString("in")} is not visible from $c${c.ccOwner.qualString("in")}" - case c: FreshCap if !elem.tryClassifyAs(c.hiddenSet.classifier) => + case c: LocalCap if !elem.tryClassifyAs(c.hiddenSet.classifier) => i"$c is classified as ${c.hiddenSet.classifier} but ${elem.showAsCapability} is not" case c: ResultCap if !c.subsumes(elem) => val toAdd = if elem.isTerminalCapability then "" else " since that capability is not a SharedCapability" @@ -1493,7 +1484,7 @@ object CaptureSet: def addHidden(hidden: HiddenSet, elem: Capability)(using Context): Boolean = if hidden.isConst then false else - if !CCState.collapseFresh then hidden.add(elem)(using ctx, this) + if !CCState.collapseLocalCaps then hidden.add(elem)(using ctx, this) true /** If root1 and root2 belong to the same binder but have different originalBinders @@ -1735,7 +1726,7 @@ object CaptureSet: def abstractTypeCase(acc: CaptureSet, t: TypeRef, upperBound: Type) = if t.derivesFrom(defn.Caps_CapSet) then t.singletonCaptureSet - else if includeTypevars && upperBound.isExactlyAny then fresh(Origin.DeepCS(t)) + else if includeTypevars && upperBound.isExactlyAny then LocalCap(Origin.DeepCS(t)).singletonCaptureSet else this(acc, upperBound) collect(CaptureSet.empty, tp) diff --git a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala index a705868fc8a1..1d47d4756896 100644 --- a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala +++ b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala @@ -114,11 +114,11 @@ object CheckCaptures: if refSym.isType && !refSym.info.derivesFrom(defn.Caps_CapSet) then report.error(em"$elem is not a legal element of a capture set", ann.srcPos) case ref: CoreCapability => - if !ref.isTrackableRef && !ref.isCapRef && !ref.isLocalMutable then + if !ref.isTrackableRef && !ref.isCapsAnyRef && !ref.isLocalMutable then report.error(em"$elem cannot be tracked since it is not a parameter or local value", ann.srcPos) case ReachCapability(ref) => check(ref) - if ref.isCapRef then + if ref.isCapsAnyRef then report.error(em"Cannot form a reach capability from `cap`", ann.srcPos) case ReadOnlyCapability(ref) => check(ref) @@ -134,7 +134,7 @@ object CheckCaptures: ann.retainedSet.retainedElementsRaw.foreach(check) /** Disallow bad roots anywhere in type `tp``. - * @param upto controls up to which owner local fresh capabilities should be disallowed. + * @param upto controls up to which owner local LocalCap capabilities should be disallowed. * See disallowBadRoots for details. */ private def disallowBadRootsIn(tp: Type, upto: Symbol, what: => String, have: => String, addendum: => String, pos: SrcPos)(using Context) = @@ -169,12 +169,12 @@ object CheckCaptures: if t eq tp then "" else // Show in context of all enclosing traversed existential scopes. - def showInOpenedFreshBinders(mts: List[MethodType]): String = mts match + def showInOpenedResultBinders(mts: List[MethodType]): String = mts match case Nil => i"the part $t of " case mt :: mts1 => inNewExistentialScope(mt): - showInOpenedFreshBinders(mts1) - showInOpenedFreshBinders(openScopes.reverse) + showInOpenedResultBinders(mts1) + showInOpenedResultBinders(openScopes.reverse) report.error( em"""$what cannot $have $tp since |${part}that type captures the root capability `cap`.$addendum""", @@ -194,7 +194,7 @@ object CheckCaptures: check.traverse(tp) end disallowBadRootsIn - private def contributesFreshToClass(sym: Symbol)(using Context): Boolean = + private def contributesLocalCapToClass(sym: Symbol)(using Context): Boolean = sym.isField && !sym.isOneOf(DeferredOrTermParamOrAccessor) && !sym.hasAnnotation(defn.UntrackedCapturesAnnot) @@ -272,10 +272,10 @@ class CheckCaptures extends Recheck, SymTransformer: val ccState1 = new CCState // Dotty problem: Rename to ccState ==> Crash in ExplicitOuter - /** A cache that stores for each class the classifiers of all fresh instances + /** A cache that stores for each class the classifiers of all LocalCap instances * in the types of its fields. */ - val knownFresh = new util.EqHashMap[Symbol, List[ClassSymbol]] + val knownLocalCapClassifiers = new util.EqHashMap[Symbol, List[ClassSymbol]] class CaptureChecker(ictx: Context) extends Rechecker(ictx), CheckerAPI: @@ -368,7 +368,7 @@ class CheckCaptures extends Recheck, SymTransformer: interpolator.traverse(tp) end interpolate - /* Also set any previously unset owners of toplevel Fresh instances to improve + /* Also set any previously unset owners of toplevel LocalCap instances to improve * error diagnostics in separation checking. */ private def anchorCaps(sym: Symbol)(using Context) = new TypeTraverser: @@ -378,7 +378,7 @@ class CheckCaptures extends Recheck, SymTransformer: case t @ CapturingType(parent, refs) => for ref <- refs.elems do ref match - case ref: FreshCap if !ref.hiddenSet.givenOwner.exists => + case ref: LocalCap if !ref.hiddenSet.givenOwner.exists => ref.hiddenSet.givenOwner = sym case _ => traverse(parent) @@ -388,7 +388,7 @@ class CheckCaptures extends Recheck, SymTransformer: traverseChildren(t) /** If `tpt` is an inferred type, interpolate capture set variables appearing contra- - * variantly in it. Also anchor Fresh instances with anchorCaps. + * variantly in it. Also anchor LocalCap instances with anchorCaps. * Note: module vals don't have inferred types but still hold capture set variables. * These capture set variables are interpolated after the associated module class * has been rechecked. @@ -575,8 +575,9 @@ class CheckCaptures extends Recheck, SymTransformer: val underlying = CaptureSet.ofTypeDeeply(c1.widen) capt.println(i"Widen reach $c to $underlying in ${env.owner}") recur(underlying.filter(!_.isTerminalCapability), env, null) - // we don't want to disallow underlying Fresh instances, since these are typically locally created - // fresh capabilities. We do check that they hide no parameter reach caps in checkEscapingUses + // We don't want to disallow underlying LocalCap instances, since these are + // typically locally created LocalCap capabilities. We do check in checkEscapingUses + // that they don't hide any parameter reach caps. case _ => def checkReadOnlyMethod(included: CaptureSet, meth: Symbol): Unit = @@ -707,12 +708,12 @@ class CheckCaptures extends Recheck, SymTransformer: // ---- Rechecking operations for different kinds of trees---------------------- /** If `tp` (possibly after widening singletons) is an ExprType - * of a parameterless method, map Result instances in it to Fresh instances + * of a parameterless method, map ResultCap instances in it to LocalCap instances */ def mapResultRoots(tp: Type, sym: Symbol)(using Context): Type = tp.widenSingleton match case tp: ExprType if sym.is(Method) => - resultToFresh(tp, Origin.ResultInstance(tp, sym)) + resultToAny(tp, Origin.ResultInstance(tp, sym)) case _ => tp @@ -838,7 +839,7 @@ class CheckCaptures extends Recheck, SymTransformer: /** Recheck `caps.unsafe.unsafeAssumePure(...)` */ def applyAssumePure(tree: Apply, pt: Type)(using Context): Type = val arg :: Nil = tree.args: @unchecked - val argType0 = recheck(arg, pt.stripCapturing.capturing(FreshCap(Origin.UnsafeAssumePure))) + val argType0 = recheck(arg, pt.stripCapturing.capturing(LocalCap(Origin.UnsafeAssumePure))) val argType = if argType0.captureSet.isAlwaysEmpty then argType0 else argType0.widen.stripCapturing @@ -863,21 +864,22 @@ class CheckCaptures extends Recheck, SymTransformer: includeCallCaptures(meth, res, tree) res - /** Recheck argument against a "freshened" version of `formal` where toplevel `cap` - * occurrences are replaced by `Fresh` instances. Also, if formal parameter carries a `@use`, - * charge the deep capture set of the actual argument to the environment. + /** Recheck argument against an instantiated version of `formal` where toplevel `any` + * occurrences are replaced by LocalCap instances. Also, if formal parameter carries a `@use` + * or @consume, charge the deep capture set of the actual argument to the environment. + * TODO: Maybe not charge deep capture sets for consume? */ protected override def recheckArg(arg: Tree, formal: Type, pref: ParamRef, app: Apply)(using Context): Type = - val freshenedFormal = capToFresh(formal, Origin.Formal(pref, app)) - val argType = recheck(arg, freshenedFormal) - .showing(i"recheck arg $arg vs $freshenedFormal = $result", capt) + val instantiatedFormal = globalToLocalCap(formal, Origin.Formal(pref, app)) + val argType = recheck(arg, instantiatedFormal) + .showing(i"recheck arg $arg vs $instantiatedFormal = $result", capt) if formal.hasAnnotation(defn.UseAnnot) || formal.hasAnnotation(defn.ConsumeAnnot) then // The @use and/or @consume annotation is added to `formal` when creating methods types. // See [[MethodTypeCompanion.adaptParamInfo]]. capt.println(i"charging deep capture set of $arg: ${argType} = ${argType.deepCaptureSet}") markFree(argType.deepCaptureSet, arg) if formal.containsCap then - sepCheckFormals(arg) = freshenedFormal + sepCheckFormals(arg) = instantiatedFormal argType /** Map existential captures in result to `cap` and implement the following @@ -904,7 +906,7 @@ class CheckCaptures extends Recheck, SymTransformer: protected override def recheckApplication(tree: Apply, qualType: Type, funType: MethodType, argTypes: List[Type])(using Context): Type = val resultType = super.recheckApplication(tree, qualType, funType, argTypes) - val appType = resultToFresh(resultType, Origin.ResultInstance(funType, tree.symbol)) + val appType = resultToAny(resultType, Origin.ResultInstance(funType, tree.symbol)) val qualCaptures = qualType.captureSet val argCaptures = for (argType, formal) <- argTypes.lazyZip(funType.paramInfos) yield @@ -1009,27 +1011,28 @@ class CheckCaptures extends Recheck, SymTransformer: case _ => locals private def memberCaps(mbr: Symbol)(using Context): List[Capability] = - if contributesFreshToClass(mbr) then + if contributesLocalCapToClass(mbr) then mbr.info.spanCaptureSet.elems .filter(_.isTerminalCapability) .toList else Nil - /** If `mbr` is a field that has (possibly restricted) FreshCaps in its span capture set, + /** If `mbr` is a field that has (possibly restricted) LocalCaps in its span capture set, * their classifiers, otherwise the empty list. */ - private def classifiersOfFreshInType(mbr: Symbol)(using Context): List[ClassSymbol] = + private def classifiersOfLocalCapsInType(mbr: Symbol)(using Context): List[ClassSymbol] = memberCaps(mbr).map(_.classifier.asClass) - private def allFreshInTypeAreRO(mbr: Symbol)(using Context): Boolean = + private def allLocalCapsInTypeAreRO(mbr: Symbol)(using Context): Boolean = memberCaps(mbr).forall(_.isReadOnly) /** The additional capture set implied by the capture sets of its fields. This * is either empty or, if some fields have a terminal capability in their span - * capture sets, it consists of a single fresh cap that subsumes all these terminal - * capabiltities. Class parameters are not counted. If the type extends Separate, - * we add a fresh cap in any case -- this is because we can currently hide - * mutability in array vals, an example is neg-customargs/captures/matrix.scala. + * capture sets, it consists of a single LocalCap that subsumes all these terminal + * capabilities. Class parameters are not counted. If the type extends Separate, + * we add a LocalCap in any case -- this is because we can currently hide + * mutability in array vals if separation checking is off, an example is + * neg-customargs/captures/matrix.scala. */ def captureSetImpliedByFields(cls: ClassSymbol, core: Type)(using Context): CaptureSet = var infos: List[String] = Nil @@ -1040,12 +1043,12 @@ class CheckCaptures extends Recheck, SymTransformer: setup.fieldsWithExplicitTypes // pick fields with explicit types for classes in this compilation unit .getOrElse(cls, cls.info.decls.toList) // pick all symbols in class scope for other classes - /** The classifiers of the fresh caps in the span capture sets of all fields + /** The classifiers of the LocalCaps in the span capture sets of all fields * in the given class `cls`. */ def impliedClassifiers(cls: Symbol): List[ClassSymbol] = cls match case cls: ClassSymbol => - var fieldClassifiers = knownFields(cls).flatMap(classifiersOfFreshInType) + var fieldClassifiers = knownFields(cls).flatMap(classifiersOfLocalCapsInType) val parentClassifiers = cls.parentSyms.map(impliedClassifiers).filter(_.nonEmpty) if fieldClassifiers.isEmpty && parentClassifiers.isEmpty @@ -1055,7 +1058,7 @@ class CheckCaptures extends Recheck, SymTransformer: def impliedReadOnly(cls: Symbol): Boolean = cls match case cls: ClassSymbol => - val fieldsRO = knownFields(cls).forall(allFreshInTypeAreRO) + val fieldsRO = knownFields(cls).forall(allLocalCapsInTypeAreRO) val parentsRO = cls.parentSyms.forall(impliedReadOnly) fieldsRO && parentsRO case _ => @@ -1064,21 +1067,21 @@ class CheckCaptures extends Recheck, SymTransformer: def maybeRO(ref: Capability) = if !cls.isSeparate && impliedReadOnly(cls) then ref.readOnly else ref - def fresh = - FreshCap(Origin.NewInstance(core)).tap: fresh => + def localCap = // TODO Maybe drop this? + LocalCap(Origin.NewInstance(core)).tap: localCap => if ctx.settings.YccVerbose.value then - pushInfo(i"Note: instance of $cls captures a $fresh that comes from a field") + pushInfo(i"Note: instance of $cls captures an $localCap that comes from a field") report.echo(infos.mkString("\n"), ctx.owner.srcPos) var implied = impliedClassifiers(cls) if cls.isSeparate then implied = dominators(cls.classifier :: Nil, implied) - knownFresh.getOrElseUpdate(cls, implied) match + knownLocalCapClassifiers.getOrElseUpdate(cls, implied) match case Nil => CaptureSet.empty case cl :: Nil => - val result = fresh + val result = localCap result.hiddenSet.adoptClassifier(cl) maybeRO(result).singletonCaptureSet - case _ => maybeRO(fresh).singletonCaptureSet + case _ => maybeRO(localCap).singletonCaptureSet end captureSetImpliedByFields /** Recheck type applications: @@ -1094,7 +1097,7 @@ class CheckCaptures extends Recheck, SymTransformer: def methDescr = if meth.exists then i"$meth's type " else "" markFreeTypeArgs(tree.fun, meth, tree.args) val funType = super.recheckTypeApply(tree, pt) - val res = resultToFresh(funType, Origin.ResultInstance(funType, meth)) + val res = resultToAny(funType, Origin.ResultInstance(funType, meth)) includeCallCaptures(tree.symbol, res, tree) checkContains(tree) res @@ -1152,7 +1155,7 @@ class CheckCaptures extends Recheck, SymTransformer: assert(params.hasSameLengthAs(argTypes), i"$mdef vs $pt, ${params}") for (argType, param) <- argTypes.lazyZip(params) do val paramTpt = param.asInstanceOf[ValDef].tpt - val paramType = freshToCap(param.symbol, paramTpt.nuType) + val paramType = localCapToGlobal(param.symbol, paramTpt.nuType) checkConformsExpr(argType, paramType, param) .showing(i"compared expected closure formal $argType against $param with ${paramTpt.nuType}", capt) if resType.isValueType && isFullyDefined(resType, ForceDegree.none) then @@ -1373,7 +1376,7 @@ class CheckCaptures extends Recheck, SymTransformer: def covers(classCapset: CaptureSet, fieldClassifiers: List[ClassSymbol]): Boolean = fieldClassifiers.forall: cls => classCapset.elems.exists: - case fresh: FreshCap => cls.isSubClass(fresh.hiddenSet.classifier) + case localCap: LocalCap => cls.isSubClass(localCap.hiddenSet.classifier) case _ => false tree.tpt match @@ -1382,19 +1385,19 @@ class CheckCaptures extends Recheck, SymTransformer: if !isExemptFromExplicitChecks(sym) then // Symbols that can't be seen outside the compilation unit can have inferred types val expected = tpt.tpe.dropAllRetains todoAtPostCheck += { () => - withCapAsRoot: + withGlobalCapAsRoot: testAdapted(tp, expected, tree.rhs, addendum(expected) :: Nil)(fail) // The check that inferred <: expected is done after recheck so that it // does not interfere with normal rechecking by constraining capture set variables. } // Test point (2) of doc comment above if sym.owner.isClass - && contributesFreshToClass(sym) + && contributesLocalCapToClass(sym) && !CaptureSet.isAssumedPure(sym) then todoAtPostCheck += { () => val cls = sym.owner.asClass - val fieldClassifiers = classifiersOfFreshInType(sym) + val fieldClassifiers = classifiersOfLocalCapsInType(sym) val classCapset = captureSetImpliedByFields(cls, cls.appliedRef) if !covers(classCapset, fieldClassifiers) then report.error( @@ -1481,7 +1484,7 @@ class CheckCaptures extends Recheck, SymTransformer: // (3) Capture set of self type includes capture sets of tracked parameters for param <- cls.paramGetters do if param.isTrackedParamAccessor then - withCapAsRoot: // OK? We need this here since self types use `cap` instead of `fresh` + withGlobalCapAsRoot: // OK? We need this here since self types use GlobalCap instead of a LocalCap checkSubset(param.termRef.captureSet, thisSet, param.srcPos) // (3b) Capture set of self type includes capture sets of fields (including fresh) @@ -2035,7 +2038,7 @@ class CheckCaptures extends Recheck, SymTransformer: otherTp.derivedTypeBounds( otherTp.lo, hi.derivedCapturingType(parent, - CaptureSet.fresh(Origin.OverriddenType(member)))))) + LocalCap(Origin.OverriddenType(member)).singletonCaptureSet)))) case _ => None case _ => None case _ => None @@ -2095,7 +2098,7 @@ class CheckCaptures extends Recheck, SymTransformer: def traverse(t: Tree)(using Context) = t match case t: Template => - withCollapsedFresh: + withCollapsedLocalCaps: checkAllOverrides(ctx.owner.asClass, OverridingPairsCheckerCC(_, _, t)) case _ => traverseChildren(t) @@ -2259,7 +2262,7 @@ class CheckCaptures extends Recheck, SymTransformer: case _ => case c: DerivedCapability => checkElem(c.underlying) - case c: FreshCap => + case c: LocalCap => c.origin match case Origin.Parameter(param) => report.error( @@ -2322,7 +2325,8 @@ class CheckCaptures extends Recheck, SymTransformer: val normArgs = args.lazyZip(tl.paramInfos).map: (arg, bounds) => arg.withType(arg.nuType.forceBoxStatus( bounds.hi.isBoxedCapturing | bounds.lo.isBoxedCapturing)) - withCollapsedFresh: // OK? We need this since bounds use `cap` instead of `fresh` + withCollapsedLocalCaps: // OK? We need this since bounds use GlobalCap instead of LocalCap + // TODO Do bounds still contain GlobalCap? checkBounds(normArgs, tl) if ccConfig.postCheckCapturesets then args.lazyZip(tl.paramNames).foreach(checkTypeParam(_, _, fun.symbol)) @@ -2349,7 +2353,7 @@ class CheckCaptures extends Recheck, SymTransformer: case tree: InferredTypeTree => case tree: New => case tree: TypeTree => - withCollapsedFresh: + withCollapsedLocalCaps: checkAppliedTypesIn(tree.withType(tree.nuType)) case _ => traverseChildren(t) checkAppliedTypes.traverse(unit) diff --git a/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala b/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala index 96f83354f5cf..c40342bf9408 100644 --- a/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala +++ b/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala @@ -7,7 +7,10 @@ import Types.*, Symbols.*, Contexts.* import Annotations.{Annotation, CompactAnnotation, EmptyAnnotation} import config.Feature -/** A class for annotations @retains, @retainsByName and @retainsCap */ +/** A class for annotations @retains, @retainsByName and @retainsCap + * We make sure that all annotations with these classes are represented + * as RetainingAnnotations. + */ class RetainingAnnotation(tpe: Type) extends CompactAnnotation(tpe): def this(cls: ClassSymbol, args: Type*)(using Context) = this(cls.typeRef.appliedTo(args.toList)) diff --git a/compiler/src/dotty/tools/dotc/cc/SepCheck.scala b/compiler/src/dotty/tools/dotc/cc/SepCheck.scala index a6d75da6509d..593606c853b3 100644 --- a/compiler/src/dotty/tools/dotc/cc/SepCheck.scala +++ b/compiler/src/dotty/tools/dotc/cc/SepCheck.scala @@ -192,7 +192,7 @@ object SepCheck: if seen.contains(newElem) then recur(seen, acc, newElems1) else newElem.stripRestricted.stripReadOnly match - case _: FreshCap if !newElem.isKnownClassifiedAs(defn.Caps_SharedCapability) => + case _: LocalCap if !newElem.isKnownClassifiedAs(defn.Caps_SharedCapability) => val hiddens = if followHidden then newElem.hiddenSet.toList else Nil recur(seen + newElem, acc + newElem, hiddens ++ newElems1) case _ if newElem.isTerminalCapability => @@ -221,7 +221,7 @@ object SepCheck: completeFootprint.peaks /** The shared elements between the peak sets `refs` and `other`. - * These are the core capabilities and fresh capabilities that appear + * These are the core capabilities and LocalCap capabilities that appear * in a (possibly classified or readOnly) version in both sets and that * that appear in a non-readOnly version in at least one of the sets. */ @@ -231,7 +231,7 @@ object SepCheck: refs1.foreach: ref => if !ref.isReadOnly then val coreRef = ref.stripRestricted - if refs2.exists(_.stripRestricted.stripReadOnly.coversFresh(coreRef)) then + if refs2.exists(_.stripRestricted.stripReadOnly.coversLocalCap(coreRef)) then acc += coreRef acc assert(refs.forall(_.isTerminalCapability)) @@ -367,9 +367,9 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: val shared = hiddenFootprint.overlapWith(clashFootprint).reduced if shared.isEmpty then i"${CaptureSet(shared)}" else shared.nth(0) match - case fresh: FreshCap => - val where = if ctx.settings.YccVerbose.value then "" else i" of ${fresh.ccOwnerStr}" - i"{$fresh$where}" + case localCap: LocalCap => + val where = if ctx.settings.YccVerbose.value then "" else i" of ${localCap.ccOwnerStr}" + i"{$localCap$where}" case _ => i"${CaptureSet(shared)}" @@ -577,13 +577,13 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: val lhsOwner = lhsType.pathOwner /** A reference escapes into an outer var if it would have produced a - * level error if it did not have an Unscoped, unprefixed FreshCap + * level error if it did not have an Unscoped, unprefixed LocalCap * in some underlying capture set. */ def escapes(ref: Capability): Boolean = ref.pathRoot match - case ref @ FreshCap(NoPrefix) + case ref @ LocalCap(NoPrefix) if ref.classifier.derivesFrom(defn.Caps_Unscoped) => - // we have an escaping reference if the FreshCap's adjustded owner + // we have an escaping reference if the LocalCap's adjustded owner // is properly contained inside the scope of the variable. ref.adjustOwner(ref.ccOwner).isProperlyContainedIn(lhsOwner) case _ => @@ -652,7 +652,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: case _ => emptyRefs /** Check validity of consumed references `refsToCheck`. The references are consumed - * because they are hidden in a Fresh result type or they are referred + * because they are hidden in a LocalCap result type or they are referred * to in an argument to a consume parameter or in a prefix of a consume method -- * which one applies is determined by the role parameter. * @@ -824,7 +824,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: c.add(c1) case t @ CapturingType(parent, cs) => val c1 = this(c, parent) - if cs.elems.exists(_.core.isInstanceOf[FreshCap]) then c1.add(Captures.Hidden) + if cs.elems.exists(_.core.isInstanceOf[LocalCap]) then c1.add(Captures.Hidden) else if !cs.elems.isEmpty then c1.add(Captures.Explicit) else c1 case t: TypeRef if t.symbol.isAbstractOrParamType => @@ -835,13 +835,13 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: case t => foldOver(c, t) - /** Check that no fresh caps from the bounds of parameters or abstract types + /** Check that no LocalCaps from the bounds of parameters or abstract types * are hidden in the result. See issue #24539 */ def checkNoTParamBounds(refsToCheck: Refs, descr: => String, pos: SrcPos): Unit = for ref <- refsToCheck do ref match - case ref: FreshCap => + case ref: LocalCap => ref.origin match case Origin.InDecl(sym) if sym.isAbstractOrParamType => report.error( diff --git a/compiler/src/dotty/tools/dotc/cc/Setup.scala b/compiler/src/dotty/tools/dotc/cc/Setup.scala index 3204504c0650..cf01b9d48d01 100644 --- a/compiler/src/dotty/tools/dotc/cc/Setup.scala +++ b/compiler/src/dotty/tools/dotc/cc/Setup.scala @@ -460,7 +460,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: && !defn.isFunctionSymbol(t.typeSymbol) && (t.dealias ne tp) => if keepFunAliases then // Hold off with dealising and expand in a second pass. - // This is necessary to bind existentialFresh instances to the right method binder. + // This is necessary to bind ResultCap instances to the right method binder. keptFunAliases = true mapOver(t) else @@ -486,7 +486,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: val tp3 = if sym.isType then stripImpliedCaptureSet(tp2) else tp2 - capToFresh(tp3, Origin.InDecl(sym)) + globalToLocalCap(tp3, Origin.InDecl(sym)) end transformExplicitType /** Update info of `sym` for CheckCaptures phase only */ @@ -582,7 +582,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: for case arg: TypeTree <- args do if defn.isTypeTestOrCast(fn.symbol) then arg.setNuType( - capToFresh(arg.tpe, Origin.TypeArg(arg.tpe))) + globalToLocalCap(arg.tpe, Origin.TypeArg(arg.tpe))) else transformTT(arg, NoSymbol, boxed = true) // type arguments in type applications are boxed @@ -665,7 +665,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: try mt.derivedLambdaType( paramInfos = - psymss.head.lazyZip(mt.paramInfos).map(freshToCap), + psymss.head.lazyZip(mt.paramInfos).map(localCapToGlobal), resType = paramsToCap(psymss.tail, mt.resType)) catch case ex: AssertionError => println(i"error while mapping params ${mt.paramInfos} of $sym") @@ -741,9 +741,9 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: val cs = CaptureSet.ProperVar(cls, CaptureSet.emptyRefs, nestedOK = false, isRefining = false) if cls.derivesFrom(defn.Caps_Capability) then - // If cls is a capability class, we need to add a fresh capability to ensure + // If cls is a capability class, we need to add a LocalCap capability to ensure // we cannot treat the class as pure. - CaptureSet.fresh(cls, cls.thisType, Origin.InDecl(cls)).subCaptures(cs) + LocalCap(cls, cls.thisType, Origin.InDecl(cls)).singletonCaptureSet.subCaptures(cs) // Add capture set variable `cs`, burying it under any refinements // that might contain infos of opaque type aliases diff --git a/compiler/src/dotty/tools/dotc/cc/ccConfig.scala b/compiler/src/dotty/tools/dotc/cc/ccConfig.scala index 120b0cee82b8..7a72817f5d69 100644 --- a/compiler/src/dotty/tools/dotc/cc/ccConfig.scala +++ b/compiler/src/dotty/tools/dotc/cc/ccConfig.scala @@ -48,8 +48,8 @@ object ccConfig: */ inline val useSpanCapset = false - /** If true, do level checking for FreshCap instances */ - def useFreshLevels(using Context): Boolean = + /** If true, do level checking for LocalCap instances */ + def useLocalCapLevels(using Context): Boolean = Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.7`) /** Not used currently. Handy for trying out new features */ diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index f3e395b505f3..3458b46fe388 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -107,7 +107,7 @@ class Definitions { * } * ImpureXYZFunctionN follow this template: * - * type ImpureXYZFunctionN[-T0,...,-T{N-1}, +R] = {cap} XYZFunctionN[T0,...,T{N-1}, R] + * type ImpureXYZFunctionN[-T0,...,-T{N-1}, +R] = XYZFunctionN[T0,...,T{N-1}, R]^{any} */ private def newFunctionNType(name: TypeName): Symbol = { val impure = name.startsWith("Impure") diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 139b7f4611a8..b9684fb206b0 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -437,7 +437,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling if (tp1.prefix.isStable) return tryLiftedToThis1 case _ => if isCaptureVarComparison then - return CCState.withCapAsRoot: + return CCState.withGlobalCapAsRoot: subCaptures(tp1.captureSet, tp2.captureSet) if (tp1 eq NothingType) || isBottom(tp1) then return true @@ -593,7 +593,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling && (isBottom(tp1) || GADTusage(tp2.symbol)) if isCaptureVarComparison then - return CCState.withCapAsRoot: + return CCState.withGlobalCapAsRoot: subCaptures(tp1.captureSet, tp2.captureSet) isSubApproxHi(tp1, info2.lo) && (trustBounds || isSubApproxHi(tp1, info2.hi)) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index cecb3c790fbc..a4738b8abd71 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -920,7 +920,7 @@ object Types extends TypeUtils { pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, rinfo) else val isRefinedMethod = rinfo.isInstanceOf[MethodOrPoly] - val joint = CCState.withCollapsedFresh: + val joint = CCState.withCollapsedLocalCaps: // We have to do a collapseFresh here since `pdenot` will see the class // view and a fresh in the class will not be able to subsume a // refinement from outside since level checking would fail. @@ -3338,7 +3338,7 @@ object Types extends TypeUtils { /** Used for refined function types created at cc/Setup that come from original * generic function types. Function types of this class don't get their result - * captures mapped from FreshCaps to ResultCaps with toResult. + * captures mapped from LocalCaps to ResultCaps with toResult. */ class InferredRefinedType(parent: Type, refinedName: Name, refinedInfo: Type) extends RefinedType(parent, refinedName, refinedInfo): @@ -6384,9 +6384,9 @@ object Types extends TypeUtils { null def mapCapability(c: Capability, deep: Boolean = false): Capability | (CaptureSet, Boolean) = c match - case c @ FreshCap(prefix) => + case c @ LocalCap(prefix) => // If `pre` is not a path, transform it to a path starting with a skolem TermRef. - // We create at most one such skolem per FreshCap/context owner pair. + // We create at most one such skolem per LocalCap/context owner pair. // This approximates towards creating fewer skolems than otherwise needed, // which means we might get more separation conflicts than otherwise. But // it's not clear we will get such conflicts anyway. @@ -6400,7 +6400,7 @@ object Types extends TypeUtils { val skolem = pre.narrow(ctx.owner) c.skolems = c.skolems.updated(ctx.owner, skolem) skolem - c.derivedFreshCap(ensurePath(apply(prefix))) + c.derivedLocalCap(ensurePath(apply(prefix))) case c: RootCapability => c case Reach(c1) => mapCapability(c1, deep = true) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index d9059bab77af..d252edfce135 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -211,8 +211,8 @@ class PlainPrinter(_ctx: Context) extends Printer { false ) isUniversal - || !refs.elems.isEmpty && refs.elems.forall(_.isCapOrFresh) && !ccVerbose - case ref :: Nil => ref.isCapRef + || !refs.elems.isEmpty && refs.elems.forall(_.isGlobalOrLocalCap) && !ccVerbose + case ref :: Nil => ref.isCapsAnyRef case _ => false protected def toTextGeneralCaptureSet(refs: GeneralCaptureSet): Text = refs match @@ -315,7 +315,7 @@ class PlainPrinter(_ctx: Context) extends Printer { def arrowText: Text = restp match case AnnotatedType(parent, ann: RetainingAnnotation) if !ann.isStrict => ann.retainedType.retainedElementsRaw match - case ref :: Nil if ref.isCapRef => Str("=>") + case ref :: Nil if ref.isCapsAnyRef => Str("=>") case refs => Str("->") ~ toTextRetainedElems(refs) case _ => if Feature.pureFunsEnabled then "->" else "=>" @@ -486,7 +486,7 @@ class PlainPrinter(_ctx: Context) extends Printer { "" case n => "outer_" * n ++ (if ccVerbose then "localcap" else "cap") vbleText ~ Str(hashStr(c.binder)).provided(printDebug) ~ Str(idStr).provided(showUniqueIds) - case c: FreshCap => + case c: LocalCap => val idStr = if showUniqueIds then s"#${c.rootId}" else "" def classified = if c.hiddenSet.classifier == defn.AnyClass then "" diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index af1affd1ae99..32a0ab5f56d0 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -106,9 +106,9 @@ object RefChecks { def checkSelfConforms(other: ClassSymbol) = var otherSelf = other.declaredSelfTypeAsSeenFrom(cls.thisType) if otherSelf.exists then - val result = CCState.withCapAsRoot: + if !CCState.withGlobalCapAsRoot: // OK? We need this here since self types use `cap` instead of `fresh` cinfo.selfType <:< otherSelf - if !result then + then report.error(DoesNotConformToSelfType("illegal inheritance", cinfo.selfType, cls, otherSelf, "parent", other), cls.srcPos) diff --git a/tests/neg-custom-args/captures/apply-fresh.check b/tests/neg-custom-args/captures/apply-fresh.check index 82924140bd9f..eb4e93481470 100644 --- a/tests/neg-custom-args/captures/apply-fresh.check +++ b/tests/neg-custom-args/captures/apply-fresh.check @@ -6,7 +6,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of value x + | where: ^ and cap refer to a root capability in the type of value x | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-fresh.scala:21:15 ---------------------------------- @@ -17,7 +17,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of value y + | where: ^ and cap refer to a root capability in the type of value y | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-fresh.scala:25:15 ---------------------------------- diff --git a/tests/neg-custom-args/captures/boundary-homebrew.check b/tests/neg-custom-args/captures/boundary-homebrew.check index 09134469f848..88c7872e5b4d 100644 --- a/tests/neg-custom-args/captures/boundary-homebrew.check +++ b/tests/neg-custom-args/captures/boundary-homebrew.check @@ -7,9 +7,9 @@ |Found: (l2: boundary.Label[Int]^'s2) ?->{l1} Int |Required: (boundary.Label[Int]^) ?=> Int | - |where: ?=> refers to a fresh root capability created in anonymous function of type (using l1²: boundary.Label[boundary.Label[Int]^]^): boundary.Label[Int]^ when checking argument to parameter body of method apply + |where: ?=> refers to a root capability created in anonymous function of type (using l1²: boundary.Label[boundary.Label[Int]^]^): boundary.Label[Int]^ when checking argument to parameter body of method apply | ^ refers to the universal root capability - | cap is a fresh root capability created in anonymous function of type (using l2: boundary.Label[Int]^'s2): Int of parameter parameter l2² of method $anonfun + | cap is a root capability created in anonymous function of type (using l2: boundary.Label[Int]^'s2): Int of parameter parameter l2² of method $anonfun | 20 | boundary.break(l2)(using l1) 21 | 15 diff --git a/tests/neg-custom-args/captures/boundary.check b/tests/neg-custom-args/captures/boundary.check index adb93f14c323..e9ff34612ad7 100644 --- a/tests/neg-custom-args/captures/boundary.check +++ b/tests/neg-custom-args/captures/boundary.check @@ -9,7 +9,7 @@ | Required: scala.util.boundary.Label[Object^]^² | | where: ^ and cap refer to the universal root capability - | ^² refers to a fresh root capability classified as Control in the type of value local + | ^² refers to a root capability classified as Control in the type of value local | 6 | boundary[Unit]: l2 ?=> 7 | boundary.break(l2)(using l1) // error @@ -32,9 +32,9 @@ |Note that capability cap is not included in capture set {cap²}. | |where: ^ refers to the universal root capability - | ^² refers to a fresh root capability classified as Control in the type of value local² - | ^³ and cap² refer to a fresh root capability classified as Control created in package when checking argument to parameter label of method break - | cap is a fresh root capability classified as Control in the type of value local + | ^² refers to a root capability classified as Control in the type of value local² + | ^³ and cap² refer to a root capability classified as Control created in package when checking argument to parameter label of method break + | cap is a root capability classified as Control in the type of value local | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/boundary.scala:5:4 --------------------------------------- @@ -49,7 +49,7 @@ | The error occurred for a synthesized tree: _ | | where: ^ and cap² refer to the universal root capability - | ^² and cap refer to a fresh root capability created in package + | ^² and cap refer to a root capability created in package | 6 | boundary[Unit]: l2 ?=> 7 | boundary.break(l2)(using l1) // error diff --git a/tests/neg-custom-args/captures/boundschecks3.check b/tests/neg-custom-args/captures/boundschecks3.check index 57bcf8cbc32a..b0e58d786284 100644 --- a/tests/neg-custom-args/captures/boundschecks3.check +++ b/tests/neg-custom-args/captures/boundschecks3.check @@ -3,7 +3,7 @@ | ^ | Type argument test.Tree^ does not conform to upper bound test.Tree in inferred type test.C[test.Tree^] | - | where: ^ refers to a fresh root capability in the type of value foo + | where: ^ refers to a root capability in the type of value foo | | longer explanation available when compiling with `-explain` -- [E057] Type Mismatch Error: tests/neg-custom-args/captures/boundschecks3.scala:10:11 -------------------------------- @@ -11,7 +11,7 @@ | ^ | Type argument test.Tree^ does not conform to upper bound test.Tree in inferred type test.C[test.Tree^] | - | where: ^ refers to a fresh root capability in the type of type T + | where: ^ refers to a root capability in the type of type T | | longer explanation available when compiling with `-explain` -- [E057] Type Mismatch Error: tests/neg-custom-args/captures/boundschecks3.scala:11:11 -------------------------------- diff --git a/tests/neg-custom-args/captures/boxed-consume.check b/tests/neg-custom-args/captures/boxed-consume.check index 81e4693cb628..e87592eadfee 100644 --- a/tests/neg-custom-args/captures/boxed-consume.check +++ b/tests/neg-custom-args/captures/boxed-consume.check @@ -9,4 +9,4 @@ | Separation failure: Illegal access to (d : Object^), which was passed as a consume parameter to method g | on line 15 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value d + | where: ^ refers to a root capability in the type of value d diff --git a/tests/neg-custom-args/captures/byname.check b/tests/neg-custom-args/captures/byname.check index 25b2ef19b17a..b6aba48e11ff 100644 --- a/tests/neg-custom-args/captures/byname.check +++ b/tests/neg-custom-args/captures/byname.check @@ -12,7 +12,7 @@ | |Note that capability cap1 is not included in capture set {cap2}. | - |where: ?=> refers to a fresh root capability created in method test when checking argument to parameter ff of method h + |where: ?=> refers to a root capability created in method test when checking argument to parameter ff of method h | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/byname.scala:19:5 ---------------------------------------- diff --git a/tests/neg-custom-args/captures/capt-depfun.check b/tests/neg-custom-args/captures/capt-depfun.check index 41cafe951ede..3cc978cc1dd6 100644 --- a/tests/neg-custom-args/captures/capt-depfun.check +++ b/tests/neg-custom-args/captures/capt-depfun.check @@ -6,7 +6,7 @@ | |Note that capability y is not included in capture set {}. | - |where: => refers to a fresh root capability created in value dc when instantiating method apply's type (x: C^): Str^{x} =>³ Str^{x} - | =>² refers to a fresh root capability in the type of value dc + |where: => refers to a root capability created in value dc when instantiating method apply's type (x: C^): Str^{x} =>³ Str^{x} + | =>² refers to a root capability in the type of value dc | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/capt1.check b/tests/neg-custom-args/captures/capt1.check index f541d77a5f3e..9d9dfbec91d6 100644 --- a/tests/neg-custom-args/captures/capt1.check +++ b/tests/neg-custom-args/captures/capt1.check @@ -55,7 +55,7 @@ | because cap is not visible from cap² in value z2. | | where: ^ and cap refer to a root capability associated with the result type of (): C^ - | ^² and cap² refer to a fresh root capability created in value z2 + | ^² and cap² refer to a root capability created in value z2 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:37:5 ----------------------------------------- @@ -68,7 +68,7 @@ | because cap is not visible from cap² in value z2. | | where: ^ and cap refer to a root capability associated with the result type of (): C^ - | ^² and cap² refer to a fresh root capability created in value z2 + | ^² and cap² refer to a root capability created in value z2 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/capt1.scala:38:51 ------------------------------------------------------------- @@ -78,8 +78,8 @@ | of value z2 with type () ->{} C^. | This type hides capabilities {cap, x} | - | where: ^ refers to a fresh root capability in the type of value z2 - | cap is a fresh root capability created in value z2 + | where: ^ refers to a root capability in the type of value z2 + | cap is a root capability created in value z2 -- Error: tests/neg-custom-args/captures/capt1.scala:40:25 ------------------------------------------------------------- 40 | val z1: () => Cap = f1(x) // error | ^ @@ -87,8 +87,8 @@ | of value z3 with type () ->{x} C^. | This type hides capabilities {cap, x} | - | where: ^ refers to a fresh root capability in the type of value z3 - | cap is a fresh root capability created in value z3 + | where: ^ refers to a root capability in the type of value z3 + | cap is a root capability created in value z3 -- Error: tests/neg-custom-args/captures/capt1.scala:43:7 -------------------------------------------------------------- 43 | if x == null then // error: separation | ^ @@ -96,8 +96,8 @@ | of value z1 with type () => C^. | This type hides capabilities {x} | - | where: => refers to a fresh root capability in the type of value z1 - | ^ refers to a fresh root capability in the type of value z1 + | where: => refers to a root capability in the type of value z1 + | ^ refers to a root capability in the type of value z1 -- Error: tests/neg-custom-args/captures/capt1.scala:44:12 ------------------------------------------------------------- 44 | () => x // error: separation | ^ @@ -105,8 +105,8 @@ | of value z1 with type () => C^. | This type hides capabilities {x} | - | where: => refers to a fresh root capability in the type of value z1 - | ^ refers to a fresh root capability in the type of value z1 + | where: => refers to a root capability in the type of value z1 + | ^ refers to a root capability in the type of value z1 -- Error: tests/neg-custom-args/captures/capt1.scala:47:2 -------------------------------------------------------------- 47 | x // error: separation | ^ @@ -114,5 +114,5 @@ | of value z1 with type () => C^. | This type hides capabilities {x} | - | where: => refers to a fresh root capability in the type of value z1 - | ^ refers to a fresh root capability in the type of value z1 + | where: => refers to a root capability in the type of value z1 + | ^ refers to a root capability in the type of value z1 diff --git a/tests/neg-custom-args/captures/cc-existential-conformance.check b/tests/neg-custom-args/captures/cc-existential-conformance.check index d3117709d6c6..856b7c6f7d2e 100644 --- a/tests/neg-custom-args/captures/cc-existential-conformance.check +++ b/tests/neg-custom-args/captures/cc-existential-conformance.check @@ -8,7 +8,7 @@ | because cap is not visible from cap² in value y. | | where: ^ refers to a root capability associated with the result type of (x²: A): B^ - | ^² and cap² refer to a fresh root capability in the type of value y + | ^² and cap² refer to a root capability in the type of value y | cap is the universal root capability | x is a value in method test | x² is a reference to a value parameter @@ -36,7 +36,7 @@ | because cap is not visible from cap² in value y. | | where: ^ refers to a root capability associated with the result type of (x²: A): B^ - | ^² and cap² refer to a fresh root capability in the type of value y + | ^² and cap² refer to a root capability in the type of value y | cap is the universal root capability | x is a value in method test2 | x² is a reference to a value parameter diff --git a/tests/neg-custom-args/captures/cc-poly-2.check b/tests/neg-custom-args/captures/cc-poly-2.check index 62be3ba87085..ec1b840a2b07 100644 --- a/tests/neg-custom-args/captures/cc-poly-2.check +++ b/tests/neg-custom-args/captures/cc-poly-2.check @@ -6,7 +6,7 @@ | | Note that capability d is not included in capture set {c1}. | - | where: ^ refers to a fresh root capability in the type of value d + | where: ^ refers to a root capability in the type of value d | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-poly-2.scala:16:20 ------------------------------------ diff --git a/tests/neg-custom-args/captures/check-inferred.check b/tests/neg-custom-args/captures/check-inferred.check index b518051d9910..309db9768309 100644 --- a/tests/neg-custom-args/captures/check-inferred.check +++ b/tests/neg-custom-args/captures/check-inferred.check @@ -27,7 +27,7 @@ | Inferred type : Object^ | Externally visible type: Object | - | where: ^ refers to a fresh root capability created in value count + | where: ^ refers to a root capability created in value count -- Error: tests/neg-custom-args/captures/check-inferred.scala:24:11 ---------------------------------------------------- 24 | val count = Ref(): Object^ // error // error | ^ @@ -35,7 +35,7 @@ | Fields capturing a root capability need to be given an explicit type unless the capability is already | subsumed by the computed capability of the enclosing class. | - | where: ^ refers to a fresh root capability in the type of value count + | where: ^ refers to a root capability in the type of value count -- Error: tests/neg-custom-args/captures/check-inferred.scala:45:15 ---------------------------------------------------- 45 | private val y = ??? : A^ // error | ^ @@ -43,7 +43,7 @@ | Fields capturing a root capability need to be given an explicit type unless the capability is already | subsumed by the computed capability of the enclosing class. | - | where: ^ refers to a fresh root capability in the type of value y + | where: ^ refers to a root capability in the type of value y -- Error: tests/neg-custom-args/captures/check-inferred.scala:49:15 ---------------------------------------------------- 49 | private val y = ??? : (() => A^{cap.only[caps.Unscoped]}) // error | ^ @@ -51,8 +51,8 @@ |Fields capturing a root capability need to be given an explicit type unless the capability is already |subsumed by the computed capability of the enclosing class. | - |where: => refers to a fresh root capability in the type of value y - | cap is a fresh root capability created in value y + |where: => refers to a root capability in the type of value y + | cap is a root capability created in value y -- Error: tests/neg-custom-args/captures/check-inferred.scala:29:21 ---------------------------------------------------- 29 | private val count = Ref() // error | ^ @@ -60,4 +60,4 @@ | Fields capturing a root capability need to be given an explicit type unless the capability is already | subsumed by the computed capability of the enclosing class. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of value count + | where: ^ refers to a root capability classified as Unscoped in the type of value count diff --git a/tests/neg-custom-args/captures/class-level-attack.check b/tests/neg-custom-args/captures/class-level-attack.check index 7cb7dc336c82..deecb7aa6a1f 100644 --- a/tests/neg-custom-args/captures/class-level-attack.check +++ b/tests/neg-custom-args/captures/class-level-attack.check @@ -1,13 +1,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/class-level-attack.scala:17:33 --------------------------- 17 | update def set(x: IO^) = r.put(x) // error | ^ - | Found: IO^{x} - | Required: IO^ + | Found: IO^{x} + | Required: IO^ | - | Note that capability x is not included in capture set {cap} - | because (x : IO^²) in method set is not visible from cap in value r. + | Note that capability x is not included in capture set {cap} + | because (x : IO^²) in method set is not visible from cap in value r. | - | where: ^ and cap refer to a fresh root capability in the type of value r - | ^² refers to a fresh root capability in the type of parameter x + | where: ^ and cap refer to a root capability in the type of value r + | ^² refers to a root capability in the type of parameter x | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/classified-inheritance2.check b/tests/neg-custom-args/captures/classified-inheritance2.check index 3d608ff53bff..6515d5483c42 100644 --- a/tests/neg-custom-args/captures/classified-inheritance2.check +++ b/tests/neg-custom-args/captures/classified-inheritance2.check @@ -10,6 +10,6 @@ | |Note that capability cap.rd is not included in capture set {}. | - |where: cap is a fresh root capability classified as SharedCapability created in value t when constructing instance Logger + |where: cap is a root capability classified as SharedCapability created in value t when constructing instance Logger | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/classifiers-secondclass.check b/tests/neg-custom-args/captures/classifiers-secondclass.check index 4ce3933ebc9b..2c2bc3b4addb 100644 --- a/tests/neg-custom-args/captures/classifiers-secondclass.check +++ b/tests/neg-custom-args/captures/classifiers-secondclass.check @@ -6,7 +6,7 @@ | |Note that capability f.write is not included in capture set {cap.only[Read]}. | - |where: cap is a fresh root capability created in anonymous function of type (f²: Levels.File^): Unit when checking argument to parameter op of method parReduce + |where: cap is a root capability created in anonymous function of type (f²: Levels.File^): Unit when checking argument to parameter op of method parReduce | 42 | f.write(42) // the error stems from here 43 | a + b + f.read() // ok @@ -20,7 +20,7 @@ | |Note that capability f.write is not included in capture set {cap.only[Read]}. | - |where: cap is a fresh root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce + |where: cap is a root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce | 54 | f.write(42) // the error stems from here 55 | a + b + f.read() + g.read() // ok @@ -34,7 +34,7 @@ | |Note that capability g.write is not included in capture set {cap.only[Read]}. | - |where: cap is a fresh root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce + |where: cap is a root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce | 57 | g.write(42) // the error stems from here 58 | 0 diff --git a/tests/neg-custom-args/captures/closure-result-typing.check b/tests/neg-custom-args/captures/closure-result-typing.check index c1a963355017..a3c9c7dbca87 100644 --- a/tests/neg-custom-args/captures/closure-result-typing.check +++ b/tests/neg-custom-args/captures/closure-result-typing.check @@ -6,6 +6,6 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of parameter c + | where: ^ and cap refer to a root capability in the type of parameter c | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/consume-in-constructor.check b/tests/neg-custom-args/captures/consume-in-constructor.check index 4937bf7fc6e4..96e94f714ab5 100644 --- a/tests/neg-custom-args/captures/consume-in-constructor.check +++ b/tests/neg-custom-args/captures/consume-in-constructor.check @@ -4,7 +4,7 @@ |Separation failure: Illegal access to (b : B^), which was passed as a consume parameter to constructor of class A2 |on line 18 and therefore is no longer available. | - |where: ^ refers to a fresh root capability in the type of value b + |where: ^ refers to a root capability in the type of value b -- Error: tests/neg-custom-args/captures/consume-in-constructor.scala:21:10 -------------------------------------------- 21 | println(a1) // error, since `b` was consumed before | ^^ @@ -13,7 +13,7 @@ | |where: b is a value in class A1 | b² is a value in method Test - | cap is a fresh root capability in the type of value a1 + | cap is a root capability in the type of value a1 -- Error: tests/neg-custom-args/captures/consume-in-constructor.scala:27:10 -------------------------------------------- 27 | println(b) // error, b is hidden in the type of a1 | ^ @@ -21,5 +21,5 @@ | of value a1 with type A1^. | This type hides capabilities {cap, b} | - | where: ^ refers to a fresh root capability in the type of value a1 - | cap is a fresh root capability created in value a1 when constructing instance A1 + | where: ^ refers to a root capability in the type of value a1 + | cap is a root capability created in value a1 when constructing instance A1 diff --git a/tests/neg-custom-args/captures/consume-tvar-bound.check b/tests/neg-custom-args/captures/consume-tvar-bound.check index 98e21039d2f4..573b323695db 100644 --- a/tests/neg-custom-args/captures/consume-tvar-bound.check +++ b/tests/neg-custom-args/captures/consume-tvar-bound.check @@ -4,21 +4,21 @@ | Separation failure: method h's result type Ref^ hides cap, which appears in the bound of type T. | This is not allowed. The type T has to be returned explicitly in the result type. | - | where: cap is a fresh root capability in the type of type T + | where: cap is a root capability in the type of type T -- Error: tests/neg-custom-args/captures/consume-tvar-bound.scala:9:30 ------------------------------------------------- 9 |def hh[T <: Ref^](x: Box[T]): (Ref^, Int) = (x.elem, 1) // error (but msg is strange since it does not highlight the underlying box conflict) | ^^^^^^^^^^^ | Separation failure: method hh's result type (Ref^, Int) hides cap, which appears in the bound of type T. | This is not allowed. The type T has to be returned explicitly in the result type. | - | where: cap is a fresh root capability in the type of type T + | where: cap is a root capability in the type of type T -- Error: tests/neg-custom-args/captures/consume-tvar-bound.scala:11:37 ------------------------------------------------ 11 |def g[T <: Ref^](consume x: Box[T]): Ref^ = x.elem // error | ^^^^ | Separation failure: method g's result type Ref^ hides cap, which appears in the bound of type T. | This is not allowed. The type T has to be returned explicitly in the result type. | - | where: cap is a fresh root capability in the type of type T + | where: cap is a root capability in the type of type T -- Error: tests/neg-custom-args/captures/consume-tvar-bound.scala:20:43 ------------------------------------------------ 20 | def f[T <: Ref^{rr}](consume x: Box[T]): Ref^ = x.elem // error | ^^^^ diff --git a/tests/neg-custom-args/captures/dcs-tvar.check b/tests/neg-custom-args/captures/dcs-tvar.check index 9460f3e7b45e..1e09990ff536 100644 --- a/tests/neg-custom-args/captures/dcs-tvar.check +++ b/tests/neg-custom-args/captures/dcs-tvar.check @@ -6,7 +6,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: => and cap refer to a fresh root capability in the type of type T + | where: => and cap refer to a root capability in the type of type T | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/dcs-tvar.scala:9:2 --------------------------------------- @@ -17,6 +17,6 @@ | | Note that capability cap is not included in capture set {}. | - | where: => and cap refer to a fresh root capability in the type of type U + | where: => and cap refer to a root capability in the type of type U | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/depfun-reach.check b/tests/neg-custom-args/captures/depfun-reach.check index 096fbf36e975..0879200cee4f 100644 --- a/tests/neg-custom-args/captures/depfun-reach.check +++ b/tests/neg-custom-args/captures/depfun-reach.check @@ -6,7 +6,7 @@ | |Note that capability op* cannot be included in capture set {} of value f. | - |where: => refers to a fresh root capability created in anonymous function of type (): Unit when checking argument to parameter op of method foreach + |where: => refers to a root capability created in anonymous function of type (): Unit when checking argument to parameter op of method foreach | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/depfun-reach.scala:19:4 ---------------------------------- @@ -17,19 +17,19 @@ | | Note that capability cap is not included in capture set {cap²}. | - | where: => and cap refer to a fresh root capability in the type of parameter op - | =>² and cap² refer to a fresh root capability in the result type of method foo + | where: => and cap refer to a root capability in the type of parameter op + | =>² and cap² refer to a root capability in the result type of method foo | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/depfun-reach.scala:26:60 --------------------------------- 26 | val b: (xs: List[() ->{io} Unit]) => List[() ->{} Unit] = a // error | ^ - | Found: (a : (xs: List[() ->{io} Unit]) => List[() ->{xs*} Unit]) - | Required: (xs: List[() ->{io} Unit]) =>² List[() -> Unit] + | Found: (a : (xs: List[() ->{io} Unit]) => List[() ->{xs*} Unit]) + | Required: (xs: List[() ->{io} Unit]) =>² List[() -> Unit] | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability cap is not included in capture set {cap²}. | - | where: => and cap refer to a fresh root capability in the type of value a - | =>² and cap² refer to a fresh root capability in the type of value b + | where: => and cap refer to a root capability in the type of value a + | =>² and cap² refer to a root capability in the type of value b | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/effect-swaps-explicit.check b/tests/neg-custom-args/captures/effect-swaps-explicit.check index d7538ae790c8..a653597a98bb 100644 --- a/tests/neg-custom-args/captures/effect-swaps-explicit.check +++ b/tests/neg-custom-args/captures/effect-swaps-explicit.check @@ -26,7 +26,7 @@ |Found: (contextual$9: boundary.Label[Result[Future[T^'s3]^'s4, E^'s5]^'s6]^'s7) ?->{fr, async} Future[T^'s8]^{fr, contextual$9} |Required: (boundary.Label[Result[Future[T^'s9]^'s2, E^'s10]]^) ?=> Future[T^'s9]^'s2 | - |where: ?=> refers to a fresh root capability created in method fail4 when checking argument to parameter body of method make + |where: ?=> refers to a root capability created in method fail4 when checking argument to parameter body of method make | ^ refers to the universal root capability | 70 | fr.await.ok @@ -40,7 +40,7 @@ | |Note that capability fr is not included in capture set {}. | - |where: ?=> refers to a fresh root capability created in method fail5 when checking argument to parameter body of method make + |where: ?=> refers to a root capability created in method fail5 when checking argument to parameter body of method make | ^ refers to the universal root capability | 74 | Future: fut ?=> diff --git a/tests/neg-custom-args/captures/effect-swaps.check b/tests/neg-custom-args/captures/effect-swaps.check index 35637778d273..22d462563e15 100644 --- a/tests/neg-custom-args/captures/effect-swaps.check +++ b/tests/neg-custom-args/captures/effect-swaps.check @@ -26,7 +26,7 @@ |Found: (contextual$9: boundary.Label[Result[Future[T^'s3]^'s4, E^'s5]^'s6]^'s7) ?->{fr, async} Future[T^'s8]^{fr, contextual$9} |Required: (boundary.Label[Result[Future[T^'s9]^'s2, E^'s10]]^) ?=> Future[T^'s9]^'s2 | - |where: ?=> refers to a fresh root capability created in method fail4 when checking argument to parameter body of method make + |where: ?=> refers to a root capability created in method fail4 when checking argument to parameter body of method make | ^ refers to the universal root capability | 70 | fr.await.ok @@ -40,7 +40,7 @@ | |Note that capability fr is not included in capture set {}. | - |where: ?=> refers to a fresh root capability created in method fail5 when checking argument to parameter body of method make + |where: ?=> refers to a root capability created in method fail5 when checking argument to parameter body of method make | ^ refers to the universal root capability | 74 | Future: fut ?=> diff --git a/tests/neg-custom-args/captures/existential-mapping.check b/tests/neg-custom-args/captures/existential-mapping.check index 10f43e941e2e..cf0c3a99965f 100644 --- a/tests/neg-custom-args/captures/existential-mapping.check +++ b/tests/neg-custom-args/captures/existential-mapping.check @@ -71,7 +71,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: => refers to a fresh root capability in the type of value _$6 + | where: => refers to a root capability in the type of value _$6 | ^ refers to the universal root capability | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² | @@ -84,8 +84,8 @@ | | Note that capability cap is not included in capture set {cap²}. | - | where: => and cap refer to a fresh root capability in the type of value y1 - | =>² and cap² refer to a fresh root capability in the type of value _$7 + | where: => and cap refer to a root capability in the type of value y1 + | =>² and cap² refer to a root capability in the type of value _$7 | ^ refers to the universal root capability | ^² refers to a root capability associated with the result type of (x: C^): C^² | @@ -98,7 +98,7 @@ | | Note that capability y2* is not included in capture set {}. | - | where: => refers to a fresh root capability in the type of value _$8 + | where: => refers to a root capability in the type of value _$8 | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -110,8 +110,8 @@ | | Note that capability cap is not included in capture set {}. | - | where: => refers to a fresh root capability in the type of value _$9 - | =>² refers to a fresh root capability in the type of value _$9 + | where: => refers to a root capability in the type of value _$9 + | =>² refers to a root capability in the type of value _$9 | ^ refers to the universal root capability | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² | @@ -124,8 +124,8 @@ | | Note that capability y4* is not included in capture set {}. | - | where: => refers to a fresh root capability in the type of value _$10 - | =>² refers to a fresh root capability in the type of value _$10 + | where: => refers to a root capability in the type of value _$10 + | =>² refers to a root capability in the type of value _$10 | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -137,8 +137,8 @@ | | Note that capability cap is not included in capture set {cap²}. | - | where: => and cap refer to a fresh root capability in the type of value y5 - | =>² and cap² refer to a fresh root capability in the type of value _$11 + | where: => and cap refer to a root capability in the type of value y5 + | =>² and cap² refer to a root capability in the type of value _$11 | ^ refers to the universal root capability | ^² refers to a root capability associated with the result type of (x: C^): C^² | @@ -151,8 +151,8 @@ | | Note that capability cap is not included in capture set {}. | - | where: => refers to a fresh root capability in the type of value _$12 - | =>² refers to a fresh root capability in the type of value _$12 + | where: => refers to a root capability in the type of value _$12 + | =>² refers to a root capability in the type of value _$12 | ^ refers to the universal root capability | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² | diff --git a/tests/neg-custom-args/captures/extending-cap-classes.check b/tests/neg-custom-args/captures/extending-cap-classes.check index 002c0c62783c..970667c31ccd 100644 --- a/tests/neg-custom-args/captures/extending-cap-classes.check +++ b/tests/neg-custom-args/captures/extending-cap-classes.check @@ -6,6 +6,6 @@ | | Note that capability cap is not included in capture set {}. | - | where: cap is a fresh root capability classified as SharedCapability in the type of value y2 + | where: cap is a root capability classified as SharedCapability in the type of value y2 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/filevar-expanded.check b/tests/neg-custom-args/captures/filevar-expanded.check index 516d03b5ed7c..a8de5f9402fa 100644 --- a/tests/neg-custom-args/captures/filevar-expanded.check +++ b/tests/neg-custom-args/captures/filevar-expanded.check @@ -13,5 +13,5 @@ | Footprint set of second argument : {io3} | The two sets overlap at : {io3} | - |where: ^ refers to a fresh root capability in the type of parameter io3 - | ^² refers to a fresh root capability created in method test when checking argument to parameter io2 of method withFile + |where: ^ refers to a root capability in the type of parameter io3 + | ^² refers to a root capability created in method test when checking argument to parameter io2 of method withFile diff --git a/tests/neg-custom-args/captures/freeze-boxes.check b/tests/neg-custom-args/captures/freeze-boxes.check index 1cee2b90d920..e6f379cefc41 100644 --- a/tests/neg-custom-args/captures/freeze-boxes.check +++ b/tests/neg-custom-args/captures/freeze-boxes.check @@ -7,7 +7,7 @@ | | Note that capability a.rd is not included in capture set {}. | - | where: cap is a fresh root capability classified as Unscoped in the type of value xs + | where: cap is a root capability classified as Unscoped in the type of value xs | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/freeze-boxes.scala:29:7 ------------------------------------------------------- @@ -17,8 +17,8 @@ |of value a with type Ref^. |This type hides capabilities {cap} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | cap is a fresh root capability classified as Unscoped created in value a when instantiating method allocRef's type (): Ref^² + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | cap is a root capability classified as Unscoped created in value a when instantiating method allocRef's type (): Ref^² -- Error: tests/neg-custom-args/captures/freeze-boxes.scala:31:6 ------------------------------------------------------- 31 | par(() => a.set(42), () => println(b.get)) // error | ^^^^^^^^^^^^^^^ @@ -34,11 +34,11 @@ | Footprint set of second argument : {b.rd, a.rd} | The two sets overlap at : {a} | - |where: => refers to a fresh root capability created in method test2 when checking argument to parameter op1 of method par + |where: => refers to a root capability created in method test2 when checking argument to parameter op1 of method par -- Error: tests/neg-custom-args/captures/freeze-boxes.scala:37:12 ------------------------------------------------------ 37 | par(() => a.set(42), () => println(b.get)) // error | ^ | Separation failure: Illegal access to (a : Ref^), which was passed as a consume parameter to method freeze | on line 36 and therefore is no longer available. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of value a + | where: ^ refers to a root capability classified as Unscoped in the type of value a diff --git a/tests/neg-custom-args/captures/fresh-counter.check b/tests/neg-custom-args/captures/fresh-counter.check index 84d3137b63bb..eb762a450016 100644 --- a/tests/neg-custom-args/captures/fresh-counter.check +++ b/tests/neg-custom-args/captures/fresh-counter.check @@ -13,7 +13,7 @@ | Footprint set of second argument : {d, c.decr, c} | The two sets overlap at : {c.incr, c.count} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter p1 of method par + |where: => refers to a root capability created in method test when checking argument to parameter p1 of method par -- Error: tests/neg-custom-args/captures/fresh-counter.scala:33:4 ------------------------------------------------------ 33 | () => count.put(count.get + 1), // error: separation failure | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -29,4 +29,4 @@ | Footprint set of second argument : {count} | The two sets overlap at : {count} | - |where: => refers to a fresh root capability created in method mkCounter when checking argument to parameter a of constructor Pair + |where: => refers to a root capability created in method mkCounter when checking argument to parameter a of constructor Pair diff --git a/tests/neg-custom-args/captures/fresh-fields.check b/tests/neg-custom-args/captures/fresh-fields.check index 4fca44da38b0..4200fbb40377 100644 --- a/tests/neg-custom-args/captures/fresh-fields.check +++ b/tests/neg-custom-args/captures/fresh-fields.check @@ -6,7 +6,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of value b + | where: ^ and cap refer to a root capability in the type of value b | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:27:13 --------------------------------- @@ -17,7 +17,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of value c + | where: ^ and cap refer to a root capability in the type of value c | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:29:13 --------------------------------- @@ -28,18 +28,18 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of value d + | where: ^ and cap refer to a root capability in the type of value d | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:31:13 --------------------------------- 31 | val _: E = e // error | ^ - | Found: (e : E^) - | Required: E + | Found: (e : E^) + | Required: E | - | Note that capability cap is not included in capture set {}. + | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability classified as SharedCapability in the type of value e + | where: ^ and cap refer to a root capability classified as SharedCapability in the type of value e | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:33:13 --------------------------------- @@ -50,6 +50,6 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of value f + | where: ^ and cap refer to a root capability in the type of value f | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/heal-tparam-cs.check b/tests/neg-custom-args/captures/heal-tparam-cs.check index 73cb8afabbbb..e90ea305deb0 100644 --- a/tests/neg-custom-args/captures/heal-tparam-cs.check +++ b/tests/neg-custom-args/captures/heal-tparam-cs.check @@ -7,7 +7,7 @@ |Found: (c: Capp^'s2) ->'s3 () ->{c} Unit |Required: (c: Capp^) => () ->'s1 Unit | - |where: => refers to a fresh root capability created in value test1 when checking argument to parameter op of method localCap + |where: => refers to a root capability created in value test1 when checking argument to parameter op of method localCap | ^ refers to the universal root capability | 11 | () => { c.use() } diff --git a/tests/neg-custom-args/captures/i15116.check b/tests/neg-custom-args/captures/i15116.check index 462c1b6ed89b..4f08998cddf3 100644 --- a/tests/neg-custom-args/captures/i15116.check +++ b/tests/neg-custom-args/captures/i15116.check @@ -7,7 +7,7 @@ | Inferred type : test.Foo{val m: (Bar.this.m² : test.STR^)}^{Bar.this.m²} | Externally visible type: test.Foo | - | where: ^ refers to a fresh root capability in the type of value m² + | where: ^ refers to a root capability in the type of value m² | m is a value in class Foo | m² is a value in class Bar -- Error: tests/neg-custom-args/captures/i15116.scala:7:13 ------------------------------------------------------------- @@ -19,7 +19,7 @@ | Inferred type : test.Foo{val m: (Baz.this.m² : test.STR^)}^{Baz.this.m²} | Externally visible type: test.Foo | - | where: ^ refers to a fresh root capability in the type of value m² + | where: ^ refers to a root capability in the type of value m² | m is a value in class Foo | m² is a value in trait Baz -- Error: tests/neg-custom-args/captures/i15116.scala:9:13 ------------------------------------------------------------- @@ -31,7 +31,7 @@ | Inferred type : test.Foo{val m: (Bar1.this.m² : test.STR^)}^{Bar1.this.m²} | Externally visible type: test.Foo | - | where: ^ refers to a fresh root capability in the type of value m² + | where: ^ refers to a root capability in the type of value m² | m is a value in class Foo | m² is a value in class Bar1 -- Error: tests/neg-custom-args/captures/i15116.scala:11:13 ------------------------------------------------------------ @@ -43,6 +43,6 @@ | Inferred type : test.Foo{val m: (Baz2.this.m² : test.STR^)}^{Baz2.this.m²} | Externally visible type: test.Foo | - | where: ^ refers to a fresh root capability in the type of value m² + | where: ^ refers to a root capability in the type of value m² | m is a value in class Foo | m² is a value in trait Baz2 diff --git a/tests/neg-custom-args/captures/i15772.check b/tests/neg-custom-args/captures/i15772.check index 08536e05a189..59d20b7f4d03 100644 --- a/tests/neg-custom-args/captures/i15772.check +++ b/tests/neg-custom-args/captures/i15772.check @@ -9,7 +9,7 @@ |since the additional capture set {c} resulting from box conversion is not allowed in C{val arg: C^²}^{c} => Unit | |where: => and ^ and cap refer to the universal root capability - | ^² refers to a fresh root capability in the type of value arg + | ^² refers to a root capability in the type of value arg -- Error: tests/neg-custom-args/captures/i15772.scala:29:35 ------------------------------------------------------------ 29 | val boxed2 : Observe[C^] = box2(c) // error | ^^^^^^^ @@ -17,7 +17,7 @@ |since the additional capture set {c} resulting from box conversion is not allowed in C{val arg: C^²}^{c} => Unit | |where: => and ^ and cap refer to the universal root capability - | ^² refers to a fresh root capability in the type of value arg + | ^² refers to a root capability in the type of value arg -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i15772.scala:35:33 --------------------------------------- 35 | val boxed2 : Observe[C]^ = box2(c) // error | ^^^^^^^ @@ -27,9 +27,9 @@ |Note that capability cap is not included in capture set {}. | |where: => refers to the universal root capability - | =>² refers to a fresh root capability in the type of value boxed2 - | ^ refers to a fresh root capability in the type of value arg - | ^² and cap refer to a fresh root capability created in value boxed2 when instantiating method c's type -> C^{cap²} + | =>² refers to a root capability in the type of value boxed2 + | ^ refers to a root capability in the type of value arg + | ^² and cap refer to a root capability created in value boxed2 when instantiating method c's type -> C^{cap²} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i15772.scala:46:2 ---------------------------------------- diff --git a/tests/neg-custom-args/captures/i15923a.check b/tests/neg-custom-args/captures/i15923a.check index d21ce5cfd04b..01e1cd3b8d2d 100644 --- a/tests/neg-custom-args/captures/i15923a.check +++ b/tests/neg-custom-args/captures/i15923a.check @@ -7,7 +7,7 @@ |Found: (lcap: Cap^'s2) ->'s3 () ->'s4 Id[Cap^'s5]^'s6 |Required: (lcap: Cap^) => () =>² Id[Cap^'s1]^'s7 | - |where: => refers to a fresh root capability created in value leak when checking argument to parameter op of method withCap + |where: => refers to a root capability created in value leak when checking argument to parameter op of method withCap | =>² refers to a root capability associated with the result type of (lcap: Cap^): () =>² Id[Cap^'s1]^'s7 | ^ refers to the universal root capability | cap is a root capability associated with the result type of (): Id[Cap^'s5]^'s6 diff --git a/tests/neg-custom-args/captures/i15923b.check b/tests/neg-custom-args/captures/i15923b.check index ef2e1ed7e16f..85133bb04841 100644 --- a/tests/neg-custom-args/captures/i15923b.check +++ b/tests/neg-custom-args/captures/i15923b.check @@ -7,7 +7,7 @@ |Found: (x$0: Cap^) -> Id[Cap^{x$0}] |Required: (lcap: Cap^) => Id[Cap^'s1]^'s2 | - |where: => refers to a fresh root capability created in value leak when checking argument to parameter op of method withCap + |where: => refers to a root capability created in value leak when checking argument to parameter op of method withCap | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i16226.check b/tests/neg-custom-args/captures/i16226.check index 860f80ade5d5..4a5cdef9ffad 100644 --- a/tests/neg-custom-args/captures/i16226.check +++ b/tests/neg-custom-args/captures/i16226.check @@ -11,8 +11,8 @@ |where: => refers to a root capability associated with the result type of (ref1: LazyRef[A^'s1]{val elem: () ->'s2 A^'s3}^'s4, f1: A^'s5 ->'s6 B^'s7): | LazyRef[B^'s9]{val elem: () => B^'s10}^{f1, ref1} | =>² refers to the universal root capability - | =>³ refers to a fresh root capability in the result type of method mapc - | ^ and cap refer to a fresh root capability in the result type of method mapc + | =>³ refers to a root capability in the result type of method mapc + | ^ and cap refer to a root capability in the result type of method mapc | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i16226.scala:15:4 ---------------------------------------- @@ -28,7 +28,7 @@ |where: => and cap refer to a root capability associated with the result type of (ref1: LazyRef[A^'s11]{val elem: () ->'s12 A^'s13}^'s14, f1: A^'s15 ->'s16 B^'s17): | LazyRef[B^'s19]{val elem: () => B^'s20}^{f1, ref1} | =>² and ^² refer to the universal root capability - | =>³ refers to a fresh root capability in the result type of method mapd + | =>³ refers to a root capability in the result type of method mapd | ^ refers to a root capability associated with the result type of (ref: LazyRef[A]^{io}, f: A =>² B): LazyRef[B]^ | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i20481.check b/tests/neg-custom-args/captures/i20481.check index e8bf7c5fc80c..f902cb356ad9 100644 --- a/tests/neg-custom-args/captures/i20481.check +++ b/tests/neg-custom-args/captures/i20481.check @@ -17,7 +17,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of parameter a + | where: ^ and cap refer to a root capability in the type of parameter a | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i20481.scala:10:16 --------------------------------------- @@ -28,7 +28,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of value f + | where: ^ and cap refer to a root capability in the type of value f | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i20481.scala:11:23 --------------------------------------- diff --git a/tests/neg-custom-args/captures/i21313.check b/tests/neg-custom-args/captures/i21313.check index 645b33053146..1b6af8626bbe 100644 --- a/tests/neg-custom-args/captures/i21313.check +++ b/tests/neg-custom-args/captures/i21313.check @@ -10,6 +10,6 @@ | |Note that capability ac1 cannot be included in capture set {ac2} of value src2. | - |where: ^ refers to a fresh root capability created in method test when checking argument to parameter src of method await + |where: ^ refers to a root capability created in method test when checking argument to parameter src of method await | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i21401.check b/tests/neg-custom-args/captures/i21401.check index ca8140e9aa4d..85c26f559c71 100644 --- a/tests/neg-custom-args/captures/i21401.check +++ b/tests/neg-custom-args/captures/i21401.check @@ -7,9 +7,9 @@ |Note that capability x is not included in capture set {cap} |because (x : IO^'s1) is not visible from cap in value a. | - |where: => refers to a fresh root capability created in value a when checking argument to parameter op of method usingIO + |where: => refers to a root capability created in value a when checking argument to parameter op of method usingIO | ^ refers to the universal root capability - | ^² and cap refer to a fresh root capability created in value a + | ^² and cap refer to a root capability created in value a | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/i21401.scala:16:66 ------------------------------------------------------------ @@ -30,7 +30,7 @@ | |where: ^ refers to the universal root capability | ^² and cap refer to a root capability associated with the result type of (x: Boxed[IO^]^'s3): Boxed[IO^²] - | ^³ and cap² refer to a fresh root capability created in value x² + | ^³ and cap² refer to a root capability created in value x² | x is a reference to a value parameter | x² is a value in method test2 | diff --git a/tests/neg-custom-args/captures/i21614.check b/tests/neg-custom-args/captures/i21614.check index 399d26c8462d..01debfbf8d91 100644 --- a/tests/neg-custom-args/captures/i21614.check +++ b/tests/neg-custom-args/captures/i21614.check @@ -6,8 +6,8 @@ | |Note that capability cap is not included in capture set {cap²}. | - |where: ^ and cap² refer to a fresh root capability classified as SharedCapability created in anonymous function of type (f²: F): Logger when checking argument to parameter f of constructor Logger - | cap is a fresh root capability classified as SharedCapability in the type of parameter f + |where: ^ and cap² refer to a root capability classified as SharedCapability created in anonymous function of type (f²: F): Logger when checking argument to parameter f of constructor Logger + | cap is a root capability classified as SharedCapability in the type of parameter f | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:15:12 --------------------------------------- @@ -19,6 +19,6 @@ |Note that capability C is not classified as trait SharedCapability, therefore it |cannot be included in capture set 's1 of parameter _$1 of SharedCapability elements. | - |where: => refers to a fresh root capability created in method mkLoggers2 when checking argument to parameter f of method map + |where: => refers to a root capability created in method mkLoggers2 when checking argument to parameter f of method map | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i21920.check b/tests/neg-custom-args/captures/i21920.check index 6479386622fa..ef9a33bf63e0 100644 --- a/tests/neg-custom-args/captures/i21920.check +++ b/tests/neg-custom-args/captures/i21920.check @@ -7,7 +7,7 @@ |Found: (f: File^'s2) ->'s3 Cell[File^'s4]{val head: () ->'s5 IterableOnce[File^'s6]^'s7}^'s8 |Required: File^ => Cell[File^'s9]{val head: () ->'s10 IterableOnce[File^'s11]^'s12}^'s13 | - |where: => refers to a fresh root capability created in value cell when checking argument to parameter f of method open + |where: => refers to a root capability created in value cell when checking argument to parameter f of method open | ^ refers to the universal root capability | cap is a root capability associated with the result type of (): IterableOnce[File^'s1]^² | diff --git a/tests/neg-custom-args/captures/i23431.check b/tests/neg-custom-args/captures/i23431.check index 403758455554..cc58ac2c616b 100644 --- a/tests/neg-custom-args/captures/i23431.check +++ b/tests/neg-custom-args/captures/i23431.check @@ -7,8 +7,8 @@ | Note that capability io is not included in capture set {cap} | because (io : IO^) in method setIO is not visible from cap in variable myIO. | - | where: ^ refers to a fresh root capability in the type of parameter io - | ^² and cap refer to a fresh root capability in the type of variable myIO + | where: ^ refers to a root capability in the type of parameter io + | ^² and cap refer to a root capability in the type of variable myIO | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23431.scala:11:13 --------------------------------------- @@ -20,8 +20,8 @@ | Note that capability io2 is not included in capture set {cap} | because (io2 : IO^) in an enclosing function is not visible from cap in variable myIO. | - | where: ^ refers to a fresh root capability in the type of parameter io2 - | ^² and cap refer to a fresh root capability in the type of variable myIO + | where: ^ refers to a root capability in the type of parameter io2 + | ^² and cap refer to a root capability in the type of variable myIO | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23431.scala:12:12 --------------------------------------- @@ -33,10 +33,10 @@ |Note that capability cap is not included in capture set {cap²} |because cap in an enclosing function is not visible from cap² in variable myIO². | - |where: => refers to a fresh root capability created in anonymous function of type (io1: IO^): Unit when checking argument to parameter op of method withIO + |where: => refers to a root capability created in anonymous function of type (io1: IO^): Unit when checking argument to parameter op of method withIO | ^ refers to the universal root capability - | cap is a fresh root capability created in anonymous function of type (io3: IO^'s1): Unit of parameter parameter io3² of method $anonfun - | cap² is a fresh root capability in the type of variable myIO² + | cap is a root capability created in anonymous function of type (io3: IO^'s1): Unit of parameter parameter io3² of method $anonfun + | cap² is a root capability in the type of variable myIO² | myIO is a value in an anonymous function in method test | myIO² is a variable in an anonymous function in method test | diff --git a/tests/neg-custom-args/captures/i23582.check b/tests/neg-custom-args/captures/i23582.check index 31327ba3ee8d..165b222ae9d2 100644 --- a/tests/neg-custom-args/captures/i23582.check +++ b/tests/neg-custom-args/captures/i23582.check @@ -6,7 +6,7 @@ | |Note that capability write is not included in capture set {cap.only[Read]}. | - |where: cap is a fresh root capability created in method test when checking argument to parameter op of method parReduce + |where: cap is a root capability created in method test when checking argument to parameter op of method parReduce | 28 | write(x) 29 | x + y + read() diff --git a/tests/neg-custom-args/captures/i23726.check b/tests/neg-custom-args/captures/i23726.check index ee59c309e370..af0c1626b13d 100644 --- a/tests/neg-custom-args/captures/i23726.check +++ b/tests/neg-custom-args/captures/i23726.check @@ -13,8 +13,8 @@ | Footprint set of function result : {a} | The two sets overlap at : {a} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | ^² refers to a fresh root capability classified as Unscoped created in method test1 when checking argument to parameter x of method apply + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | ^² refers to a root capability classified as Unscoped created in method test1 when checking argument to parameter x of method apply -- Error: tests/neg-custom-args/captures/i23726.scala:16:5 ------------------------------------------------------------- 16 | f3(b) // error | ^ @@ -30,8 +30,8 @@ | Footprint set of function result : {op, b} | The two sets overlap at : {b} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value b - | ^² refers to a fresh root capability classified as Unscoped created in method test1 when checking argument to parameter x of method apply + |where: ^ refers to a root capability classified as Unscoped in the type of value b + | ^² refers to a root capability classified as Unscoped created in method test1 when checking argument to parameter x of method apply -- Error: tests/neg-custom-args/captures/i23726.scala:24:5 ------------------------------------------------------------- 24 | f7(a) // error | ^ @@ -47,5 +47,5 @@ | Footprint set of function prefix : {f7*, a, b} | The two sets overlap at : {a} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | ^² refers to a fresh root capability classified as Unscoped created in method test1 when checking argument to parameter x of method apply + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | ^² refers to a root capability classified as Unscoped created in method test1 when checking argument to parameter x of method apply diff --git a/tests/neg-custom-args/captures/i23746.check b/tests/neg-custom-args/captures/i23746.check index 1db206879f02..d8467cfe1c63 100644 --- a/tests/neg-custom-args/captures/i23746.check +++ b/tests/neg-custom-args/captures/i23746.check @@ -6,7 +6,7 @@ | | Note that capability cap is not included in capture set {}. | - | where: => and cap refer to a fresh root capability in the type of type X + | where: => and cap refer to a root capability in the type of type X | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23746.scala:10:4 ---------------------------------------- diff --git a/tests/neg-custom-args/captures/i24310.check b/tests/neg-custom-args/captures/i24310.check index 4c825514e01e..e21c7bb7d2dd 100644 --- a/tests/neg-custom-args/captures/i24310.check +++ b/tests/neg-custom-args/captures/i24310.check @@ -4,4 +4,4 @@ | Read-only method run accesses exclusive capability (Matrix.this.f : () => Int); | method run should be declared an update method to allow this. | - | where: => refers to a fresh root capability in the type of value f + | where: => refers to a root capability in the type of value f diff --git a/tests/neg-custom-args/captures/i24335.check b/tests/neg-custom-args/captures/i24335.check index b70624a44460..27fc065f6e33 100644 --- a/tests/neg-custom-args/captures/i24335.check +++ b/tests/neg-custom-args/captures/i24335.check @@ -14,4 +14,4 @@ | Fields capturing a root capability need to be given an explicit type unless the capability is already | subsumed by the computed capability of the enclosing class. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of value r + | where: ^ refers to a root capability classified as Unscoped in the type of value r diff --git a/tests/neg-custom-args/captures/i24373.check b/tests/neg-custom-args/captures/i24373.check index 08e196fc1dc9..3c1b5f31471b 100644 --- a/tests/neg-custom-args/captures/i24373.check +++ b/tests/neg-custom-args/captures/i24373.check @@ -4,18 +4,18 @@ | Separation failure: Illegal access to (x1 : Foo^), which was used as a prefix to consume method sink1 | on line 27 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value x1 + | where: ^ refers to a root capability in the type of value x1 -- Error: tests/neg-custom-args/captures/i24373.scala:32:2 ------------------------------------------------------------- 32 | x2.sink2 // error | ^^ | Separation failure: Illegal access to (x2 : Bar^), which was used as a prefix to consume method sink2 | on line 31 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value x2 + | where: ^ refers to a root capability in the type of value x2 -- Error: tests/neg-custom-args/captures/i24373.scala:49:8 ------------------------------------------------------------- 49 | sink6(x6) // error | ^^ | Separation failure: Illegal access to (x6 : Bar^), which was passed as a consume parameter to method sink6 | on line 48 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value x6 + | where: ^ refers to a root capability in the type of value x6 diff --git a/tests/neg-custom-args/captures/i24373a.check b/tests/neg-custom-args/captures/i24373a.check index 61198e8cc676..b926de919a1c 100644 --- a/tests/neg-custom-args/captures/i24373a.check +++ b/tests/neg-custom-args/captures/i24373a.check @@ -4,7 +4,7 @@ | Separation failure: Illegal access to (x1 : Bar^), which was passed as a consume parameter to method sink1 | on line 13 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value x1 + | where: ^ refers to a root capability in the type of value x1 -- Error: tests/neg-custom-args/captures/i24373a.scala:19:8 ------------------------------------------------------------ 19 | sink1(x2) // error | ^^ @@ -16,14 +16,14 @@ | Separation failure: Illegal access to (x2 : Bar^), which was passed as a consume parameter to method sink2 | on line 18 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value x2 + | where: ^ refers to a root capability in the type of value x2 -- Error: tests/neg-custom-args/captures/i24373a.scala:25:8 ------------------------------------------------------------ 25 | sink2(x3) // error | ^^ | Separation failure: Illegal access to (x3 : Bar^), which was passed as a consume parameter to method sink3 | on line 23 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value x3 + | where: ^ refers to a root capability in the type of value x3 -- Error: tests/neg-custom-args/captures/i24373a.scala:29:8 ------------------------------------------------------------ 29 | sink3(x4) // error | ^^ @@ -35,4 +35,4 @@ | Separation failure: Illegal access to (x4 : Bar^), which was passed as a consume parameter to method sink2 | on line 28 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of value x4 + | where: ^ refers to a root capability in the type of value x4 diff --git a/tests/neg-custom-args/captures/implied-ro.check b/tests/neg-custom-args/captures/implied-ro.check index c11bf580c0ea..afd2b18fe967 100644 --- a/tests/neg-custom-args/captures/implied-ro.check +++ b/tests/neg-custom-args/captures/implied-ro.check @@ -1,11 +1,11 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/implied-ro.scala:12:16 ----------------------------------- 12 | val _: C^{} = c // error | ^ - | Found: (c : C^{cap.rd}) - | Required: C + | Found: (c : C^{cap.rd}) + | Required: C | - | Note that capability cap.rd is not included in capture set {}. + | Note that capability cap.rd is not included in capture set {}. | - | where: cap is a fresh root capability classified as Unscoped created in value c when constructing instance C + | where: cap is a root capability classified as Unscoped created in value c when constructing instance C | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/indirect-avoid.check b/tests/neg-custom-args/captures/indirect-avoid.check index b548646f5c06..207889feddd5 100644 --- a/tests/neg-custom-args/captures/indirect-avoid.check +++ b/tests/neg-custom-args/captures/indirect-avoid.check @@ -15,7 +15,7 @@ | |Note that capability cap.rd is not included in capture set {}. | - |where: cap is a fresh root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{cap².rd, ll} + |where: cap is a root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{cap².rd, ll} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/indirect-avoid.scala:32:4 -------------------------------- @@ -34,4 +34,4 @@ |Fields capturing a root capability need to be given an explicit type unless the capability is already |subsumed by the computed capability of the enclosing class. | - |where: cap is a fresh root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{cap².rd, ll} + |where: cap is a root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{cap².rd, ll} diff --git a/tests/neg-custom-args/captures/lazyListState.check b/tests/neg-custom-args/captures/lazyListState.check index bb84f3d7f006..65c78d47c040 100644 --- a/tests/neg-custom-args/captures/lazyListState.check +++ b/tests/neg-custom-args/captures/lazyListState.check @@ -4,7 +4,7 @@ | error overriding method tail in trait State of type -> LazyListIterable[A]^{cap}; | value tail of type LazyListIterable[A]^ has incompatible type | - | where: ^ refers to a fresh root capability in the type of value tail + | where: ^ refers to a root capability in the type of value tail | cap is a root capability associated with the result type of -> LazyListIterable[A²]^² | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazyref.check b/tests/neg-custom-args/captures/lazyref.check index 56d0c8a2d329..8d2002fd858d 100644 --- a/tests/neg-custom-args/captures/lazyref.check +++ b/tests/neg-custom-args/captures/lazyref.check @@ -46,7 +46,7 @@ | of method get with result type () => T. | This type hides capabilities {LazyRef.this.elem} | - | where: => refers to a fresh root capability in the result type of method get + | where: => refers to a root capability in the result type of method get -- Error: tests/neg-custom-args/captures/lazyref.scala:29:9 ------------------------------------------------------------ 29 | .map(g) // error: separation failure | ^ @@ -62,4 +62,4 @@ | Footprint set of function prefix : {ref1, cap1, ref2, cap2, ref2*} | The two sets overlap at : {cap2} | - |where: => refers to a fresh root capability created in value ref4 when checking argument to parameter f of method map + |where: => refers to a root capability created in value ref4 when checking argument to parameter f of method map diff --git a/tests/neg-custom-args/captures/lazyvals-sep.check b/tests/neg-custom-args/captures/lazyvals-sep.check index 7140b2015f7e..5840fcc00bb5 100644 --- a/tests/neg-custom-args/captures/lazyvals-sep.check +++ b/tests/neg-custom-args/captures/lazyvals-sep.check @@ -32,7 +32,7 @@ |Note that {cap} is an exclusive capture set of the stateful type Ref^, |it cannot subsume a read-only capture set of the stateful type Ref^{TestClass.this.r.rd}. | - |where: ^ and cap refer to a fresh root capability classified as Unscoped created in lazy value lazyVal8 when checking argument to parameter ref of constructor Wrapper + |where: ^ and cap refer to a root capability classified as Unscoped created in lazy value lazyVal8 when checking argument to parameter ref of constructor Wrapper | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals-sep.scala:77:12 --------------------------------- @@ -44,7 +44,7 @@ |Note that {cap} is an exclusive capture set of the stateful type Ref^, |it cannot subsume a read-only capture set of the stateful type Ref^{TestClass.this.r.rd}. | - |where: ^ and cap refer to a fresh root capability classified as Unscoped created in lazy value lazyVal9 when checking argument to parameter ref of constructor Wrapper + |where: ^ and cap refer to a root capability classified as Unscoped created in lazy value lazyVal9 when checking argument to parameter ref of constructor Wrapper | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/lazyvals-sep.scala:82:8 ------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/leaking-iterators.check b/tests/neg-custom-args/captures/leaking-iterators.check index cfc7cdf32e6e..9a516cb1a1d9 100644 --- a/tests/neg-custom-args/captures/leaking-iterators.check +++ b/tests/neg-custom-args/captures/leaking-iterators.check @@ -7,7 +7,7 @@ |Found: (log: java.io.FileOutputStream^'s2) ->'s3 cctest.Iterator[Int]^{log} |Required: java.io.FileOutputStream^ => cctest.Iterator[Int]^'s1 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | 57 | xs.iterator.map: x => diff --git a/tests/neg-custom-args/captures/linear-buffer-2.check b/tests/neg-custom-args/captures/linear-buffer-2.check index 6a3853770f4e..dc002ba7f591 100644 --- a/tests/neg-custom-args/captures/linear-buffer-2.check +++ b/tests/neg-custom-args/captures/linear-buffer-2.check @@ -4,32 +4,32 @@ | Separation failure: Illegal access to (buf : Buffer[Int]^), which was used as a prefix to consume method append | on line 11 and therefore is no longer available. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of parameter buf + | where: ^ refers to a root capability classified as Unscoped in the type of parameter buf -- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:20:13 --------------------------------------------------- 20 | val buf3 = buf1.append(4) // error | ^^^^ |Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was used as a prefix to consume method append |on line 18 and therefore is no longer available. | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value buf1 + |where: ^ refers to a root capability classified as Unscoped in the type of value buf1 -- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:28:13 --------------------------------------------------- 28 | val buf3 = buf1.append(4) // error | ^^^^ |Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was used as a prefix to consume method append |on line 25 and therefore is no longer available. | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value buf1 + |where: ^ refers to a root capability classified as Unscoped in the type of value buf1 -- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:38:13 --------------------------------------------------- 38 | val buf3 = buf1.append(4) // error | ^^^^ |Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was used as a prefix to consume method append |on line 33 and therefore is no longer available. | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value buf1 + |where: ^ refers to a root capability classified as Unscoped in the type of value buf1 -- Error: tests/neg-custom-args/captures/linear-buffer-2.scala:42:4 ---------------------------------------------------- 42 | buf.append(1) // error | ^^^ | Separation failure: (buf : Buffer[Int]^) appears in a loop, therefore it cannot | be used as a prefix to consume method append. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of parameter buf + | where: ^ refers to a root capability classified as Unscoped in the type of parameter buf diff --git a/tests/neg-custom-args/captures/linear-buffer.check b/tests/neg-custom-args/captures/linear-buffer.check index 225792af4189..302fd2b0db82 100644 --- a/tests/neg-custom-args/captures/linear-buffer.check +++ b/tests/neg-custom-args/captures/linear-buffer.check @@ -1,13 +1,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/linear-buffer.scala:7:29 --------------------------------- 7 | def bar: BadBuffer[T]^ = this // error // error separation | ^^^^ - | Found: BadBuffer[T]^{BadBuffer.this.rd} - | Required: BadBuffer[T]^ + | Found: BadBuffer[T]^{BadBuffer.this.rd} + | Required: BadBuffer[T]^ | - | Note that {cap} is an exclusive capture set of the stateful type BadBuffer[T]^, - | it cannot subsume a read-only capture set of the stateful type BadBuffer[T]^{BadBuffer.this.rd}. + | Note that {cap} is an exclusive capture set of the stateful type BadBuffer[T]^, + | it cannot subsume a read-only capture set of the stateful type BadBuffer[T]^{BadBuffer.this.rd}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the result type of method bar + | where: ^ and cap refer to a root capability classified as Unscoped in the result type of method bar | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/linear-buffer.scala:5:27 ------------------------------------------------------ @@ -23,11 +23,11 @@ -- Error: tests/neg-custom-args/captures/linear-buffer.scala:10:29 ----------------------------------------------------- 10 | def bar: BadBuffer[T]^ = this // error // error | ^^^^ - | Separation failure: Illegal access to {BadBuffer.this} which is hidden by the previous definition - | of method append with result type BadBuffer[T]^. - | This type hides capabilities {BadBuffer.this} + | Separation failure: Illegal access to {BadBuffer.this} which is hidden by the previous definition + | of method append with result type BadBuffer[T]^. + | This type hides capabilities {BadBuffer.this} | - | where: ^ refers to a fresh root capability classified as Unscoped in the result type of method append + | where: ^ refers to a root capability classified as Unscoped in the result type of method append -- Error: tests/neg-custom-args/captures/linear-buffer.scala:10:13 ----------------------------------------------------- 10 | def bar: BadBuffer[T]^ = this // error // error | ^^^^^^^^^^^^^ @@ -39,35 +39,35 @@ |Separation failure: Illegal access to (buf : Buffer[Int]^), which was passed as a consume parameter to method app |on line 21 and therefore is no longer available. | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of parameter buf + |where: ^ refers to a root capability classified as Unscoped in the type of parameter buf -- Error: tests/neg-custom-args/captures/linear-buffer.scala:30:17 ----------------------------------------------------- 30 | val buf3 = app(buf1, 4) // error | ^^^^ |Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was passed as a consume parameter to method app |on line 28 and therefore is no longer available. | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value buf1 + |where: ^ refers to a root capability classified as Unscoped in the type of value buf1 -- Error: tests/neg-custom-args/captures/linear-buffer.scala:38:17 ----------------------------------------------------- 38 | val buf3 = app(buf1, 4) // error | ^^^^ |Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was passed as a consume parameter to method app |on line 35 and therefore is no longer available. | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value buf1 + |where: ^ refers to a root capability classified as Unscoped in the type of value buf1 -- Error: tests/neg-custom-args/captures/linear-buffer.scala:48:17 ----------------------------------------------------- 48 | val buf3 = app(buf1, 4) // error | ^^^^ |Separation failure: Illegal access to (buf1 : Buffer[Int]^), which was passed as a consume parameter to method app |on line 43 and therefore is no longer available. | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value buf1 + |where: ^ refers to a root capability classified as Unscoped in the type of value buf1 -- Error: tests/neg-custom-args/captures/linear-buffer.scala:52:8 ------------------------------------------------------ 52 | app(buf, 1) // error | ^^^ | Separation failure: (buf : Buffer[Int]^) appears in a loop, therefore it cannot | be passed as a consume parameter to method app. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of parameter buf + | where: ^ refers to a root capability classified as Unscoped in the type of parameter buf -- Error: tests/neg-custom-args/captures/linear-buffer.scala:62:20 ----------------------------------------------------- 62 | val c3 = contents(buf) // error | ^^^ diff --git a/tests/neg-custom-args/captures/local-mutables-2.check b/tests/neg-custom-args/captures/local-mutables-2.check index ae3b185568f4..bfeccab7928c 100644 --- a/tests/neg-custom-args/captures/local-mutables-2.check +++ b/tests/neg-custom-args/captures/local-mutables-2.check @@ -6,16 +6,16 @@ |Another part, Int => Unit, captures capabilities {cap³, cap, cap²}. |The two sets overlap at {cap of value r}. | - |where: => and cap³ refer to a fresh root capability classified as Unscoped in the result type of method foo - | cap is a fresh root capability classified as Unscoped in the type of value r - | cap² is a fresh root capability classified as Unscoped created in value r when constructing instance Ref + |where: => and cap³ refer to a root capability classified as Unscoped in the result type of method foo + | cap is a root capability classified as Unscoped in the type of value r + | cap² is a root capability classified as Unscoped created in value r when constructing instance Ref -- Error: tests/neg-custom-args/captures/local-mutables-2.scala:11:10 -------------------------------------------------- 11 |def foo2() = // error: separation failure | ^ - | Separation failure in method foo2's inferred result type (() ->{cap.rd} Int, Int => Unit)^{}. - | One part, Int => Unit, hides capabilities {cap}. - | Another part, () ->{cap.rd} Int, captures capabilities {cap.rd}. - | The two sets overlap at {cap of variable r}. + | Separation failure in method foo2's inferred result type (() ->{cap.rd} Int, Int => Unit)^{}. + | One part, Int => Unit, hides capabilities {cap}. + | Another part, () ->{cap.rd} Int, captures capabilities {cap.rd}. + | The two sets overlap at {cap of variable r}. | - | where: => refers to a fresh root capability classified as Unscoped in the result type of method foo2 - | cap is a fresh root capability classified as Unscoped in the type of variable r + | where: => refers to a root capability classified as Unscoped in the result type of method foo2 + | cap is a root capability classified as Unscoped in the type of variable r diff --git a/tests/neg-custom-args/captures/local-mutables.check b/tests/neg-custom-args/captures/local-mutables.check index b34cdc457beb..7c748fe03d02 100644 --- a/tests/neg-custom-args/captures/local-mutables.check +++ b/tests/neg-custom-args/captures/local-mutables.check @@ -19,10 +19,10 @@ -- Error: tests/neg-custom-args/captures/local-mutables.scala:22:22 ---------------------------------------------------- 22 | def set(x: Int) = r.set(x) // error | ^ - | Read-only method set accesses exclusive capability (r : Ref^); - | method set should be declared an update method to allow this. + | Read-only method set accesses exclusive capability (r : Ref^); + | method set should be declared an update method to allow this. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of value r + | where: ^ refers to a root capability classified as Unscoped in the type of value r -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/local-mutables.scala:35:21 ------------------------------- 35 | val _: () -> Int = getter // error | ^^^^^^ @@ -44,7 +44,7 @@ -- Error: tests/neg-custom-args/captures/local-mutables.scala:47:22 ---------------------------------------------------- 47 | def set(x: Int) = r = x // error | ^ - | Read-only method set accesses exclusive capability (r : scala.caps.internal.Var[Int]^); - | method set should be declared an update method to allow this. + | Read-only method set accesses exclusive capability (r : scala.caps.internal.Var[Int]^); + | method set should be declared an update method to allow this. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of variable r² + | where: ^ refers to a root capability classified as Unscoped in the type of variable r² diff --git a/tests/neg-custom-args/captures/matrix.check b/tests/neg-custom-args/captures/matrix.check index 6345f34802f8..52a532ab8ea2 100644 --- a/tests/neg-custom-args/captures/matrix.check +++ b/tests/neg-custom-args/captures/matrix.check @@ -13,7 +13,7 @@ | Footprint set of third argument : {m2} | The two sets overlap at : {m2} | - |where: cap is a fresh root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul + |where: cap is a root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul -- Error: tests/neg-custom-args/captures/matrix.scala:30:11 ------------------------------------------------------------ 30 | mul1(m1, m2, m2) // error: will fail separation checking | ^^ @@ -29,4 +29,4 @@ | Footprint set of third argument : {m2} | The two sets overlap at : {m2} | - |where: cap is a fresh root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul1 + |where: cap is a root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul1 diff --git a/tests/neg-custom-args/captures/mut-iterator.check b/tests/neg-custom-args/captures/mut-iterator.check index 22c1c425cd7b..6fdccb96f3c0 100644 --- a/tests/neg-custom-args/captures/mut-iterator.check +++ b/tests/neg-custom-args/captures/mut-iterator.check @@ -4,7 +4,7 @@ | Read-only method next accesses exclusive capability (f : T => U); | method next should be declared an update method to allow this. | - | where: => refers to a fresh root capability in the type of parameter f + | where: => refers to a root capability in the type of parameter f -- Error: tests/neg-custom-args/captures/mut-iterator.scala:17:14 ------------------------------------------------------ 17 | current = xs1 // error | ^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ | Read-only method next accesses exclusive capability (f : T => U); | method next should be declared an update method to allow this. | - | where: => refers to a fresh root capability in the type of parameter f + | where: => refers to a root capability in the type of parameter f -- Error: tests/neg-custom-args/captures/mut-iterator.scala:7:25 ------------------------------------------------------- 7 | def map[U](f: T => U): Iterator[U] = new Iterator: // error | ^^^^^^^^^^^ diff --git a/tests/neg-custom-args/captures/mut-iterator4.check b/tests/neg-custom-args/captures/mut-iterator4.check index 298faaec996c..bbbca6a04677 100644 --- a/tests/neg-custom-args/captures/mut-iterator4.check +++ b/tests/neg-custom-args/captures/mut-iterator4.check @@ -13,7 +13,7 @@ | |Note that capability cap is not included in capture set {it, f}. | - |where: cap is a fresh root capability created in method mappedIterator when constructing instance Object with (Iterator[U]^{cap².rd}) {...} + |where: cap is a root capability created in method mappedIterator when constructing instance Object with (Iterator[U]^{cap².rd}) {...} | 22 | def hasNext = it.hasNext 23 | update def next() = f(it.next()) diff --git a/tests/neg-custom-args/captures/mut-widen-empty.check b/tests/neg-custom-args/captures/mut-widen-empty.check index 2a23fdeab58a..e85b6fd2cff6 100644 --- a/tests/neg-custom-args/captures/mut-widen-empty.check +++ b/tests/neg-custom-args/captures/mut-widen-empty.check @@ -1,24 +1,24 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mut-widen-empty.scala:12:24 ------------------------------ 12 | val c: Arr[String]^ = b // error | ^ - | Found: (b : Arr[String]^{}) - | Required: Arr[String]^ + | Found: (b : Arr[String]^{}) + | Required: Arr[String]^ | - | Note that {cap} is an exclusive capture set of the stateful type Arr[String]^, - | it cannot subsume a read-only capture set of the stateful type Arr[String]^{}. + | Note that {cap} is an exclusive capture set of the stateful type Arr[String]^, + | it cannot subsume a read-only capture set of the stateful type Arr[String]^{}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the type of value c + | where: ^ and cap refer to a root capability classified as Unscoped in the type of value c | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mut-widen-empty.scala:18:26 ------------------------------ 18 | val c: Array[String]^ = b // error | ^ - | Found: (b : Array[String]^{}) - | Required: Array[String]^ + | Found: (b : Array[String]^{}) + | Required: Array[String]^ | - | Note that {cap} is an exclusive capture set of the stateful type Array[String]^, - | it cannot subsume a read-only capture set of the stateful type Array[String]^{}. + | Note that {cap} is an exclusive capture set of the stateful type Array[String]^, + | it cannot subsume a read-only capture set of the stateful type Array[String]^{}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the type of value c + | where: ^ and cap refer to a root capability classified as Unscoped in the type of value c | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/mutability.check b/tests/neg-custom-args/captures/mutability.check index 0ab347f2ec48..06742900f208 100644 --- a/tests/neg-custom-args/captures/mutability.check +++ b/tests/neg-custom-args/captures/mutability.check @@ -11,13 +11,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:10:25 ----------------------------------- 10 | val self2: Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the type of value self2 + | where: ^ and cap refer to a root capability classified as Unscoped in the type of value self2 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:11:13 -------------------------------------------------------- @@ -26,7 +26,7 @@ | Read-only method sneakyHide accesses exclusive capability (Ref.this : Ref[T]^); | method sneakyHide should be declared an update method to allow this. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of class Ref + | where: ^ refers to a root capability classified as Unscoped in the type of class Ref -- Error: tests/neg-custom-args/captures/mutability.scala:14:12 -------------------------------------------------------- 14 | self3().set(x) // error | ^^^^^^^^^^^ @@ -35,14 +35,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:15:31 ----------------------------------- 15 | val self4: () => Ref[T]^ = () => this // error | ^^^^^^^^^^ - | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} - | Required: () => Ref[T]^ + | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} + | Required: () => Ref[T]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. + | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, + | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. | - | where: => refers to a fresh root capability in the type of value self4 - | ^ and cap refer to a fresh root capability classified as Unscoped in the type of value self4 + | where: => refers to a root capability in the type of value self4 + | ^ and cap refer to a root capability classified as Unscoped in the type of value self4 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:16:15 -------------------------------------------------------- @@ -51,7 +51,7 @@ | Read-only method sneakyHide accesses exclusive capability (Ref.this : Ref[T]^); | method sneakyHide should be declared an update method to allow this. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of class Ref + | where: ^ refers to a root capability classified as Unscoped in the type of class Ref -- Error: tests/neg-custom-args/captures/mutability.scala:19:12 -------------------------------------------------------- 19 | self5().set(x) // error | ^^^^^^^^^^^ @@ -60,13 +60,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:20:27 ----------------------------------- 20 | def self6(): Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the result type of method self6 + | where: ^ and cap refer to a root capability classified as Unscoped in the result type of method self6 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:21:15 -------------------------------------------------------- @@ -75,7 +75,7 @@ | Read-only method sneakyHide accesses exclusive capability (Ref.this : Ref[T]^); | method sneakyHide should be declared an update method to allow this. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of class Ref + | where: ^ refers to a root capability classified as Unscoped in the type of class Ref -- Error: tests/neg-custom-args/captures/mutability.scala:25:25 -------------------------------------------------------- 25 | def set(x: T) = this.x.set(x) // error | ^^^^^^^^^^ @@ -94,14 +94,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:43:29 ----------------------------------- 43 | val r5: () => Ref2[Int]^ = () => ref2 // error | ^^^^^^^^^^ - | Found: () ->{ref2.rd} Ref2[Int]^{ref2} - | Required: () => Ref2[Int]^ + | Found: () ->{ref2.rd} Ref2[Int]^{ref2} + | Required: () => Ref2[Int]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref2[Int]^, - | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. + | Note that {cap} is an exclusive capture set of the stateful type Ref2[Int]^, + | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. | - | where: => refers to a fresh root capability in the type of value r5 - | ^ and cap refer to a fresh root capability classified as Unscoped in the type of value r5 + | where: => refers to a root capability in the type of value r5 + | ^ and cap refer to a root capability classified as Unscoped in the type of value r5 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:46:9 --------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/mutvars.check b/tests/neg-custom-args/captures/mutvars.check index 169059d9bc61..fb9136658f29 100644 --- a/tests/neg-custom-args/captures/mutvars.check +++ b/tests/neg-custom-args/captures/mutvars.check @@ -11,13 +11,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:9:25 --------------------------------------- 9 | val self2: Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the type of value self2 + | where: ^ and cap refer to a root capability classified as Unscoped in the type of value self2 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:13:16 ----------------------------------------------------------- @@ -28,14 +28,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:14:31 -------------------------------------- 14 | val self4: () => Ref[T]^ = () => this // error | ^^^^^^^^^^ - | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} - | Required: () => Ref[T]^ + | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} + | Required: () => Ref[T]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. + | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, + | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. | - | where: => refers to a fresh root capability in the type of value self4 - | ^ and cap refer to a fresh root capability classified as Unscoped in the type of value self4 + | where: => refers to a root capability in the type of value self4 + | ^ and cap refer to a root capability classified as Unscoped in the type of value self4 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:18:16 ----------------------------------------------------------- @@ -46,13 +46,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:19:27 -------------------------------------- 19 | def self6(): Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the result type of method self6 + | where: ^ and cap refer to a root capability classified as Unscoped in the result type of method self6 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:24:29 ----------------------------------------------------------- @@ -73,14 +73,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:41:29 -------------------------------------- 41 | val r5: () => Ref2[Int]^ = () => ref2 // error | ^^^^^^^^^^ - | Found: () ->{ref2.rd} Ref2[Int]^{ref2} - | Required: () => Ref2[Int]^ + | Found: () ->{ref2.rd} Ref2[Int]^{ref2} + | Required: () => Ref2[Int]^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref2[Int]^, - | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. + | Note that {cap} is an exclusive capture set of the stateful type Ref2[Int]^, + | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. | - | where: => refers to a fresh root capability in the type of value r5 - | ^ and cap refer to a fresh root capability classified as Unscoped in the type of value r5 + | where: => refers to a root capability in the type of value r5 + | ^ and cap refer to a root capability classified as Unscoped in the type of value r5 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:44:13 ----------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/outer-var.check b/tests/neg-custom-args/captures/outer-var.check index 4cb75e7415fe..70a6c96d2f89 100644 --- a/tests/neg-custom-args/captures/outer-var.check +++ b/tests/neg-custom-args/captures/outer-var.check @@ -6,7 +6,7 @@ | | Note that capability q is not included in capture set {p, q²}. | - | where: => refers to a fresh root capability in the type of parameter q + | where: => refers to a root capability in the type of parameter q | q is a parameter in method inner | q² is a parameter in method test | @@ -19,7 +19,7 @@ | | Note that capability cap is not included in capture set {p, q}. | - | where: => and cap refer to a fresh root capability created in method inner + | where: => and cap refer to a root capability created in method inner | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:14:9 ------------------------------------- @@ -30,7 +30,7 @@ | | Note that capability cap cannot be included in capture set {p} of variable y. | - | where: => and cap refer to a fresh root capability created in method inner + | where: => and cap refer to a root capability created in method inner | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:15:8 ------------------------------------- @@ -41,6 +41,6 @@ | | Note that capability q cannot be included in capture set {p} of variable y. | - | where: => refers to a fresh root capability in the type of parameter q + | where: => refers to a root capability in the type of parameter q | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/reaches.check b/tests/neg-custom-args/captures/reaches.check index 67f47d05529b..89ec6941cea0 100644 --- a/tests/neg-custom-args/captures/reaches.check +++ b/tests/neg-custom-args/captures/reaches.check @@ -6,9 +6,9 @@ | |Note that capability cap is not included in capture set {C}. | - |where: => refers to a fresh root capability created in method runAll0 when checking argument to parameter f of method usingFile + |where: => refers to a root capability created in method runAll0 when checking argument to parameter f of method usingFile | ^ refers to the universal root capability - | cap is a fresh root capability created in anonymous function of type (f: File^'s1): Unit of parameter parameter f² of method $anonfun + | cap is a root capability created in anonymous function of type (f: File^'s1): Unit of parameter parameter f² of method $anonfun | 21 | cur = (() => f.write()) :: Nil | @@ -21,9 +21,9 @@ | |Note that capability cap cannot be included in capture set {C} of value cur. | - |where: => refers to a fresh root capability created in method runAll1 when checking argument to parameter f of method usingFile + |where: => refers to a root capability created in method runAll1 when checking argument to parameter f of method usingFile | ^ refers to the universal root capability - | cap is a fresh root capability created in anonymous function of type (f: File^'s2): Unit of parameter parameter f² of method $anonfun + | cap is a root capability created in anonymous function of type (f: File^'s2): Unit of parameter parameter f² of method $anonfun | 31 | cur.set: 32 | (() => f.write()) :: Nil @@ -38,9 +38,9 @@ | Note that capability cap is not included in capture set {cap²} | because cap is not visible from cap² in value id. | - | where: => and cap² refer to a fresh root capability created in value id + | where: => and cap² refer to a root capability created in value id | =>² and cap refer to the universal root capability - | =>³ refers to a fresh root capability in the type of value id + | =>³ refers to a root capability in the type of value id | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:57:27 -------------------------------------- @@ -54,7 +54,7 @@ | | where: ^ refers to the universal root capability | ^² and cap refer to a root capability associated with the result type of (x: File^): File^² - | ^³ and cap² refer to a fresh root capability in the type of value id + | ^³ and cap² refer to a root capability in the type of value id | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:68:27 -------------------------------------- @@ -65,7 +65,7 @@ | |Note that capability cap is not included in capture set {id*}. | - |where: ^ and cap refer to a fresh root capability created in value f1 when instantiating method apply's type (x: File^²): File^³ + |where: ^ and cap refer to a root capability created in value f1 when instantiating method apply's type (x: File^²): File^³ | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:85:10 -------------------------------------- @@ -76,7 +76,7 @@ | |Note that capability ps* cannot be included in capture set {} of value x. | - |where: => refers to a fresh root capability created in method mapCompose when checking argument to parameter f of method map + |where: => refers to a root capability created in method mapCompose when checking argument to parameter f of method map | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -88,7 +88,7 @@ | |Note that capability C cannot be included in capture set {} of value x. | - |where: => refers to a fresh root capability created in method mapCompose2 when checking argument to parameter f of method map + |where: => refers to a root capability created in method mapCompose2 when checking argument to parameter f of method map | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -105,9 +105,9 @@ -- Error: tests/neg-custom-args/captures/reaches.scala:60:36 ----------------------------------------------------------- 60 | val leaked = usingFile[File^{id*}]: f => // error: separation | ^ - | Local cap created in type of parameter x leaks into capture scope of an enclosing function + | Local cap created in type of parameter x leaks into capture scope of an enclosing function | - | where: cap is a fresh root capability created in value id of parameter parameter x of method $anonfun + | where: cap is a root capability created in value id of parameter parameter x of method $anonfun | 61 | val f1: File^{id*} = id(f) 62 | f1 diff --git a/tests/neg-custom-args/captures/real-try.check b/tests/neg-custom-args/captures/real-try.check index 1e71fc964cd6..bcc5b3db7e01 100644 --- a/tests/neg-custom-args/captures/real-try.check +++ b/tests/neg-custom-args/captures/real-try.check @@ -11,7 +11,7 @@ | that type captures the root capability `cap`. | This is often caused by a locally generated exception capability leaking as part of its result. | - | where: => refers to a fresh root capability classified as Control in the type of given instance canThrow$1 + | where: => refers to a root capability classified as Control in the type of given instance canThrow$1 | 15 | () => foo(1) 16 |... diff --git a/tests/neg-custom-args/captures/ref-with-file.check b/tests/neg-custom-args/captures/ref-with-file.check index 3a23292c1d7e..7df3ab5e8e5f 100644 --- a/tests/neg-custom-args/captures/ref-with-file.check +++ b/tests/neg-custom-args/captures/ref-with-file.check @@ -6,10 +6,10 @@ | |Note that capability cap cannot be included in capture set {} of value r. | - |where: => refers to a fresh root capability created in method Test when checking argument to parameter op of method withFile - | ^ refers to a fresh root capability classified as Unscoped in the type of value r + |where: => refers to a root capability created in method Test when checking argument to parameter op of method withFile + | ^ refers to a root capability classified as Unscoped in the type of value r | ^² refers to the universal root capability - | cap is a fresh root capability created in anonymous function of type (f: File^'s1): Ref[File^'s3]^ of parameter parameter f² of method $anonfun + | cap is a root capability created in anonymous function of type (f: File^'s1): Ref[File^'s3]^ of parameter parameter f² of method $anonfun | 19 | val r = Ref(f) 20 | r @@ -23,9 +23,9 @@ | |Note that capability cap cannot be included in capture set {} of value r. | - |where: => refers to a fresh root capability created in method Test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method Test when checking argument to parameter op of method withFile | ^ refers to the universal root capability - | cap is a fresh root capability created in anonymous function of type (f: File^'s6): (??? : -> Nothing) of parameter parameter f² of method $anonfun + | cap is a root capability created in anonymous function of type (f: File^'s6): (??? : -> Nothing) of parameter parameter f² of method $anonfun | 22 | val r = Ref(f) 23 | ??? @@ -40,7 +40,7 @@ |Found: (f: File^'s9, r: Ref[String]^) ->'s10 Ref[String]^ |Required: (f: File^, r: Ref[String]^) => Ref[String]^'s8 | - |where: => refers to a fresh root capability created in method Test when checking argument to parameter op of method withFileAndRef + |where: => refers to a root capability created in method Test when checking argument to parameter op of method withFileAndRef | ^ and cap refer to the universal root capability | 26 | r.put(f.read()) diff --git a/tests/neg-custom-args/captures/reference-cc.check b/tests/neg-custom-args/captures/reference-cc.check index bc6e7b6853b6..37442a4641ce 100644 --- a/tests/neg-custom-args/captures/reference-cc.check +++ b/tests/neg-custom-args/captures/reference-cc.check @@ -7,7 +7,7 @@ |Found: (file: java.io.FileOutputStream^'s2) ->'s3 () ->{file} Unit |Required: java.io.FileOutputStream^ => () ->'s1 Unit | - |where: => refers to a fresh root capability created in value later when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in value later when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -20,7 +20,7 @@ |Found: (f: java.io.FileOutputStream^'s5) ->'s6 LzyList[Int]^{f} |Required: java.io.FileOutputStream^ => LzyList[Int]^'s4 | - |where: => refers to a fresh root capability created in value xs when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in value xs when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | 48 | LzyList(1, 2, 3).map { x => f.write(x); x * x } @@ -35,6 +35,6 @@ |Note that capability canThrow$1 is not included in capture set {cap} |because (canThrow$1 : CanThrow[LimitExceeded]) in an enclosing try expression is not visible from cap in an enclosing function. | - |where: => and cap refer to a fresh root capability created in anonymous function of type (using erased x$1: CanThrow[LimitExceeded]): () => Double when instantiating expected result type () ->{cap²} Double of function literal + |where: => and cap refer to a root capability created in anonymous function of type (using erased x$1: CanThrow[LimitExceeded]): () => Double when instantiating expected result type () ->{cap²} Double of function literal | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/ro-mut-conformance.check b/tests/neg-custom-args/captures/ro-mut-conformance.check index c4ab6f6b5e3e..3011ca7738d8 100644 --- a/tests/neg-custom-args/captures/ro-mut-conformance.check +++ b/tests/neg-custom-args/captures/ro-mut-conformance.check @@ -6,16 +6,16 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:12:21 --------------------------- 12 | val t: Ref^{cap} = a // error // error separation | ^ - | Found: (a : Ref) - | Required: Ref^ + | Found: (a : Ref) + | Required: Ref^ | - | Note that {cap} is an exclusive capture set of the stateful type Ref^, - | it cannot subsume a read-only capture set of the stateful type (a : Ref). + | Note that {cap} is an exclusive capture set of the stateful type Ref^, + | it cannot subsume a read-only capture set of the stateful type (a : Ref). | - | Note that capability cap².rd is not included in capture set {cap}. + | Note that capability cap².rd is not included in capture set {cap}. | - | where: ^ and cap refer to a fresh root capability classified as Unscoped in the type of value t - | cap² is a fresh root capability classified as Unscoped in the type of parameter a + | where: ^ and cap refer to a root capability classified as Unscoped in the type of value t + | cap² is a root capability classified as Unscoped in the type of parameter a | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:12:9 ------------------------------------------------- diff --git a/tests/neg-custom-args/captures/scope-extrude-mut.check b/tests/neg-custom-args/captures/scope-extrude-mut.check index c67d73069205..d529a81f2d8e 100644 --- a/tests/neg-custom-args/captures/scope-extrude-mut.check +++ b/tests/neg-custom-args/captures/scope-extrude-mut.check @@ -7,7 +7,7 @@ | Note that capability a1 is not included in capture set {cap} | because (a1 : A^) in method b is not visible from cap in variable a. | - | where: ^ refers to a fresh root capability in the type of value a1 - | ^² and cap refer to a fresh root capability in the type of variable a + | where: ^ refers to a root capability in the type of value a1 + | ^² and cap refer to a root capability in the type of variable a | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/scope-extrusions.check b/tests/neg-custom-args/captures/scope-extrusions.check index c6346503cb82..11a7a4302163 100644 --- a/tests/neg-custom-args/captures/scope-extrusions.check +++ b/tests/neg-custom-args/captures/scope-extrusions.check @@ -1,13 +1,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:10:8 ------------------------------ 10 | v = x // error | ^ - | Found: (x : IO) - | Required: IO^ + | Found: (x : IO) + | Required: IO^ | - | Note that capability x is not included in capture set {cap} - | because (x : IO) in method f1 is not visible from cap in variable v. + | Note that capability x is not included in capture set {cap} + | because (x : IO) in method f1 is not visible from cap in variable v. | - | where: ^ and cap refer to a fresh root capability classified as SharedCapability in the type of variable v + | where: ^ and cap refer to a root capability classified as SharedCapability in the type of variable v | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:11:8 ------------------------------ @@ -19,7 +19,7 @@ | Note that capability x is not included in capture set {cap} | because (x : IO) in method f1 is not visible from cap in variable w. | - | where: => and cap refer to a fresh root capability in the type of variable w + | where: => and cap refer to a root capability in the type of variable w | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:20:11 ----------------------------- @@ -31,7 +31,7 @@ |Found: (io: IO^'s2) ->'s3 IO^{io} |Required: IO^ => IO^'s1 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -44,7 +44,7 @@ |Found: (x: IO^) ->'s5 IO^{x} |Required: IO^ => IO^'s4 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -57,7 +57,7 @@ |Found: (x: IO^'s7) ->'s8 IO^{x} |Required: IO^ => IO^'s6 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -70,7 +70,7 @@ |Found: (x: IO^) ->'s10 IO^² |Required: IO^ => IO^'s9 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to the universal root capability | ^² refers to a root capability associated with the result type of (x: IO^): IO^² | cap is a root capability associated with the result type of (x: IO^): IO^'s9 @@ -85,7 +85,7 @@ |Found: (x: IO^'s12) ->'s13 IO^ |Required: IO^² => IO^'s11 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to a root capability associated with the result type of (x: IO^'s12): IO^ | ^² refers to the universal root capability | cap is a root capability associated with the result type of (x: IO^²): IO^'s11 @@ -100,7 +100,7 @@ |Found: (x: IO^'s15) ->'s16 IO^'s17 |Required: IO^ => IO^'s14 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to the universal root capability | cap is a root capability associated with the result type of (x: IO^): IO^'s14 | @@ -114,7 +114,7 @@ |Found: (x: IO^'s19) ->'s20 IO^'s21 |Required: IO^ => IO^'s18 | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to the universal root capability | cap is a root capability associated with the result type of (x: IO^): IO^'s18 | @@ -128,7 +128,7 @@ |Found: (io: IO^'s23) ->'s24 () ->{io} Unit |Required: IO^ => () ->'s22 Unit | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method withFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile | ^ refers to the universal root capability | 29 | () => println(io) @@ -137,28 +137,28 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:31:21 ----------------------------- 31 | val f2: IO => IO = (x: IO) => x // error | ^^^^^^^^^^^^ - | Found: (x: IO^) ->'s25 IO^{x} - | Required: IO^ => IO^² + | Found: (x: IO^) ->'s25 IO^{x} + | Required: IO^ => IO^² | - | Note that capability x is not included in capture set {cap} - | because (x : IO) is not visible from cap in value f2. + | Note that capability x is not included in capture set {cap} + | because (x : IO) is not visible from cap in value f2. | - | where: => refers to a fresh root capability in the type of value f2 - | ^ refers to the universal root capability - | ^² and cap refer to a fresh root capability classified as SharedCapability in the type of value f2 + | where: => refers to a root capability in the type of value f2 + | ^ refers to the universal root capability + | ^² and cap refer to a root capability classified as SharedCapability in the type of value f2 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:33:21 ----------------------------- 33 | val f4: IO => IO = f3 // error | ^^ - | Found: (f3 : (x$0: IO) ->{} IO^{x$0}) - | Required: IO^ => IO^² + | Found: (f3 : (x$0: IO) ->{} IO^{x$0}) + | Required: IO^ => IO^² | - | Note that capability x$0 is not included in capture set {cap} - | because (x$0 : IO) is not visible from cap in value f4. + | Note that capability x$0 is not included in capture set {cap} + | because (x$0 : IO) is not visible from cap in value f4. | - | where: => refers to a fresh root capability in the type of value f4 - | ^ refers to the universal root capability - | ^² and cap refer to a fresh root capability classified as SharedCapability in the type of value f4 + | where: => refers to a root capability in the type of value f4 + | ^ refers to the universal root capability + | ^² and cap refer to a root capability classified as SharedCapability in the type of value f4 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/scoped-caps.check b/tests/neg-custom-args/captures/scoped-caps.check index d01b55ad0747..87095fe2cbaa 100644 --- a/tests/neg-custom-args/captures/scoped-caps.check +++ b/tests/neg-custom-args/captures/scoped-caps.check @@ -9,7 +9,7 @@ | | where: ^ and cap refer to the universal root capability | ^² refers to a root capability associated with the result type of (x: A^): B^² - | ^³ and cap² refer to a fresh root capability in the type of value g + | ^³ and cap² refer to a root capability in the type of value g | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:9:25 ----------------------------------- @@ -35,7 +35,7 @@ | | where: ^ and cap refer to the universal root capability | ^² refers to a root capability associated with the result type of (x: A^): B^² - | ^³ and cap² refer to a fresh root capability in the type of value _$3 + | ^³ and cap² refer to a root capability in the type of value _$3 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:12:20 ---------------------------------- @@ -49,7 +49,7 @@ | | where: ^ refers to the universal root capability | ^² and cap refer to a root capability associated with the result type of (x: A^): B^² - | ^³ and cap² refer to a fresh root capability in the type of value _$5 + | ^³ and cap² refer to a root capability in the type of value _$5 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:16:24 ---------------------------------- @@ -75,7 +75,7 @@ | | where: ^ refers to a root capability associated with the result type of (x: S^²): B^ | ^² and cap refer to the universal root capability - | ^³ and cap² refer to a fresh root capability in the type of value _$13 + | ^³ and cap² refer to a root capability in the type of value _$13 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:27:25 ---------------------------------- @@ -87,7 +87,7 @@ |Note that capability cap is not included in capture set {cap²} |because cap in an enclosing function is not visible from cap² in value _$14. | - |where: ^ and cap refer to a fresh root capability created in anonymous function of type (x: S): B^³ when instantiating method apply's type (x: S^³): B^⁴ - | ^² and cap² refer to a fresh root capability in the type of value _$14 + |where: ^ and cap refer to a root capability created in anonymous function of type (x: S): B^³ when instantiating method apply's type (x: S^³): B^⁴ + | ^² and cap² refer to a root capability in the type of value _$14 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/scoped-caps2.check b/tests/neg-custom-args/captures/scoped-caps2.check index cd739e80bc20..f7d6d762a23c 100644 --- a/tests/neg-custom-args/captures/scoped-caps2.check +++ b/tests/neg-custom-args/captures/scoped-caps2.check @@ -6,8 +6,8 @@ | | Note that capability cap is not included in capture set {cap²}. | - | where: => and cap refer to a fresh root capability in the type of value b - | =>² and cap² refer to a fresh root capability in the type of value _$1 + | where: => and cap refer to a root capability in the type of value b + | =>² and cap² refer to a root capability in the type of value _$1 | ^ refers to the universal root capability | ^² refers to a root capability associated with the result type of (x: C^): C^² | @@ -15,43 +15,43 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:6:18 ---------------------------------- 6 | val _: C => C = a // error | ^ - | Found: (a : (x: C) => C) - | Required: C^ =>² C^² + | Found: (a : (x: C) => C) + | Required: C^ =>² C^² | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability cap is not included in capture set {cap²}. | - | where: => and cap refer to a fresh root capability in the type of value a - | =>² and cap² refer to a fresh root capability in the type of value _$2 - | ^ refers to the universal root capability - | ^² refers to a fresh root capability classified as SharedCapability in the type of value _$2 + | where: => and cap refer to a root capability in the type of value a + | =>² and cap² refer to a root capability in the type of value _$2 + | ^ refers to the universal root capability + | ^² refers to a root capability classified as SharedCapability in the type of value _$2 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:8:18 ---------------------------------- 8 | val _: C => C = (x: C) => a(x) // error | ^^^^^^^^^^^^^^ - | Found: (x: C^) ->{a} C^² - | Required: C^ => C^³ + | Found: (x: C^) ->{a} C^² + | Required: C^ => C^³ | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value _$4. + | Note that capability cap is not included in capture set {cap²} + | because cap is not visible from cap² in value _$4. | - | where: => refers to a fresh root capability in the type of value _$4 - | ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² - | ^³ and cap² refer to a fresh root capability classified as SharedCapability in the type of value _$4 + | where: => refers to a root capability in the type of value _$4 + | ^ refers to the universal root capability + | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² + | ^³ and cap² refer to a root capability classified as SharedCapability in the type of value _$4 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:14:18 --------------------------------- 14 | val _: C -> C = a // error | ^ - | Found: (a : (x: C) -> C) - | Required: C^ -> C^² + | Found: (a : (x: C) -> C) + | Required: C^ -> C^² | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value _$6. + | Note that capability cap is not included in capture set {cap²} + | because cap is not visible from cap² in value _$6. | - | where: ^ and cap refer to the universal root capability - | ^² and cap² refer to a fresh root capability classified as SharedCapability in the type of value _$6 + | where: ^ and cap refer to the universal root capability + | ^² and cap² refer to a root capability classified as SharedCapability in the type of value _$6 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:16:29 --------------------------------- @@ -63,7 +63,7 @@ |Note that capability cap is not included in capture set {cap²} |because cap in an enclosing function is not visible from cap² in value _$8. | - |where: ^ and cap refer to a fresh root capability classified as SharedCapability created in anonymous function of type (x: C): C when instantiating method apply's type (x: C^³): C^⁴ - | ^² and cap² refer to a fresh root capability classified as SharedCapability in the type of value _$8 + |where: ^ and cap refer to a root capability classified as SharedCapability created in anonymous function of type (x: C): C when instantiating method apply's type (x: C^³): C^⁴ + | ^² and cap² refer to a root capability classified as SharedCapability in the type of value _$8 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/sep-box.check b/tests/neg-custom-args/captures/sep-box.check index 548284898742..e5dcc6942368 100644 --- a/tests/neg-custom-args/captures/sep-box.check +++ b/tests/neg-custom-args/captures/sep-box.check @@ -13,4 +13,4 @@ | Footprint set of second argument : {xs*} | The two sets overlap at : {xs*} | - |where: ^ refers to a fresh root capability classified as Unscoped created in method test when checking argument to parameter x of method par + |where: ^ refers to a root capability classified as Unscoped created in method test when checking argument to parameter x of method par diff --git a/tests/neg-custom-args/captures/sep-compose.check b/tests/neg-custom-args/captures/sep-compose.check index b53bc3036d4e..f95169c26f96 100644 --- a/tests/neg-custom-args/captures/sep-compose.check +++ b/tests/neg-custom-args/captures/sep-compose.check @@ -13,7 +13,7 @@ | Footprint set of second argument : {f, a, io} | The two sets overlap at : {f, a, io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter x of method seq3 + |where: => refers to a root capability created in method test when checking argument to parameter x of method seq3 -- Error: tests/neg-custom-args/captures/sep-compose.scala:33:10 ------------------------------------------------------- 33 | seq4(f)(f) // error | ^ @@ -29,7 +29,7 @@ | Footprint set of first argument : {f, a, io} | The two sets overlap at : {f, a, io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter y of method seq4 + |where: => refers to a root capability created in method test when checking argument to parameter y of method seq4 -- Error: tests/neg-custom-args/captures/sep-compose.scala:34:7 -------------------------------------------------------- 34 | seq5(f)(f) // error | ^ @@ -45,7 +45,7 @@ | Footprint set of second argument : {f, a, io} | The two sets overlap at : {f, a, io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter x of method seq5 + |where: => refers to a root capability created in method test when checking argument to parameter x of method seq5 -- Error: tests/neg-custom-args/captures/sep-compose.scala:35:7 -------------------------------------------------------- 35 | seq6(f, f) // error | ^ @@ -61,7 +61,7 @@ | Footprint set of second argument : {f, a, io} | The two sets overlap at : {f, a, io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter x of method seq6 + |where: => refers to a root capability created in method test when checking argument to parameter x of method seq6 -- Error: tests/neg-custom-args/captures/sep-compose.scala:36:10 ------------------------------------------------------- 36 | seq7(f, f) // error | ^ @@ -77,7 +77,7 @@ | Footprint set of first argument : {f, a, io} | The two sets overlap at : {f, a, io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter y of method seq7 + |where: => refers to a root capability created in method test when checking argument to parameter y of method seq7 -- Error: tests/neg-custom-args/captures/sep-compose.scala:37:7 -------------------------------------------------------- 37 | seq8(f)(f) // error | ^ @@ -93,7 +93,7 @@ | Footprint set of second argument : {f, a, io} | The two sets overlap at : {f, a, io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter x of method seq8 + |where: => refers to a root capability created in method test when checking argument to parameter x of method seq8 -- Error: tests/neg-custom-args/captures/sep-compose.scala:40:5 -------------------------------------------------------- 40 | p1(f) // error | ^ @@ -109,7 +109,7 @@ | Footprint set of function prefix : {p1, f, a, io} | The two sets overlap at : {f, a, io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter v1 of method apply + |where: => refers to a root capability created in method test when checking argument to parameter v1 of method apply -- Error: tests/neg-custom-args/captures/sep-compose.scala:41:38 ------------------------------------------------------- 41 | val p8 = (x: () ->{a} Unit) => seq8(f)(x) // error | ^ @@ -125,4 +125,4 @@ | Footprint set of second argument : {x, a, io} | The two sets overlap at : {a, io} | - |where: => refers to a fresh root capability created in anonymous function of type (x²: () ->{a} Unit): Unit when checking argument to parameter x of method seq8 + |where: => refers to a root capability created in anonymous function of type (x²: () ->{a} Unit): Unit when checking argument to parameter x of method seq8 diff --git a/tests/neg-custom-args/captures/sep-consume.check b/tests/neg-custom-args/captures/sep-consume.check index 40521e319b61..29282e4dfb40 100644 --- a/tests/neg-custom-args/captures/sep-consume.check +++ b/tests/neg-custom-args/captures/sep-consume.check @@ -9,14 +9,14 @@ | Separation failure: Illegal access to (x : Ref^), which was passed as a consume parameter to method bad | on line 18 and therefore is no longer available. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of parameter x + | where: ^ refers to a root capability classified as Unscoped in the type of parameter x -- Error: tests/neg-custom-args/captures/sep-consume.scala:21:16 ------------------------------------------------------- 21 | par(rx, () => x.put(42)) // error | ^ | Separation failure: Illegal access to (x : Ref^), which was passed as a consume parameter to method bad | on line 18 and therefore is no longer available. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of parameter x + | where: ^ refers to a root capability classified as Unscoped in the type of parameter x -- Error: tests/neg-custom-args/captures/sep-consume.scala:26:16 ------------------------------------------------------- 26 | def foo = bad(f) // error | ^ diff --git a/tests/neg-custom-args/captures/sep-counter.check b/tests/neg-custom-args/captures/sep-counter.check index aa751eba09b0..ecd5063e21dc 100644 --- a/tests/neg-custom-args/captures/sep-counter.check +++ b/tests/neg-custom-args/captures/sep-counter.check @@ -1,12 +1,12 @@ -- Error: tests/neg-custom-args/captures/sep-counter.scala:12:19 ------------------------------------------------------- 12 | def mkCounter(): Pair[Ref^, Ref^] = // error | ^^^^^^^^^^^^^^^^ - |Separation failure in method mkCounter's result type Pair[Ref^, Ref^²]. - |One part, Ref^, hides capabilities {c, cap, cap²}. - |Another part, Ref^², captures capabilities {c}. - |The two sets overlap at {c}. + | Separation failure in method mkCounter's result type Pair[Ref^, Ref^²]. + | One part, Ref^, hides capabilities {c, cap, cap²}. + | Another part, Ref^², captures capabilities {c}. + | The two sets overlap at {c}. | - |where: ^ refers to a fresh root capability classified as Unscoped in the result type of method mkCounter - | ^² refers to a fresh root capability classified as Unscoped in the result type of method mkCounter - | cap is a fresh root capability classified as Unscoped in the type of value c - | cap² is a fresh root capability classified as Unscoped created in value c when constructing instance Ref + | where: ^ refers to a root capability classified as Unscoped in the result type of method mkCounter + | ^² refers to a root capability classified as Unscoped in the result type of method mkCounter + | cap is a root capability classified as Unscoped in the type of value c + | cap² is a root capability classified as Unscoped created in value c when constructing instance Ref diff --git a/tests/neg-custom-args/captures/sep-curried-par.check b/tests/neg-custom-args/captures/sep-curried-par.check index 2172c5699fa8..b9b2603cb6e6 100644 --- a/tests/neg-custom-args/captures/sep-curried-par.check +++ b/tests/neg-custom-args/captures/sep-curried-par.check @@ -31,15 +31,15 @@ | Footprint set of second argument : {p} | The two sets overlap at : {p} | - |where: => refers to a fresh root capability in the type of value p - | =>² refers to a fresh root capability created in method test when checking argument to parameter p1 of method par + |where: => refers to a root capability in the type of value p + | =>² refers to a root capability created in method test when checking argument to parameter p1 of method par -- Error: tests/neg-custom-args/captures/sep-curried-par.scala:18:16 --------------------------------------------------- 18 | parCurried(p)(p) // error: consume failure | ^ |Separation failure: Illegal access to (p : () => Unit), which was passed as a consume parameter to method parCurried |on line 18 and therefore is no longer available. | - |where: => refers to a fresh root capability in the type of value p + |where: => refers to a root capability in the type of value p -- Error: tests/neg-custom-args/captures/sep-curried-par.scala:21:9 ---------------------------------------------------- 21 | foo(c)(c) // error: separation | ^ @@ -55,5 +55,5 @@ | Footprint set of function prefix : {c} | The two sets overlap at : {c} | - |where: => refers to a fresh root capability in the type of parameter c - | =>² refers to a fresh root capability created in method test when checking argument to parameter v1 of method apply + |where: => refers to a root capability in the type of parameter c + | =>² refers to a root capability created in method test when checking argument to parameter v1 of method apply diff --git a/tests/neg-custom-args/captures/sep-curried.check b/tests/neg-custom-args/captures/sep-curried.check index 232144c1ebaf..06fd4cef0ad0 100644 --- a/tests/neg-custom-args/captures/sep-curried.check +++ b/tests/neg-custom-args/captures/sep-curried.check @@ -24,8 +24,8 @@ | Footprint set of second argument : {a} | The two sets overlap at : {a} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | ^² refers to a fresh root capability classified as Unscoped created in method test0 when checking argument to parameter x of method foo + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | ^² refers to a root capability classified as Unscoped created in method test0 when checking argument to parameter x of method foo -- Error: tests/neg-custom-args/captures/sep-curried.scala:22:44 ------------------------------------------------------- 22 | val f: (y: Ref[Int]^{a}) ->{a} Unit = foo(a) // error | ^ @@ -41,8 +41,8 @@ | Footprint set of function result : {a} | The two sets overlap at : {a} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | ^² refers to a fresh root capability classified as Unscoped created in value f when checking argument to parameter x of method apply + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | ^² refers to a root capability classified as Unscoped created in value f when checking argument to parameter x of method apply -- Error: tests/neg-custom-args/captures/sep-curried.scala:29:6 -------------------------------------------------------- 29 | foo(a)(a) // error | ^ @@ -58,8 +58,8 @@ | Footprint set of function result : {a} | The two sets overlap at : {a} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | ^² refers to a fresh root capability classified as Unscoped created in method test2 when checking argument to parameter x of method apply + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | ^² refers to a root capability classified as Unscoped created in method test2 when checking argument to parameter x of method apply -- Error: tests/neg-custom-args/captures/sep-curried.scala:35:9 -------------------------------------------------------- 35 | foo(a)(a) // error | ^ @@ -75,8 +75,8 @@ | Footprint set of function prefix : {a} | The two sets overlap at : {a} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | ^² refers to a fresh root capability classified as Unscoped created in method test3 when checking argument to parameter y of method apply + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | ^² refers to a root capability classified as Unscoped created in method test3 when checking argument to parameter y of method apply -- Error: tests/neg-custom-args/captures/sep-curried.scala:42:4 -------------------------------------------------------- 42 | f(a) // error | ^ @@ -92,5 +92,5 @@ | Footprint set of function prefix : {f, a} | The two sets overlap at : {a} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value a - | ^² refers to a fresh root capability classified as Unscoped created in method test4 when checking argument to parameter y of method apply + |where: ^ refers to a root capability classified as Unscoped in the type of value a + | ^² refers to a root capability classified as Unscoped created in method test4 when checking argument to parameter y of method apply diff --git a/tests/neg-custom-args/captures/sep-list.check b/tests/neg-custom-args/captures/sep-list.check index 7b5b6bd69fa7..0be8af0f3b0d 100644 --- a/tests/neg-custom-args/captures/sep-list.check +++ b/tests/neg-custom-args/captures/sep-list.check @@ -13,4 +13,4 @@ | Footprint set of second argument : {h2, xs*} | The two sets overlap at : {xs*} | - |where: ^ refers to a fresh root capability classified as Unscoped created in method test when checking argument to parameter x of method par + |where: ^ refers to a root capability classified as Unscoped created in method test when checking argument to parameter x of method par diff --git a/tests/neg-custom-args/captures/sep-pairs-unboxed.check b/tests/neg-custom-args/captures/sep-pairs-unboxed.check index 7dd80ba80a15..fc007e05260b 100644 --- a/tests/neg-custom-args/captures/sep-pairs-unboxed.check +++ b/tests/neg-custom-args/captures/sep-pairs-unboxed.check @@ -13,8 +13,8 @@ | Footprint set of second argument : {x} | The two sets overlap at : {x} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of parameter x - | ^² refers to a fresh root capability classified as Unscoped created in method mkPair when checking argument to parameter fst of constructor Pair + |where: ^ refers to a root capability classified as Unscoped in the type of parameter x + | ^² refers to a root capability classified as Unscoped created in method mkPair when checking argument to parameter fst of constructor Pair -- Error: tests/neg-custom-args/captures/sep-pairs-unboxed.scala:35:25 ------------------------------------------------- 35 | val twoCopy = Pair(two.fst, two.fst) // error | ^^^^^^^ @@ -30,8 +30,8 @@ | Footprint set of second argument : {two.fst} | The two sets overlap at : {two.fst} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value fst - | ^² refers to a fresh root capability classified as Unscoped created in value twoCopy when checking argument to parameter fst of constructor Pair + |where: ^ refers to a root capability classified as Unscoped in the type of value fst + | ^² refers to a root capability classified as Unscoped created in value twoCopy when checking argument to parameter fst of constructor Pair -- Error: tests/neg-custom-args/captures/sep-pairs-unboxed.scala:41:29 ------------------------------------------------- 41 | val twisted = PairPair(two.fst, two) // error | ^^^^^^^ @@ -47,8 +47,8 @@ | Footprint set of second argument : {two*} | The two sets overlap at : {cap of a new instance of class Pair} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value fst - | ^² refers to a fresh root capability classified as Unscoped created in value twisted when checking argument to parameter fst of constructor PairPair + |where: ^ refers to a root capability classified as Unscoped in the type of value fst + | ^² refers to a root capability classified as Unscoped created in value twisted when checking argument to parameter fst of constructor PairPair -- Error: tests/neg-custom-args/captures/sep-pairs-unboxed.scala:47:33 ------------------------------------------------- 47 | val twisted = swapped(two, two.snd) // error | ^^^^^^^ @@ -64,8 +64,8 @@ | Footprint set of first argument : {two*} | The two sets overlap at : {cap of a new instance of class Pair} | - |where: ^ refers to a fresh root capability classified as Unscoped in the type of value snd - | ^² refers to a fresh root capability classified as Unscoped created in value twisted when checking argument to parameter y of method swapped + |where: ^ refers to a root capability classified as Unscoped in the type of value snd + | ^² refers to a root capability classified as Unscoped created in value twisted when checking argument to parameter y of method swapped -- Error: tests/neg-custom-args/captures/sep-pairs-unboxed.scala:58:26 ------------------------------------------------- 58 | val twoOther = Pair(two.fst, two.snd) // error // error | ^^^^^^^ @@ -73,7 +73,7 @@ | of value twoCopy with type Pair^. | This type hides capabilities {two.fst, two.snd} | - | where: ^ refers to a fresh root capability in the type of value twoCopy + | where: ^ refers to a root capability in the type of value twoCopy -- Error: tests/neg-custom-args/captures/sep-pairs-unboxed.scala:58:35 ------------------------------------------------- 58 | val twoOther = Pair(two.fst, two.snd) // error // error | ^^^^^^^ @@ -81,4 +81,4 @@ | of value twoCopy with type Pair^. | This type hides capabilities {two.fst, two.snd} | - | where: ^ refers to a fresh root capability in the type of value twoCopy + | where: ^ refers to a root capability in the type of value twoCopy diff --git a/tests/neg-custom-args/captures/sep-pairs.check b/tests/neg-custom-args/captures/sep-pairs.check index 9b6cb295d8e8..2af59556d78f 100644 --- a/tests/neg-custom-args/captures/sep-pairs.check +++ b/tests/neg-custom-args/captures/sep-pairs.check @@ -6,27 +6,27 @@ | Another part, Ref^², captures capabilities {r0}. | The two sets overlap at {r0}. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of value r1 - | ^² refers to a fresh root capability classified as Unscoped in the type of value r1 + | where: ^ refers to a root capability classified as Unscoped in the type of value r1 + | ^² refers to a root capability classified as Unscoped in the type of value r1 -- Error: tests/neg-custom-args/captures/sep-pairs.scala:13:9 ---------------------------------------------------------- 13 |def bad: Pair[Ref^, Ref^] = // error: overlap at r1*, r0 | ^^^^^^^^^^^^^^^^ - | Separation failure in method bad's result type Pair[Ref^, Ref^²]. - | One part, Ref^, hides capabilities {r1*, cap, cap², r0}. - | Another part, Ref^², captures capabilities {r1*, r0}. - | The two sets overlap at {r1*, r0}. + | Separation failure in method bad's result type Pair[Ref^, Ref^²]. + | One part, Ref^, hides capabilities {r1*, cap, cap², r0}. + | Another part, Ref^², captures capabilities {r1*, r0}. + | The two sets overlap at {r1*, r0}. | - | where: ^ refers to a fresh root capability classified as Unscoped in the result type of method bad - | ^² refers to a fresh root capability classified as Unscoped in the result type of method bad - | cap is a fresh root capability classified as Unscoped in the type of value r1 - | cap² is a fresh root capability classified as Unscoped in the type of value r1 + | where: ^ refers to a root capability classified as Unscoped in the result type of method bad + | ^² refers to a root capability classified as Unscoped in the result type of method bad + | cap is a root capability classified as Unscoped in the type of value r1 + | cap² is a root capability classified as Unscoped in the type of value r1 -- Error: tests/neg-custom-args/captures/sep-pairs.scala:43:18 --------------------------------------------------------- 43 | val sameToPair: Pair[Ref^, Ref^] = Pair(fstSame, sndSame) // error | ^^^^^^^^^^^^^^^^ - | Separation failure in value sameToPair's type Pair[Ref^, Ref^²]. - | One part, Ref^, hides capabilities {fstSame}. - | Another part, Ref^², captures capabilities {sndSame, same.snd*}. - | The two sets overlap at {cap of value same}. + | Separation failure in value sameToPair's type Pair[Ref^, Ref^²]. + | One part, Ref^, hides capabilities {fstSame}. + | Another part, Ref^², captures capabilities {sndSame, same.snd*}. + | The two sets overlap at {cap of value same}. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of value sameToPair - | ^² refers to a fresh root capability classified as Unscoped in the type of value sameToPair + | where: ^ refers to a root capability classified as Unscoped in the type of value sameToPair + | ^² refers to a root capability classified as Unscoped in the type of value sameToPair diff --git a/tests/neg-custom-args/captures/sep-use.check b/tests/neg-custom-args/captures/sep-use.check index 5d8636007fdc..d858540b464f 100644 --- a/tests/neg-custom-args/captures/sep-use.check +++ b/tests/neg-custom-args/captures/sep-use.check @@ -5,7 +5,7 @@ | of value x with type () => Unit. | This type hides capabilities {io} | - | where: => refers to a fresh root capability in the type of value x + | where: => refers to a root capability in the type of value x -- Error: tests/neg-custom-args/captures/sep-use.scala:12:12 ----------------------------------------------------------- 12 | def x: () => Unit = () => println(io) // error | ^^^^^^^^^^ @@ -17,7 +17,7 @@ | of method x with result type () => Unit. | This type hides capabilities {io} | - | where: => refers to a fresh root capability in the result type of method x + | where: => refers to a root capability in the result type of method x -- Error: tests/neg-custom-args/captures/sep-use.scala:18:10 ----------------------------------------------------------- 18 | def xx: (y: Int) => Unit = _ => println(io) // error | ^^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ | of method xx with result type (y: Int) => Unit. | This type hides capabilities {io} | - | where: => refers to a fresh root capability in the result type of method xx + | where: => refers to a root capability in the result type of method xx -- Error: tests/neg-custom-args/captures/sep-use.scala:24:19 ----------------------------------------------------------- 24 | def xxx(y: Int): Object^ = io // error | ^^^^^^^ @@ -41,4 +41,4 @@ | of method xxx with result type Object^. | This type hides capabilities {io} | - | where: ^ refers to a fresh root capability in the result type of method xxx + | where: ^ refers to a root capability in the result type of method xxx diff --git a/tests/neg-custom-args/captures/sep-use2.check b/tests/neg-custom-args/captures/sep-use2.check index 5aa02461c983..30063f1f5110 100644 --- a/tests/neg-custom-args/captures/sep-use2.check +++ b/tests/neg-custom-args/captures/sep-use2.check @@ -9,7 +9,7 @@ | of method cc with result type Object^. | This type hides capabilities {c} | - | where: ^ refers to a fresh root capability in the result type of method cc + | where: ^ refers to a root capability in the result type of method cc -- Error: tests/neg-custom-args/captures/sep-use2.scala:16:10 ---------------------------------------------------------- 16 | def cc: Object^ = c // error | ^^^^^^^ @@ -21,7 +21,7 @@ | of method cc with result type Object^. | This type hides capabilities {c} | - | where: ^ refers to a fresh root capability in the result type of method cc + | where: ^ refers to a root capability in the result type of method cc -- Error: tests/neg-custom-args/captures/sep-use2.scala:20:6 ----------------------------------------------------------- 20 | { f(c) } // error // error | ^ @@ -29,7 +29,7 @@ | of method cc with result type Object^. | This type hides capabilities {c} | - | where: ^ refers to a fresh root capability in the result type of method cc + | where: ^ refers to a root capability in the result type of method cc -- Error: tests/neg-custom-args/captures/sep-use2.scala:20:8 ----------------------------------------------------------- 20 | { f(c) } // error // error | ^ @@ -37,7 +37,7 @@ | of method cc with result type Object^. | This type hides capabilities {c} | - | where: ^ refers to a fresh root capability in the result type of method cc + | where: ^ refers to a root capability in the result type of method cc -- Error: tests/neg-custom-args/captures/sep-use2.scala:24:8 ----------------------------------------------------------- 24 | { f(c) } // error | ^ @@ -53,8 +53,8 @@ | Footprint set of function prefix : {f*, c} | The two sets overlap at : {c} | - |where: ^ refers to a fresh root capability in the type of parameter c - | ^² refers to a fresh root capability created in value x4 when checking argument to parameter v1 of method apply + |where: ^ refers to a root capability in the type of parameter c + | ^² refers to a root capability created in value x4 when checking argument to parameter v1 of method apply -- Error: tests/neg-custom-args/captures/sep-use2.scala:23:10 ---------------------------------------------------------- 23 | val x4: Object^ = // error: ^ hides f*, needs consume | ^^^^^^^ @@ -75,8 +75,8 @@ | Footprint set of function prefix : {f*, c} | The two sets overlap at : {c} | - |where: ^ refers to a fresh root capability in the type of parameter c - | ^² refers to a fresh root capability created in value x4 when checking argument to parameter v1 of method apply + |where: ^ refers to a root capability in the type of parameter c + | ^² refers to a root capability created in value x4 when checking argument to parameter v1 of method apply -- Error: tests/neg-custom-args/captures/sep-use2.scala:27:10 ---------------------------------------------------------- 27 | val x4: Object^ = // error: ^ hides f* which refers to c, so c needs consume | ^^^^^^^ diff --git a/tests/neg-custom-args/captures/sepchecks2.check b/tests/neg-custom-args/captures/sepchecks2.check index 6e991003c5a2..3823162bbec3 100644 --- a/tests/neg-custom-args/captures/sepchecks2.check +++ b/tests/neg-custom-args/captures/sepchecks2.check @@ -6,8 +6,8 @@ | Another part, Object^², captures capabilities {c}. | The two sets overlap at {c}. | - | where: ^ refers to a fresh root capability in the type of value x1 - | ^² refers to a fresh root capability in the type of value x1 + | where: ^ refers to a root capability in the type of value x1 + | ^² refers to a root capability in the type of value x1 -- Error: tests/neg-custom-args/captures/sepchecks2.scala:15:10 -------------------------------------------------------- 15 | val x2: (Object^, Object^{d}) = (d, d) // error | ^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ | Another part, Object^{d}, captures capabilities {d}. | The two sets overlap at {d}. | - | where: ^ refers to a fresh root capability in the type of value x2 + | where: ^ refers to a root capability in the type of value x2 -- Error: tests/neg-custom-args/captures/sepchecks2.scala:27:6 --------------------------------------------------------- 27 | bar((c, c)) // error | ^^^^^^ @@ -25,8 +25,8 @@ |Another part, Object^², captures capabilities {c}. |The two sets overlap at {c}. | - |where: ^ refers to a fresh root capability created in method Test6 when checking argument to parameter x of method bar - | ^² refers to a fresh root capability created in method Test6 when checking argument to parameter x of method bar + |where: ^ refers to a root capability created in method Test6 when checking argument to parameter x of method bar + | ^² refers to a root capability created in method Test6 when checking argument to parameter x of method bar -- Error: tests/neg-custom-args/captures/sepchecks2.scala:30:9 --------------------------------------------------------- 30 | val x: (Object^, Object^{c}) = (d, c) // error | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/neg-custom-args/captures/sepchecks4.check b/tests/neg-custom-args/captures/sepchecks4.check index 64ebb04239d5..d88f3ba7c379 100644 --- a/tests/neg-custom-args/captures/sepchecks4.check +++ b/tests/neg-custom-args/captures/sepchecks4.check @@ -23,4 +23,4 @@ | Footprint set of second argument : {io} | The two sets overlap at : {io} | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op1 of method par + |where: => refers to a root capability created in method test when checking argument to parameter op1 of method par diff --git a/tests/neg-custom-args/captures/sepchecks5.check b/tests/neg-custom-args/captures/sepchecks5.check index ab7ae86a9cef..555b93f2b629 100644 --- a/tests/neg-custom-args/captures/sepchecks5.check +++ b/tests/neg-custom-args/captures/sepchecks5.check @@ -14,4 +14,4 @@ | Separation failure: Illegal access to (io : Object^), which was passed as a consume parameter to method g | on line 19 and therefore is no longer available. | - | where: ^ refers to a fresh root capability in the type of parameter io + | where: ^ refers to a root capability in the type of parameter io diff --git a/tests/neg-custom-args/captures/simple-using.check b/tests/neg-custom-args/captures/simple-using.check index 84206a8f78ce..05179ef80418 100644 --- a/tests/neg-custom-args/captures/simple-using.check +++ b/tests/neg-custom-args/captures/simple-using.check @@ -7,7 +7,7 @@ |Found: (f: java.io.FileOutputStream^'s2) ->'s3 () ->{f} Unit |Required: java.io.FileOutputStream^ => () ->'s1 Unit | - |where: => refers to a fresh root capability created in method test when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in method test when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/try.check b/tests/neg-custom-args/captures/try.check index b80ceac7f0b2..14a07b055ddc 100644 --- a/tests/neg-custom-args/captures/try.check +++ b/tests/neg-custom-args/captures/try.check @@ -7,9 +7,9 @@ |Note that capability x is not included in capture set {cap} |because (x : CT[Exception]^) is not visible from cap in value a. | - |where: => refers to a fresh root capability created in value a when checking argument to parameter op of method handle + |where: => refers to a root capability created in value a when checking argument to parameter op of method handle | ^ refers to the universal root capability - | ^² and cap refer to a fresh root capability created in value a + | ^² and cap refer to a root capability created in value a | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:30:4 ------------------------------------------- @@ -20,7 +20,7 @@ | |Note that capability x is not included in capture set {}. | - |where: => refers to a fresh root capability created in value b when checking argument to parameter op of method handle + |where: => refers to a root capability created in value b when checking argument to parameter op of method handle | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -33,7 +33,7 @@ |Found: (x: CT[Exception]^) ->'s4 () ->{x} Int |Required: CT[Exception]^ => () ->'s3 Int | - |where: => refers to a fresh root capability created in value xx when checking argument to parameter op of method handle + |where: => refers to a root capability created in value xx when checking argument to parameter op of method handle | ^ refers to the universal root capability | 37 | () => @@ -50,7 +50,7 @@ |Found: (x: CT[Exception]^) ->'s6 () ->{x} Int |Required: CT[Exception]^ => () ->'s5 Int | - |where: => refers to a fresh root capability created in value global when checking argument to parameter op of method handle + |where: => refers to a root capability created in value global when checking argument to parameter op of method handle | ^ refers to the universal root capability | 49 | () => diff --git a/tests/neg-custom-args/captures/unbox-overrides.check b/tests/neg-custom-args/captures/unbox-overrides.check index 883ab56c59a5..24c5719f244c 100644 --- a/tests/neg-custom-args/captures/unbox-overrides.check +++ b/tests/neg-custom-args/captures/unbox-overrides.check @@ -4,8 +4,8 @@ |error overriding method foo in trait A of type [C >: scala.caps.CapSet <: scala.caps.CapSet^]: Object^{C}; | method foo of type [C >: scala.caps.CapSet <: scala.caps.CapSet^²]: Object^{C} has a parameter C with different @reserve status than the corresponding parameter in the overridden definition | - |where: ^ refers to a fresh root capability in the type of type C² - | ^² refers to a fresh root capability in the type of type C³ + |where: ^ refers to a root capability in the type of type C² + | ^² refers to a root capability in the type of type C³ | | longer explanation available when compiling with `-explain` -- [E164] Declaration Error: tests/neg-custom-args/captures/unbox-overrides.scala:9:6 ---------------------------------- @@ -14,8 +14,8 @@ |error overriding method bar in trait A of type [C >: scala.caps.CapSet <: scala.caps.CapSet^]: Object^{C}; | method bar of type [C >: scala.caps.CapSet <: scala.caps.CapSet^²]: Object^{C} has a parameter C with different @reserve status than the corresponding parameter in the overridden definition | - |where: ^ refers to a fresh root capability in the type of type C² - | ^² refers to a fresh root capability in the type of type C³ + |where: ^ refers to a root capability in the type of type C² + | ^² refers to a root capability in the type of type C³ | | longer explanation available when compiling with `-explain` -- [E164] Declaration Error: tests/neg-custom-args/captures/unbox-overrides.scala:15:15 -------------------------------- @@ -24,7 +24,7 @@ |error overriding method foo in trait A of type [C >: scala.caps.CapSet <: scala.caps.CapSet^]: Object^{C}; | method foo in trait B2 of type [C >: scala.caps.CapSet <: scala.caps.CapSet^²]: Object^{C} has a parameter C with different @reserve status than the corresponding parameter in the overridden definition | - |where: ^ refers to a fresh root capability in the type of type C² - | ^² refers to a fresh root capability in the type of type C³ + |where: ^ refers to a root capability in the type of type C² + | ^² refers to a root capability in the type of type C³ | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/unscoped-classifier.check b/tests/neg-custom-args/captures/unscoped-classifier.check index 6df15e71c769..be7132a7c2f5 100644 --- a/tests/neg-custom-args/captures/unscoped-classifier.check +++ b/tests/neg-custom-args/captures/unscoped-classifier.check @@ -3,17 +3,17 @@ | ^ | reference (A.this.a : Async) is not included in the allowed capture set {cap} of the self type of class A | - | where: cap is a fresh root capability classified as Unscoped in the type of class A + | where: cap is a root capability classified as Unscoped in the type of class A -- Error: tests/neg-custom-args/captures/unscoped-classifier.scala:10:8 ------------------------------------------------ 10 |class C(f: () => Unit) extends caps.Unscoped // error but msg could be better | ^ | reference (C.this.f : () => Unit) is not included in the allowed capture set {cap} of the self type of class C | - | where: cap is a fresh root capability classified as Unscoped in the type of class C + | where: cap is a root capability classified as Unscoped in the type of class C -- Error: tests/neg-custom-args/captures/unscoped-classifier.scala:17:15 ----------------------------------------------- 17 | def gg() = g() // error but msg could be better | ^ | Read-only method gg accesses exclusive capability (g : () => Unit); | method gg should be declared an update method to allow this. | - | where: => refers to a fresh root capability in the type of parameter g + | where: => refers to a root capability in the type of parameter g diff --git a/tests/neg-custom-args/captures/unscoped-extrude.check b/tests/neg-custom-args/captures/unscoped-extrude.check index b59c6bc2fb48..2fca013524fb 100644 --- a/tests/neg-custom-args/captures/unscoped-extrude.check +++ b/tests/neg-custom-args/captures/unscoped-extrude.check @@ -4,4 +4,4 @@ | Separation failure: Illegal access to (r : Ref[String]^), which was consumed in an assignment to variable x | on line 12 and therefore is no longer available. | - | where: ^ refers to a fresh root capability classified as Unscoped in the type of value r + | where: ^ refers to a root capability classified as Unscoped in the type of value r diff --git a/tests/neg-custom-args/captures/unsound-reach-4.check b/tests/neg-custom-args/captures/unsound-reach-4.check index 344679727343..0a98ed8e7e9f 100644 --- a/tests/neg-custom-args/captures/unsound-reach-4.check +++ b/tests/neg-custom-args/captures/unsound-reach-4.check @@ -14,8 +14,8 @@ | Note that capability cap is not included in capture set {cap²} | because cap in class Bar is not visible from cap² in value backdoor. | - | where: ^ and cap² refer to a fresh root capability in the type of value backdoor - | cap is a fresh root capability created in class Bar + | where: ^ and cap² refer to a root capability in the type of value backdoor + | cap is a root capability created in class Bar | | longer explanation available when compiling with `-explain` -- [E164] Declaration Error: tests/neg-custom-args/captures/unsound-reach-4.scala:17:6 --------------------------------- @@ -25,7 +25,7 @@ | method use of type (@consume x: File^): File^³ has incompatible type | | where: ^ refers to the universal root capability - | ^² refers to a fresh root capability created in class Bar + | ^² refers to a root capability created in class Bar | ^³ refers to a root capability associated with the result type of (@consume x: File^): File^³ | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/unsound-reach.check b/tests/neg-custom-args/captures/unsound-reach.check index 4cf788de0f24..ad0e9ee7a8e1 100644 --- a/tests/neg-custom-args/captures/unsound-reach.check +++ b/tests/neg-custom-args/captures/unsound-reach.check @@ -8,26 +8,26 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/unsound-reach.scala:18:31 -------------------------------- 18 | val backdoor: Foo[File^] = new Bar // error | ^^^^^^^ - | Found: Bar^'s1 - | Required: Foo[File^] + | Found: Bar^'s1 + | Required: Foo[File^] | - | Note that capability cap is not included in capture set {cap²} - | because cap in class Bar is not visible from cap² in value backdoor. + | Note that capability cap is not included in capture set {cap²} + | because cap in class Bar is not visible from cap² in value backdoor. | - | where: ^ and cap² refer to a fresh root capability in the type of value backdoor - | cap is a fresh root capability created in class Bar + | where: ^ and cap² refer to a root capability in the type of value backdoor + | cap is a root capability created in class Bar | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/unsound-reach.scala:27:32 -------------------------------- 27 | val backdoor: Foo2[File^] = new Bar2 // error | ^^^^^^^^ - | Found: Bar2^'s2 - | Required: Foo2[File^] + | Found: Bar2^'s2 + | Required: Foo2[File^] | - | Note that capability cap is not included in capture set {cap²} - | because cap in class Bar2 is not visible from cap² in value backdoor. + | Note that capability cap is not included in capture set {cap²} + | because cap in class Bar2 is not visible from cap² in value backdoor. | - | where: ^ and cap² refer to a fresh root capability in the type of value backdoor - | cap is a fresh root capability created in class Bar2 + | where: ^ and cap² refer to a root capability in the type of value backdoor + | cap is a root capability created in class Bar2 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/usingLogFile.check b/tests/neg-custom-args/captures/usingLogFile.check index 51cbe5b334d1..3fe0db17fe0c 100644 --- a/tests/neg-custom-args/captures/usingLogFile.check +++ b/tests/neg-custom-args/captures/usingLogFile.check @@ -7,7 +7,7 @@ |Found: (f: java.io.FileOutputStream^'s2) ->'s3 () ->{f} Unit |Required: java.io.FileOutputStream^ => () ->'s1 Unit | - |where: => refers to a fresh root capability created in value later when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in value later when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -20,7 +20,7 @@ |Found: (f: java.io.FileOutputStream^'s5) ->'s6 Test2.Cell[() ->{f} Unit]^'s7 |Required: java.io.FileOutputStream^ => Test2.Cell[() ->'s4 Unit]^'s8 | - |where: => refers to a fresh root capability created in value later2 when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in value later2 when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -33,7 +33,7 @@ |Found: (f: java.io.OutputStream^'s10) ->'s11 Int ->{f} Unit |Required: java.io.OutputStream^ => Int ->'s9 Unit | - |where: => refers to a fresh root capability created in value later when checking argument to parameter op of method usingFile + |where: => refers to a root capability created in value later when checking argument to parameter op of method usingFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -46,7 +46,7 @@ |Found: (_$1: java.io.OutputStream^'s13) ->'s14 () ->{_$1} Unit |Required: java.io.OutputStream^ => () ->'s12 Unit | - |where: => refers to a fresh root capability created in value later when checking argument to parameter op of method usingFile + |where: => refers to a root capability created in value later when checking argument to parameter op of method usingFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/vars-simple.check b/tests/neg-custom-args/captures/vars-simple.check index e19f414d0b2e..1cd12195566a 100644 --- a/tests/neg-custom-args/captures/vars-simple.check +++ b/tests/neg-custom-args/captures/vars-simple.check @@ -6,7 +6,7 @@ | | Note that capability cap is not included in capture set {cap1, cap2}. | - | where: => and cap refer to a fresh root capability created in method scope + | where: => and cap refer to a root capability created in method scope | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars-simple.scala:16:8 ----------------------------------- diff --git a/tests/neg-custom-args/captures/widen-reach.check b/tests/neg-custom-args/captures/widen-reach.check index 48c5989b285b..e37c371f6db2 100644 --- a/tests/neg-custom-args/captures/widen-reach.check +++ b/tests/neg-custom-args/captures/widen-reach.check @@ -16,7 +16,7 @@ | | where: ^ refers to the universal root capability | ^² and cap refer to a root capability associated with the result type of (x: IO^): IO^² - | ^³ and cap² refer to a fresh root capability in the type of value foo + | ^³ and cap² refer to a root capability in the type of value foo | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/widen-reach.scala:13:26 ---------------------------------- @@ -28,7 +28,7 @@ | Note that capability x* is not included in capture set {}. | | where: ^ refers to the universal root capability - | ^² refers to a fresh root capability in the type of value y2 + | ^² refers to a root capability in the type of value y2 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/widen-reach.scala:14:30 ---------------------------------- diff --git a/tests/neg-custom-args/captures/withFile.check b/tests/neg-custom-args/captures/withFile.check index 0eda97de2804..8e67504f6f8e 100644 --- a/tests/neg-custom-args/captures/withFile.check +++ b/tests/neg-custom-args/captures/withFile.check @@ -7,7 +7,7 @@ |Found: (f: Test2.File^'s2) ->'s3 () ->{f} Unit |Required: Test2.File^ => () ->'s1 Unit | - |where: => refers to a fresh root capability created in value later1 when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in value later1 when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -20,7 +20,7 @@ |Found: (f: Test2.File^'s5) ->'s6 Test2.Box[Test2.File^'s7]^'s8 |Required: Test2.File^ => Test2.Box[Test2.File^'s4]^'s9 | - |where: => refers to a fresh root capability created in value later2 when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in value later2 when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability | cap is a root capability associated with the result type of (f: Test2.File^): Test2.Box[Test2.File^'s4]^'s9 | @@ -34,8 +34,8 @@ |Note that capability f is not included in capture set {cap} |because (f : Test2.File^'s10) is not visible from cap in value later3. | - |where: => refers to a fresh root capability created in value later3 when checking argument to parameter op of method usingLogFile - | =>² and cap refer to a fresh root capability created in value later3 + |where: => refers to a root capability created in value later3 when checking argument to parameter op of method usingLogFile + | =>² and cap refer to a root capability created in value later3 | ^ refers to the universal root capability | | longer explanation available when compiling with `-explain` @@ -48,9 +48,9 @@ |Note that capability cap is not included in capture set {cap²} |because cap is not visible from cap² in value later4. | - |where: => refers to a fresh root capability created in value later4 when checking argument to parameter op of method usingLogFile + |where: => refers to a root capability created in value later4 when checking argument to parameter op of method usingLogFile | ^ refers to the universal root capability - | ^² and cap² refer to a fresh root capability created in value later4 + | ^² and cap² refer to a root capability created in value later4 | cap is a root capability associated with the result type of (f: Test2.File^'s12): Test2.Box[Test2.File^'s14]^'s15 | | longer explanation available when compiling with `-explain` @@ -61,4 +61,4 @@ | Fields capturing a root capability need to be given an explicit type unless the capability is already | subsumed by the computed capability of the enclosing class. | - | where: => refers to a fresh root capability in the type of value later3 + | where: => refers to a root capability in the type of value later3 From 8bc2164a5293e09e02947f6132c88846693f2a61 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 12 Jan 2026 21:24:37 +0100 Subject: [PATCH 2/3] Rename `cap` to `any`, and add `fresh` - Introduce `fresh` - New global definition: `caps.fresh`. - `fresh` is for ResultCaps in function types. - Disallow `fresh` outside result types of function types. - Fix isTrackableRef: previously, a static term ref was trackable if its prefix was the ThisType of a package, but was not trackable if the prefix was a TermRef to the same package. Now both versions are trackable. - Don't go to basetypes when comparing dependent functions at cc - Improve printing of capabilities: - Don't elide a universal capture set in a TypeMismatch message if one of its capabilities is mentioned in an error note. - Don't elide capture sets containing fresh when printing - Don't use the verbose output for fresh if there are no open existentials - Systematically backquote all entities shown as capabilities --- .../src/dotty/tools/dotc/ast/TreeInfo.scala | 6 +- compiler/src/dotty/tools/dotc/ast/untpd.scala | 2 +- .../src/dotty/tools/dotc/cc/CCState.scala | 16 +- .../src/dotty/tools/dotc/cc/Capability.scala | 93 ++++++----- .../src/dotty/tools/dotc/cc/CaptureOps.scala | 39 ++++- .../src/dotty/tools/dotc/cc/CaptureSet.scala | 111 +++++++------ .../dotty/tools/dotc/cc/CheckCaptures.scala | 65 ++++---- .../tools/dotc/cc/RetainingAnnotation.scala | 2 +- .../src/dotty/tools/dotc/cc/SepCheck.scala | 12 +- compiler/src/dotty/tools/dotc/cc/Setup.scala | 26 ++-- .../src/dotty/tools/dotc/cc/Synthetics.scala | 10 +- .../dotty/tools/dotc/core/Definitions.scala | 14 +- .../src/dotty/tools/dotc/core/StdNames.scala | 3 +- .../dotty/tools/dotc/core/TypeComparer.scala | 14 +- .../src/dotty/tools/dotc/core/Types.scala | 2 +- .../dotty/tools/dotc/parsing/Parsers.scala | 2 +- .../dotty/tools/dotc/parsing/Scanners.scala | 6 +- .../tools/dotc/printing/PlainPrinter.scala | 49 +++--- .../tools/dotc/printing/RefinedPrinter.scala | 2 +- .../dotty/tools/dotc/reporting/Message.scala | 32 ++-- .../dotty/tools/dotc/reporting/messages.scala | 8 +- .../dotty/tools/dotc/typer/RefChecks.scala | 2 +- .../src/dotty/tools/dotc/typer/Typer.scala | 8 +- library/src/scala/annotation/retains.scala | 2 +- .../unchecked/uncheckedCaptures.scala | 2 +- library/src/scala/caps/package.scala | 19 ++- library/src/scala/collection/Iterator.scala | 2 +- project/MiMaFilters.scala | 2 +- .../neg-custom-args/captures/capt-wf.scala | 4 +- .../neg-custom-args/captures/try2.scala | 2 +- .../captures/unsound-reach-7.scala | 2 +- tests/neg-custom-args/boxmap.scala | 4 +- .../captures/apply-fresh.check | 14 +- .../neg-custom-args/captures/apply-rule.check | 8 +- .../captures/boundary-homebrew.check | 6 +- tests/neg-custom-args/captures/boundary.check | 30 ++-- .../captures/boundschecks3.check | 4 +- .../captures/box-adapt-cases.check | 4 +- .../captures/box-adapt-contra.check | 4 +- tests/neg-custom-args/captures/byname.check | 8 +- .../neg-custom-args/captures/caps-reach.check | 8 +- .../neg-custom-args/captures/caps-reach.scala | 4 +- .../captures/capset-bound2.scala | 2 +- .../captures/capset-variance.scala | 4 +- .../captures/capt-depfun.check | 4 +- .../captures/capt-depfun.scala | 2 +- .../captures/capt-depfun2.scala | 2 +- .../neg-custom-args/captures/capt-test.scala | 6 +- tests/neg-custom-args/captures/capt-wf.scala | 8 +- tests/neg-custom-args/captures/capt1.check | 42 ++--- tests/neg-custom-args/captures/capt1.scala | 12 +- tests/neg-custom-args/captures/capt3.scala | 2 +- .../captures/caseclass/Test_2.scala | 2 +- .../captures/cc-existential-conformance.check | 52 +++---- tests/neg-custom-args/captures/cc-glb.check | 2 +- .../neg-custom-args/captures/cc-poly-2.check | 4 +- .../captures/cc-subst-param-exact.scala | 6 +- tests/neg-custom-args/captures/cc-this.check | 6 +- tests/neg-custom-args/captures/cc-this2.check | 4 +- tests/neg-custom-args/captures/cc-this3.check | 2 +- tests/neg-custom-args/captures/cc-this4.check | 6 +- tests/neg-custom-args/captures/cc-this5.check | 2 +- tests/neg-custom-args/captures/cc1.scala | 2 +- .../captures/check-inferred.check | 6 +- .../captures/check-inferred.scala | 14 +- .../neg-custom-args/captures/class-caps.check | 18 +-- .../captures/class-contra.check | 2 +- .../captures/class-level-attack.check | 10 +- .../captures/class-level-attack.scala | 2 +- .../neg-custom-args/captures/class-uses.check | 2 +- .../captures/classified-inheritance2.check | 6 +- .../captures/classified-inheritance2.scala | 2 +- .../captures/classified-wf.check | 4 +- .../captures/classified-wf.scala | 4 +- .../captures/classifiers-secondclass.check | 18 +-- .../captures/classifiers-secondclass.scala | 2 +- .../captures/closure-result-typing.check | 6 +- .../captures/constructor-uses.check | 6 +- .../captures/consume-in-constructor.check | 10 +- .../captures/consume-in-constructor.scala | 6 +- .../captures/consume-tvar-bound.check | 12 +- .../neg-custom-args/captures/contracap.check | 6 +- tests/neg-custom-args/captures/dcs-tvar.check | 12 +- .../captures/delayedRunops.check | 4 +- .../captures/depfun-reach.check | 22 +-- .../captures/depfun-reach.scala | 4 +- .../captures/effect-swaps-explicit.check | 10 +- .../captures/effect-swaps.check | 10 +- .../captures/exception-definitions.check | 4 +- .../captures/existential-mapping.check | 118 +++++++------- .../captures/extending-cap-classes.check | 4 +- tests/neg-custom-args/captures/filevar.check | 6 +- tests/neg-custom-args/captures/filevar.scala | 2 +- .../captures/freeze-boxes.check | 12 +- .../captures/fresh-counter.scala | 4 +- .../captures/fresh-fields.check | 32 ++-- .../captures/fresh-outside-result.check | 45 ++++++ .../captures/fresh-outside-result.scala | 15 ++ .../captures/gears-problem.check | 4 +- .../captures/heal-tparam-cs.check | 23 ++- tests/neg-custom-args/captures/i15749.scala | 2 +- tests/neg-custom-args/captures/i15772.check | 24 +-- tests/neg-custom-args/captures/i15923.check | 8 +- tests/neg-custom-args/captures/i15923.scala | 4 +- tests/neg-custom-args/captures/i15923a.check | 10 +- tests/neg-custom-args/captures/i15923b.check | 4 +- tests/neg-custom-args/captures/i16114.check | 8 +- tests/neg-custom-args/captures/i16226.check | 36 ++--- tests/neg-custom-args/captures/i18518.scala | 2 +- tests/neg-custom-args/captures/i19330.check | 4 +- tests/neg-custom-args/captures/i19470.check | 2 +- tests/neg-custom-args/captures/i20481.check | 22 ++- tests/neg-custom-args/captures/i21313.check | 2 +- tests/neg-custom-args/captures/i21347.check | 2 +- tests/neg-custom-args/captures/i21401.check | 34 ++-- tests/neg-custom-args/captures/i21614.check | 10 +- tests/neg-custom-args/captures/i21620.check | 4 +- tests/neg-custom-args/captures/i21920.check | 8 +- tests/neg-custom-args/captures/i23207.check | 8 +- tests/neg-custom-args/captures/i23431.check | 30 ++-- tests/neg-custom-args/captures/i23582.check | 6 +- tests/neg-custom-args/captures/i23582.scala | 4 +- tests/neg-custom-args/captures/i23746.check | 8 +- tests/neg-custom-args/captures/i24310.check | 4 +- tests/neg-custom-args/captures/i24335.check | 2 +- tests/neg-custom-args/captures/i24667.check | 4 +- .../neg-custom-args/captures/implied-ro.check | 6 +- .../neg-custom-args/captures/implied-ro.scala | 6 +- .../captures/indirect-avoid.check | 14 +- .../captures/indirect-avoid.scala | 2 +- tests/neg-custom-args/captures/io.scala | 8 +- .../captures/lazyListState.check | 8 +- .../captures/lazylist-global.check | 18 +-- tests/neg-custom-args/captures/lazylist.check | 18 +-- .../captures/lazylists-exceptions.check | 2 +- .../neg-custom-args/captures/lazylists1.check | 6 +- .../neg-custom-args/captures/lazylists2.check | 12 +- tests/neg-custom-args/captures/lazyref.check | 8 +- .../captures/lazyvals-sep.check | 12 +- .../captures/lazyvals-sep.scala | 6 +- tests/neg-custom-args/captures/lazyvals.check | 4 +- .../neg-custom-args/captures/lazyvals2.check | 2 +- .../neg-custom-args/captures/lazyvals3.check | 6 +- .../neg-custom-args/captures/lazyvals4.check | 8 +- .../neg-custom-args/captures/lazyvals5.check | 22 +-- .../neg-custom-args/captures/lazyvals6.check | 22 +-- .../captures/leak-problem-2.check | 2 +- .../captures/leaked-curried.check | 4 +- .../captures/leaking-iterators.check | 4 +- tests/neg-custom-args/captures/leaky.check | 6 +- tests/neg-custom-args/captures/levels.check | 2 +- .../captures/linear-buffer-2.scala | 2 +- .../captures/linear-buffer.check | 10 +- .../captures/linear-buffer.scala | 2 +- .../captures/local-mutables-2.check | 24 +-- .../captures/local-mutables.check | 16 +- .../captures/local-mutables.scala | 4 +- tests/neg-custom-args/captures/lubs.check | 6 +- tests/neg-custom-args/captures/matrix.check | 12 +- tests/neg-custom-args/captures/matrix.scala | 8 +- .../captures/mut-iterator.check | 12 +- .../captures/mut-iterator.scala | 4 +- .../captures/mut-iterator2.check | 8 +- .../captures/mut-iterator3.scala | 4 +- .../captures/mut-iterator4-global.scala | 4 +- .../captures/mut-iterator4.check | 10 +- .../captures/mut-iterator4.scala | 4 +- .../captures/mut-iterator5.check | 6 +- .../captures/mut-iterator5.scala | 2 +- .../captures/mut-widen-empty.check | 20 +-- .../neg-custom-args/captures/mutability.check | 60 ++++--- tests/neg-custom-args/captures/mutvars.check | 48 +++--- .../captures/nested-classes-2.check | 4 +- .../captures/nestedclass.check | 2 +- tests/neg-custom-args/captures/nicolas1.check | 4 +- tests/neg-custom-args/captures/nicolas2.check | 2 +- .../captures/non-local-consume.scala | 2 +- .../captures/object-uses.check | 4 +- .../neg-custom-args/captures/outer-var.check | 16 +- .../captures/path-patmat-should-be-pos.scala | 4 +- .../captures/paths-complex-consume.scala | 2 +- .../captures/paths-derivedcaps-consume.scala | 6 +- tests/neg-custom-args/captures/reaches.check | 116 +++++++------- tests/neg-custom-args/captures/reaches.scala | 5 +- tests/neg-custom-args/captures/reaches2.check | 2 +- .../captures/read-only-use.check | 6 +- tests/neg-custom-args/captures/readOnly.check | 4 +- tests/neg-custom-args/captures/readOnly.scala | 4 +- tests/neg-custom-args/captures/real-try.check | 8 +- .../captures/ref-with-file.check | 22 +-- .../captures/reference-cc.check | 16 +- .../captures/restrict-subsumes.scala | 4 +- .../captures/ro-mut-conformance.check | 18 +-- .../captures/ro-mut-conformance.scala | 10 +- .../captures/scope-extrude-mut.check | 10 +- .../captures/scope-extrusions.check | 110 ++++++------- .../captures/scope-extrusions.scala | 8 +- .../captures/scoped-caps-global.scala | 28 ++-- .../captures/scoped-caps.check | 146 ++++++++++-------- .../captures/scoped-caps.scala | 26 ++-- .../captures/scoped-caps2.check | 91 +++++------ .../captures/scoped-caps2.scala | 13 +- tests/neg-custom-args/captures/sep-box.scala | 2 +- .../captures/sep-compose.check | 8 +- .../captures/sep-compose.scala | 16 +- .../captures/sep-consume.scala | 4 +- .../captures/sep-counter.check | 6 +- .../captures/sep-counter.scala | 2 +- .../captures/sep-curried-par.check | 8 +- .../captures/sep-curried-par.scala | 8 +- .../captures/sep-curried.check | 6 +- tests/neg-custom-args/captures/sep-list.scala | 2 +- .../captures/sep-pairs-2.scala | 2 +- .../captures/sep-pairs-global.scala | 2 +- .../captures/sep-pairs-unboxed.check | 6 +- .../captures/sep-pairs-unboxed.scala | 2 +- .../neg-custom-args/captures/sep-pairs.check | 8 +- .../neg-custom-args/captures/sep-pairs.scala | 2 +- tests/neg-custom-args/captures/sep-use.scala | 2 +- tests/neg-custom-args/captures/sep-use2.check | 54 +++---- tests/neg-custom-args/captures/sep-use2.scala | 15 +- .../neg-custom-args/captures/sepchecks.scala | 8 +- .../neg-custom-args/captures/sepchecks4.scala | 2 +- .../neg-custom-args/captures/sepchecks5.scala | 2 +- .../captures/simple-using.check | 4 +- .../captures/stack-alloc.scala | 2 +- tests/neg-custom-args/captures/try.check | 24 +-- tests/neg-custom-args/captures/try.scala | 4 +- tests/neg-custom-args/captures/try3.scala | 2 +- .../captures/unscoped-classifier-global.scala | 2 +- .../captures/unscoped-classifier.check | 12 +- .../captures/unscoped-classifier.scala | 2 +- .../captures/unsound-reach-4.check | 22 +-- .../captures/unsound-reach-6.check | 4 +- .../captures/unsound-reach.check | 24 +-- .../captures/use-alternatives.scala | 2 +- .../neg-custom-args/captures/use-capset.check | 4 +- tests/neg-custom-args/captures/uses.check | 8 +- .../captures/usingLogFile.check | 48 ++++-- .../captures/usingLogFile.scala | 4 +- .../neg-custom-args/captures/var-access.check | 4 +- .../captures/vars-simple.check | 10 +- tests/neg-custom-args/captures/vars.check | 24 +-- .../captures/widen-reach.check | 26 ++-- tests/neg-custom-args/captures/withFile.check | 38 ++--- tests/new/test.scala | 5 +- tests/patmat/optionless.scala | 4 +- .../captures/boxmap-paper.scala | 6 +- tests/pos-custom-args/captures/byname.scala | 4 +- .../captures/cap-paramlist8-desugared.scala | 10 +- .../captures/cap-paramlists4.scala | 4 +- .../captures/caps-universal.scala | 2 +- .../captures/capt-depfun.scala | 4 +- .../captures/capt-depfun2.scala | 2 +- tests/pos-custom-args/captures/capt0.scala | 2 +- tests/pos-custom-args/captures/capt2.scala | 2 +- .../captures/cc-dep-param.scala | 4 +- .../pos-custom-args/captures/cc-expand.scala | 2 +- .../captures/cc-poly-varargs.scala | 2 +- .../check-override-typebounds-2.scala | 4 +- .../captures/closure-avoidance.scala | 9 +- .../captures/closure-result-typing.scala | 3 +- tests/pos-custom-args/captures/ctest.scala | 3 +- .../pos-custom-args/captures/deep-adapt.scala | 10 +- .../captures/dotty-experimental.scala | 2 +- .../captures/erased-methods.scala | 5 +- .../captures/erased-methods2-shared.scala | 7 +- .../captures/eta-expansions.scala | 4 + .../captures/filter-iterable.scala | 6 +- tests/pos-custom-args/captures/i15749.scala | 4 +- tests/pos-custom-args/captures/i15749a.scala | 10 +- tests/pos-custom-args/captures/i19751.scala | 4 +- .../captures/i20237-explicit.scala | 4 +- tests/pos-custom-args/captures/i20237.scala | 2 +- tests/pos-custom-args/captures/i21868.scala | 2 +- tests/pos-custom-args/captures/i23170.scala | 4 +- tests/pos-custom-args/captures/i24137.scala | 6 +- .../captures/mark-free-ro.scala | 4 +- tests/pos-custom-args/captures/matrix.scala | 8 +- .../captures/mut-iterator.scala | 2 +- .../captures/mutable-capturing-sharable.scala | 2 +- .../captures/mutable-hiding-shared.scala | 2 +- .../pos-custom-args/captures/overrides.scala | 2 +- .../captures/reach-in-results-shared.scala | 12 +- .../captures/reach-in-results.scala | 8 +- tests/pos-custom-args/captures/reaches.scala | 2 +- .../captures/restrict-subsumes.scala | 4 +- tests/pos-custom-args/captures/ro-array.scala | 2 +- .../captures/scoped-caps.scala | 7 +- .../captures/sep-compose.scala | 6 +- tests/pos-custom-args/captures/sep-eq.scala | 8 +- .../pos-custom-args/captures/sep-pairs.scala | 2 +- .../captures/shared-capability.scala | 2 +- tests/pos-custom-args/captures/try.scala | 2 +- .../captures/unsafe-captures.scala | 2 +- .../captures/use-alternatives.scala | 2 +- tests/pos-special/stdlib/Test2.scala | 2 +- tests/pos/caps-universal.scala | 2 +- tests/pos/cc-use-alternatives.scala | 2 +- .../colltest5/CollectionStrawManCC5_1.scala | 16 +- .../captures/colltest5/Test_2.scala | 2 +- .../stdlibExperimentalDefinitions.scala | 7 +- 302 files changed, 1793 insertions(+), 1607 deletions(-) create mode 100644 tests/neg-custom-args/captures/fresh-outside-result.check create mode 100644 tests/neg-custom-args/captures/fresh-outside-result.scala rename tests/{neg-custom-args => pos-custom-args}/captures/closure-avoidance.scala (54%) diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index b8f78dfd9353..34189aee2ec4 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -522,8 +522,8 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] } } - /** Under pureFunctions: A builder and extractor for `=> T`, which is an alias for `->{cap} T`. - * Only trees of the form `=> T` are matched; trees written directly as `->{cap} T` + /** Under pureFunctions: A builder and extractor for `=> T`, which is an alias for `->{any} T`. + * Only trees of the form `=> T` are matched; trees written directly as `->{any} T` * are ignored by the extractor. */ object ImpureByNameTypeTree: @@ -535,7 +535,7 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] def unapply(tp: Tree)(using Context): Option[Tree] = tp match case untpd.ByNameTypeTree( - untpd.CapturesAndResult(id @ Select(_, nme.CAPTURE_ROOT) :: Nil, result)) + untpd.CapturesAndResult(id @ Select(_, nme.any) :: Nil, result)) if id.span == result.span.startPos => Some(result) case _ => None end ImpureByNameTypeTree diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala index b6cd126bab57..12e1c597e522 100644 --- a/compiler/src/dotty/tools/dotc/ast/untpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala @@ -534,7 +534,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { Select(Select(scalaDot(nme.caps), nme.internal), name) def captureRoot(using Context): Select = - Select(scalaDot(nme.caps), nme.CAPTURE_ROOT) + Select(scalaDot(nme.caps), nme.any) def makeRetaining(parent: Tree, refs: List[Tree], annotName: TypeName)(using Context): Annotated = var annot: Tree = scalaAnnotationDot(annotName) diff --git a/compiler/src/dotty/tools/dotc/cc/CCState.scala b/compiler/src/dotty/tools/dotc/cc/CCState.scala index a0accb8c5653..12af5d2fdf6a 100644 --- a/compiler/src/dotty/tools/dotc/cc/CCState.scala +++ b/compiler/src/dotty/tools/dotc/cc/CCState.scala @@ -88,7 +88,7 @@ class CCState: private var openExistentialScopes: List[MethodType] = Nil - private var globalAnyIsRoot: Boolean = false + private var globalCapIsRoot: Boolean = false private var collapseLocalCaps: Boolean = false @@ -119,16 +119,16 @@ object CCState: inline def withGlobalCapAsRoot[T](op: => T)(using Context): T = if isCaptureCheckingOrSetup then val ccs = ccState - val saved = ccs.globalAnyIsRoot - ccs.globalAnyIsRoot = true - try op finally ccs.globalAnyIsRoot = saved + val saved = ccs.globalCapIsRoot + ccs.globalCapIsRoot = true + try op finally ccs.globalCapIsRoot = saved else op - /** Is `caps.cap` a root capability that is allowed to subsume other capabilities? */ - def globalAnyIsRoot(using Context): Boolean = ccState.globalAnyIsRoot + /** Is `caps.any` a root capability that is allowed to subsume other capabilities? */ + def globalCapIsRoot(using Context): Boolean = ccState.globalCapIsRoot /** Run `op` under the assumption that all LocalCap instances are equal - * to each other and to GlobalCap. + * to each other and to GlobalAny. * Needed to make override checking work for types containing LocalCaps. * Asserted in override checking, tested in maxSubsumes. * Is this sound? Test case is neg-custom-args/captures/leaked-curried.scala. @@ -141,7 +141,7 @@ object CCState: try op finally ccs.collapseLocalCaps = saved else op - /** Should all LocalCap instances be treated as equal to GlobalCap? */ + /** Should all LocalCap instances be treated as equal to GlobalAny? */ def collapseLocalCaps(using Context): Boolean = ccState.collapseLocalCaps /** Run `op` but suppress all recording of uses in `markFree` */ diff --git a/compiler/src/dotty/tools/dotc/cc/Capability.scala b/compiler/src/dotty/tools/dotc/cc/Capability.scala index f8f1ae3379b7..92d8b3d2c999 100644 --- a/compiler/src/dotty/tools/dotc/cc/Capability.scala +++ b/compiler/src/dotty/tools/dotc/cc/Capability.scala @@ -125,12 +125,11 @@ object Capabilities: */ case class Reach(underlying: ObjectCapability) extends DerivedCapability - /** The global root capability referenced as `caps.any`. It does not subsume - * other capabilities, except in arguments of `withCapAsRoot` calls. + /** A class for the global root capabilities referenced as `caps.any` and `caps.fresh`. + * They do not subsume other capabilities, except in arguments of `withCapAsRoot` calls. */ - @sharable // We override below all operations that access internal capability state - object GlobalCap extends RootCapability: - def descr(using Context) = "the universal root capability" + class GlobalCap(val fullName: String) extends RootCapability: + def descr(using Context) = s"the root capability $fullName" override val maybe = Maybe(this) override val readOnly = ReadOnly(this) override def restrict(cls: ClassSymbol)(using Context) = Restricted(this, cls) @@ -140,7 +139,15 @@ object Capabilities: override def cached[C <: DerivedCapability](newRef: C): C = unsupported("cached") override def invalidateCaches() = () - /** The class of local roots named "any". These do subsume other capabilities in scope. + /** The global root capability referenced as `caps.any` */ + @sharable // We override in GlobalCap all operations that access internal capability state + object GlobalAny extends GlobalCap("caps.any") + + /** The global root capability referenced as `caps.fresh` */ + @sharable // We override in GlobalCap all operations that access internal capability state + object GlobalFresh extends GlobalCap("caps.fresh") + + /** The class of local roots named "any". These do subsume other capabilties in scope. * They track with hidden sets which other capabilities were subsumed. * Hidden sets are inspected by separation checking. * @param owner the owner of the context in which the LocalCap was created @@ -257,7 +264,7 @@ object Capabilities: */ case class ResultCap(binder: MethodicType) extends RootCapability: - private var myOrigin: RootCapability = GlobalCap + private var myOrigin: RootCapability = GlobalAny private var variants: SimpleIdentitySet[ResultCap] = SimpleIdentitySet.empty /** Every ResultCap capability has an origin. This is @@ -266,7 +273,7 @@ object Capabilities: * - Another ResultCap capability `r`, if the current capability was created * via a chain of `derivedResult` calls from an original ResultCap `r` * (which was not created using `derivedResult`). - * - GlobalCap otherwise + * - GlobalAny otherwise */ def origin: RootCapability = myOrigin @@ -274,8 +281,8 @@ object Capabilities: * if separation checks are turned off). * @pre The capability's origin was not yet set. */ - def setOrigin(localCapOrigin: LocalCap | GlobalCap.type): this.type = - assert(myOrigin eq GlobalCap) + def setOrigin(localCapOrigin: LocalCap | GlobalCap): this.type = + assert(myOrigin.isInstanceOf[GlobalCap]) myOrigin = localCapOrigin this @@ -418,11 +425,6 @@ object Capabilities: case Maybe(ref1) => ref1.stripReach.maybe case _ => this - /** Is this reference the global root capability `caps.any` or a LocalCap instance? */ - final def isGlobalOrLocalCap(using Context): Boolean = this match - case GlobalCap | _: LocalCap => true - case _ => false - /** Is this reference a root capability or a derived version of one? * These capabilities have themselves as their captureSetOfInfo. */ @@ -514,7 +516,7 @@ object Capabilities: final def pathOwner(using Context): Symbol = pathRoot match case tp1: ThisType => tp1.cls case tp1: NamedType => tp1.symbol.owner - case GlobalCap => defn.CapsModule.moduleClass + case _: GlobalCap => defn.CapsModule.moduleClass case tp1: LocalCap => tp1.ccOwner case _ => NoSymbol @@ -829,14 +831,14 @@ object Capabilities: y match case y: ResultCap => vs.unify(x, y) case _ => y.derivesFromShared - case GlobalCap => + case _: GlobalCap => y match - case GlobalCap => true + case _: GlobalCap => this eq y case _: ResultCap => false case _: LocalCap if CCState.collapseLocalCaps => true case _ => y.derivesFromShared - || canAddHidden && vs != VarState.HardSeparate && CCState.globalAnyIsRoot + || canAddHidden && vs != VarState.HardSeparate && CCState.globalCapIsRoot case Restricted(x1, cls) => y.isKnownClassifiedAs(cls) && x1.maxSubsumes(y, canAddHidden) case _ => @@ -924,7 +926,7 @@ object Capabilities: * and should only be used for printing or phases not related to CC. */ def toType(using Context): Type = this match - case c: RootCapability => defn.captureRoot.termRef + case c: RootCapability => defn.Caps_any.termRef case c: CoreCapability => c case c: DerivedCapability => val c1 = c.underlying.toType @@ -1047,7 +1049,7 @@ object Capabilities: /** Map each occurrence of `caps.any` to a different LocalCap instance * Exception: CapSet^ stays as it is. */ - class GlobalToLocalCap(origin: Origin)(using Context) extends BiTypeMap, FollowAliasesMap: + class GlobalCapToLocal(origin: Origin)(using Context) extends BiTypeMap, FollowAliasesMap: thisMap => override def apply(t: Type) = @@ -1062,13 +1064,15 @@ object Capabilities: mapOver(CapturingType(this(parent), ann.toCaptureSet)) case t @ AnnotatedType(parent, ann) => t.derivedAnnotatedType(this(parent), ann) - case defn.RefinedFunctionOf(_) => - t // stop at dependent function types + case t @ defn.RefinedFunctionOf(mt) => + if ccConfig.newScheme + then t.derivedRefinedType(refinedInfo = mapOver(mt)) + else t case _ => mapFollowingAliases(t) override def mapCapability(c: Capability, deep: Boolean): Capability = c match - case GlobalCap => LocalCap(origin) + case GlobalAny => LocalCap(origin) case _ => super.mapCapability(c, deep) override def fuse(next: BiTypeMap)(using Context) = next match @@ -1083,7 +1087,7 @@ object Capabilities: case _ => mapFollowingAliases(t) override def mapCapability(c: Capability, deep: Boolean): Capability = c match - case _: LocalCap => GlobalCap + case _: LocalCap => GlobalAny case _ => super.mapCapability(c, deep) def inverse = thisMap @@ -1091,7 +1095,7 @@ object Capabilities: lazy val inverse = Inverse() - end GlobalToLocalCap + end GlobalCapToLocal /** Maps caps.any to LocalCap instances. GlobalToLocalCap is a BiTypeMap since we don't want to * freeze a set when it is mapped. On the other hand, we do not want LocalCap @@ -1099,13 +1103,13 @@ object Capabilities: * tests elsewhere. We therefore use `withoutMappedFutureElems` to prevent * the map being installed for future use. */ - def globalToLocalCap(tp: Type, origin: Origin)(using Context): Type = + def globalCapToLocal(tp: Type, origin: Origin)(using Context): Type = ccState.withoutMappedFutureElems: - GlobalToLocalCap(origin)(tp) + GlobalCapToLocal(origin)(tp) /** Maps all LocalCap instances to caps.any */ def localCapToGlobal(param: Symbol, tp: Type)(using Context): Type = - GlobalToLocalCap(Origin.Parameter(param)).inverse(tp) + GlobalCapToLocal(Origin.Parameter(param)).inverse(tp) /** The local dual of a result type of a closure type. * @param binder the method type of the anonymous function whose result is mapped @@ -1173,7 +1177,7 @@ object Capabilities: /** Map top-level free ResultCaps one-to-one to LocalCap instances */ def resultToAny(tp: Type, origin: Origin)(using Context): Type = val subst = new TypeMap: - val seen = EqHashMap[ResultCap, LocalCap | GlobalCap.type]() + val seen = EqHashMap[ResultCap, LocalCap | GlobalCap]() var localBinders: SimpleIdentitySet[MethodType] = SimpleIdentitySet.empty def apply(t: Type): Type = t match @@ -1217,7 +1221,7 @@ object Capabilities: class ToResult(localResType: Type, mt: MethodicType, sym: Symbol, fail: Message => Unit)(using Context) extends CapMap: def apply(t: Type) = t match - case defn.FunctionNOf(args, res, contextual) if t.typeSymbol.name.isImpureFunction => + case defn.FunctionNOf(args, res, contextual) if t.typeSymbol.name.isImpureFunction && !(ccConfig.newScheme) => if variance > 0 then super.mapOver: defn.FunctionNOf(args, res, contextual) @@ -1227,17 +1231,22 @@ object Capabilities: mapOver(t) override def mapCapability(c: Capability, deep: Boolean) = c match - case c: (LocalCap | GlobalCap.type) => + case c: (LocalCap | GlobalCap) => if variance > 0 then c match case c: LocalCap => - if sym.isAnonymousFunction && c.classifier.derivesFrom(defn.Caps_Unscoped) - then c - else ResultCap(mt).setOrigin(c) - case _ => ResultCap(mt) + if sym.isAnonymousFunction && c.classifier.derivesFrom(defn.Caps_Unscoped) then + c + else if sym.exists && !c.ccOwner.isContainedIn(sym.skipAnonymousOwners) then + //println(i"not mapping $c with ${c.ccOwner} in $sym") + c + else + ResultCap(mt).setOrigin(c) + case _ => + if c == GlobalFresh || !(ccConfig.newScheme) then ResultCap(mt) else c else if variance == 0 then - fail(em"""$localResType captures the root capability `cap` in invariant position. + fail(em"""$localResType captures the root capability `any` in invariant position. |This capability cannot be converted to an existential in the result type of a function.""") // we accept variance < 0, and leave the `any` as it is c @@ -1254,7 +1263,7 @@ object Capabilities: case c @ ResultCap(`mt`) => val primary = c.primaryResultCap primary.origin match - case GlobalCap => + case _: GlobalCap => val localCap = LocalCap(Origin.LocalInstance(mt.resType)) primary.setOrigin(localCap) localCap @@ -1284,8 +1293,14 @@ object Capabilities: case rt @ defn.RefinedFunctionOf(mt) => rt.derivedRefinedType(refinedInfo = if rt.isInstanceOf[InferredRefinedType] - then mapOver(mt) + then mapOver(mt) // Don't map to Result for dependent function types created from non-dependent ones in inferred types else apply(mt)) + case t @ AppliedType(tycon, args) + if defn.isNonRefinedFunction(t) && args.last.containsFresh && ccConfig.newScheme => + // Convert to dependent function so that we have a binder for `fresh` in result type. + apply( + depFun(args.init, args.last, + isContextual = defn.isContextFunctionClass(tycon.classSymbol))) case t: MethodType if variance > 0 && t.marksExistentialScope => val t1 = mapOver(t).asInstanceOf[MethodType] t1.derivedLambdaType(resType = toResult(t1.resType, t1, sym, fail)) diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala index b4c6bb4e8247..861ae1e027a7 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala @@ -58,7 +58,7 @@ extension (tree: Tree) case Apply(TypeApply(_, refs :: Nil), _) => refs.tpe case _ => if tree.symbol.maybeOwner == defn.RetainsCapAnnot - then defn.captureRoot.termRef + then defn.Caps_any.termRef else NoType extension (tp: Type) @@ -71,7 +71,9 @@ extension (tp: Type) case OnlyCapability(tp1, cls) => tp1.toCapability.restrict(cls) case ref: TermRef if ref.isCapsAnyRef => - GlobalCap + GlobalAny + case ref: TermRef if ref.isCapsFreshRef => + GlobalFresh case ref: Capability if ref.isTrackableRef => ref case ref: TermRef if ref.isLocalMutable => @@ -117,7 +119,7 @@ extension (tp: Type) !tp.underlying.exists // might happen during construction of lambdas with annotations on parameters || ((tp.prefix eq NoPrefix) - || tp.symbol.isField && tp.prefix.isTrackableRef + || tp.symbol.isField && tp.prefix.isPrefixOfTrackableRef ) && !tp.symbol.isOneOf(UnstableValueFlags) case tp: TypeRef => tp.symbol.isType && tp.derivesFrom(defn.Caps_CapSet) @@ -127,6 +129,11 @@ extension (tp: Type) case _ => false + private def isPrefixOfTrackableRef(using Context): Boolean = + isTrackableRef || tp.match + case tp: TermRef => tp.symbol.is(Package) + case _ => false + /** The capture set of a type. This is: * - For object capabilities: The singleton capture set consisting of * just the reference, provided the underlying capture set of their info is not empty. @@ -343,9 +350,14 @@ extension (tp: Type) case _ => false - /** Is this a reference to caps.any? Note this is _not_ the GlobalCap capability. */ + /** Is this a reference to caps.any? Note this is _not_ the GlobalAny capability. */ def isCapsAnyRef(using Context): Boolean = tp match - case tp: TermRef => tp.name == nme.CAPTURE_ROOT && tp.symbol == defn.captureRoot + case tp: TermRef => tp.name == nme.any && tp.symbol == defn.Caps_any + case _ => false + + /** Is this a reference to caps.any? Note this is _not_ the GlobalFresh capability. */ + def isCapsFreshRef(using Context): Boolean = tp match + case tp: TermRef => tp.name == nme.fresh && tp.symbol == defn.Caps_fresh case _ => false /** Knowing that `tp` is a function type, is it an alias to a function other @@ -490,6 +502,19 @@ extension (tp: Type) if tp.isArrayUnderStrictMut then defn.Caps_Unscoped else tp.classSymbols.map(_.classifier).foldLeft(defn.AnyClass)(leastClassifier) + /** Does `tp` contain a `fresh` directly, which is not in the result of some function type? + */ + def containsFresh(using Context): Boolean = + val search = new TypeAccumulator[Boolean]: + def apply(x: Boolean, tp: Type): Boolean = + if x then true + else if defn.isFunctionType(tp) then false + else tp match + case CapturingType(parent, refs) => + refs.elems.exists(_.core == GlobalFresh) || apply(x, parent) + case _ => foldOver(x, tp) + search(false, tp) + extension (tp: MethodType) /** A method marks an existential scope unless it is the prefix of a curried method */ def marksExistentialScope(using Context): Boolean = @@ -684,6 +709,10 @@ extension (sym: Symbol) info = defn.Caps_Var.typeRef.appliedTo(sym.info) .capturing(LocalCap(sym, Origin.InDecl(sym))))) + def skipAnonymousOwners(using Context): Symbol = + if sym.isAnonymousFunction then sym.owner.skipAnonymousOwners + else sym + extension (tp: AnnotatedType) /** Is this a boxed capturing type? */ def isBoxed(using Context): Boolean = tp.annot match diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala index 4dff4a8019ef..67502f119d4c 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala @@ -120,9 +120,11 @@ sealed abstract class CaptureSet extends Showable: /** Does this capture set contain the root reference `caps.any` as element? */ final def isUniversal(using Context) = - elems.contains(GlobalCap) + elems.contains(GlobalAny) - /** Does this capture set contain a root reference `cap` or `cap.rd` as element? */ + /** Does this capture set contain a root capability `any` or `fresh` or + * a derived instance thereof as element? + */ final def containsTerminalCapability(using Context) = elems.exists(_.isTerminalCapability) @@ -137,12 +139,12 @@ sealed abstract class CaptureSet extends Showable: !containsResultCapability && elems.exists: elem => elem.core match - case GlobalCap => true + case _: GlobalCap => true case _: LocalCap => true case _ => false final def containsGlobalCapDerivs(using Context) = - elems.exists(_.core eq GlobalCap) + elems.exists(_.core.isInstanceOf[GlobalCap]) final def isReadOnly(using Context): Boolean = elems.forall(_.isReadOnly) @@ -262,7 +264,8 @@ sealed abstract class CaptureSet extends Showable: !x.isTerminalCapability && !x.coreType.derivesFrom(defn.Caps_CapSet) && !(vs.isSeparating && x.captureSetOfInfo.containsTerminalCapability) - // in VarState.Separate, don't try to widen to cap since that might succeed with {cap} <: {cap} + // in VarState.Separate, don't try to widen to `any` since that might succeed with {any} <: {any} + // and might therefore insert an element that is too unspecific. && x.captureSetOfInfo.subCaptures(this, VarState.Separate) comparer match @@ -275,7 +278,7 @@ sealed abstract class CaptureSet extends Showable: * for `x` in a state where we assume all supersets of `x` have just the elements * known at this point. On the other hand if x's capture set has no known elements, * a set `cs` might account for `x` only if it subsumes `x` or it contains the - * root capability `cap`. + * root capability `any`. */ def mightAccountFor(x: Capability)(using Context): Boolean = reporting.trace(i"$this mightAccountFor $x, ${x.captureSetOfInfo}?", show = true): @@ -312,7 +315,11 @@ sealed abstract class CaptureSet extends Showable: capt.println(i"WIDEN ro $this with ${this.mutability} <:< $that with ${that.mutability} to $this1") this1.subCaptures(that, vs) else - that.tryInclude(elems, this) && addDependent(that) + try + that.tryInclude(elems, this) && addDependent(that) + catch case ex: AssertionError => + println(i"err while subcap $this <:< $that") + throw ex /** Two capture sets are considered =:= equal if they mutually subcapture each other * in a frozen state. @@ -475,20 +482,21 @@ sealed abstract class CaptureSet extends Showable: /** A bad root `elem` is inadmissible as a member of this set. What is a bad roots depends * on the value of `rootLimit`. * If the limit is null, all capture roots are good. - * If the limit is NoSymbol, all Fresh roots are good, but cap and Result roots are bad. - * If the limit is some other symbol, cap and Result roots are bad, as well as - * all Fresh roots that are contained (via ccOwner) in `rootLimit`. + * If the limit is NoSymbol, all local roots are good, but + * `caps.any`, `caps.fresh` and Result roots are bad. + * If the limit is some other symbol, global and result roots are bad, as well as + * all local roots that are contained (via ccOwner) in `rootLimit`. */ protected def isBadRoot(rootLimit: Symbol | Null, elem: Capability)(using Context): Boolean = if rootLimit == null then false else elem.core match - case GlobalCap | _: ResultCap => true + case _: GlobalCap | _: ResultCap => true case elem: LocalCap => elem.ccOwner.isContainedIn(rootLimit) case _ => false /** Invoke `handler` if this set has (or later aquires) a bad root capability. - * Fresh instances count as good as long as their ccOwner is outside `upto`. - * If `upto` is NoSymbol, all Fresh instances are admitted. + * Local roots count as good as long as their ccOwner is outside `upto`. + * If `upto` is NoSymbol, all local roots are admitted. */ def disallowBadRoots(upto: Symbol)(handler: () => Context ?=> Unit)(using Context): Unit = checkAddedElems: elem => @@ -584,13 +592,13 @@ object CaptureSet: class EmptyOfBoxed(val tp1: Type, val tp2: Type) extends Const(emptyRefs): override def toString = "{} of boxed mismatch" - /** The universal capture set `{cap}` */ + /** The universal capture set `{caps.any}` */ def universal(using Context): Const = - Const(SimpleIdentitySet(GlobalCap)) + Const(SimpleIdentitySet(GlobalAny)) - /** The shared capture set `{cap.rd}` */ + /** The shared capture set `{caps.any.rd}` */ def shared(using Context): Const = - GlobalCap.readOnly.singletonCaptureSet + GlobalAny.readOnly.singletonCaptureSet /** Used as a recursion brake */ @sharable private[dotc] val Pending = Const(SimpleIdentitySet.empty) @@ -671,10 +679,10 @@ object CaptureSet: && variance >= 0 && sym.isContainedIn(defn.ScalaPackageClass) if parent.derivesFromStateful && !isArrayFromScalaPackage - then GlobalCap.readOnly - else GlobalCap + then GlobalAny.readOnly + else GlobalAny - /* The same as {cap} but generated implicitly for references of Capability subtypes. + /* The same as {caps.any} but generated implicitly for references of Capability subtypes. * @param parent the type to which the capture set will be attached * @param sym the symbol carrying that type * @param variance the variance in which `parent` appears in the type of `sym` @@ -884,7 +892,7 @@ object CaptureSet: def levelOK(elem: Capability)(using Context): Boolean = elem match case elem @ ResultCap(binder) => rootLimit == null && isPartOf(binder.resType) - case GlobalCap => + case _: GlobalCap => rootLimit == null case elem: ParamRef => isPartOf(elem.binder.resType) @@ -913,7 +921,7 @@ object CaptureSet: /** Roughly: the intersection of all constant known supersets of this set. * The aim is to find an as-good-as-possible constant set that is a superset - * of this set. The universal set {cap} is a sound fallback. + * of this set. The universal set {caps.any} is a sound fallback. */ final def upperApprox(origin: CaptureSet)(using Context): CaptureSet = if isConst then @@ -929,7 +937,7 @@ object CaptureSet: if approx.elems.exists(_.isInstanceOf[ResultCap]) then ccState.approxWarnings += em"""Capture set variable $this gets upper-approximated - |to existential variable from $approx, using {cap} instead.""" + |to existential variable from $approx, using {any} instead.""" universal else approx finally computingApprox = false @@ -945,7 +953,7 @@ object CaptureSet: def solve()(using Context): Unit = CCState.withGlobalCapAsRoot: // OK here since we infer parameter types that get checked later val approx = upperApprox(empty) - .map(GlobalToLocalCap(Origin.Unknown).inverse) // Fresh --> cap + .map(GlobalCapToLocal(Origin.Unknown).inverse) // local -> global .showing(i"solve $this = $result", capt) //println(i"solving var $this $approx ${approx.isConst} deps = ${deps.toList}") val newElems = approx.elems -- elems @@ -1249,14 +1257,14 @@ object CaptureSet: def elemIntersection(cs1: CaptureSet, cs2: CaptureSet)(using Context): Refs = cs1.elems.filter(cs2.accountsFor) ++ cs2.elems.filter(cs1.accountsFor) - /** A capture set variable used to record the references hidden by a Fresh instance, + /** A capture set variable used to record the references hidden by a local root, * The elems and deps members are repurposed as follows: * elems: Set of hidden references - * deps : Set of hidden sets for which the Fresh instance owning this set + * deps : Set of hidden sets for which the local root owning this set * is a hidden element. * Hidden sets may become aliases of other hidden sets, which means that * reads and writes of elems go to the alias. - * If H is an alias of R.hidden for some Fresh instance R then: + * If H is an alias of R.hidden for some local root R then: * H.elems == {R} * H.deps = {R.hidden} * This encoding was chosen because it relies only on the elems and deps fields @@ -1338,7 +1346,8 @@ object CaptureSet: trait IdentityCaptRefMap extends TypeMap /** Failure indicating that `elem` cannot be included in `cs` */ - case class IncludeFailure(cs: CaptureSet, elem: Capability, levelError: Boolean = false) extends Note, Showable: + case class IncludeFailure(cs: CaptureSet, elem: Capability, levelError: Boolean = false) + extends Note, Showable: private var myTrace: List[CaptureSet] = cs :: Nil def trace: List[CaptureSet] = myTrace @@ -1347,6 +1356,9 @@ object CaptureSet: res.myTrace = cs1 :: this.myTrace res + //assert(elem != GlobalFresh) + //assert(!cs.elems.contains(GlobalFresh)) + override def showAsPrefix(using Context) = cs match case cs: Var => !cs.levelOK(elem) @@ -1390,23 +1402,23 @@ object CaptureSet: case ref: TermRef => i"${ref.symbol.maybeOwner.qualString("defined in")} outlives its scope:\n" case _ => " outlives its scope: " leading: - i"""Capability ${elem.showAsCapability}${outlivesStr}it leaks into outer capture set $cs$ownerStr""" + i"""Capability `${elem.showAsCapability}`${outlivesStr}it leaks into outer capture set $cs$ownerStr""" else if !elem.tryClassifyAs(cs.classifier) then trailing: - i"""capability ${elem.showAsCapability} is not classified as ${cs.classifier}, therefore it + i"""capability `${elem.showAsCapability}` is not classified as ${cs.classifier}, therefore it |cannot be included in capture set $cs of ${cs.classifier.name} elements""" else if cs.isBadRoot(elem) then elem match case elem: LocalCap => leading: - i"""Local capability ${elem.showAsCapability} created in ${elem.ccOwner} outlives its scope: + i"""Local capability `${elem.showAsCapability}` created in ${elem.ccOwner} outlives its scope: |It leaks into outer capture set $cs$ownerStr""" case _ => trailing: - i"universal capability ${elem.showAsCapability} cannot be included in capture set $cs" + i"universal capability `${elem.showAsCapability}` cannot be included in capture set $cs" else trailing: - i"capability ${elem.showAsCapability} cannot be included in capture set $cs" + i"capability `${elem.showAsCapability}` cannot be included in capture set $cs" case cs: EmptyOfBoxed => trailing: val (boxed, unboxed) = @@ -1418,15 +1430,17 @@ object CaptureSet: case c: LocalCap if !c.acceptsLevelOf(elem) => i"$elem${elem.levelOwner.qualString("in")} is not visible from $c${c.ccOwner.qualString("in")}" case c: LocalCap if !elem.tryClassifyAs(c.hiddenSet.classifier) => - i"$c is classified as ${c.hiddenSet.classifier} but ${elem.showAsCapability} is not" + i"`$c` is classified as ${c.hiddenSet.classifier} but `${elem.showAsCapability}` is not" case c: ResultCap if !c.subsumes(elem) => val toAdd = if elem.isTerminalCapability then "" else " since that capability is not a SharedCapability" - i"$c, which is existentially bound in ${c.originalBinder.resType}, cannot subsume ${elem.showAsCapability}$toAdd" + i"`$c`, which is existentially bound in ${c.originalBinder.resType}, cannot subsume `${elem.showAsCapability}`$toAdd" if reasons.isEmpty then "" else reasons.mkString("\nbecause ", "\nand ", "") trailing: - i"capability ${elem.showAsCapability} is not included in capture set $cs$why" + i"capability `${elem.showAsCapability}` is not included in capture set $cs$why" + + override def mentions = cs.elems + elem override def toText(printer: Printer): Text = inContext(printer.printerContext): @@ -1444,7 +1458,7 @@ object CaptureSet: * @param lo the lower type of the orginal type comparison, or NoType if not known * @param hi the upper type of the orginal type comparison, or NoType if not known */ - case class MutAdaptFailure(cs: CaptureSet, lo: Type = NoType, hi: Type = NoType) extends Note: + case class MutAdaptFailure(cs: CaptureSet, lo: Type = NoType, hi: Type = NoType) extends Note { def render(using Context): String = def ofType(tp: Type) = if tp.exists then i"of the stateful type $tp" else "of a stateful type" @@ -1456,7 +1470,9 @@ object CaptureSet: // Show only one failure of this kind override def covers(other: Note)(using Context) = other.isInstanceOf[MutAdaptFailure] - end MutAdaptFailure + + override def mentions = cs.elems + } /** A VarState serves as a snapshot mechanism that can undo * additions of elements or super sets if an operation fails @@ -1529,7 +1545,7 @@ object CaptureSet: /** A class for states that do not allow to record elements or dependent sets. * In effect this means that no new elements or dependent sets can be added * in these states (since the previous state cannot be recorded in a snapshot) - * On the other hand, these states do allow by default Fresh instances to + * On the other hand, these states do allow by default local roots to * subsume arbitary types, which are then recorded in their hidden sets. */ class Closed extends VarState: @@ -1537,8 +1553,8 @@ object CaptureSet: override def isOpen = false override def toString = "closed varState" - /** A closed state that allows a Fresh instance to subsume a - * reference `r` only if `r` is already present in the hidden set of the instance. + /** A closed state that allows a local root to subsume a reference `r` + * only if `r` is already present in the hidden set of the instance. * No new references can be added. */ class Separating extends Closed: @@ -1546,13 +1562,10 @@ object CaptureSet: override def toString = "separating varState" override def isSeparating = true - /** A closed state that allows a Fresh instance to subsume a - * reference `r` only if `r` is already present in the hidden set of the instance. - * No new references can be added. - */ + /** The default Separating state */ def Separate(using Context): Separating = ccState.Separate - /** Like Separate but in addition we assume that `cap` never subsumes anything else. + /** Like Separate but in addition we assume that `any` never subsumes anything else. * Used in `++` to not lose track of dependencies between function parameters. */ def HardSeparate(using Context): Separating = ccState.HardSeparate @@ -1667,8 +1680,8 @@ object CaptureSet: case c: RootCapability => c.singletonCaptureSet case c: ParamRef if !c.underlying.exists => - // might happen during construction of lambdas, assume `{cap}` in this case so that - // `ref` will not seem subsumed by other capabilities in a `++`. + // might happen during construction of lambdas, assume `{caps.any}` in this case, + // so that `ref` will not seem subsumed by other capabilities in a `++`. universal case c: TermRef if isAssumedPure(c.symbol) => CaptureSet.empty @@ -1715,7 +1728,7 @@ object CaptureSet: //.showing(i"capture set of $tp = $result", captDebug) /** The deep capture set of a type is the union of all covariant occurrences of - * capture sets. Nested existential sets are approximated with `cap`. + * capture sets. Nested existential sets are approximated with `any`. */ def ofTypeDeeply(tp: Type, includeTypevars: Boolean = false, includeBoxed: Boolean = true)(using Context): CaptureSet = { val collect = new DeepTypeAccumulator[CaptureSet]: diff --git a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala index 1d47d4756896..ff233f771a6c 100644 --- a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala +++ b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala @@ -114,12 +114,12 @@ object CheckCaptures: if refSym.isType && !refSym.info.derivesFrom(defn.Caps_CapSet) then report.error(em"$elem is not a legal element of a capture set", ann.srcPos) case ref: CoreCapability => - if !ref.isTrackableRef && !ref.isCapsAnyRef && !ref.isLocalMutable then + if !ref.isTrackableRef && !ref.isLocalMutable then report.error(em"$elem cannot be tracked since it is not a parameter or local value", ann.srcPos) case ReachCapability(ref) => check(ref) - if ref.isCapsAnyRef then - report.error(em"Cannot form a reach capability from `cap`", ann.srcPos) + if ref.isCapsAnyRef || ref.isCapsFreshRef then + report.error(em"Cannot form a reach capability from `${ref.termSymbol.name}`", ann.srcPos) case ReadOnlyCapability(ref) => check(ref) case OnlyCapability(ref, cls) => @@ -177,7 +177,7 @@ object CheckCaptures: showInOpenedResultBinders(openScopes.reverse) report.error( em"""$what cannot $have $tp since - |${part}that type captures the root capability `cap`.$addendum""", + |${part}that type captures the root capability `any`.$addendum""", pos) traverse(parent) case defn.RefinedFunctionOf(mt) => @@ -215,7 +215,7 @@ object CheckCaptures: def hasNuType: Boolean /** Is this tree passed to a parameter or assigned to a value with a type - * that contains cap in no-flip covariant position, which will necessite + * that contains `any` in no-flip covariant position, which will necessite * a separation check? */ def needsSepCheck: Boolean @@ -453,8 +453,10 @@ class CheckCaptures extends Recheck, SymTransformer: provenance: => String = "", cs1description: String = "")(using Context) = checkOK( TypeComparer.compareResult(cs1.subCaptures(cs2)), - if cs1.elems.size == 1 then i"reference ${cs1.elems.nth(0)}$cs1description is not" - else i"references $cs1$cs1description are not all", + if cs1.elems.size == 1 then + i"reference `${cs1.elems.nth(0).showAsCapability}`$cs1description is not" + else + i"references $cs1$cs1description are not all", cs1, cs2, pos, provenance) /** If `sym` is a method or a non-static inner class, a capture set variable @@ -534,7 +536,7 @@ class CheckCaptures extends Recheck, SymTransformer: } /** Avoid locally defined capability by charging the underlying type - * (which may not be cap). This scheme applies only under the deferredReaches setting. + * (which may not be `any`). This scheme applies only under the deferredReaches setting. */ def avoidLocalCapability(c: Capability, env: Env, lastEnv: Env | Null): Unit = if c.isParamPath then @@ -554,7 +556,7 @@ class CheckCaptures extends Recheck, SymTransformer: CaptureSet.ofType(c1.widen, followResult = ccConfig.useSpanCapset) capt.println(i"Widen reach $c to $underlying in ${env.owner}") underlying.disallowBadRoots(NoSymbol): () => - report.error(em"Local capability $c${env.owner.qualString("in")} cannot have `cap` as underlying capture set", tree.srcPos) + report.error(em"Local capability `${c.showAsCapability}`${env.owner.qualString("in")} cannot have `any` as underlying capture set", tree.srcPos) recur(underlying, env, lastEnv) /** Avoid locally defined capability if it is a reach capability or capture set @@ -565,12 +567,12 @@ class CheckCaptures extends Recheck, SymTransformer: // Parameter reaches are rejected in checkEscapingUses. // When a reach capabilty x* where `x` is not a parameter goes out // of scope, we need to continue with `x`'s underlying deep capture set. - // It is an error if that set contains cap. + // It is an error if that set contains `any`. // The same is not an issue for normal capabilities since in a local // definition `val x = e`, the capabilities of `e` have already been charged. // Note: It's not true that the underlying capture set of a reach capability - // is always cap. Reach capabilities over paths depend on the prefix, which - // might turn a cap into something else. + // is always `any`. Reach capabilities over paths depend on the prefix, which + // might turn an `any` into something else. // The path-use.scala neg test contains an example. val underlying = CaptureSet.ofTypeDeeply(c1.widen) capt.println(i"Widen reach $c to $underlying in ${env.owner}") @@ -584,7 +586,7 @@ class CheckCaptures extends Recheck, SymTransformer: included.checkAddedElems: elem => if elem.isExclusive() then report.error( - em"""Read-only $meth accesses exclusive capability $elem; + em"""Read-only $meth accesses exclusive capability `${elem.showAsCapability}`; |$meth should be declared an update method to allow this.""", tree.srcPos) @@ -633,7 +635,7 @@ class CheckCaptures extends Recheck, SymTransformer: /** Type arguments come either from a TypeApply node or from an AppliedType * which represents a trait parent in a template. - * - Disallow global cap and result caps in such arguments. + * - Disallow GlobalCaps and ResultCaps in such arguments. * - If a corresponding formal type parameter is declared or implied @use, * charge the deep capture set of the argument to the environent. * @param fn the type application, of type TypeApply or TypeTree @@ -696,7 +698,7 @@ class CheckCaptures extends Recheck, SymTransformer: ref.paramPathRoot match case tp: TermRef => report.warning( - em"""Reach capability $ref in function result refers to ${tp.symbol}. + em"""Reach capability `${ref.showAsCapability}` in function result refers to ${tp.symbol}. |To avoid errors of the form "Local reach capability $ref leaks into capture scope ..." |you should replace the reach capability with a new capset variable in ${tree.symbol}.""", tree.tpt.srcPos) @@ -812,7 +814,7 @@ class CheckCaptures extends Recheck, SymTransformer: // - on the LHS of assignments, or // - if the qualifier or selection type is boxed, or // - the selection is either a trackable capture reference or a pure type, or - // - if the selection is of a parameterless method capturing a result cap + // - if the selection is of a parameterless method capturing a ResultCap if noWiden(selType, pt) || qualType.isBoxedCapturing || selType.isBoxedCapturing @@ -870,7 +872,7 @@ class CheckCaptures extends Recheck, SymTransformer: * TODO: Maybe not charge deep capture sets for consume? */ protected override def recheckArg(arg: Tree, formal: Type, pref: ParamRef, app: Apply)(using Context): Type = - val instantiatedFormal = globalToLocalCap(formal, Origin.Formal(pref, app)) + val instantiatedFormal = globalCapToLocal(formal, Origin.Formal(pref, app)) val argType = recheck(arg, instantiatedFormal) .showing(i"recheck arg $arg vs $instantiatedFormal = $result", capt) if formal.hasAnnotation(defn.UseAnnot) || formal.hasAnnotation(defn.ConsumeAnnot) then @@ -882,8 +884,8 @@ class CheckCaptures extends Recheck, SymTransformer: sepCheckFormals(arg) = instantiatedFormal argType - /** Map existential captures in result to `cap` and implement the following - * rele: + /** Map existential captures in result to a new local `any` and implement the + * following rule: * * E |- q: Tq^Cq * E |- q.f: Ta^Ca ->Cf Tr^Cr @@ -1021,7 +1023,8 @@ class CheckCaptures extends Recheck, SymTransformer: * their classifiers, otherwise the empty list. */ private def classifiersOfLocalCapsInType(mbr: Symbol)(using Context): List[ClassSymbol] = - memberCaps(mbr).map(_.classifier.asClass) + memberCaps(mbr).map(_.classifier).collect: + case cl: ClassSymbol => cl private def allLocalCapsInTypeAreRO(mbr: Symbol)(using Context): Boolean = memberCaps(mbr).forall(_.isReadOnly) @@ -1085,9 +1088,9 @@ class CheckCaptures extends Recheck, SymTransformer: end captureSetImpliedByFields /** Recheck type applications: - * - Map existential captures in result to `cap` + * - Map existential captures in result to new local `any`s * - include captures of called methods in environment - * - don't allow cap to appear covariantly in type arguments + * - don't allow `any` to appear covariantly in type arguments * - special handling of `contains[A, B]` calls */ override def recheckTypeApply(tree: TypeApply, pt: Type)(using Context): Type = @@ -1210,7 +1213,7 @@ class CheckCaptures extends Recheck, SymTransformer: super.seqLiteralElemProto(tree, pt, declared).boxed /** Recheck val and var definitions: - * - disallow cap in the type of mutable vars. + * - disallow `any` in the type of mutable vars. * - for externally visible definitions: check that their inferred type * does not refine what was known before capture checking. * - Interpolate contravariant capture set variables in result type. @@ -1450,7 +1453,7 @@ class CheckCaptures extends Recheck, SymTransformer: * 3. The capture set of the self type of a class includes the capture set of every class * parameter, unless the parameter is marked @constructorOnly or @untrackedCaptures. * 4. If the class extends a pure base class, the capture set of the self type must be empty. - * 5. Check that trait parents represented as applied types don't have cap in their + * 5. Check that trait parents represented as applied types don't have `any` in their * type arguments. Charge deep capture sets of type arguments to non-reserved typevars * to the environment. Other generic parents are represented as TypeApplys, where the * same check is already done in the TypeApply. @@ -1484,11 +1487,11 @@ class CheckCaptures extends Recheck, SymTransformer: // (3) Capture set of self type includes capture sets of tracked parameters for param <- cls.paramGetters do if param.isTrackedParamAccessor then - withGlobalCapAsRoot: // OK? We need this here since self types use GlobalCap instead of a LocalCap + withGlobalCapAsRoot: // OK? We need this here since self types use GlobalAny instead of a LocalCap checkSubset(param.termRef.captureSet, thisSet, param.srcPos) // (3b) Capture set of self type includes capture sets of fields (including fresh) - withCapAsRoot: + withGlobalCapAsRoot: checkSubset(captureSetImpliedByFields(cls, cls.appliedRef), thisSet, tree.srcPos) // (4) If class extends Pure, capture set of self type is empty @@ -1534,7 +1537,7 @@ class CheckCaptures extends Recheck, SymTransformer: case _ => super.recheckTyped(tree) - /** Under the sealed policy and with saferExceptions, disallow cap in the + /** Under the sealed policy and with saferExceptions, disallow `any` in the * result type of a try */ override def recheckTry(tree: Try, pt: Type)(using Context): Type = @@ -1624,7 +1627,7 @@ class CheckCaptures extends Recheck, SymTransformer: // - Relax expected capture set containing `this.type`s by adding references only // accessible through those types (c.f. addOuterRefs, also #14930 for a discussion). // - Adapt box status and environment capture sets by simulating box/unbox operations. - // - Instantiate covariant occurrenves of `cap` in actual to reach capabilities. + // - Instantiate covariant occurrenves of `any` in actual to reach capabilities. private inline val debugSuccesses = false @@ -2142,7 +2145,7 @@ class CheckCaptures extends Recheck, SymTransformer: /** Check that self types of subclasses conform to self types of super classes. * (See comment below how this is achieved). The check assumes that classes - * without an explicit self type have the universal capture set `{cap}` on the + * without an explicit self type have the universal capture set `{caps.any}` on the * self type. If a class without explicit self type is not `effectivelySealed` * it is checked that the inferred self type is universal, in order to assure * that joint and separate compilation give the same result. @@ -2325,8 +2328,8 @@ class CheckCaptures extends Recheck, SymTransformer: val normArgs = args.lazyZip(tl.paramInfos).map: (arg, bounds) => arg.withType(arg.nuType.forceBoxStatus( bounds.hi.isBoxedCapturing | bounds.lo.isBoxedCapturing)) - withCollapsedLocalCaps: // OK? We need this since bounds use GlobalCap instead of LocalCap - // TODO Do bounds still contain GlobalCap? + withCollapsedLocalCaps: // OK? We need this since bounds use GlobalAny instead of LocalCap + // TODO Do bounds still contain GlobalAny? checkBounds(normArgs, tl) if ccConfig.postCheckCapturesets then args.lazyZip(tl.paramNames).foreach(checkTypeParam(_, _, fun.symbol)) diff --git a/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala b/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala index c40342bf9408..7026313ef41c 100644 --- a/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala +++ b/compiler/src/dotty/tools/dotc/cc/RetainingAnnotation.scala @@ -39,7 +39,7 @@ class RetainingAnnotation(tpe: Type) extends CompactAnnotation(tpe): def isStrict(using Context): Boolean = symbol.isRetains def retainedType(using Context): Type = - if symbol == defn.RetainsCapAnnot then defn.captureRoot.termRef + if symbol == defn.RetainsCapAnnot then defn.Caps_any.termRef else argumentType(0) private var myCaptureSet: CaptureSet | Null = null diff --git a/compiler/src/dotty/tools/dotc/cc/SepCheck.scala b/compiler/src/dotty/tools/dotc/cc/SepCheck.scala index 593606c853b3..1bd264980634 100644 --- a/compiler/src/dotty/tools/dotc/cc/SepCheck.scala +++ b/compiler/src/dotty/tools/dotc/cc/SepCheck.scala @@ -290,7 +290,7 @@ object SepCheck: else refs /** The non-terminal elements hidden directly or indirectly by a terminal - * capability in `refs`. E g. if `R = {x, >}` then + * capability in `refs`. E g. if `R = {x, >}` then * its hidden set is `{y, z}`. */ private def transHiddenSet(using Context): Refs = @@ -346,7 +346,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: private var openLabeled: List[(Name, mutable.ListBuffer[ConsumedSet])] = Nil /** The deep capture set of an argument or prefix widened to the formal parameter, if - * the latter contains a cap. + * the latter contains an `any`. */ private def formalCaptures(arg: Tree)(using Context): Refs = arg.formalType.orElse(arg.nuType).spanCaptureSet.elems @@ -368,8 +368,8 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: if shared.isEmpty then i"${CaptureSet(shared)}" else shared.nth(0) match case localCap: LocalCap => - val where = if ctx.settings.YccVerbose.value then "" else i" of ${localCap.ccOwnerStr}" - i"{$localCap$where}" + if ctx.settings.YccVerbose.value then i"{$localCap}" + else i"{`$localCap` of ${localCap.ccOwnerStr}}" case _ => i"${CaptureSet(shared)}" @@ -488,7 +488,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: * capability in later arguments, if the corresponding formal parameter mentions * the parameter where the capability was hidden. For instance in * - * def seq(x: () => Unit; y ->{cap, x} Unit): Unit + * def seq(x: () => Unit; y ->{any, x} Unit): Unit * def f: () ->{io} Unit * * we do allow `seq(f, f)` even though `{f, io}` is in the hidden set of the @@ -898,7 +898,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser: /** The inter-parameter dependencies of the function reference `fn` applied * to the argument lists `argss`. For instance, if `f` has type * - * f(x: A, y: B^{cap, x}, z: C^{x, y}): D + * f(x: A, y: B^{any, x}, z: C^{x, y}): D * * then the dependencies of an application `f(a, b, c)` of type C^{y} is the map * diff --git a/compiler/src/dotty/tools/dotc/cc/Setup.scala b/compiler/src/dotty/tools/dotc/cc/Setup.scala index cf01b9d48d01..5b7b2331c5e6 100644 --- a/compiler/src/dotty/tools/dotc/cc/Setup.scala +++ b/compiler/src/dotty/tools/dotc/cc/Setup.scala @@ -350,7 +350,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: * 1. Expand throws aliases to contextual function type with CanThrow parameters * 2. Map types with retains annotations to CapturingTypes * 3. Add universal capture sets to types deriving from Capability - * 4. Map `cap` in function result types to existentially bound variables. + * 4. Map `any` in function result types to existentially bound variables. * 5. Schedule deferred well-formed tests for types with retains annotations. * 6. Perform normalizeCaptures */ @@ -360,7 +360,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: if !tptToCheck.isEmpty then report.error(msg, tptToCheck.srcPos) /** If C derives from Capability and we have a C^cs in source, we leave it as is - * instead of expanding it to C^{cap}^cs. We do this by stripping capability-generated + * instead of expanding it to C^{any}^cs. We do this by stripping capability-generated * universal capture sets from the parent of a CapturingType. */ def stripImpliedCaptureSet(tp: Type): Type = tp match @@ -418,8 +418,8 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: case _ => tp - /** Map references to capability classes C to C^{cap.rd}, - * normalize captures and map to dependent functions. + /** Map references to capability classes C to C^{any}, or (if Mutable) + * tp C^{any.rd}. Normalize captures and map to dependent functions. */ def defaultApply(t: Type) = if t.derivesFromCapability @@ -486,7 +486,14 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: val tp3 = if sym.isType then stripImpliedCaptureSet(tp2) else tp2 - globalToLocalCap(tp3, Origin.InDecl(sym)) + if tp3.containsFresh then + fail( + em"""`fresh` occurs outside function result in $tp3. + | + |The `fresh` capability may only be used in the result of a function type, + |following a function arrow such as `=>` or `->`.""") + + globalCapToLocal(tp3, Origin.InDecl(sym)) end transformExplicitType /** Update info of `sym` for CheckCaptures phase only */ @@ -582,7 +589,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: for case arg: TypeTree <- args do if defn.isTypeTestOrCast(fn.symbol) then arg.setNuType( - globalToLocalCap(arg.tpe, Origin.TypeArg(arg.tpe))) + globalCapToLocal(arg.tpe, Origin.TypeArg(arg.tpe))) else transformTT(arg, NoSymbol, boxed = true) // type arguments in type applications are boxed @@ -732,7 +739,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: // is cls is known to be pure, nothing needs to be added to self type selfInfo else if !cls.isEffectivelySealed && !cls.baseClassHasExplicitNonUniversalSelfType then - // assume {cap} for completely unconstrained self types of publicly extensible classes + // assume {caps.any} for completely unconstrained self types of publicly extensible classes CapturingType(cinfo.selfType, CaptureSet.universal) else { // Infer the self type for the rest, which is all classes without explicit @@ -857,7 +864,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: case CapturingOrRetainsType(parent, refs) => needsVariable(parent) && refs.isConst // if refs is a variable, no need to add another - && !refs.isUniversal // if refs is {cap}, an added variable would not change anything + && !refs.isUniversal // if refs is {caps.any}, an added variable would not change anything case AnnotatedType(parent, _) => needsVariable(parent) case _ => @@ -966,7 +973,8 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: private def checkWellformed(parent: Type, ann: RetainingAnnotation, tpt: Tree)(using Context): Unit = capt.println(i"checkWF post $parent ${ann.retainedType} in $tpt") try - var retained = ann.retainedType.retainedElements.toArray + val retained = ann.retainedType.retainedElements.toArray + for i <- 0 until retained.length do val ref = retained(i) def pos = tpt.srcPos diff --git a/compiler/src/dotty/tools/dotc/cc/Synthetics.scala b/compiler/src/dotty/tools/dotc/cc/Synthetics.scala index 1277edddcae9..aa6e5673a1cd 100644 --- a/compiler/src/dotty/tools/dotc/cc/Synthetics.scala +++ b/compiler/src/dotty/tools/dotc/cc/Synthetics.scala @@ -65,9 +65,9 @@ object Synthetics: /** Add capture dependencies to the type of the `apply` or `copy` method of a case class. * An apply method in a case class like this: - * case class CC(a: A^{d}, b: B, c: C^{cap}) + * case class CC(a: A^{d}, b: B, c: C^{any}) * would get type - * def apply(a': A^{d}, b: B, c': C^{cap}): CC^{a', c'} { val a = A^{a'}, val c = C^{c'} } + * def apply(a': A^{d}, b: B, c': C^{any}): CC^{a', c'} { val a = A^{a'}, val c = C^{c'} } * where `'` is used to indicate the difference between parameter symbol and refinement name. * Analogous for the copy method. */ @@ -112,7 +112,7 @@ object Synthetics: case _ => info - /** Augment an unapply of type `(x: C): D` to `(x: C^{cap}): D^{x}` */ + /** Augment an unapply of type `(x: C): D` to `(x: C^{any}): D^{x}` */ def transformUnapplyCaptures(info: Type)(using Context): Type = info match case info: MethodType => val paramInfo :: Nil = info.paramInfos: @unchecked @@ -132,7 +132,7 @@ object Synthetics: val (pt: PolyType) = info: @unchecked val (mt: MethodType) = pt.resType: @unchecked val (enclThis: ThisType) = owner.thisType: @unchecked - val paramCaptures = CaptureSet(enclThis, GlobalCap) + val paramCaptures = CaptureSet(enclThis, GlobalAny) pt.derivedLambdaType(resType = MethodType(mt.paramNames)( mt1 => mt.paramInfos.map(_.capturing(paramCaptures)), mt1 => CapturingType(mt.resType, CaptureSet(enclThis, mt1.paramRefs.head)))) @@ -150,7 +150,7 @@ object Synthetics: def transformCompareCaptures = val (enclThis: ThisType) = symd.owner.thisType: @unchecked MethodType( - defn.ObjectType.capturing(CaptureSet(GlobalCap, enclThis)) :: Nil, + defn.ObjectType.capturing(CaptureSet(GlobalAny, enclThis)) :: Nil, defn.BooleanType) symd.copySymDenotation(info = symd.name match diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 3458b46fe388..98957ba759bd 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1007,7 +1007,8 @@ class Definitions { @tu lazy val BreakClass: Symbol = requiredClass("scala.util.boundary.Break") @tu lazy val CapsModule: Symbol = requiredPackage("scala.caps") - @tu lazy val captureRoot: TermSymbol = CapsModule.requiredValue("cap") + @tu lazy val Caps_any: TermSymbol = CapsModule.requiredValue("any") + @tu lazy val Caps_fresh: TermSymbol = CapsModule.requiredValue("fresh") @tu lazy val Caps_Capability: ClassSymbol = requiredClass("scala.caps.Capability") @tu lazy val Caps_Classifier: ClassSymbol = requiredClass("scala.caps.Classifier") @tu lazy val Caps_SharedCapability: ClassSymbol = requiredClass("scala.caps.SharedCapability") @@ -1769,7 +1770,7 @@ class Definitions { /** Is `tp` (an alias) of either a scala.FunctionN or a scala.ContextFunctionN * instance? */ - def isNonRefinedFunction(tp: Type)(using Context): Boolean = + def isNonRefinedFunction(tp: Type)(using Context): Boolean = { val arity = functionArity(tp) val sym = tp.dealias.typeSymbol @@ -1778,7 +1779,12 @@ class Definitions { && tp.isRef( FunctionType(arity, sym.name.isContextFunction).typeSymbol, skipRefined = false) - end isNonRefinedFunction + } + + /** Is a dependent function type represented as a RefinedType? + */ + def isRefinedFunction(tp: Type)(using Context): Boolean = + tp.dropDependentRefinement ne tp /** Returns whether `tp` is an instance or a refined instance of: * - scala.FunctionN @@ -1991,7 +1997,7 @@ class Definitions { /* Caps_Classifier, Caps_SharedCapability, Caps_Control, -- already stable */ Caps_ExclusiveCapability, Caps_Mutable, Caps_Read, Caps_Unscoped, Caps_Stateful, Caps_Separate, Caps_Shared, RequiresCapabilityAnnot, - captureRoot, Caps_CapSet, Caps_ContainsTrait, Caps_ContainsModule, Caps_ContainsModule.moduleClass, + Caps_any, Caps_fresh, Caps_CapSet, Caps_ContainsTrait, Caps_ContainsModule, Caps_ContainsModule.moduleClass, ConsumeAnnot, UseAnnot, ReserveAnnot, CapsUnsafeModule, CapsUnsafeModule.moduleClass, Caps_freeze, Caps_Var, CapsInternalModule, CapsInternalModule.moduleClass, diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index c265b97c7062..34fa92c220fc 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -285,7 +285,6 @@ object StdNames { // ----- Term names ----------------------------------------- // Compiler-internal - val CAPTURE_ROOT: N = "cap" val CBCompanion: N = "" val CONSTRUCTOR: N = "" val STATIC_CONSTRUCTOR: N = "" @@ -404,6 +403,7 @@ object StdNames { val adhocExtensions: N = "adhocExtensions" val andThen: N = "andThen" val annotation: N = "annotation" + val any: N = "any" val any2stringadd: N = "any2stringadd" val anyHash: N = "anyHash" val anyValClass: N = "anyValClass" @@ -500,6 +500,7 @@ object StdNames { val floatHash: N = "floatHash" val foreach: N = "foreach" val format: N = "format" + val fresh: N = "fresh" val fromDigits: N = "fromDigits" val fromProduct: N = "fromProduct" val genericArrayOps: N = "genericArrayOps" diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index b9684fb206b0..4f9ec4942634 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -940,6 +940,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling && (!caseLambda.exists || widenAbstractOKFor(tp2) || tp1.widen.underlyingClassRef(refinementOK = true).exists) + && !(isCaptureCheckingOrSetup + && tp1.isSingleton + && defn.isRefinedFunction(tp1.widen.stripCapturing)) + // If tp1 is a refined function, `base` is the parent function, but that type + // is unreliabe since nonDependentResultApprox does not yield a true supertype + // for LocalCaps and ResultCaps. We should go the alternative route of widening + // in fourthTry instead. then def checkBase = isSubType(base, tp2, if tp1.isRef(cls2) then approx else approx.addLow) @@ -1041,11 +1048,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling comparePaths || isSubType(tp1widened, tp2, approx.addLow) case tp1: RefinedType => - if isCaptureCheckingOrSetup then - tp2.stripCapturing match - case defn.RefinedFunctionOf(_) => // was already handled in thirdTry - return false - case _ => + if isCaptureCheckingOrSetup && defn.isRefinedFunction(tp2.stripCapturing) then + return false isNewSubType(tp1.parent) case tp1: RecType => isNewSubType(tp1.parent) diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index a4738b8abd71..b0aeb4c6ce2e 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4237,7 +4237,7 @@ object Types extends TypeUtils { case Reach(c1) => apply(c1) match case tp1a: ObjectCapability if tp1a.isTrackableRef => tp1a.reach - case _ => GlobalCap + case _ => GlobalAny case _ => super.mapCapability(c, deep) } dropDependencies(resultType) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 03dba04b1ff6..7043ad2b9010 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1924,7 +1924,7 @@ object Parsers { def refinedType() = refinedTypeRest(withType()) - /** Disambiguation: a `^` is treated as a postfix operator meaning `^{cap}` + /** Disambiguation: a `^` is treated as a postfix operator meaning `^{any}` * if followed by `{`, `->`, or `?->`, * or followed by a new line (significant or not), * or followed by a token that cannot start an infix type. diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 796704759722..872b0bfdd5e2 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -426,7 +426,11 @@ object Scanners { def isLeadingInfixOperator(nextWidth: IndentWidth = indentWidth(offset), inConditional: Boolean = true) = allowLeadingInfixOperators && isOperator - && (isWhitespace(ch) || ch == LF) + && (isWhitespace(ch) || ch == LF + || Feature.ccEnabled + && (isIdent(nme.PUREARROW) || isIdent(nme.PURECTXARROW)) + && ch == '{' + ) && !pastBlankLine && { // Is current lexeme assumed to start an expression? diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index d252edfce135..2353bb55939e 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -30,10 +30,10 @@ class PlainPrinter(_ctx: Context) extends Printer { protected def printDebug = ctx.settings.YprintDebug.value - /** Print Fresh instances as */ + /** Print local roots as */ protected def ccVerbose = ctx.settings.YccVerbose.value - /** Elide redundant ^ and ^{cap.rd} when printing instances of Capability + /** Elide redundant ^ and ^{any.rd} when printing instances of Capability * classes. Gets set when singletons are printed as `(x: T)` to reduce verbosity. */ private var elideCapabilityCaps = false @@ -195,23 +195,14 @@ class PlainPrinter(_ctx: Context) extends Printer { type GeneralCaptureSet = CaptureSet | List[Type] - protected def isUniversalCaptureSet(refs: GeneralCaptureSet): Boolean = refs match + protected def isElidableUniversal(refs: GeneralCaptureSet): Boolean = refs match case refs: CaptureSet => - // The set if universal if it consists only of caps.cap or - // only of an existential Fresh that is bound to the immediately enclosing method. - val isUniversal = - refs.elems.size == 1 - && (refs.isUniversal - || !printDebug && !ccVerbose && !showUniqueIds && refs.elems.nth(0).match - case ResultCap(binder) => - CCState.openExistentialScopes match - case b :: _ => binder eq b - case _ => false - case _ => - false - ) - isUniversal - || !refs.elems.isEmpty && refs.elems.forall(_.isGlobalOrLocalCap) && !ccVerbose + !refs.elems.isEmpty + && refs.elems.forall: + case _: LocalCap => true + case GlobalAny => true + case _ => false + && !ccVerbose case ref :: Nil => ref.isCapsAnyRef case _ => false @@ -227,7 +218,7 @@ class PlainPrinter(_ctx: Context) extends Printer { boxText ~ toTextLocal(parent) ~ "^" - ~ toTextGeneralCaptureSet(refs).provided(!isUniversalCaptureSet(refs) || ccVerbose) + ~ toTextGeneralCaptureSet(refs).provided(!isElidableUniversal(refs) || ccVerbose) def toText(tp: Type): Text = controlled { homogenize(tp) match { @@ -477,14 +468,18 @@ class PlainPrinter(_ctx: Context) extends Printer { case Restricted(c1, cls) => toTextCapability(c1) ~ s".only[${nameString(cls)}]" case Reach(c1) => toTextCapability(c1) ~ "*" case Maybe(c1) => toTextCapability(c1) ~ "?" - case GlobalCap => "cap" + case GlobalAny => "any" + case GlobalFresh => "fresh" case c: ResultCap => def idStr = s"##${c.rootId}" - // TODO: Better printing? USe a mode where we print more detailed - val vbleText: Text = CCState.openExistentialScopes.indexOf(c.binder) match - case -1 => - "" - case n => "outer_" * n ++ (if ccVerbose then "localcap" else "cap") + // TODO: Better printing? USe a mode where we print more + val openExistentials = CCState.openExistentialScopes + val vbleText: Text = openExistentials.indexOf(c.binder) match + case -1 if openExistentials.nonEmpty => + // Use long output if we are printing a result of a function type, but the + // ResultCap does not prefer to a prefix in that type + "" + case n => "outer_" * n ++ "fresh" vbleText ~ Str(hashStr(c.binder)).provided(printDebug) ~ Str(idStr).provided(showUniqueIds) case c: LocalCap => val idStr = if showUniqueIds then s"#${c.rootId}" else "" @@ -498,8 +493,8 @@ class PlainPrinter(_ctx: Context) extends Printer { case pre: SingletonType => toTextRef(pre) ~ "." case pre => toText(pre) ~ "." def core: Text = - if ccVerbose then s"" - else "cap" + if ccVerbose then s"" + else "any" prefixTxt ~ core case tp: TypeProxy => homogenize(tp) match diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 68d15f256f44..3d84b7a785bc 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -169,7 +169,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { protected def funMiddleText(isContextual: Boolean, isPure: Boolean, refs: GeneralCaptureSet | Null): Text = val (printPure, refsText) = if refs == null then (isPure, Str("")) - else if isUniversalCaptureSet(refs) then (false, Str("")) + else if isElidableUniversal(refs) then (false, Str("")) else (isPure, toTextGeneralCaptureSet(refs)) arrow(isContextual, printPure) ~ refsText diff --git a/compiler/src/dotty/tools/dotc/reporting/Message.scala b/compiler/src/dotty/tools/dotc/reporting/Message.scala index 1c71b7468c0b..6a443e97916a 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Message.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Message.scala @@ -5,9 +5,10 @@ package reporting import core.* import Contexts.*, Decorators.*, Symbols.*, Types.*, Flags.* import printing.{RefinedPrinter, MessageLimiter, ErrorMessageLimiter} -import printing.Texts.Text +import printing.Texts.{Text, Str} import printing.Formatting.hl import config.SourceVersion +import util.SimpleIdentitySet import cc.CaptureSet import cc.Capabilities.* @@ -42,7 +43,7 @@ object Message: else "" /** A note can produce an added string for an error message */ - abstract class Note: + abstract class Note { /** Should the note be shown before the actual message or after? * Default is after. @@ -59,6 +60,9 @@ object Message: */ def covers(other: Note)(using Context): Boolean = false + def mentions: SimpleIdentitySet[Capability] = SimpleIdentitySet.empty + } + object Note: def apply(msg: Context ?=> String) = new Note: def render(using Context) = msg @@ -250,7 +254,7 @@ object Message: end Seen /** Printer to be used when formatting messages */ - private class Printer(val seen: Seen, _ctx: Context) extends RefinedPrinter(_ctx): + private class Printer(val seen: Seen, msg: Message, _ctx: Context) extends RefinedPrinter(_ctx): /** True if printer should a show source module instead of its module class */ private def useSourceModule(sym: Symbol): Boolean = @@ -267,13 +271,16 @@ object Message: case tp: SkolemType => seen.record(tp.repr.toString, isType = true, tp) case _ => super.toTextRef(tp) - override def toTextCapability(c: Capability): Text = c match - case c: RootCapability if seen.isActive => seen.record("cap", isType = false, c) - case _ => super.toTextCapability(c) + override def toTextCapability(c: Capability): Text = + (c, super.toTextCapability(c)) match + case (c: RootCapability, Str(s)) if seen.isActive => + seen.record(s, isType = false, c) + case (_, txt) => + txt override def toTextCapturing(parent: Type, refs: GeneralCaptureSet, boxText: Text) = refs match case refs: CaptureSet - if isUniversalCaptureSet(refs) && !defn.isFunctionType(parent) && !printDebug && seen.isActive => + if isElidableUniversal(refs) && !defn.isFunctionType(parent) && !printDebug && seen.isActive => boxText ~ toTextLocal(parent) ~ seen.record("^", isType = true, refs.elems.nth(0).asInstanceOf[RootCapability]) @@ -282,11 +289,18 @@ object Message: override def funMiddleText(isContextual: Boolean, isPure: Boolean, refs: GeneralCaptureSet | Null): Text = refs match - case refs: CaptureSet if isUniversalCaptureSet(refs) && seen.isActive => + case refs: CaptureSet if isElidableUniversal(refs) && seen.isActive => seen.record(arrow(isContextual, isPure = false), isType = true, refs.elems.nth(0).asInstanceOf[RootCapability]) case _ => super.funMiddleText(isContextual, isPure, refs) + override def isElidableUniversal(refs: GeneralCaptureSet): Boolean = + super.isElidableUniversal(refs) && (refs, msg).match + case (refs: CaptureSet, msg: TypeMismatch) => + msg.notes.forall: note => + (refs.elems ** note.mentions).isEmpty + case _ => true + override def toText(tp: Type): Text = if !tp.exists || tp.isErroneous then seen.nonSensical = true tp match @@ -415,7 +429,7 @@ abstract class Message(val errorId: ErrorMessageID)(using Context) { self => case _: Message.Printer => ctx case _ => val seen = Seen(disambiguate) - val ctx1 = ctx.fresh.setPrinterFn(Message.Printer(seen, _)) + val ctx1 = ctx.fresh.setPrinterFn(Message.Printer(seen, this, _)) if !ctx1.property(MessageLimiter).isDefined then ctx1.setProperty(MessageLimiter, ErrorMessageLimiter()) ctx1 diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index a77d1be6e9a5..6a487c60498f 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -31,6 +31,7 @@ import ast.tpd import scala.util.matching.Regex import java.util.regex.Matcher.quoteReplacement import cc.CaptureSet.IdentityCaptRefMap +import cc.Capabilities.Capability import dotty.tools.dotc.rewrites.Rewrites.ActionPatch import dotty.tools.dotc.util.Spans.Span import dotty.tools.dotc.util.SourcePosition @@ -38,6 +39,7 @@ import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.config.SourceVersion import DidYouMean.* import Message.{Disambiguation, Note} +import dotty.tools.dotc.util.SimpleIdentitySet /** Messages * ======== @@ -303,8 +305,8 @@ extends NotFoundMsg(MissingIdentID) { } } -class TypeMismatch(val found: Type, expected: Type, val inTree: Option[untpd.Tree], notes: List[Note] = Nil)(using Context) - extends TypeMismatchMsg(found, expected)(TypeMismatchID): +class TypeMismatch(val found: Type, expected: Type, val inTree: Option[untpd.Tree], val notes: List[Note] = Nil)(using Context) + extends TypeMismatchMsg(found, expected)(TypeMismatchID) { private val shouldSuggestNN = if ctx.mode.is(Mode.SafeNulls) && expected.isValueType then @@ -390,7 +392,7 @@ class TypeMismatch(val found: Type, expected: Type, val inTree: Option[untpd.Tre case _ => List() } -end TypeMismatch +} class NotAMember(site: Type, val name: Name, selected: String, proto: Type, addendum: => String = "")(using Context) extends NotFoundMsg(NotAMemberID), ShowMatchTrace(site) { diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index 32a0ab5f56d0..f3cf441a89fb 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -106,7 +106,7 @@ object RefChecks { def checkSelfConforms(other: ClassSymbol) = var otherSelf = other.declaredSelfTypeAsSeenFrom(cls.thisType) if otherSelf.exists then - if !CCState.withGlobalCapAsRoot: // OK? We need this here since self types use `cap` instead of `fresh` + if !CCState.withGlobalCapAsRoot: // OK? We need this here since self types use `caps.any` instead of a LocalCap cinfo.selfType <:< otherSelf then report.error(DoesNotConformToSelfType("illegal inheritance", cinfo.selfType, cls, otherSelf, "parent", other), diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 29be088643c6..09cb3e2ed0d3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2564,15 +2564,15 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer def typedThrow(tree: untpd.Throw)(using Context): Tree = val expr1 = typed(tree.expr, defn.ThrowableType) - val cap = checkCanThrow(expr1.tpe.widen, tree.span) + val ctEvidence = checkCanThrow(expr1.tpe.widen, tree.span) var res = Throw(expr1).withSpan(tree.span) - if Feature.ccEnabled && !cap.isEmpty && !ctx.isAfterTyper then - // Record access to the CanThrow capabulity recovered in `cap` by wrapping + if Feature.ccEnabled && !ctEvidence.isEmpty && !ctx.isAfterTyper then + // Record access to the CanThrow capabulity recovered in `capEvidence` by wrapping // the type of the `throw` (i.e. Nothing) in a `@requiresCapability` annotation. res = Typed(res, TypeTree( AnnotatedType(res.tpe, - Annotation(defn.RequiresCapabilityAnnot, cap, tree.span)))) + Annotation(defn.RequiresCapabilityAnnot, ctEvidence, tree.span)))) res.withNotNullInfo(expr1.notNullInfo.terminatedInfo) def typedSeqLiteral(tree: untpd.SeqLiteral, pt: Type)(using Context): SeqLiteral = { diff --git a/library/src/scala/annotation/retains.scala b/library/src/scala/annotation/retains.scala index f526a17c053e..7b75a55c76b9 100644 --- a/library/src/scala/annotation/retains.scala +++ b/library/src/scala/annotation/retains.scala @@ -16,7 +16,7 @@ import language.experimental.captureChecking @experimental class retains[Elems] extends annotation.StaticAnnotation -/** Equivalent in meaning to `@retains[cap.type]`, but consumes less bytecode. +/** Equivalent in meaning to `@retains[any.type]`, but consumes less bytecode. */ @experimental class retainsCap extends annotation.StaticAnnotation diff --git a/library/src/scala/annotation/unchecked/uncheckedCaptures.scala b/library/src/scala/annotation/unchecked/uncheckedCaptures.scala index e494cef28a0e..c4102bb6edd7 100644 --- a/library/src/scala/annotation/unchecked/uncheckedCaptures.scala +++ b/library/src/scala/annotation/unchecked/uncheckedCaptures.scala @@ -4,7 +4,7 @@ package unchecked import language.experimental.captureChecking /** An annotation for mutable variables that are allowed to capture - * the root capability `cap`. Allowing this is not capture safe since + * the root capability `any`. Allowing this is not capture safe since * it can cause leakage of capabilities from local scopes by assigning * values retaining such capabilties to the annotated variable in * an outer scope. diff --git a/library/src/scala/caps/package.scala b/library/src/scala/caps/package.scala index b8dbb9eedc4c..17c98867f9ef 100644 --- a/library/src/scala/caps/package.scala +++ b/library/src/scala/caps/package.scala @@ -41,7 +41,14 @@ trait Classifier /** The universal capture reference. */ @experimental -object cap extends Capability +object any extends Capability + +/** The universal result capture reference. */ +@experimental +object fresh extends Capability + +@experimental // TODO: Drop once we bootstrap with 3.8.1 +val cap: any.type = any /** Marker trait for capabilities that can be safely shared in a concurrent context. * @@ -86,7 +93,7 @@ trait Control extends SharedCapability, Classifier trait Stateful extends ExclusiveCapability /** Marker trait for classes that produce fresh capabilities with their values. If a value of a type - * extending Separate is created, a fresh `cap` is automatically added to the value's capture set. + * extending Separate is created, a fresh `any` is automatically added to the value's capture set. */ @experimental trait Separate extends Stateful @@ -169,9 +176,9 @@ object internal: @deprecated final class refineOverride extends annotation.StaticAnnotation - /** An annotation used internally for root capability wrappers of `cap` that + /** An annotation used internally for root capability wrappers of `any` that * represent either Fresh or Result capabilities. - * A capability is encoded as `caps.cap @rootCapability(...)` where + * A capability is encoded as `caps.any @rootCapability(...)` where * `rootCapability(...)` is a special kind of annotation of type `root.Annot` * that contains either a hidden set for Fresh instances or a method type binder * for Result instances. @@ -221,11 +228,11 @@ object unsafe: * * class A { val b B^ = ... }; new A() * - * has type A^ since b contributes a cap. But + * has type A^ since b contributes an `any`. But * * class A { @untrackedCaptures val b: B^ = ... }; new A() * - * has type A. The `b` field does not contribute its cap. + * has type A. The `b` field does not contribute its `any`. * * 3. Allows a field to be declarewd in a class that does not extend Stateful, * and suppresses checks for updates to the field. diff --git a/library/src/scala/collection/Iterator.scala b/library/src/scala/collection/Iterator.scala index 8995990c43b6..69bcfbfe4203 100644 --- a/library/src/scala/collection/Iterator.scala +++ b/library/src/scala/collection/Iterator.scala @@ -922,7 +922,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite new AbstractIterator[B] { // TODO We should be able to prove that origElems is safe even though it is // declared as Iterator[B]^. We could show that origElems is never assigned a - // freh cap. Maybe we can invent another annotation that is checked and that + // fresh `any`. Maybe we can invent another annotation that is checked and that // shows that the `^` is just used as an upper bound for concete non-fresh // capabilities. @untrackedCaptures private var origElems: Iterator[B]^ = self diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index 3a44f0d02e43..c04c92f27317 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -9,8 +9,8 @@ object MiMaFilters { // Additions that require a new minor version of the library Build.mimaPreviousDottyVersion -> Seq( ProblemFilters.exclude[DirectMissingMethodProblem]("scala.caps.package#package.freeze"), + ProblemFilters.exclude[DirectMissingMethodProblem]("scala.caps.package#package.cap"), ), - ) val BackwardsBreakingChanges: Map[String, Seq[ProblemFilter]] = Map( diff --git a/tests/disabled/neg-custom-args/captures/capt-wf.scala b/tests/disabled/neg-custom-args/captures/capt-wf.scala index fe04d6709f91..b7cc3e348471 100644 --- a/tests/disabled/neg-custom-args/captures/capt-wf.scala +++ b/tests/disabled/neg-custom-args/captures/capt-wf.scala @@ -1,7 +1,7 @@ // No longer valid class C -type Cap = C @retains[caps.cap.type] -type Top = Any @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] +type Top = Any @retains[caps.any.type] type T = (x: Cap) => List[String @retains[x.type]] => Unit // error val x: (x: Cap) => Array[String @retains[x.type]] = ??? // error diff --git a/tests/disabled/neg-custom-args/captures/try2.scala b/tests/disabled/neg-custom-args/captures/try2.scala index 0687173b4d3d..d2b7f0d124e1 100644 --- a/tests/disabled/neg-custom-args/captures/try2.scala +++ b/tests/disabled/neg-custom-args/captures/try2.scala @@ -5,7 +5,7 @@ import annotation.ability @ability erased val canThrow: * = ??? class CanThrow[E <: Exception] extends Retains[canThrow.type] -type Top = Any @retains[caps.cap.type] +type Top = Any @retains[caps.any.type] infix type throws[R, E <: Exception] = (erased CanThrow[E]) ?=> R diff --git a/tests/invalid/neg-custom-args/captures/unsound-reach-7.scala b/tests/invalid/neg-custom-args/captures/unsound-reach-7.scala index aa4ea932e5b7..71da12a6ebc1 100644 --- a/tests/invalid/neg-custom-args/captures/unsound-reach-7.scala +++ b/tests/invalid/neg-custom-args/captures/unsound-reach-7.scala @@ -1,5 +1,5 @@ import language.experimental.captureChecking -import caps.{cap, use} +import caps.{any, use} trait IO trait Async diff --git a/tests/neg-custom-args/boxmap.scala b/tests/neg-custom-args/boxmap.scala index 5a91947edba3..82456c1baaed 100644 --- a/tests/neg-custom-args/boxmap.scala +++ b/tests/neg-custom-args/boxmap.scala @@ -1,5 +1,5 @@ import annotation.retains -type Top = Any @retains[caps.cap.type] +type Top = Any @retains[caps.any.type] type Box[+T <: Top] = ([K <: Top] -> (T => K) -> K) @@ -17,5 +17,5 @@ def test[A <: Top, B <: Top] = () => b[Box[B]]((x: A) => box(f(x))) val x0: (b: Box[A]) -> (f: A => B) -> (() -> Box[B]) = lazymap[A, B] // error val x: (b: Box[A]) -> (f: A => B) -> (() ->{b, f} Box[B]) = lazymap[A, B] // works - val y: (b: Box[A]) -> (f: A => B) -> (() ->{cap} Box[B]) = lazymap[A, B] // works + val y: (b: Box[A]) -> (f: A => B) -> (() ->{any} Box[B]) = lazymap[A, B] // works () diff --git a/tests/neg-custom-args/captures/apply-fresh.check b/tests/neg-custom-args/captures/apply-fresh.check index eb4e93481470..198f2aeedb4e 100644 --- a/tests/neg-custom-args/captures/apply-fresh.check +++ b/tests/neg-custom-args/captures/apply-fresh.check @@ -1,23 +1,23 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-fresh.scala:17:15 ---------------------------------- 17 | val _: Ref = x // error | ^ - | Found: (x : Ref^) + | Found: (x : Ref^{any}) | Required: Ref | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of value x + | where: any is a root capability in the type of value x | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-fresh.scala:21:15 ---------------------------------- 21 | val _: Ref = y // error | ^ - | Found: (y : Ref^) + | Found: (y : Ref^{any}) | Required: Ref | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of value y + | where: any is a root capability in the type of value y | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-fresh.scala:25:15 ---------------------------------- @@ -26,6 +26,6 @@ | Found: (z : Ref^{bar.newRef}) | Required: Ref | - | Note that capability bar.newRef is not included in capture set {}. + | Note that capability `bar.newRef` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/apply-rule.check b/tests/neg-custom-args/captures/apply-rule.check index 73665fc79fdf..8036ca5ad46d 100644 --- a/tests/neg-custom-args/captures/apply-rule.check +++ b/tests/neg-custom-args/captures/apply-rule.check @@ -4,7 +4,7 @@ | Found: (x : () ->{s*} A^{}) | Required: () -> A | - | Note that capability s* is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-rule.scala:5:19 ------------------------------------ @@ -13,7 +13,7 @@ | Found: (y : () ->{s*} A^{}) | Required: () -> A | - | Note that capability s* is not included in capture set {}. + | Note that capability `y` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-rule.scala:9:19 ------------------------------------ @@ -22,7 +22,7 @@ | Found: (x : () ->{C} A^{}) | Required: () -> A | - | Note that capability C is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/apply-rule.scala:11:19 ----------------------------------- @@ -31,7 +31,7 @@ | Found: (y : () ->{C} A^{}) | Required: () -> A | - | Note that capability C is not included in capture set {}. + | Note that capability `y` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/apply-rule.scala:2:11 --------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/boundary-homebrew.check b/tests/neg-custom-args/captures/boundary-homebrew.check index 88c7872e5b4d..4d6a93b2989b 100644 --- a/tests/neg-custom-args/captures/boundary-homebrew.check +++ b/tests/neg-custom-args/captures/boundary-homebrew.check @@ -1,15 +1,15 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/boundary-homebrew.scala:19:19 ---------------------------- 19 | boundary[Int]: l2 ?=> // error | ^ - |Capability cap outlives its scope: it leaks into outer capture set 's1 of parameter l1. + |Capability `any` outlives its scope: it leaks into outer capture set 's1 of parameter l1. |The leakage occurred when trying to match the following types: | |Found: (l2: boundary.Label[Int]^'s2) ?->{l1} Int |Required: (boundary.Label[Int]^) ?=> Int | |where: ?=> refers to a root capability created in anonymous function of type (using l1²: boundary.Label[boundary.Label[Int]^]^): boundary.Label[Int]^ when checking argument to parameter body of method apply - | ^ refers to the universal root capability - | cap is a root capability created in anonymous function of type (using l2: boundary.Label[Int]^'s2): Int of parameter parameter l2² of method $anonfun + | ^ refers to the root capability caps.any + | any is a root capability created in anonymous function of type (using l2: boundary.Label[Int]^'s2): Int of parameter parameter l2² of method $anonfun | 20 | boundary.break(l2)(using l1) 21 | 15 diff --git a/tests/neg-custom-args/captures/boundary.check b/tests/neg-custom-args/captures/boundary.check index e9ff34612ad7..b81078498fcc 100644 --- a/tests/neg-custom-args/captures/boundary.check +++ b/tests/neg-custom-args/captures/boundary.check @@ -2,14 +2,14 @@ 4 | boundary[AnyRef^]: 5 | l1 ?=> // error // error | ^ - | Capability cap outlives its scope: it leaks into outer capture set 's1 which is owned by value local. + | Capability `any` outlives its scope: it leaks into outer capture set 's1 which is owned by value local. | The leakage occurred when trying to match the following types: | | Found: scala.util.boundary.Label[Object^'s1]^'s2 - | Required: scala.util.boundary.Label[Object^]^² + | Required: scala.util.boundary.Label[Object^{any}]^ | - | where: ^ and cap refer to the universal root capability - | ^² refers to a root capability classified as Control in the type of value local + | where: ^ refers to a root capability classified as Control in the type of value local + | any is the root capability caps.any | 6 | boundary[Unit]: l2 ?=> 7 | boundary.break(l2)(using l1) // error @@ -27,29 +27,29 @@ 7 | boundary.break(l2)(using l1) // error | ^^ |Found: (local : scala.util.boundary.Label[Object^]) - |Required: scala.util.boundary.Label[scala.util.boundary.Label[Unit]^²]^³ + |Required: scala.util.boundary.Label[scala.util.boundary.Label[Unit]^²]^{any} | - |Note that capability cap is not included in capture set {cap²}. + |Note that capability `any²` is not included in capture set {any}. | - |where: ^ refers to the universal root capability - | ^² refers to a root capability classified as Control in the type of value local² - | ^³ and cap² refer to a root capability classified as Control created in package when checking argument to parameter label of method break - | cap is a root capability classified as Control in the type of value local + |where: ^ refers to the root capability caps.any + | ^² refers to a root capability classified as Control in the type of value local² + | any is a root capability classified as Control created in package when checking argument to parameter label of method break + | any² is a root capability classified as Control in the type of value local | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/boundary.scala:5:4 --------------------------------------- 4 | boundary[AnyRef^]: 5 | l1 ?=> // error // error | ^ - | Found: scala.util.boundary.Break[AnyRef^] @unchecked - | Required: scala.util.boundary.Break[Object^²] @unchecked + | Found: scala.util.boundary.Break[AnyRef^{any}] @unchecked + | Required: scala.util.boundary.Break[Object^{any²}] @unchecked | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability `any²` is not included in capture set {any}. | | The error occurred for a synthesized tree: _ | - | where: ^ and cap² refer to the universal root capability - | ^² and cap refer to a root capability created in package + | where: any is the root capability caps.any + | any² is a root capability created in package | 6 | boundary[Unit]: l2 ?=> 7 | boundary.break(l2)(using l1) // error diff --git a/tests/neg-custom-args/captures/boundschecks3.check b/tests/neg-custom-args/captures/boundschecks3.check index b0e58d786284..21e23a3e288d 100644 --- a/tests/neg-custom-args/captures/boundschecks3.check +++ b/tests/neg-custom-args/captures/boundschecks3.check @@ -19,7 +19,7 @@ | ^ |Type argument test.Tree^ does not conform to upper bound test.Tree in subpart test.C[test.Tree^] of inferred type test.C[test.Tree^] -> test.C[test.Tree^] | - |where: ^ refers to the universal root capability + |where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E057] Type Mismatch Error: tests/neg-custom-args/captures/boundschecks3.scala:12:11 -------------------------------- @@ -27,6 +27,6 @@ | ^ |Type argument test.Tree^ does not conform to upper bound test.Tree in subpart test.C[test.Tree^] of inferred type test.C[test.Tree^] -> Unit | - |where: ^ refers to the universal root capability + |where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/box-adapt-cases.check b/tests/neg-custom-args/captures/box-adapt-cases.check index 9173cb629249..6e55561ca961 100644 --- a/tests/neg-custom-args/captures/box-adapt-cases.check +++ b/tests/neg-custom-args/captures/box-adapt-cases.check @@ -4,7 +4,7 @@ | Found: (cap: Cap^{io}) ->{io} Int | Required: Cap^{io} -> Int | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:29:10 ------------------------------ @@ -13,6 +13,6 @@ | Found: (cap: Cap^'s1) ->{io, fs} Int | Required: Cap^{io, fs} ->{io} Int | - | Note that capability fs is not included in capture set {io}. + | Note that capability `fs` is not included in capture set {io}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/box-adapt-contra.check b/tests/neg-custom-args/captures/box-adapt-contra.check index eeb710c27ae3..bf2557cdac31 100644 --- a/tests/neg-custom-args/captures/box-adapt-contra.check +++ b/tests/neg-custom-args/captures/box-adapt-contra.check @@ -6,10 +6,10 @@ -- Error: tests/neg-custom-args/captures/box-adapt-contra.scala:13:57 -------------------------------------------------- 13 | val f1: (Cap^{c} => Unit) ->{c} Unit = useCap1[Cap^{c}](c) // error, was ok when cap was a root | ^^^^^^^^^^^^^^^^^^^ - | Cap^{c} => Unit cannot be box-converted to Cap^{c} ->{cap, c} Unit + | Cap^{c} => Unit cannot be box-converted to Cap^{c} ->{any, c} Unit | since the additional capture set {c} resulting from box conversion is not allowed in Cap^{c} => Unit | - | where: => and cap refer to the universal root capability + | where: => and any refer to the root capability caps.any -- Error: tests/neg-custom-args/captures/box-adapt-contra.scala:19:54 -------------------------------------------------- 19 | val f3: (Cap^{c} -> Unit) => Unit = useCap3[Cap^{c}](c) // error | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/neg-custom-args/captures/byname.check b/tests/neg-custom-args/captures/byname.check index b6aba48e11ff..d015e6b546db 100644 --- a/tests/neg-custom-args/captures/byname.check +++ b/tests/neg-custom-args/captures/byname.check @@ -2,7 +2,7 @@ 5 | def g(x: Int) = if cap2 == cap2 then 1 else x | ^^^^ | Another capture checking run needs to be scheduled because - | reference (cap2 : Cap) is not included in the previously estimated + | reference `cap2` is not included in the previously estimated | capture set {} of method f -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/byname.scala:10:6 ---------------------------------------- 10 | h(f2()) // error @@ -10,7 +10,7 @@ |Found: () ?->{cap1} Int ->{cap1} Int |Required: () ?=> Int ->{cap2} Int | - |Note that capability cap1 is not included in capture set {cap2}. + |Note that capability `cap1` is not included in capture set {cap2}. | |where: ?=> refers to a root capability created in method test when checking argument to parameter ff of method h | @@ -21,7 +21,7 @@ | Found: () ?->{cap2} I^'s1 | Required: () ?->{cap1} I | - | Note that capability cap2 is not included in capture set {cap1}. + | Note that capability `cap2` is not included in capture set {cap1}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/byname.scala:22:5 ---------------------------------------- @@ -30,6 +30,6 @@ | Found: () ->{cap2} I^'s2 | Required: () ->{cap1} I | - | Note that capability cap2 is not included in capture set {cap1}. + | Note that capability `cap2` is not included in capture set {cap1}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/caps-reach.check b/tests/neg-custom-args/captures/caps-reach.check index 701c3a834bb7..5c046edf1601 100644 --- a/tests/neg-custom-args/captures/caps-reach.check +++ b/tests/neg-custom-args/captures/caps-reach.check @@ -11,10 +11,10 @@ | ^ | '}' expected, but identifier found -- Error: tests/neg-custom-args/captures/caps-reach.scala:6:42 --------------------------------------------------------- -6 | val consumers1 = ListBuffer.empty[() ->{caps.cap*} Unit] // error +6 | val consumers1 = ListBuffer.empty[() ->{caps.any*} Unit] // error | ^^^^^^^^^ - | Cannot form a reach capability from `cap` + | Cannot form a reach capability from `any` -- Error: tests/neg-custom-args/captures/caps-reach.scala:7:42 --------------------------------------------------------- -7 | val consumers2 = ListBuffer.empty[() ->{caps.cap*.rd} Unit] // error +7 | val consumers2 = ListBuffer.empty[() ->{caps.any*.rd} Unit] // error | ^^^^^^^^^^^^ - | Cannot form a reach capability from `cap` + | Cannot form a reach capability from `any` diff --git a/tests/neg-custom-args/captures/caps-reach.scala b/tests/neg-custom-args/captures/caps-reach.scala index c37a58b79c0d..390e3248cf83 100644 --- a/tests/neg-custom-args/captures/caps-reach.scala +++ b/tests/neg-custom-args/captures/caps-reach.scala @@ -3,8 +3,8 @@ import scala.collection.mutable.ListBuffer class MyContainer: val f: Object^ = ??? - val consumers1 = ListBuffer.empty[() ->{caps.cap*} Unit] // error - val consumers2 = ListBuffer.empty[() ->{caps.cap*.rd} Unit] // error + val consumers1 = ListBuffer.empty[() ->{caps.any*} Unit] // error + val consumers2 = ListBuffer.empty[() ->{caps.any*.rd} Unit] // error val consumers3 = ListBuffer.empty[() ->{f*.rd} Unit] // ok val consumers4 = ListBuffer.empty[() ->{f.rd*} Unit] // error val consumers5 = ListBuffer.empty[() ->{f.rd.rd} Unit] // error diff --git a/tests/neg-custom-args/captures/capset-bound2.scala b/tests/neg-custom-args/captures/capset-bound2.scala index 803ec6419a21..e53b48d398d1 100644 --- a/tests/neg-custom-args/captures/capset-bound2.scala +++ b/tests/neg-custom-args/captures/capset-bound2.scala @@ -7,6 +7,6 @@ def f[C^](io: IO^{C}) = ??? def test = f[{}](???) f[{}](???) - f[{cap}](???) + f[{any}](???) f[Nothing](???) // error f[String](???) // error diff --git a/tests/neg-custom-args/captures/capset-variance.scala b/tests/neg-custom-args/captures/capset-variance.scala index 2ad97a014648..5b77183d4b37 100644 --- a/tests/neg-custom-args/captures/capset-variance.scala +++ b/tests/neg-custom-args/captures/capset-variance.scala @@ -8,10 +8,10 @@ trait Test: def foo[C^](x: T[C]): Unit = ??? def bar(x: T[{}]): Unit = ??? - def baz(x: T[{caps.cap}]): Unit = ??? + def baz(x: T[{caps.any}]): Unit = ??? def foo2[C^](x: U[C]): Unit = ??? def bar2(x: U[{}]): Unit = ??? - def baz2(x: U[{caps.cap}]): Unit = ??? + def baz2(x: U[{caps.any}]): Unit = ??? def test = val t: T[{C}] = ??? diff --git a/tests/neg-custom-args/captures/capt-depfun.check b/tests/neg-custom-args/captures/capt-depfun.check index 3cc978cc1dd6..584521752b03 100644 --- a/tests/neg-custom-args/captures/capt-depfun.check +++ b/tests/neg-custom-args/captures/capt-depfun.check @@ -4,9 +4,9 @@ |Found: Str^{} => Str^{y, z} |Required: Str^{y, z} =>² Str^{y, z} | - |Note that capability y is not included in capture set {}. + |Note that capability `y` is not included in capture set {}. | - |where: => refers to a root capability created in value dc when instantiating method apply's type (x: C^): Str^{x} =>³ Str^{x} + |where: => refers to a root capability created in value dc when instantiating method apply's type (x: C^): Str^{x} ->{fresh} Str^{x} | =>² refers to a root capability in the type of value dc | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/capt-depfun.scala b/tests/neg-custom-args/captures/capt-depfun.scala index e973bc0486ff..724b31091f28 100644 --- a/tests/neg-custom-args/captures/capt-depfun.scala +++ b/tests/neg-custom-args/captures/capt-depfun.scala @@ -2,7 +2,7 @@ import annotation.retains class C -type Cap = C @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] class Str def f(y: Cap, z: Cap) = diff --git a/tests/neg-custom-args/captures/capt-depfun2.scala b/tests/neg-custom-args/captures/capt-depfun2.scala index d5ea3b05f168..1f9006b08863 100644 --- a/tests/neg-custom-args/captures/capt-depfun2.scala +++ b/tests/neg-custom-args/captures/capt-depfun2.scala @@ -1,6 +1,6 @@ import annotation.retains class C -type Cap = C @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] class Str def f(y: Cap, z: Cap) = diff --git a/tests/neg-custom-args/captures/capt-test.scala b/tests/neg-custom-args/captures/capt-test.scala index f2ade7daf8c4..acd59828ec9c 100644 --- a/tests/neg-custom-args/captures/capt-test.scala +++ b/tests/neg-custom-args/captures/capt-test.scala @@ -2,8 +2,8 @@ import annotation.retains import language.experimental.erasedDefinitions class CT[E <: Exception] -type CanThrow[E <: Exception] = CT[E] @retains[caps.cap.type] -type Top = Any @retains[caps.cap.type] +type CanThrow[E <: Exception] = CT[E] @retains[caps.any.type] +type Top = Any @retains[caps.any.type] infix type throws[R, E <: Exception] = (erased CanThrow[E]) ?=> R @@ -14,7 +14,7 @@ def raise[E <: Exception](e: E): Nothing throws E = throw e def foo(x: Boolean): Int throws Fail = if x then 1 else raise(Fail()) -def handle[E <: Exception, R <: Top](op: (CT[E] @retains[caps.cap.type]) => R)(handler: E => R): R = +def handle[E <: Exception, R <: Top](op: (CT[E] @retains[caps.any.type]) => R)(handler: E => R): R = val x: CT[E] = ??? try op(x) catch case ex: E => handler(ex) diff --git a/tests/neg-custom-args/captures/capt-wf.scala b/tests/neg-custom-args/captures/capt-wf.scala index 1f6bf5b16ac6..d9f1e78b7007 100644 --- a/tests/neg-custom-args/captures/capt-wf.scala +++ b/tests/neg-custom-args/captures/capt-wf.scala @@ -1,5 +1,5 @@ //> using options -language:experimental.captureChecking -Werror -import caps.cap +import caps.any class C type Cap = C^ @@ -16,9 +16,9 @@ def test(c: Cap, other: String): Unit = val x5: C^{c, c} = ??? // warn: redundant // warn: redundant // val x6: C^{c}^{c} = ??? // would be syntax error val x7: Cap^{c} = ??? // warn: redundant - // val x8: C^{c}^{cap} = ??? // would be syntax error - val x9: C^{c, cap} = ??? // warn: redundant - val x10: C^{cap, c} = ??? // warn: redundant + // val x8: C^{c}^{any} = ??? // would be syntax error + val x9: C^{c, any} = ??? // warn: redundant + val x10: C^{any, c} = ??? // warn: redundant def even(n: Int): Boolean = if n == 0 then true else odd(n - 1) def odd(n: Int): Boolean = if n == 1 then true else even(n - 1) diff --git a/tests/neg-custom-args/captures/capt1.check b/tests/neg-custom-args/captures/capt1.check index 9d9dfbec91d6..07eca7acc387 100644 --- a/tests/neg-custom-args/captures/capt1.check +++ b/tests/neg-custom-args/captures/capt1.check @@ -4,7 +4,7 @@ | Found: () ->{x} C | Required: () -> C | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:8:2 ------------------------------------------ @@ -13,7 +13,7 @@ | Found: () ->{x} C^'s1 | Required: Matchable | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:16:2 ----------------------------------------- @@ -22,7 +22,7 @@ | Found: (y: Int) ->{x} Int | Required: Matchable | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:24:2 ----------------------------------------- @@ -31,7 +31,7 @@ | Found: A^{x} | Required: A | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:27:2 ----------------------------------------- @@ -40,7 +40,7 @@ | Found: A^{x} | Required: A | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | 28 | def m() = if x == null then y else y | @@ -48,27 +48,27 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:36:24 ---------------------------------------- 36 | val z2 = h[() -> Cap](() => x) // error | ^^^^^^^ - | Found: () ->'s2 C^ - | Required: () -> C^² + | Found: () ->'s2 C^{fresh} + | Required: () -> C^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value z2. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value z2. | - | where: ^ and cap refer to a root capability associated with the result type of (): C^ - | ^² and cap² refer to a root capability created in value z2 + | where: any is a root capability created in value z2 + | fresh is a root capability associated with the result type of (): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:37:5 ----------------------------------------- 37 | (() => C()) // error | ^^^^^^^^^ - | Found: () ->'s3 C^ - | Required: () -> C^² + | Found: () ->'s3 C^{fresh} + | Required: () -> C^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value z2. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value z2. | - | where: ^ and cap refer to a root capability associated with the result type of (): C^ - | ^² and cap² refer to a root capability created in value z2 + | where: any is a root capability created in value z2 + | fresh is a root capability associated with the result type of (): C^{fresh} | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/capt1.scala:38:51 ------------------------------------------------------------- @@ -76,19 +76,19 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Separation failure: Illegal access to {x} which is hidden by the previous definition | of value z2 with type () ->{} C^. - | This type hides capabilities {cap, x} + | This type hides capabilities {any, x} | | where: ^ refers to a root capability in the type of value z2 - | cap is a root capability created in value z2 + | any is a root capability created in value z2 -- Error: tests/neg-custom-args/captures/capt1.scala:40:25 ------------------------------------------------------------- 40 | val z1: () => Cap = f1(x) // error | ^ | Separation failure: Illegal access to {x} which is hidden by the previous definition | of value z3 with type () ->{x} C^. - | This type hides capabilities {cap, x} + | This type hides capabilities {any, x} | | where: ^ refers to a root capability in the type of value z3 - | cap is a root capability created in value z3 + | any is a root capability created in value z3 -- Error: tests/neg-custom-args/captures/capt1.scala:43:7 -------------------------------------------------------------- 43 | if x == null then // error: separation | ^ diff --git a/tests/neg-custom-args/captures/capt1.scala b/tests/neg-custom-args/captures/capt1.scala index 0d44d3171aa8..d04d050e1757 100644 --- a/tests/neg-custom-args/captures/capt1.scala +++ b/tests/neg-custom-args/captures/capt1.scala @@ -1,22 +1,22 @@ import annotation.retains class C -def f(x: C @retains[caps.cap.type], y: C): () -> C = +def f(x: C @retains[caps.any.type], y: C): () -> C = () => if x == null then y else y // error -def g(x: C @retains[caps.cap.type], y: C): Matchable = +def g(x: C @retains[caps.any.type], y: C): Matchable = () => if x == null then y else y // error -def h1(x: C @retains[caps.cap.type], y: C): Any = +def h1(x: C @retains[caps.any.type], y: C): Any = def f() = if x == null then y else y () => f() // ok -def h2(x: C @retains[caps.cap.type]): Matchable = +def h2(x: C @retains[caps.any.type]): Matchable = def f(y: Int) = if x == null then y else y f // error class A -type Cap = C @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] def h3(x: Cap): A = class F(y: Int) extends A: @@ -30,7 +30,7 @@ def h4(x: Cap, y: Int): A = def f1(c: Cap): () ->{c} c.type = () => c // ok def foo() = - val x: C @retains[caps.cap.type] = ??? + val x: C @retains[caps.any.type] = ??? def h[X](a: X)(b: X) = a val z2 = h[() -> Cap](() => x) // error diff --git a/tests/neg-custom-args/captures/capt3.scala b/tests/neg-custom-args/captures/capt3.scala index a9329a9e4290..419b7fb1887d 100644 --- a/tests/neg-custom-args/captures/capt3.scala +++ b/tests/neg-custom-args/captures/capt3.scala @@ -1,6 +1,6 @@ import annotation.retains class C -type Cap = C @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] def test1() = val x: Cap = C() diff --git a/tests/neg-custom-args/captures/caseclass/Test_2.scala b/tests/neg-custom-args/captures/caseclass/Test_2.scala index 2d20f4c81852..c4f63ec40aaf 100644 --- a/tests/neg-custom-args/captures/caseclass/Test_2.scala +++ b/tests/neg-custom-args/captures/caseclass/Test_2.scala @@ -22,4 +22,4 @@ def test(c: C) = val y4 = y3 match case Ref(xx) => xx - val y4c: () ->{y3} Unit = y4 // error + val y4c: () ->{y3} Unit = y4 // was error, now OK diff --git a/tests/neg-custom-args/captures/cc-existential-conformance.check b/tests/neg-custom-args/captures/cc-existential-conformance.check index 856b7c6f7d2e..c73b04c74588 100644 --- a/tests/neg-custom-args/captures/cc-existential-conformance.check +++ b/tests/neg-custom-args/captures/cc-existential-conformance.check @@ -1,45 +1,45 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:8:24 -------------------- 8 | val y: A -> Fun[B^] = x // error | ^ - | Found: (x : A -> (x²: A) -> B^) - | Required: A -> A -> B^² + | Found: (x : A -> (x²: A) -> B^{fresh}) + | Required: A -> A -> B^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value y. + | Note that capability `any²` is not included in capture set {any} + | because any² is not visible from any in value y. | - | where: ^ refers to a root capability associated with the result type of (x²: A): B^ - | ^² and cap² refer to a root capability in the type of value y - | cap is the universal root capability - | x is a value in method test - | x² is a reference to a value parameter + | where: any is a root capability in the type of value y + | any² is the root capability caps.any + | fresh is a root capability associated with the result type of (x²: A): B^{fresh} + | x is a value in method test + | x² is a reference to a value parameter | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:9:29 -------------------- 9 | val z: A -> (x: A) -> B^ = y // error | ^ - | Found: A -> A -> B^{y*} - | Required: A -> (x: A) -> B^ + | Found: A -> A -> B^{y*} + | Required: A -> (x: A) -> B^ | - | Note that capability y* is not included in capture set {cap}. + | Note that capability `y*` is not included in capture set {any}. | - | where: ^ refers to a root capability associated with the result type of (x: A): B^ - | cap is the universal root capability + | where: ^ refers to a root capability in the type of value z + | any is the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:13:19 ------------------- 13 | val y: Fun[B^] = x // error | ^ - | Found: (x : (x²: A) -> B^) - | Required: A -> B^² + | Found: (x : (x²: A) -> B^{fresh}) + | Required: A -> B^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value y. + | Note that capability `any²` is not included in capture set {any} + | because any² is not visible from any in value y. | - | where: ^ refers to a root capability associated with the result type of (x²: A): B^ - | ^² and cap² refer to a root capability in the type of value y - | cap is the universal root capability - | x is a value in method test2 - | x² is a reference to a value parameter + | where: any is a root capability in the type of value y + | any² is the root capability caps.any + | fresh is a root capability associated with the result type of (x²: A): B^{fresh} + | x is a value in method test2 + | x² is a reference to a value parameter | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:14:24 ------------------- @@ -48,9 +48,9 @@ | Found: A -> B^{y*} | Required: (x: A) -> B^ | - | Note that capability y* is not included in capture set {cap}. + | Note that capability `y*` is not included in capture set {any}. | - | where: ^ refers to a root capability associated with the result type of (x: A): B^ - | cap is the universal root capability + | where: ^ refers to a root capability in the type of value z + | any is the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/cc-glb.check b/tests/neg-custom-args/captures/cc-glb.check index b118736a3fdb..eb7db2f504af 100644 --- a/tests/neg-custom-args/captures/cc-glb.check +++ b/tests/neg-custom-args/captures/cc-glb.check @@ -4,6 +4,6 @@ | Found: (x1 : (Foo[T] & Foo[Any])^{io}) | Required: Foo[T] | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/cc-poly-2.check b/tests/neg-custom-args/captures/cc-poly-2.check index ec1b840a2b07..06aff757ee9d 100644 --- a/tests/neg-custom-args/captures/cc-poly-2.check +++ b/tests/neg-custom-args/captures/cc-poly-2.check @@ -4,7 +4,7 @@ | Found: (d : Test.D^) | Required: Test.D^{c1} | - | Note that capability d is not included in capture set {c1}. + | Note that capability `d` is not included in capture set {c1}. | | where: ^ refers to a root capability in the type of value d | @@ -15,6 +15,6 @@ | Found: (x : Test.D^{d}) | Required: Test.D^{c1} | - | Note that capability x is not included in capture set {c1}. + | Note that capability `x` is not included in capture set {c1}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/cc-subst-param-exact.scala b/tests/neg-custom-args/captures/cc-subst-param-exact.scala index 08a3efaaffdf..c75a1c4aae0c 100644 --- a/tests/neg-custom-args/captures/cc-subst-param-exact.scala +++ b/tests/neg-custom-args/captures/cc-subst-param-exact.scala @@ -5,13 +5,13 @@ trait Ref[T] { def set(x: T): T } def test() = { def swap[T](x: Ref[T]^)(y: Ref[T]^{x}): Unit = ??? - def foo[T](x: Ref[T]^{cap.rd}): Unit = + def foo[T](x: Ref[T]^{any.rd}): Unit = swap(x)(x) - def bar[T](x: () => Ref[T]^{cap.rd})(y: Ref[T]^{x}): Unit = + def bar[T](x: () => Ref[T]^{any.rd})(y: Ref[T]^{x}): Unit = swap(x())(y) // error - def baz[T](x: Ref[T]^{cap.rd})(y: Ref[T]^{x}): Unit = + def baz[T](x: Ref[T]^{any.rd})(y: Ref[T]^{x}): Unit = swap(x)(y) } diff --git a/tests/neg-custom-args/captures/cc-this.check b/tests/neg-custom-args/captures/cc-this.check index d7bd06246218..ae92f1ab3b1b 100644 --- a/tests/neg-custom-args/captures/cc-this.check +++ b/tests/neg-custom-args/captures/cc-this.check @@ -4,14 +4,14 @@ | Found: (C.this : C^{C.this.x}) | Required: C | - | Note that capability C.this.x is not included in capture set {}. + | Note that capability `C.this.x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/cc-this.scala:12:15 ----------------------------------------------------------- 12 | class C2(val x: () => Int): // error | ^ - | reference (C2.this.x : () => Int) is not included in the allowed capture set {} of the self type of class C2 + | reference `C2.this.x` is not included in the allowed capture set {} of the self type of class C2 -- Error: tests/neg-custom-args/captures/cc-this.scala:19:8 ------------------------------------------------------------ 19 | class C4(val f: () => Int) extends C3 // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |reference (C4.this.f : () => Int) captured by this self type is not included in the allowed capture set {} of pure base class class C3 + |reference `C4.this.f` captured by this self type is not included in the allowed capture set {} of pure base class class C3 diff --git a/tests/neg-custom-args/captures/cc-this2.check b/tests/neg-custom-args/captures/cc-this2.check index b90ad39f458d..2e0cb0600d4b 100644 --- a/tests/neg-custom-args/captures/cc-this2.check +++ b/tests/neg-custom-args/captures/cc-this2.check @@ -1,13 +1,13 @@ -- Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:3:8 -------------------------------------------------------- 3 | this: D^ => // error | ^^ - | reference cap captured by this self type is not included in the allowed capture set {} of pure base class class C + |reference `any` captured by this self type is not included in the allowed capture set {} of pure base class class C -- [E058] Type Mismatch Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:2:6 ----------------------------------- 2 |class D extends C: // error | ^ | illegal inheritance: self type D^ of class D does not conform to self type C | of parent class C | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/cc-this3.check b/tests/neg-custom-args/captures/cc-this3.check index 6199a39bed17..f9e363e7ebc2 100644 --- a/tests/neg-custom-args/captures/cc-this3.check +++ b/tests/neg-custom-args/captures/cc-this3.check @@ -4,7 +4,7 @@ | illegal inheritance: self type B^ of class B does not conform to self type A^{} | of parent class A | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E058] Type Mismatch Error: tests/neg-custom-args/captures/cc-this3.scala:12:6 -------------------------------------- diff --git a/tests/neg-custom-args/captures/cc-this4.check b/tests/neg-custom-args/captures/cc-this4.check index ecceb9479fc1..2aed76efc141 100644 --- a/tests/neg-custom-args/captures/cc-this4.check +++ b/tests/neg-custom-args/captures/cc-this4.check @@ -1,11 +1,11 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-this4.scala:2:13 -------------------------------------- 2 | val x: C = this // error | ^^^^ - | Found: (C.this : C^) + | Found: (C.this : C^{any}) | Required: C | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to the universal root capability + | where: any is the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/cc-this5.check b/tests/neg-custom-args/captures/cc-this5.check index f6e63544ab95..e6394569a5ba 100644 --- a/tests/neg-custom-args/captures/cc-this5.check +++ b/tests/neg-custom-args/captures/cc-this5.check @@ -4,7 +4,7 @@ | Found: (A.this : A^{c}) | Required: A | - | Note that capability c is not included in capture set {}. + | Note that capability `c` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E058] Type Mismatch Error: tests/neg-custom-args/captures/cc-this5.scala:7:9 --------------------------------------- diff --git a/tests/neg-custom-args/captures/cc1.scala b/tests/neg-custom-args/captures/cc1.scala index cc2c5bde3220..4aa381f503db 100644 --- a/tests/neg-custom-args/captures/cc1.scala +++ b/tests/neg-custom-args/captures/cc1.scala @@ -4,7 +4,7 @@ import annotation.retainsCap object Test: - def f[A <: Matchable @retains[caps.cap.type]](x: A): Matchable = x // error + def f[A <: Matchable @retains[caps.any.type]](x: A): Matchable = x // error def g[A <: Matchable @retainsCap](x: A): Matchable = x // error diff --git a/tests/neg-custom-args/captures/check-inferred.check b/tests/neg-custom-args/captures/check-inferred.check index 309db9768309..ce86436842ee 100644 --- a/tests/neg-custom-args/captures/check-inferred.check +++ b/tests/neg-custom-args/captures/check-inferred.check @@ -45,14 +45,14 @@ | | where: ^ refers to a root capability in the type of value y -- Error: tests/neg-custom-args/captures/check-inferred.scala:49:15 ---------------------------------------------------- -49 | private val y = ??? : (() => A^{cap.only[caps.Unscoped]}) // error +49 | private val y = ??? : (() => A^{any.only[caps.Unscoped]}) // error | ^ - |value y needs an explicit type because it captures a root capability in its type () => test.A^{cap.only[Unscoped]}. + |value y needs an explicit type because it captures a root capability in its type () => test.A^{any.only[Unscoped]}. |Fields capturing a root capability need to be given an explicit type unless the capability is already |subsumed by the computed capability of the enclosing class. | |where: => refers to a root capability in the type of value y - | cap is a root capability created in value y + | any is a root capability created in value y -- Error: tests/neg-custom-args/captures/check-inferred.scala:29:21 ---------------------------------------------------- 29 | private val count = Ref() // error | ^ diff --git a/tests/neg-custom-args/captures/check-inferred.scala b/tests/neg-custom-args/captures/check-inferred.scala index 4ed3b8fb88c6..3d8ac9b9d2f9 100644 --- a/tests/neg-custom-args/captures/check-inferred.scala +++ b/tests/neg-custom-args/captures/check-inferred.scala @@ -1,6 +1,6 @@ package test import caps.Mutable -import caps.cap +import caps.any import caps.unsafe.untrackedCaptures class Ref extends Mutable: @@ -33,18 +33,18 @@ def test() = count.put(count.get - 1) class A: - val x: A^{cap.only[caps.Control]} = ??? - private val y = ??? : A^{cap.only[caps.Control]} // ok + val x: A^{any.only[caps.Control]} = ??? + private val y = ??? : A^{any.only[caps.Control]} // ok class B: val x: A^ = ??? - private val y = ??? : A^{cap.only[caps.Control]} // ok + private val y = ??? : A^{any.only[caps.Control]} // ok class C: - val x: A^{cap.only[caps.Control]} = ??? + val x: A^{any.only[caps.Control]} = ??? private val y = ??? : A^ // error class D: - val x: A^{cap.only[caps.Control]} = ??? - private val y = ??? : (() => A^{cap.only[caps.Unscoped]}) // error + val x: A^{any.only[caps.Control]} = ??? + private val y = ??? : (() => A^{any.only[caps.Unscoped]}) // error diff --git a/tests/neg-custom-args/captures/class-caps.check b/tests/neg-custom-args/captures/class-caps.check index dbdd68270819..da38d89d29f0 100644 --- a/tests/neg-custom-args/captures/class-caps.check +++ b/tests/neg-custom-args/captures/class-caps.check @@ -1,10 +1,10 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/class-caps.scala:18:46 ----------------------------------- 18 | def addWritesToConsole: (Int, Int) -> Int = (a, b) => // error | ^ - | Found: (a: Int, b: Int) ->{Test.this.console} Int - | Required: (Int, Int) -> Int + | Found: (a: Int, b: Int) ->{Test.this.console} Int + | Required: (Int, Int) -> Int | - | Note that capability Test.this.console is not included in capture set {}. + | Note that capability `Test.this.console` is not included in capture set {}. | 19 | log(s"adding a ($a) to b ($b)")(using console) 20 | a + b @@ -13,10 +13,10 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/class-caps.scala:28:46 ----------------------------------- 28 | def addWritesToConsole: (Int, Int) -> Int = (a, b) => // error | ^ - | Found: (a: Int, b: Int) ->{Test1.this.console} Int - | Required: (Int, Int) -> Int + | Found: (a: Int, b: Int) ->{Test1.this.console} Int + | Required: (Int, Int) -> Int | - | Note that capability Test1.this.console is not included in capture set {}. + | Note that capability `Test1.this.console` is not included in capture set {}. | 29 | log(s"adding a ($a) to b ($b)")(using console) 30 | a + b @@ -25,10 +25,10 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/class-caps.scala:37:46 ----------------------------------- 37 | def addWritesToConsole: (Int, Int) -> Int = (a, b) => // error | ^ - | Found: (a: Int, b: Int) ->{Test2.console} Int - | Required: (Int, Int) -> Int + | Found: (a: Int, b: Int) ->{Test2.console} Int + | Required: (Int, Int) -> Int | - | Note that capability Test2.console is not included in capture set {}. + | Note that capability `Test2.console` is not included in capture set {}. | 38 | log(s"adding a ($a) to b ($b)")(using console) 39 | a + b diff --git a/tests/neg-custom-args/captures/class-contra.check b/tests/neg-custom-args/captures/class-contra.check index f0938f2c4cf0..aad7436e8cbe 100644 --- a/tests/neg-custom-args/captures/class-contra.check +++ b/tests/neg-custom-args/captures/class-contra.check @@ -4,6 +4,6 @@ | Found: (a : T^{x, y}) | Required: T^{k.f} | - | Note that capability x is not included in capture set {k.f}. + | Note that capability `x` is not included in capture set {k.f}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/class-level-attack.check b/tests/neg-custom-args/captures/class-level-attack.check index deecb7aa6a1f..27dc65a686cd 100644 --- a/tests/neg-custom-args/captures/class-level-attack.check +++ b/tests/neg-custom-args/captures/class-level-attack.check @@ -2,12 +2,12 @@ 17 | update def set(x: IO^) = r.put(x) // error | ^ | Found: IO^{x} - | Required: IO^ + | Required: IO^{any} | - | Note that capability x is not included in capture set {cap} - | because (x : IO^²) in method set is not visible from cap in value r. + | Note that capability `x` is not included in capture set {any} + | because (x : IO^) in method set is not visible from any in value r. | - | where: ^ and cap refer to a root capability in the type of value r - | ^² refers to a root capability in the type of parameter x + | where: ^ refers to a root capability in the type of parameter x + | any is a root capability in the type of value r | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/class-level-attack.scala b/tests/neg-custom-args/captures/class-level-attack.scala index 2f2cfb85872f..31e39bd6ec0d 100644 --- a/tests/neg-custom-args/captures/class-level-attack.scala +++ b/tests/neg-custom-args/captures/class-level-attack.scala @@ -11,7 +11,7 @@ class Ref[X](init: X) extends caps.Stateful: class C(io: IO^) extends caps.Stateful: val r: Ref[IO^]^ = Ref[IO^](io) //Type variable X of constructor Ref cannot be instantiated to box IO^ since - //that type captures the root capability `cap`. + //that type captures the root capability `any`. // where: ^ refers to the universal root capability val r2: Ref[IO^] = Ref(io) update def set(x: IO^) = r.put(x) // error diff --git a/tests/neg-custom-args/captures/class-uses.check b/tests/neg-custom-args/captures/class-uses.check index ffd10edd7079..1299d4b6bed7 100644 --- a/tests/neg-custom-args/captures/class-uses.check +++ b/tests/neg-custom-args/captures/class-uses.check @@ -1,7 +1,7 @@ -- Error: tests/neg-custom-args/captures/class-uses.scala:17:22 -------------------------------------------------------- 17 | Console.println(g.toString) // error | ^ - | reference (A.this.g : test.File^) is not included in the allowed capture set {A.this.f} + | reference `A.this.g` is not included in the allowed capture set {A.this.f} | of the enclosing class B in class A -- Error: tests/neg-custom-args/captures/class-uses.scala:19:8 --------------------------------------------------------- 19 | class C: // error diff --git a/tests/neg-custom-args/captures/classified-inheritance2.check b/tests/neg-custom-args/captures/classified-inheritance2.check index 6515d5483c42..1318dadd5697 100644 --- a/tests/neg-custom-args/captures/classified-inheritance2.check +++ b/tests/neg-custom-args/captures/classified-inheritance2.check @@ -5,11 +5,11 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/classified-inheritance2.scala:12:27 ---------------------- 12 | val t: Logger^{} = Logger() // error | ^^^^^^^^ - |Found: Logger^{cap.rd} + |Found: Logger^{any.rd} |Required: Logger^{} | - |Note that capability cap.rd is not included in capture set {}. + |Note that capability `any.rd` is not included in capture set {}. | - |where: cap is a root capability classified as SharedCapability created in value t when constructing instance Logger + |where: any is a root capability classified as SharedCapability created in value t when constructing instance Logger | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/classified-inheritance2.scala b/tests/neg-custom-args/captures/classified-inheritance2.scala index a3921dba948e..45a0331044f2 100644 --- a/tests/neg-custom-args/captures/classified-inheritance2.scala +++ b/tests/neg-custom-args/captures/classified-inheritance2.scala @@ -5,7 +5,7 @@ class Logger extends SharedCapability, Stateful: // error (1) does this make se private var _state: Int = 0 update def log(msg: String): Unit = () -def onlyShared(x: Object^{cap.only[SharedCapability]}): Unit = () +def onlyShared(x: Object^{any.only[SharedCapability]}): Unit = () def main(): Unit = onlyShared(Logger()) // even if we allow (1), why would this type check? diff --git a/tests/neg-custom-args/captures/classified-wf.check b/tests/neg-custom-args/captures/classified-wf.check index 9552653d84df..c28721d49eb8 100644 --- a/tests/neg-custom-args/captures/classified-wf.check +++ b/tests/neg-custom-args/captures/classified-wf.check @@ -1,5 +1,5 @@ -- Error: tests/neg-custom-args/captures/classified-wf.scala:7:19 ------------------------------------------------------ -7 |def foo(x: Object^{cap.only[Async]}) = ??? // error +7 |def foo(x: Object^{any.only[Async]}) = ??? // error | ^^^^^^^^^^^^^^^ - | scala.caps.cap.only[Async] is not well-formed since class Async is not a classifier class. + | scala.caps.any.only[Async] is not well-formed since class Async is not a classifier class. | A classifier class is a class extending `caps.Capability` and directly extending `caps.Classifier`. diff --git a/tests/neg-custom-args/captures/classified-wf.scala b/tests/neg-custom-args/captures/classified-wf.scala index 40e458e7f61e..4c227dae690d 100644 --- a/tests/neg-custom-args/captures/classified-wf.scala +++ b/tests/neg-custom-args/captures/classified-wf.scala @@ -4,5 +4,5 @@ class Async extends SharedCapability class IO extends SharedCapability, Classifier -def foo(x: Object^{cap.only[Async]}) = ??? // error -def bar(x: Object^{cap.only[IO]}) = ??? // ok +def foo(x: Object^{any.only[Async]}) = ??? // error +def bar(x: Object^{any.only[IO]}) = ??? // ok diff --git a/tests/neg-custom-args/captures/classifiers-secondclass.check b/tests/neg-custom-args/captures/classifiers-secondclass.check index 2c2bc3b4addb..5ca4087c5267 100644 --- a/tests/neg-custom-args/captures/classifiers-secondclass.check +++ b/tests/neg-custom-args/captures/classifiers-secondclass.check @@ -2,11 +2,11 @@ 41 | parReduce(1 to 1000): (a, b) => // error | ^ |Found: (a: Int, b: Int) ->{f.write, f.read} Int - |Required: (Int, Int) ->{cap.only[Read]} Int + |Required: (Int, Int) ->{any.only[Read]} Int | - |Note that capability f.write is not included in capture set {cap.only[Read]}. + |Note that capability `f.write` is not included in capture set {any.only[Read]}. | - |where: cap is a root capability created in anonymous function of type (f²: Levels.File^): Unit when checking argument to parameter op of method parReduce + |where: any is a root capability created in anonymous function of type (f²: Levels.File^): Unit when checking argument to parameter op of method parReduce | 42 | f.write(42) // the error stems from here 43 | a + b + f.read() // ok @@ -16,11 +16,11 @@ 53 | parReduce(1 to 1000): (a, b) => // error | ^ |Found: (a: Int, b: Int) ->{f.write, f.read, g.read} Int - |Required: (Int, Int) ->{cap.only[Read]} Int + |Required: (Int, Int) ->{any.only[Read]} Int | - |Note that capability f.write is not included in capture set {cap.only[Read]}. + |Note that capability `f.write` is not included in capture set {any.only[Read]}. | - |where: cap is a root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce + |where: any is a root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce | 54 | f.write(42) // the error stems from here 55 | a + b + f.read() + g.read() // ok @@ -30,11 +30,11 @@ 56 | parReduce(1 to 1000): (a, b) => // error | ^ |Found: (a: Int, b: Int) ->{g.write} Int - |Required: (Int, Int) ->{cap.only[Read]} Int + |Required: (Int, Int) ->{any.only[Read]} Int | - |Note that capability g.write is not included in capture set {cap.only[Read]}. + |Note that capability `g.write` is not included in capture set {any.only[Read]}. | - |where: cap is a root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce + |where: any is a root capability created in anonymous function of type (g²: Levels.File^): Unit when checking argument to parameter op of method parReduce | 57 | g.write(42) // the error stems from here 58 | 0 diff --git a/tests/neg-custom-args/captures/classifiers-secondclass.scala b/tests/neg-custom-args/captures/classifiers-secondclass.scala index 8fa2f386b526..da26e88d9c17 100644 --- a/tests/neg-custom-args/captures/classifiers-secondclass.scala +++ b/tests/neg-custom-args/captures/classifiers-secondclass.scala @@ -31,7 +31,7 @@ object Levels: } def withFile[U](name: String)(block: File^ => U): U = block(File(name)) // unrestricted use of files & other capabilities - def parReduce[U](xs: Seq[U])(op: (U, U) ->{cap.only[Read]} U): U = xs.reduce(op) // only Read-classified allowed + def parReduce[U](xs: Seq[U])(op: (U, U) ->{any.only[Read]} U): U = xs.reduce(op) // only Read-classified allowed @main def test = withFile("foo.txt"): f => diff --git a/tests/neg-custom-args/captures/closure-result-typing.check b/tests/neg-custom-args/captures/closure-result-typing.check index a3c9c7dbca87..86fc0ab03a83 100644 --- a/tests/neg-custom-args/captures/closure-result-typing.check +++ b/tests/neg-custom-args/captures/closure-result-typing.check @@ -1,11 +1,11 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/closure-result-typing.scala:2:30 ------------------------- 2 | val x: () -> Object = () => c // error | ^ - | Found: (c : Object^) + | Found: (c : Object^{any}) | Required: Object | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of parameter c + | where: any is a root capability in the type of parameter c | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/constructor-uses.check b/tests/neg-custom-args/captures/constructor-uses.check index c991e18078a2..11f9813fefb4 100644 --- a/tests/neg-custom-args/captures/constructor-uses.check +++ b/tests/neg-custom-args/captures/constructor-uses.check @@ -6,7 +6,7 @@ -- Error: tests/neg-custom-args/captures/constructor-uses.scala:17:12 -------------------------------------------------- 17 | val v = g.toString // error | ^ - | reference (A.this.g : test.File^) is not included in the allowed capture set {A.this.f} + | reference `A.this.g` is not included in the allowed capture set {A.this.f} | of the enclosing constructor D in class D -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/constructor-uses.scala:28:21 ----------------------------- 28 | val _: () -> a.B = f // error @@ -14,7 +14,7 @@ | Found: (f : () ->{a.f²} a.B^{}) | Required: () -> a.B | - | Note that capability a.f² is not included in capture set {}. + | Note that capability `f` is not included in capture set {}. | | where: f is a value in method test | f² is a value in class A @@ -26,6 +26,6 @@ | Found: (g : () ->{c} C^{}) | Required: () -> C | - | Note that capability c is not included in capture set {}. + | Note that capability `g` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/consume-in-constructor.check b/tests/neg-custom-args/captures/consume-in-constructor.check index 96e94f714ab5..88e8ec3a059d 100644 --- a/tests/neg-custom-args/captures/consume-in-constructor.check +++ b/tests/neg-custom-args/captures/consume-in-constructor.check @@ -8,18 +8,18 @@ -- Error: tests/neg-custom-args/captures/consume-in-constructor.scala:21:10 -------------------------------------------- 21 | println(a1) // error, since `b` was consumed before | ^^ - |Separation failure: Illegal access to (a1 : A1{val b: B^{b²}}^{cap, b²}), which was passed as a consume parameter to constructor of class A2 + |Separation failure: Illegal access to (a1 : A1{val b: B^{b²}}^{any, b²}), which was passed as a consume parameter to constructor of class A2 |on line 18 and therefore is no longer available. | - |where: b is a value in class A1 + |where: any is a root capability in the type of value a1 + | b is a value in class A1 | b² is a value in method Test - | cap is a root capability in the type of value a1 -- Error: tests/neg-custom-args/captures/consume-in-constructor.scala:27:10 -------------------------------------------- 27 | println(b) // error, b is hidden in the type of a1 | ^ | Separation failure: Illegal access to {b} which is hidden by the previous definition | of value a1 with type A1^. - | This type hides capabilities {cap, b} + | This type hides capabilities {any, b} | | where: ^ refers to a root capability in the type of value a1 - | cap is a root capability created in value a1 when constructing instance A1 + | any is a root capability created in value a1 when constructing instance A1 diff --git a/tests/neg-custom-args/captures/consume-in-constructor.scala b/tests/neg-custom-args/captures/consume-in-constructor.scala index 3a087c41cfbb..ead2a7554315 100644 --- a/tests/neg-custom-args/captures/consume-in-constructor.scala +++ b/tests/neg-custom-args/captures/consume-in-constructor.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful} +import caps.{any, Stateful} class B @@ -13,10 +13,10 @@ class A4(consume val b: B^) extends Stateful { var x: Int = 1 } // ok def Test = val b: B^ = B() val a1 = A1(b) - val _: A1^{cap, b} = a1 + val _: A1^{any, b} = a1 println(b) // OK since a1's type mentions `b` explicitly val a2 = A2(b) - val _: A2^{cap, b} = a2 + val _: A2^{any, b} = a2 println(b) // error println(a1) // error, since `b` was consumed before println(a2) // OK since b belongs to a2 diff --git a/tests/neg-custom-args/captures/consume-tvar-bound.check b/tests/neg-custom-args/captures/consume-tvar-bound.check index 573b323695db..33b1008344f6 100644 --- a/tests/neg-custom-args/captures/consume-tvar-bound.check +++ b/tests/neg-custom-args/captures/consume-tvar-bound.check @@ -1,24 +1,24 @@ -- Error: tests/neg-custom-args/captures/consume-tvar-bound.scala:7:29 ------------------------------------------------- 7 |def h[T <: Ref^](x: Box[T]): Ref^ = x.elem // error | ^^^^ - | Separation failure: method h's result type Ref^ hides cap, which appears in the bound of type T. + | Separation failure: method h's result type Ref^ hides any, which appears in the bound of type T. | This is not allowed. The type T has to be returned explicitly in the result type. | - | where: cap is a root capability in the type of type T + | where: any is a root capability in the type of type T -- Error: tests/neg-custom-args/captures/consume-tvar-bound.scala:9:30 ------------------------------------------------- 9 |def hh[T <: Ref^](x: Box[T]): (Ref^, Int) = (x.elem, 1) // error (but msg is strange since it does not highlight the underlying box conflict) | ^^^^^^^^^^^ - | Separation failure: method hh's result type (Ref^, Int) hides cap, which appears in the bound of type T. + | Separation failure: method hh's result type (Ref^, Int) hides any, which appears in the bound of type T. | This is not allowed. The type T has to be returned explicitly in the result type. | - | where: cap is a root capability in the type of type T + | where: any is a root capability in the type of type T -- Error: tests/neg-custom-args/captures/consume-tvar-bound.scala:11:37 ------------------------------------------------ 11 |def g[T <: Ref^](consume x: Box[T]): Ref^ = x.elem // error | ^^^^ - | Separation failure: method g's result type Ref^ hides cap, which appears in the bound of type T. + | Separation failure: method g's result type Ref^ hides any, which appears in the bound of type T. | This is not allowed. The type T has to be returned explicitly in the result type. | - | where: cap is a root capability in the type of type T + | where: any is a root capability in the type of type T -- Error: tests/neg-custom-args/captures/consume-tvar-bound.scala:20:43 ------------------------------------------------ 20 | def f[T <: Ref^{rr}](consume x: Box[T]): Ref^ = x.elem // error | ^^^^ diff --git a/tests/neg-custom-args/captures/contracap.check b/tests/neg-custom-args/captures/contracap.check index 7b2b04ae5eb1..ba5432c8c53a 100644 --- a/tests/neg-custom-args/captures/contracap.check +++ b/tests/neg-custom-args/captures/contracap.check @@ -1,11 +1,11 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/contracap.scala:15:48 ------------------------------------ 15 | val g: (Ref[Int]^{a}, Ref[Int]^{a}) -> Unit = f // error | ^ - | Found: (f : (Ref[Int]^, Ref[Int]^) -> Unit) + | Found: (f : (Ref[Int]^{any}, Ref[Int]^{any}) -> Unit) | Required: (Ref[Int]^{a}, Ref[Int]^{a}) -> Unit | - | Note that capability a is not included in capture set {cap}. + | Note that capability `a` is not included in capture set {any}. | - | where: ^ and cap refer to the universal root capability + | where: any is the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/dcs-tvar.check b/tests/neg-custom-args/captures/dcs-tvar.check index 1e09990ff536..f21369f25a3c 100644 --- a/tests/neg-custom-args/captures/dcs-tvar.check +++ b/tests/neg-custom-args/captures/dcs-tvar.check @@ -1,22 +1,22 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/dcs-tvar.scala:6:2 --------------------------------------- 6 | () => runOps(xs) // error | ^^^^^^^^^^^^^^^^ - | Found: () => Unit + | Found: () ->{any} Unit | Required: () -> Unit | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: => and cap refer to a root capability in the type of type T + | where: any is a root capability in the type of type T | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/dcs-tvar.scala:9:2 --------------------------------------- 9 | () => runOps(xs) // error | ^^^^^^^^^^^^^^^^ - | Found: () => Unit + | Found: () ->{any} Unit | Required: () -> Unit | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: => and cap refer to a root capability in the type of type U + | where: any is a root capability in the type of type U | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/delayedRunops.check b/tests/neg-custom-args/captures/delayedRunops.check index b64944cd1963..793a53e8cfec 100644 --- a/tests/neg-custom-args/captures/delayedRunops.check +++ b/tests/neg-custom-args/captures/delayedRunops.check @@ -4,7 +4,7 @@ | Found: () ->{ops*} Unit | Required: () -> Unit | - | Note that capability ops* is not included in capture set {}. + | Note that capability `ops*` is not included in capture set {}. | 13 | val ops1 = ops 14 | runOps(ops1) @@ -16,7 +16,7 @@ | Found: () ->{ops*} Unit | Required: () -> Unit | - | Note that capability ops* is not included in capture set {}. + | Note that capability `ops*` is not included in capture set {}. | 25 | val ops1: List[() ->{ops*} Unit] = ops 26 | runOps(ops1) diff --git a/tests/neg-custom-args/captures/depfun-reach.check b/tests/neg-custom-args/captures/depfun-reach.check index 0879200cee4f..7cd69b856b26 100644 --- a/tests/neg-custom-args/captures/depfun-reach.check +++ b/tests/neg-custom-args/captures/depfun-reach.check @@ -4,7 +4,7 @@ |Found: (x$1: (() ->'s1 Unit, () ->'s2 Unit)^'s3) ->'s4 Unit |Required: ((() ->{op*} Unit, () ->{op*} Unit)) => Unit | - |Note that capability op* cannot be included in capture set {} of value f. + |Note that capability `op*` cannot be included in capture set {} of value f. | |where: => refers to a root capability created in anonymous function of type (): Unit when checking argument to parameter op of method foreach | @@ -12,24 +12,24 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/depfun-reach.scala:19:4 ---------------------------------- 19 | op // error | ^^ - | Found: (op : (xs: List[(X, () ->{io} Unit)]) => List[() ->{xs*} Unit]) - | Required: (xs: List[(X, () ->{io} Unit)]) =>² List[() -> Unit] + | Found: (op : (xs: List[(X, () ->{io} Unit)]) ->{any} List[() ->{xs*} Unit]) + | Required: (xs: List[(X, () ->{io} Unit)]) ->{any²} List[() -> Unit] | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability `any` is not included in capture set {any²}. | - | where: => and cap refer to a root capability in the type of parameter op - | =>² and cap² refer to a root capability in the result type of method foo + | where: any is a root capability in the type of parameter op + | any² is a root capability in the result type of method foo | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/depfun-reach.scala:26:60 --------------------------------- 26 | val b: (xs: List[() ->{io} Unit]) => List[() ->{} Unit] = a // error | ^ - | Found: (a : (xs: List[() ->{io} Unit]) => List[() ->{xs*} Unit]) - | Required: (xs: List[() ->{io} Unit]) =>² List[() -> Unit] + | Found: (a : (xs: List[() ->{io} Unit]) ->{any} List[() ->{xs*} Unit]) + | Required: (xs: List[() ->{io} Unit]) ->{any²} List[() -> Unit] | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability `any` is not included in capture set {any²}. | - | where: => and cap refer to a root capability in the type of value a - | =>² and cap² refer to a root capability in the type of value b + | where: any is a root capability in the type of value a + | any² is a root capability in the type of value b | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/depfun-reach.scala b/tests/neg-custom-args/captures/depfun-reach.scala index f9a4589ab5c4..8b296ed9411d 100644 --- a/tests/neg-custom-args/captures/depfun-reach.scala +++ b/tests/neg-custom-args/captures/depfun-reach.scala @@ -1,5 +1,5 @@ import language.experimental.captureChecking -import caps.cap +import caps.any trait List[+T]: def foreach(op: T => Unit): Unit = ??? @@ -8,7 +8,7 @@ object List: def apply[T](elem: T): List[T] = ??? def test(io: Object^, async: Object^) = - def compose(op: List[(() ->{cap} Unit, () ->{cap} Unit)]): List[() ->{op*} Unit] = + def compose(op: List[(() ->{any} Unit, () ->{any} Unit)]): List[() ->{op*} Unit] = List(() => op.foreach((f,g) => { f(); g() })) // error (???) def compose1(op: List[(() ->{async} Unit, () ->{io} Unit)]): List[() ->{op*} Unit] = diff --git a/tests/neg-custom-args/captures/effect-swaps-explicit.check b/tests/neg-custom-args/captures/effect-swaps-explicit.check index a653597a98bb..20f421605a65 100644 --- a/tests/neg-custom-args/captures/effect-swaps-explicit.check +++ b/tests/neg-custom-args/captures/effect-swaps-explicit.check @@ -5,7 +5,7 @@ | Found: Result.Ok[Future[T^'s1]^{fr, contextual$1}] | Required: Result[Future[T], Nothing] | - | Note that capability fr is not included in capture set {}. + | Note that capability `fr` is not included in capture set {}. | 65 | fr.await.ok |-------------------------------------------------------------------------------------------------------------------- @@ -20,14 +20,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps-explicit.scala:69:10 ------------------------ 69 | Future: fut ?=> // error, type mismatch | ^ - |Capability contextual$9 outlives its scope: it leaks into outer capture set 's2 which is owned by method fail4. + |Capability `contextual$9` outlives its scope: it leaks into outer capture set 's2 which is owned by method fail4. |The leakage occurred when trying to match the following types: | |Found: (contextual$9: boundary.Label[Result[Future[T^'s3]^'s4, E^'s5]^'s6]^'s7) ?->{fr, async} Future[T^'s8]^{fr, contextual$9} |Required: (boundary.Label[Result[Future[T^'s9]^'s2, E^'s10]]^) ?=> Future[T^'s9]^'s2 | |where: ?=> refers to a root capability created in method fail4 when checking argument to parameter body of method make - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 70 | fr.await.ok | @@ -38,10 +38,10 @@ |Found: (lbl: boundary.Label[Result[Future[T^'s11]^'s12, E^'s13]^'s14]^'s15) ?->{fr, async} Future[T^'s16]^{fr, lbl} |Required: (boundary.Label[Result[Future[T], E]]^) ?=> Future[T] | - |Note that capability fr is not included in capture set {}. + |Note that capability `fr` is not included in capture set {}. | |where: ?=> refers to a root capability created in method fail5 when checking argument to parameter body of method make - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 74 | Future: fut ?=> 75 | fr.await.ok diff --git a/tests/neg-custom-args/captures/effect-swaps.check b/tests/neg-custom-args/captures/effect-swaps.check index 22d462563e15..1cbc53d7077c 100644 --- a/tests/neg-custom-args/captures/effect-swaps.check +++ b/tests/neg-custom-args/captures/effect-swaps.check @@ -5,7 +5,7 @@ | Found: Result.Ok[Future[T^'s1]^{fr, contextual$1}] | Required: Result[Future[T], Nothing] | - | Note that capability fr is not included in capture set {}. + | Note that capability `fr` is not included in capture set {}. | 65 | fr.await.ok |-------------------------------------------------------------------------------------------------------------------- @@ -20,14 +20,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps.scala:69:10 --------------------------------- 69 | Future: fut ?=> // error, type mismatch | ^ - |Capability contextual$9 outlives its scope: it leaks into outer capture set 's2 which is owned by method fail4. + |Capability `contextual$9` outlives its scope: it leaks into outer capture set 's2 which is owned by method fail4. |The leakage occurred when trying to match the following types: | |Found: (contextual$9: boundary.Label[Result[Future[T^'s3]^'s4, E^'s5]^'s6]^'s7) ?->{fr, async} Future[T^'s8]^{fr, contextual$9} |Required: (boundary.Label[Result[Future[T^'s9]^'s2, E^'s10]]^) ?=> Future[T^'s9]^'s2 | |where: ?=> refers to a root capability created in method fail4 when checking argument to parameter body of method make - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 70 | fr.await.ok | @@ -38,10 +38,10 @@ |Found: (lbl: boundary.Label[Result[Future[T^'s11]^'s12, E^'s13]^'s14]^'s15) ?->{fr, async} Future[T^'s16]^{fr, lbl} |Required: (boundary.Label[Result[Future[T], E]]^) ?=> Future[T] | - |Note that capability fr is not included in capture set {}. + |Note that capability `fr` is not included in capture set {}. | |where: ?=> refers to a root capability created in method fail5 when checking argument to parameter body of method make - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 74 | Future: fut ?=> 75 | fr.await.ok diff --git a/tests/neg-custom-args/captures/exception-definitions.check b/tests/neg-custom-args/captures/exception-definitions.check index 9429628b4bde..6979341885dc 100644 --- a/tests/neg-custom-args/captures/exception-definitions.check +++ b/tests/neg-custom-args/captures/exception-definitions.check @@ -5,8 +5,8 @@ -- Error: tests/neg-custom-args/captures/exception-definitions.scala:7:8 ----------------------------------------------- 7 | val x = c // error | ^^^^^^^^^ - | reference (c : Object^) is not included in the allowed capture set {} of the self type of class Err2 + | reference `c` is not included in the allowed capture set {} of the self type of class Err2 -- Error: tests/neg-custom-args/captures/exception-definitions.scala:8:13 ---------------------------------------------- 8 | class Err3(c: Object^) extends Exception // error | ^ - | reference (Err3.this.c : Object^) is not included in the allowed capture set {} of the self type of class Err3 + | reference `Err3.this.c` is not included in the allowed capture set {} of the self type of class Err3 diff --git a/tests/neg-custom-args/captures/existential-mapping.check b/tests/neg-custom-args/captures/existential-mapping.check index cf0c3a99965f..33817e395e7e 100644 --- a/tests/neg-custom-args/captures/existential-mapping.check +++ b/tests/neg-custom-args/captures/existential-mapping.check @@ -1,20 +1,20 @@ -- Error: tests/neg-custom-args/captures/existential-mapping.scala:46:10 ----------------------------------------------- 46 | val z2: (x: A^) => Array[C^] = ??? // error | ^^^^^^^^^^^^^^^^^^^^ - | Array[C^]^{cap.rd} captures the root capability `cap` in invariant position. + | Array[C^]^{any.rd} captures the root capability `any` in invariant position. | This capability cannot be converted to an existential in the result type of a function. | - | where: ^ and cap refer to the universal root capability + | where: ^ and any refer to the root capability caps.any -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:9:25 --------------------------- 9 | val _: (x: C^) -> C = x1 // error | ^^ - | Found: (x1 : (x: C^) -> C^²) - | Required: (x: C^) -> C + | Found: (x1 : (x: C^) -> C^{fresh}) + | Required: (x: C^) -> C | - | Note that capability cap is not included in capture set {}. + | Note that capability `fresh` is not included in capture set {}. | - | where: ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² + | where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:12:20 -------------------------- @@ -23,21 +23,21 @@ | Found: C^ -> C^{x2*} | Required: C^ -> C | - | Note that capability x2* is not included in capture set {}. + | Note that capability `x2*` is not included in capture set {}. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:15:30 -------------------------- 15 | val _: A^ -> (x: C^) -> C = x3 // error | ^^ - | Found: (x3 : A^ -> (x: C^) -> C^²) - | Required: A^ -> (x: C^) -> C + | Found: (x3 : A^ -> (x: C^) -> C^{fresh}) + | Required: A^ -> (x: C^) -> C | - | Note that capability cap is not included in capture set {}. + | Note that capability `fresh` is not included in capture set {}. | - | where: ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² + | where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:18:25 -------------------------- @@ -46,48 +46,48 @@ | Found: A^ -> C^ -> C^{x4*} | Required: A^ -> C^ -> C | - | Note that capability x4* is not included in capture set {}. + | Note that capability `x4*` is not included in capture set {}. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:21:30 -------------------------- 21 | val _: A^ -> (x: C^) -> C = x5 // error | ^^ - | Found: (x5 : A^ -> (x: C^) -> C^²) - | Required: A^ -> (x: C^) -> C + | Found: (x5 : A^ -> (x: C^) -> C^{fresh}) + | Required: A^ -> (x: C^) -> C | - | Note that capability cap is not included in capture set {}. + | Note that capability `fresh` is not included in capture set {}. | - | where: ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² + | where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:24:30 -------------------------- 24 | val _: A^ -> (x: C^) => C = x6 // error | ^^ - | Found: A^ -> (x: C^) ->{x6*} C^² - | Required: A^ -> (x: C^) => C + | Found: A^ -> (x: C^) ->{x6*} C^{fresh} + | Required: A^ -> (x: C^) => C | - | Note that capability cap is not included in capture set {}. + | Note that capability `fresh` is not included in capture set {}. | - | where: => refers to a root capability in the type of value _$6 - | ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² + | where: => refers to a root capability in the type of value _$6 + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:27:25 -------------------------- 27 | val _: (x: C^) => C = y1 // error | ^^ - | Found: (y1 : (x: C^) => C^²) - | Required: (x: C^) =>² C + | Found: (y1 : (x: C^) ->{any} C^{fresh}) + | Required: (x: C^) ->{any²} C | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability `any` is not included in capture set {any²}. | - | where: => and cap refer to a root capability in the type of value y1 - | =>² and cap² refer to a root capability in the type of value _$7 - | ^ refers to the universal root capability - | ^² refers to a root capability associated with the result type of (x: C^): C^² + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value y1 + | any² is a root capability in the type of value _$7 + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:30:20 -------------------------- @@ -96,24 +96,24 @@ | Found: C^ ->{y2} C^{y2*} | Required: C^ => C | - | Note that capability y2* is not included in capture set {}. + | Note that capability `y2*` is not included in capture set {}. | | where: => refers to a root capability in the type of value _$8 - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:33:30 -------------------------- 33 | val _: A^ => (x: C^) => C = y3 // error | ^^ - | Found: A^ ->{y3} (x: C^) ->{y3*} C^² - | Required: A^ => (x: C^) =>² C + | Found: A^ ->{y3} (x: C^) ->{y3*} C^{fresh} + | Required: A^ => (x: C^) =>² C | - | Note that capability cap is not included in capture set {}. + | Note that capability `fresh` is not included in capture set {}. | - | where: => refers to a root capability in the type of value _$9 - | =>² refers to a root capability in the type of value _$9 - | ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² + | where: => refers to a root capability in the type of value _$9 + | =>² refers to a root capability in the type of value _$9 + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:36:25 -------------------------- @@ -122,38 +122,38 @@ | Found: A^ ->{y4} C^ ->{y4*} C^{y4*} | Required: A^ => C^ =>² C | - | Note that capability y4* is not included in capture set {}. + | Note that capability `y4*` is not included in capture set {}. | | where: => refers to a root capability in the type of value _$10 | =>² refers to a root capability in the type of value _$10 - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:39:30 -------------------------- 39 | val _: A^ => (x: C^) -> C = y5 // error | ^^ - | Found: (y5 : A^ => (x: C^) -> C^²) - | Required: A^ =>² (x: C^) -> C + | Found: (y5 : A^ ->{any} (x: C^) -> C^{fresh}) + | Required: A^ ->{any²} (x: C^) -> C | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability `any` is not included in capture set {any²}. | - | where: => and cap refer to a root capability in the type of value y5 - | =>² and cap² refer to a root capability in the type of value _$11 - | ^ refers to the universal root capability - | ^² refers to a root capability associated with the result type of (x: C^): C^² + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value y5 + | any² is a root capability in the type of value _$11 + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:42:30 -------------------------- 42 | val _: A^ => (x: C^) => C = y6 // error | ^^ - | Found: A^ ->{y6} (x: C^) ->{y6*} C^² - | Required: A^ => (x: C^) =>² C + | Found: A^ ->{y6} (x: C^) ->{y6*} C^{fresh} + | Required: A^ => (x: C^) =>² C | - | Note that capability cap is not included in capture set {}. + | Note that capability `fresh` is not included in capture set {}. | - | where: => refers to a root capability in the type of value _$12 - | =>² refers to a root capability in the type of value _$12 - | ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² + | where: => refers to a root capability in the type of value _$12 + | =>² refers to a root capability in the type of value _$12 + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/extending-cap-classes.check b/tests/neg-custom-args/captures/extending-cap-classes.check index 970667c31ccd..d0f61bbfa957 100644 --- a/tests/neg-custom-args/captures/extending-cap-classes.check +++ b/tests/neg-custom-args/captures/extending-cap-classes.check @@ -4,8 +4,8 @@ | Found: (y2 : C2) | Required: C1 | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: cap is a root capability classified as SharedCapability in the type of value y2 + | where: any is a root capability classified as SharedCapability in the type of value y2 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/filevar.check b/tests/neg-custom-args/captures/filevar.check index 2c146d99c737..34d826ab888b 100644 --- a/tests/neg-custom-args/captures/filevar.check +++ b/tests/neg-custom-args/captures/filevar.check @@ -1,14 +1,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/filevar.scala:15:12 -------------------------------------- 15 | withFile: f => // error with level checking, was OK under both schemes before | ^ - |Capability l outlives its scope: it leaks into outer capture set 's1 of parameter f. + |Capability `l` outlives its scope: it leaks into outer capture set 's1 of parameter f. |The leakage occurred when trying to match the following types: | |Found: (l: scala.caps.Capability^) ?->'s2 File^'s3 ->'s4 Unit |Required: (l²: scala.caps.Capability^) ?-> (f: File^{l²}) => Unit | - |where: => refers to a root capability associated with the result type of (using l²: scala.caps.Capability^): (f: File^{l²}) => Unit - | ^ refers to the universal root capability + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile + | ^ refers to the root capability caps.any | l is a reference to a value parameter | l² is a reference to a value parameter | diff --git a/tests/neg-custom-args/captures/filevar.scala b/tests/neg-custom-args/captures/filevar.scala index 537bed3af2b1..95abd021985a 100644 --- a/tests/neg-custom-args/captures/filevar.scala +++ b/tests/neg-custom-args/captures/filevar.scala @@ -9,7 +9,7 @@ class Service extends caps.Stateful: def log = file.write("log") // OK, was error under unsealed def withFile[T](op: (l: caps.Capability) ?-> (f: File^{l}) => T): T = - op(using caps.cap)(new File) + op(using caps.any)(new File) def test = withFile: f => // error with level checking, was OK under both schemes before diff --git a/tests/neg-custom-args/captures/freeze-boxes.check b/tests/neg-custom-args/captures/freeze-boxes.check index e6f379cefc41..fc250ae71194 100644 --- a/tests/neg-custom-args/captures/freeze-boxes.check +++ b/tests/neg-custom-args/captures/freeze-boxes.check @@ -3,22 +3,22 @@ 22 | Box(a) // error | ^ | Found: Box[Ref^{a.rd}]^{} - | Required: Box[Ref^{}]^{cap.rd} + | Required: Box[Ref^{}]^{any.rd} | - | Note that capability a.rd is not included in capture set {}. + | Note that capability `a.rd` is not included in capture set {}. | - | where: cap is a root capability classified as Unscoped in the type of value xs + | where: any is a root capability classified as Unscoped in the type of value xs | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/freeze-boxes.scala:29:7 ------------------------------------------------------- 29 | Box(a) // error | ^^^^^^ - |Separation failure: Illegal access to {cap of value a} which is hidden by the previous definition + |Separation failure: Illegal access to {`any` of value a} which is hidden by the previous definition |of value a with type Ref^. - |This type hides capabilities {cap} + |This type hides capabilities {any} | |where: ^ refers to a root capability classified as Unscoped in the type of value a - | cap is a root capability classified as Unscoped created in value a when instantiating method allocRef's type (): Ref^² + | any is a root capability classified as Unscoped created in value a when instantiating method allocRef's type (): Ref^{fresh} -- Error: tests/neg-custom-args/captures/freeze-boxes.scala:31:6 ------------------------------------------------------- 31 | par(() => a.set(42), () => println(b.get)) // error | ^^^^^^^^^^^^^^^ diff --git a/tests/neg-custom-args/captures/fresh-counter.scala b/tests/neg-custom-args/captures/fresh-counter.scala index 233b0e3c91e2..0aef5ffa1d44 100644 --- a/tests/neg-custom-args/captures/fresh-counter.scala +++ b/tests/neg-custom-args/captures/fresh-counter.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref extends Mutable: var x = 0 @@ -14,7 +14,7 @@ class Counter: count.put(count.get - 1) def par(p1: () => Unit, p2: () => Unit) = () -def seq(p1: () => Unit, p2: () ->{cap, p1} Unit) = () +def seq(p1: () => Unit, p2: () ->{any, p1} Unit) = () def test() = val c = Counter() diff --git a/tests/neg-custom-args/captures/fresh-fields.check b/tests/neg-custom-args/captures/fresh-fields.check index 4200fbb40377..b9df6617fbe5 100644 --- a/tests/neg-custom-args/captures/fresh-fields.check +++ b/tests/neg-custom-args/captures/fresh-fields.check @@ -1,55 +1,55 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:25:13 --------------------------------- 25 | val _: B = b // error | ^ - | Found: (b : B^) + | Found: (b : B^{any}) | Required: B | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of value b + | where: any is a root capability in the type of value b | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:27:13 --------------------------------- 27 | val _: C = c // error | ^ - | Found: (c : C^) + | Found: (c : C^{any}) | Required: C | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of value c + | where: any is a root capability in the type of value c | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:29:13 --------------------------------- 29 | val _: D = d // error | ^ - | Found: (d : D^) + | Found: (d : D^{any}) | Required: D | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of value d + | where: any is a root capability in the type of value d | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:31:13 --------------------------------- 31 | val _: E = e // error | ^ - | Found: (e : E^) - | Required: E + | Found: (e : E^{any}) + | Required: E | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability classified as SharedCapability in the type of value e + | where: any is a root capability classified as SharedCapability in the type of value e | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/fresh-fields.scala:33:13 --------------------------------- 33 | val _: F = f // error | ^ - | Found: (f : F^) + | Found: (f : F^{any}) | Required: F | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of value f + | where: any is a root capability in the type of value f | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/fresh-outside-result.check b/tests/neg-custom-args/captures/fresh-outside-result.check new file mode 100644 index 000000000000..bd69a08fb7ea --- /dev/null +++ b/tests/neg-custom-args/captures/fresh-outside-result.check @@ -0,0 +1,45 @@ +-- Error: tests/neg-custom-args/captures/fresh-outside-result.scala:6:13 ----------------------------------------------- +6 | def foo(x: A^{fresh}) // error + | ^^^^^^^^^ + | `fresh` occurs outside function result in A^{fresh}. + | + | The `fresh` capability may only be used in the result of a function type, + | following a function arrow such as `=>` or `->`. + | + | where: fresh is the root capability caps.fresh +-- Error: tests/neg-custom-args/captures/fresh-outside-result.scala:7:6 ------------------------------------------------ +7 | : A^{fresh} // error + | ^^^^^^^^^ + | `fresh` occurs outside function result in A^{fresh}. + | + | The `fresh` capability may only be used in the result of a function type, + | following a function arrow such as `=>` or `->`. + | + | where: fresh is the root capability caps.fresh +-- Error: tests/neg-custom-args/captures/fresh-outside-result.scala:9:9 ------------------------------------------------ +9 | val a: A^{fresh} = ??? // error + | ^^^^^^^^^ + | `fresh` occurs outside function result in A^{fresh}. + | + | The `fresh` capability may only be used in the result of a function type, + | following a function arrow such as `=>` or `->`. + | + | where: fresh is the root capability caps.fresh +-- Error: tests/neg-custom-args/captures/fresh-outside-result.scala:11:11 ---------------------------------------------- +11 | type Y = List[A^{fresh}] // error + | ^^^^^^^^^^^^^^^ + | `fresh` occurs outside function result in List[A^{fresh}]. + | + | The `fresh` capability may only be used in the result of a function type, + | following a function arrow such as `=>` or `->`. + | + | where: fresh is the root capability caps.fresh +-- Error: tests/neg-custom-args/captures/fresh-outside-result.scala:14:15 ---------------------------------------------- +14 | val b = bar[{fresh}] // error + | ^^^^^ + | `fresh` occurs outside function result in scala.caps.CapSet^{fresh}. + | + | The `fresh` capability may only be used in the result of a function type, + | following a function arrow such as `=>` or `->`. + | + | where: fresh is the root capability caps.fresh diff --git a/tests/neg-custom-args/captures/fresh-outside-result.scala b/tests/neg-custom-args/captures/fresh-outside-result.scala new file mode 100644 index 000000000000..5ac087b3bb21 --- /dev/null +++ b/tests/neg-custom-args/captures/fresh-outside-result.scala @@ -0,0 +1,15 @@ +import caps.fresh + +class A + +object Test: + def foo(x: A^{fresh}) // error + : A^{fresh} // error + = x + val a: A^{fresh} = ??? // error + type X = A^ -> A^{fresh}// OK + type Y = List[A^{fresh}] // error + + def bar[X^]: List[A^{X}] = ??? + val b = bar[{fresh}] // error + diff --git a/tests/neg-custom-args/captures/gears-problem.check b/tests/neg-custom-args/captures/gears-problem.check index c4b0eb83fc22..165b45716e7b 100644 --- a/tests/neg-custom-args/captures/gears-problem.check +++ b/tests/neg-custom-args/captures/gears-problem.check @@ -4,7 +4,7 @@ | Found: Future[T]^{collector.futures*} | Required: Future[T]^{C} | - | Note that capability collector.futures* is not included in capture set {C}. + | Note that capability `collector.futures*` is not included in capture set {C}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/gears-problem.scala:24:32 -------------------------------- @@ -13,7 +13,7 @@ | Found: Future[T^{}]^{collector.futures*} | Required: Future[T]^{C} | - | Note that capability collector.futures* is not included in capture set {C}. + | Note that capability `collector.futures*` is not included in capture set {C}. | | longer explanation available when compiling with `-explain` there were 4 deprecation warnings; re-run with -deprecation for details diff --git a/tests/neg-custom-args/captures/heal-tparam-cs.check b/tests/neg-custom-args/captures/heal-tparam-cs.check index e90ea305deb0..0c6c566e0b11 100644 --- a/tests/neg-custom-args/captures/heal-tparam-cs.check +++ b/tests/neg-custom-args/captures/heal-tparam-cs.check @@ -1,14 +1,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/heal-tparam-cs.scala:10:25 ------------------------------- 10 | val test1 = localCap { c => // error | ^ - |Capability c outlives its scope: it leaks into outer capture set 's1 which is owned by value test1. + |Capability `c` outlives its scope: it leaks into outer capture set 's1 which is owned by value test1. |The leakage occurred when trying to match the following types: | |Found: (c: Capp^'s2) ->'s3 () ->{c} Unit |Required: (c: Capp^) => () ->'s1 Unit | |where: => refers to a root capability created in value test1 when checking argument to parameter op of method localCap - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 11 | () => { c.use() } | @@ -16,15 +16,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/heal-tparam-cs.scala:15:13 ------------------------------- 15 | localCap { c => // error | ^ - |Found: (x$0: Capp^'s4) ->'s5 () ->{x$0} Unit - |Required: (c: Capp^) -> () => Unit + | Found: (x$0: Capp^'s4) ->'s5 () ->{x$0} Unit + | Required: (c: Capp^) -> () ->{any} Unit | - |Note that capability x$0 is not included in capture set {cap} - |because cap, which is existentially bound in () =>² Unit, cannot subsume x$0 since that capability is not a SharedCapability. + | Note that capability `x$0` is not included in capture set {any} + | because (x$0 : Capp^'s4) is not visible from any in value test2. | - |where: => refers to a root capability associated with the result type of (c: Capp^): () => Unit - | =>² and ^ refer to the universal root capability - | cap is a root capability associated with the result type of (x$0: Capp^'s4): () ->{x$0} Unit + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value test2 | 16 | (c1: Capp^) => () => { c1.use() } 17 | } @@ -36,7 +35,7 @@ | Found: (x$0: Capp^'s6) ->'s7 () ->{x$0} Unit | Required: (c: Capp^{io}) -> () ->{net} Unit | - | Note that capability x$0 is not included in capture set {net}. + | Note that capability `x$0` is not included in capture set {net}. | 26 | (c1: Capp^{io}) => () => { c1.use() } 27 | } @@ -48,7 +47,7 @@ | Found: () ->{io} Unit | Required: () -> Unit | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/heal-tparam-cs.scala:44:10 ------------------------------- @@ -57,6 +56,6 @@ | Found: () ->{io} Unit | Required: () -> Unit | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i15749.scala b/tests/neg-custom-args/captures/i15749.scala index 9a4e8b0b81ae..9c737583fa42 100644 --- a/tests/neg-custom-args/captures/i15749.scala +++ b/tests/neg-custom-args/captures/i15749.scala @@ -13,5 +13,5 @@ class Foo[T](val x: T) type BoxedLazyVal[T] = Foo[LazyVal[T]] def force[A](v: BoxedLazyVal[A]): A = - // Γ ⊢ v.x : □ {cap} Unit -> A + // Γ ⊢ v.x : □ {any} Unit -> A v.x(unit) // error: (unbox v.x)(unit), was ok under the sealed policy \ No newline at end of file diff --git a/tests/neg-custom-args/captures/i15772.check b/tests/neg-custom-args/captures/i15772.check index 59d20b7f4d03..f9374c56ef55 100644 --- a/tests/neg-custom-args/captures/i15772.check +++ b/tests/neg-custom-args/captures/i15772.check @@ -5,31 +5,31 @@ -- Error: tests/neg-custom-args/captures/i15772.scala:22:46 ------------------------------------------------------------ 22 | val boxed1 : ((C^) => Unit) -> Unit = box1(c) // error | ^^^^^^^ - |C^ => Unit cannot be box-converted to C{val arg: C^²}^{c} ->{cap, c} Unit + |C^ => Unit cannot be box-converted to C{val arg: C^²}^{c} ->{any, c} Unit |since the additional capture set {c} resulting from box conversion is not allowed in C{val arg: C^²}^{c} => Unit | - |where: => and ^ and cap refer to the universal root capability + |where: => and ^ and any refer to the root capability caps.any | ^² refers to a root capability in the type of value arg -- Error: tests/neg-custom-args/captures/i15772.scala:29:35 ------------------------------------------------------------ 29 | val boxed2 : Observe[C^] = box2(c) // error | ^^^^^^^ - |C^ => Unit cannot be box-converted to C{val arg: C^²}^{c} ->{cap, c} Unit + |C^ => Unit cannot be box-converted to C{val arg: C^²}^{c} ->{any, c} Unit |since the additional capture set {c} resulting from box conversion is not allowed in C{val arg: C^²}^{c} => Unit | - |where: => and ^ and cap refer to the universal root capability + |where: => and ^ and any refer to the root capability caps.any | ^² refers to a root capability in the type of value arg -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i15772.scala:35:33 --------------------------------------- 35 | val boxed2 : Observe[C]^ = box2(c) // error | ^^^^^^^ - |Found: (C{val arg: C^}^² => Unit) -> Unit - |Required: (C => Unit) =>² Unit + | Found: (C{val arg: C^}^{any} => Unit) -> Unit + | Required: (C => Unit) =>² Unit | - |Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - |where: => refers to the universal root capability - | =>² refers to a root capability in the type of value boxed2 - | ^ refers to a root capability in the type of value arg - | ^² and cap refer to a root capability created in value boxed2 when instantiating method c's type -> C^{cap²} + | where: => refers to the root capability caps.any + | =>² refers to a root capability in the type of value boxed2 + | ^ refers to a root capability in the type of value arg + | any is a root capability created in value boxed2 when instantiating method c's type -> C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i15772.scala:46:2 ---------------------------------------- @@ -38,7 +38,7 @@ | Found: (x : () ->{filesList, sayHello} Unit) | Required: () -> Unit | - | Note that capability filesList is not included in capture set {}. + | Note that capability `filesList` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/i15772.scala:34:10 ------------------------------------------------------------ diff --git a/tests/neg-custom-args/captures/i15923.check b/tests/neg-custom-args/captures/i15923.check index 389903582bfe..55fbbbb2901d 100644 --- a/tests/neg-custom-args/captures/i15923.check +++ b/tests/neg-custom-args/captures/i15923.check @@ -1,15 +1,15 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i15923.scala:12:21 --------------------------------------- 12 | val leak = withCap(cap => mkId(cap)) // error | ^^^^^^^^^^^^^^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's1 which is owned by value leak. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's1 which is owned by value leak. |The leakage occurred when trying to match the following types: | |Found: (lcap: scala.caps.Capability^) ?->'s2 Cap^'s3 ->'s4 Id[Cap^'s5]^'s6 |Required: (lcap²: scala.caps.Capability^) ?-> Cap^{lcap²} => Id[Cap^'s1]^'s7 | - |where: => refers to a root capability associated with the result type of (using lcap²: scala.caps.Capability^): Cap^{lcap²} => Id[Cap^'s1]^'s7 - | ^ refers to the universal root capability - | cap is a root capability associated with the result type of (x$0: Cap^'s3): Id[Cap^'s5]^'s6 + |where: => refers to a root capability created in value leak when checking argument to parameter op of method withCap + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x$0: Cap^'s3): Id[Cap^'s5]^'s6 | lcap is a reference to a value parameter | lcap² is a reference to a value parameter | diff --git a/tests/neg-custom-args/captures/i15923.scala b/tests/neg-custom-args/captures/i15923.scala index 8287be150761..a764724edd4c 100644 --- a/tests/neg-custom-args/captures/i15923.scala +++ b/tests/neg-custom-args/captures/i15923.scala @@ -5,7 +5,7 @@ def mkId[X](x: X): Id[X] = Id([T] => (op: X => T) => op(x)) def bar() = { def withCap[X](op: (lcap: caps.Capability) ?-> Cap^{lcap} => X): X = { val cap: Cap = new Cap { def use() = { println("cap is used"); 0 } } - val result = op(using caps.cap)(cap) + val result = op(using caps.any)(cap) result } @@ -20,7 +20,7 @@ object test2: def bar() = { def withCap[X](op: (lcap: caps.Capability) ?-> Cap^{lcap} => X): X = { val cap: Cap = new Cap { def use() = { println("cap is used"); 0 } } - val result = op(using caps.cap)(cap) + val result = op(using caps.any)(cap) result } diff --git a/tests/neg-custom-args/captures/i15923a.check b/tests/neg-custom-args/captures/i15923a.check index 01e1cd3b8d2d..5a85984c1b18 100644 --- a/tests/neg-custom-args/captures/i15923a.check +++ b/tests/neg-custom-args/captures/i15923a.check @@ -1,15 +1,15 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i15923a.scala:7:21 --------------------------------------- 7 | val leak = withCap(lcap => () => mkId(lcap)) // error | ^^^^^^^^^^^^^^^^^^^^^^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's1 which is owned by value leak. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's1 which is owned by value leak. |The leakage occurred when trying to match the following types: | |Found: (lcap: Cap^'s2) ->'s3 () ->'s4 Id[Cap^'s5]^'s6 |Required: (lcap: Cap^) => () =>² Id[Cap^'s1]^'s7 | - |where: => refers to a root capability created in value leak when checking argument to parameter op of method withCap - | =>² refers to a root capability associated with the result type of (lcap: Cap^): () =>² Id[Cap^'s1]^'s7 - | ^ refers to the universal root capability - | cap is a root capability associated with the result type of (): Id[Cap^'s5]^'s6 + |where: => refers to a root capability created in value leak when checking argument to parameter op of method withCap + | =>² refers to a root capability created in value leak when checking argument to parameter op of method withCap + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (): Id[Cap^'s5]^'s6 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i15923b.check b/tests/neg-custom-args/captures/i15923b.check index 85133bb04841..4e31a056d49c 100644 --- a/tests/neg-custom-args/captures/i15923b.check +++ b/tests/neg-custom-args/captures/i15923b.check @@ -1,13 +1,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i15923b.scala:8:21 --------------------------------------- 8 | val leak = withCap(f) // error | ^ - |Capability lcap outlives its scope: it leaks into outer capture set 's1 which is owned by value leak. + |Capability `lcap` outlives its scope: it leaks into outer capture set 's1 which is owned by value leak. |The leakage occurred when trying to match the following types: | |Found: (x$0: Cap^) -> Id[Cap^{x$0}] |Required: (lcap: Cap^) => Id[Cap^'s1]^'s2 | |where: => refers to a root capability created in value leak when checking argument to parameter op of method withCap - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i16114.check b/tests/neg-custom-args/captures/i16114.check index 36c9881a2e75..8478384d0057 100644 --- a/tests/neg-custom-args/captures/i16114.check +++ b/tests/neg-custom-args/captures/i16114.check @@ -4,7 +4,7 @@ | Found: (x: Unit) ->{io, fs} Unit | Required: Unit ->{io} Unit | - | Note that capability fs is not included in capture set {io}. + | Note that capability `fs` is not included in capture set {io}. | 18 | expect[Cap^] { 19 |... @@ -17,7 +17,7 @@ | Found: (x: Unit) ->{fs, io} Unit | Required: Unit ->{fs} Unit | - | Note that capability io is not included in capture set {fs}. + | Note that capability `io` is not included in capture set {fs}. | 24 | expect[Cap^] { 25 |... @@ -30,7 +30,7 @@ | Found: (x: Unit) ->{io} Unit | Required: Unit -> Unit | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | 36 | expect[Cap^](io) | @@ -41,7 +41,7 @@ | Found: (x: Unit) ->{io} Unit | Required: Unit -> Unit | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | 39 | expect[Cap^] { 40 |... diff --git a/tests/neg-custom-args/captures/i16226.check b/tests/neg-custom-args/captures/i16226.check index 4a5cdef9ffad..2b0e2c64bc18 100644 --- a/tests/neg-custom-args/captures/i16226.check +++ b/tests/neg-custom-args/captures/i16226.check @@ -2,33 +2,33 @@ 13 | (ref1, f1) => map[A, B](ref1, f1) // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |Found: (ref1: LazyRef[A^'s1]{val elem: () ->'s2 A^'s3}^'s4, f1: A^'s5 ->'s6 B^'s7) ->'s8 - | LazyRef[B^'s9]{val elem: () => B^'s10}^{f1, ref1} - |Required: (LazyRef[A]^{io}, A =>² B) =>³ LazyRef[B]^ + | LazyRef[B^'s9]{val elem: () ->{fresh} B^'s10}^{f1, ref1} + |Required: (LazyRef[A]^{io}, A => B) =>² LazyRef[B]^{any} | - |Note that capability f1 is not included in capture set {cap} - |because (f1 : A^'s5 ->'s6 B^'s7) is not visible from cap in method mapc. + |Note that capability `f1` is not included in capture set {any} + |because (f1 : A^'s5 ->'s6 B^'s7) is not visible from any in method mapc. | - |where: => refers to a root capability associated with the result type of (ref1: LazyRef[A^'s1]{val elem: () ->'s2 A^'s3}^'s4, f1: A^'s5 ->'s6 B^'s7): - | LazyRef[B^'s9]{val elem: () => B^'s10}^{f1, ref1} - | =>² refers to the universal root capability - | =>³ refers to a root capability in the result type of method mapc - | ^ and cap refer to a root capability in the result type of method mapc + |where: => refers to the root capability caps.any + | =>² refers to a root capability in the result type of method mapc + | any is a root capability in the result type of method mapc + | fresh is a root capability associated with the result type of (ref1: LazyRef[A^'s1]{val elem: () ->'s2 A^'s3}^'s4, f1: A^'s5 ->'s6 B^'s7): + | LazyRef[B^'s9]{val elem: () ->{fresh} B^'s10}^{f1, ref1} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i16226.scala:15:4 ---------------------------------------- 15 | (ref1, f1) => map[A, B](ref1, f1) // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |Found: (ref1: LazyRef[A^'s11]{val elem: () ->'s12 A^'s13}^'s14, f1: A^'s15 ->'s16 B^'s17) ->'s18 - | LazyRef[B^'s19]{val elem: () => B^'s20}^{f1, ref1} - |Required: (ref: LazyRef[A]^{io}, f: A =>² B) =>³ LazyRef[B]^ + | LazyRef[B^'s19]{val elem: () ->{fresh} B^'s20}^{f1, ref1} + |Required: (ref: LazyRef[A]^{io}, f: A => B) =>² LazyRef[B]^{any} | - |Note that capability f1 is not included in capture set {cap} - |because cap, which is existentially bound in LazyRef[B]^², cannot subsume f1 since that capability is not a SharedCapability. + |Note that capability `f1` is not included in capture set {any} + |because (f1 : A^'s15 ->'s16 B^'s17) is not visible from any in method mapd. | - |where: => and cap refer to a root capability associated with the result type of (ref1: LazyRef[A^'s11]{val elem: () ->'s12 A^'s13}^'s14, f1: A^'s15 ->'s16 B^'s17): - | LazyRef[B^'s19]{val elem: () => B^'s20}^{f1, ref1} - | =>² and ^² refer to the universal root capability - | =>³ refers to a root capability in the result type of method mapd - | ^ refers to a root capability associated with the result type of (ref: LazyRef[A]^{io}, f: A =>² B): LazyRef[B]^ + |where: => refers to the root capability caps.any + | =>² refers to a root capability in the result type of method mapd + | any is a root capability in the result type of method mapd + | fresh is a root capability associated with the result type of (ref1: LazyRef[A^'s11]{val elem: () ->'s12 A^'s13}^'s14, f1: A^'s15 ->'s16 B^'s17): + | LazyRef[B^'s19]{val elem: () ->{fresh} B^'s20}^{f1, ref1} | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i18518.scala b/tests/neg-custom-args/captures/i18518.scala index 61e63a54141c..334b147fcdec 100644 --- a/tests/neg-custom-args/captures/i18518.scala +++ b/tests/neg-custom-args/captures/i18518.scala @@ -1,5 +1,5 @@ import language.experimental.captureChecking type Foo1 = [R] -> (x: Unit) ->{} Unit // error -type Foo2 = [R] -> (x: Unit) ->{cap} Unit // error +type Foo2 = [R] -> (x: Unit) ->{any} Unit // error type Foo3 = (c: Int^) -> [R] -> (x: Unit) ->{c} Unit // error type Foo4 = (c: Int^) -> [R] -> (x0: Unit) -> (x: Unit) ->{c} Unit diff --git a/tests/neg-custom-args/captures/i19330.check b/tests/neg-custom-args/captures/i19330.check index abdeeb1eded3..efb0ee1a0312 100644 --- a/tests/neg-custom-args/captures/i19330.check +++ b/tests/neg-custom-args/captures/i19330.check @@ -2,14 +2,14 @@ 15 | val leaked = usingLogger[x.T]: l => // error | ^^^ | Type variable T of method usingLogger cannot be instantiated to x.T since - | the part () => Logger^ of that type captures the root capability `cap`. + | the part () => Logger^ of that type captures the root capability `any`. -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i19330.scala:17:4 ---------------------------------------- 17 | t: x.T // error | ^ | Found: () ->{t} Logger^{t*} | Required: x.T | - | Note that capability t is not included in capture set {}. + | Note that capability `t` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/i19330.scala:16:14 ------------------------------------------------------------ diff --git a/tests/neg-custom-args/captures/i19470.check b/tests/neg-custom-args/captures/i19470.check index fc56db33ffe2..379db7d4ea3d 100644 --- a/tests/neg-custom-args/captures/i19470.check +++ b/tests/neg-custom-args/captures/i19470.check @@ -4,6 +4,6 @@ | Found: Inv[IO^{f?}] | Required: Inv[IO^'s1]^'s2 | - | Note that capability f is not included in capture set {f?}. + | Note that capability `f` is not included in capture set {f?}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i20481.check b/tests/neg-custom-args/captures/i20481.check index f902cb356ad9..e0e969f5fb45 100644 --- a/tests/neg-custom-args/captures/i20481.check +++ b/tests/neg-custom-args/captures/i20481.check @@ -1,34 +1,32 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i20481.scala:4:13 ---------------------------------------- 4 | val b: A = this // error | ^^^^ - | Found: (A.this : A^) + | Found: (A.this : A^{any}) | Required: A | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a fresh root capability in the type of class A + | where: any is a root capability in the type of class A | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i20481.scala:8:14 ---------------------------------------- 8 | val c1: A = a // error | ^ - | Found: (a : A^) + | Found: (a : A^{any}) | Required: A | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: ^ and cap refer to a root capability in the type of parameter a + | where: any is a root capability in the type of parameter a | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i20481.scala:10:16 --------------------------------------- 10 | val c3: A = a.f // error | ^^^ - | Found: (a.f : A^) + | Found: (a.f : A^{a.any}) | Required: A | - | Note that capability cap is not included in capture set {}. - | - | where: ^ and cap refer to a root capability in the type of value f + | Note that capability `a.any` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i20481.scala:11:23 --------------------------------------- @@ -37,7 +35,7 @@ | Found: () ->{a} Unit | Required: () -> Unit | - | Note that capability a is not included in capture set {}. + | Note that capability `a` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i20481.scala:13:23 --------------------------------------- @@ -46,6 +44,6 @@ | Found: () ->{a.f} Unit | Required: () -> Unit | - | Note that capability a.f is not included in capture set {}. + | Note that capability `a.f` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i21313.check b/tests/neg-custom-args/captures/i21313.check index 1b6af8626bbe..d727166ecc45 100644 --- a/tests/neg-custom-args/captures/i21313.check +++ b/tests/neg-custom-args/captures/i21313.check @@ -8,7 +8,7 @@ |Found: (src2 : Source[Int, scala.caps.CapSet^{ac2}]^{}) |Required: Source[Int, scala.caps.CapSet^{ac1}]^ | - |Note that capability ac1 cannot be included in capture set {ac2} of value src2. + |Note that capability `ac1` cannot be included in capture set {ac2} of value src2. | |where: ^ refers to a root capability created in method test when checking argument to parameter src of method await | diff --git a/tests/neg-custom-args/captures/i21347.check b/tests/neg-custom-args/captures/i21347.check index baa6b4fd2042..3d7d8acc86c5 100644 --- a/tests/neg-custom-args/captures/i21347.check +++ b/tests/neg-custom-args/captures/i21347.check @@ -4,7 +4,7 @@ | Found: () ->{f} Unit | Required: () -> Unit | - | Note that capability f is not included in capture set {}. + | Note that capability `f` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/i21347.scala:11:15 ------------------------------------------------------------ diff --git a/tests/neg-custom-args/captures/i21401.check b/tests/neg-custom-args/captures/i21401.check index 85c26f559c71..e33e672905cf 100644 --- a/tests/neg-custom-args/captures/i21401.check +++ b/tests/neg-custom-args/captures/i21401.check @@ -2,36 +2,36 @@ 15 | val a = usingIO[IO^](x => x) // error | ^^^^^^ |Found: (x: IO^'s1) ->'s2 IO^{x} - |Required: IO^ => IO^² + |Required: IO^ => IO^{any} | - |Note that capability x is not included in capture set {cap} - |because (x : IO^'s1) is not visible from cap in value a. + |Note that capability `x` is not included in capture set {any} + |because (x : IO^'s1) is not visible from any in value a. | - |where: => refers to a root capability created in value a when checking argument to parameter op of method usingIO - | ^ refers to the universal root capability - | ^² and cap refer to a root capability created in value a + |where: => refers to a root capability created in value a when checking argument to parameter op of method usingIO + | ^ refers to the root capability caps.any + | any is a root capability created in value a | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/i21401.scala:16:66 ------------------------------------------------------------ 16 | val leaked: [R, X <: Boxed[IO^] -> R] -> (op: X) -> R = usingIO[Res](mkRes) // error | ^^^ | Type variable R of method usingIO cannot be instantiated to [R, X <: Boxed[IO^] -> R] => (op: X) -> R since - | the part IO^ of that type captures the root capability `cap`. + | the part IO^ of that type captures the root capability `any`. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21401.scala:17:67 --------------------------------------- 17 | val x: Boxed[IO^] = leaked[Boxed[IO^], Boxed[IO^] -> Boxed[IO^]](x => x) // error | ^^^^^^ - |Found: (x: Boxed[IO^]^'s3) ->'s4 Boxed[IO^²] - |Required: Boxed[IO^] -> Boxed[IO^³] + | Found: (x: Boxed[IO^]^'s3) ->'s4 Boxed[IO^{fresh}] + | Required: Boxed[IO^] -> Boxed[IO^{any}] | - |Note that capability cap is not included in capture set {cap²} - |because cap is not visible from cap² in value x². + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value x². | - |where: ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: Boxed[IO^]^'s3): Boxed[IO^²] - | ^³ and cap² refer to a root capability created in value x² - | x is a reference to a value parameter - | x² is a value in method test2 + | where: ^ refers to the root capability caps.any + | any is a root capability created in value x² + | fresh is a root capability associated with the result type of (x: Boxed[IO^]^'s3): Boxed[IO^{fresh}] + | x is a reference to a value parameter + | x² is a value in method test2 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i21614.check b/tests/neg-custom-args/captures/i21614.check index 01debfbf8d91..0b1499fa5f61 100644 --- a/tests/neg-custom-args/captures/i21614.check +++ b/tests/neg-custom-args/captures/i21614.check @@ -2,12 +2,12 @@ 12 | files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)? | ^ |Found: (f : F) - |Required: File^ + |Required: File^{any} | - |Note that capability cap is not included in capture set {cap²}. + |Note that capability `any²` is not included in capture set {any}. | - |where: ^ and cap² refer to a root capability classified as SharedCapability created in anonymous function of type (f²: F): Logger when checking argument to parameter f of constructor Logger - | cap is a root capability classified as SharedCapability in the type of parameter f + |where: any is a root capability classified as SharedCapability created in anonymous function of type (f²: F): Logger when checking argument to parameter f of constructor Logger + | any² is a root capability classified as SharedCapability in the type of parameter f | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:15:12 --------------------------------------- @@ -16,7 +16,7 @@ |Found: (_$1: File^'s1) ->{C} Logger{val f: File^{_$1}}^{_$1} |Required: File^{C} => Logger{val f: File^'s2}^'s3 | - |Note that capability C is not classified as trait SharedCapability, therefore it + |Note that capability `C` is not classified as trait SharedCapability, therefore it |cannot be included in capture set 's1 of parameter _$1 of SharedCapability elements. | |where: => refers to a root capability created in method mkLoggers2 when checking argument to parameter f of method map diff --git a/tests/neg-custom-args/captures/i21620.check b/tests/neg-custom-args/captures/i21620.check index b5a925e7f62c..5de674b68124 100644 --- a/tests/neg-custom-args/captures/i21620.check +++ b/tests/neg-custom-args/captures/i21620.check @@ -16,7 +16,7 @@ | Found: (f : () ->{x} () ->{x} Unit) | Required: () -> () ->{x} Unit | - | Note that capability x is not included in capture set {}. + | Note that capability `f` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21620.scala:20:33 --------------------------------------- @@ -25,6 +25,6 @@ | Found: (f : () ->{x} () ->{x} Unit) | Required: () -> () ->{x} Unit | - | Note that capability x is not included in capture set {}. + | Note that capability `f` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i21920.check b/tests/neg-custom-args/captures/i21920.check index ef9a33bf63e0..94739facde03 100644 --- a/tests/neg-custom-args/captures/i21920.check +++ b/tests/neg-custom-args/captures/i21920.check @@ -1,14 +1,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21920.scala:34:35 --------------------------------------- 34 | val cell: Cell[File] = File.open(f => Cell(() => Seq(f))) // error | ^^^^^^^^^^^^^^^^^^^^^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's1 which is owned by an enclosing function. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's1 which is owned by an enclosing function. |The leakage occurred when trying to match the following types: | |Found: (f: File^'s2) ->'s3 Cell[File^'s4]{val head: () ->'s5 IterableOnce[File^'s6]^'s7}^'s8 |Required: File^ => Cell[File^'s9]{val head: () ->'s10 IterableOnce[File^'s11]^'s12}^'s13 | - |where: => refers to a root capability created in value cell when checking argument to parameter f of method open - | ^ refers to the universal root capability - | cap is a root capability associated with the result type of (): IterableOnce[File^'s1]^² + |where: => refers to a root capability created in value cell when checking argument to parameter f of method open + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (): IterableOnce[File^'s1]^² | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i23207.check b/tests/neg-custom-args/captures/i23207.check index 626655686d87..036f1956ccb4 100644 --- a/tests/neg-custom-args/captures/i23207.check +++ b/tests/neg-custom-args/captures/i23207.check @@ -4,7 +4,7 @@ | Found: (box.x : (b : B^{io})^{b}) | Required: A | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23207.scala:18:13 --------------------------------------- @@ -13,7 +13,7 @@ | Found: (c : B^{b}) | Required: A | - | Note that capability b is not included in capture set {}. + | Note that capability `b` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23207.scala:19:2 ---------------------------------------- @@ -22,7 +22,7 @@ | Found: A^{c} | Required: A | - | Note that capability c is not included in capture set {}. + | Note that capability `c` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23207.scala:27:2 ---------------------------------------- @@ -31,6 +31,6 @@ | Found: A^{c} | Required: A | - | Note that capability c is not included in capture set {}. + | Note that capability `c` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i23431.check b/tests/neg-custom-args/captures/i23431.check index cc58ac2c616b..7dd14f9c9676 100644 --- a/tests/neg-custom-args/captures/i23431.check +++ b/tests/neg-custom-args/captures/i23431.check @@ -2,26 +2,26 @@ 8 | myIO = io // error, level mismatch | ^^ | Found: (io : IO^) - | Required: IO^² + | Required: IO^{any} | - | Note that capability io is not included in capture set {cap} - | because (io : IO^) in method setIO is not visible from cap in variable myIO. + | Note that capability `io` is not included in capture set {any} + | because (io : IO^) in method setIO is not visible from any in variable myIO. | - | where: ^ refers to a root capability in the type of parameter io - | ^² and cap refer to a root capability in the type of variable myIO + | where: ^ refers to a root capability in the type of parameter io + | any is a root capability in the type of variable myIO | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23431.scala:11:13 --------------------------------------- 11 | myIO = io2 // error, level mismatch | ^^^ | Found: (io2 : IO^) - | Required: IO^² + | Required: IO^{any} | - | Note that capability io2 is not included in capture set {cap} - | because (io2 : IO^) in an enclosing function is not visible from cap in variable myIO. + | Note that capability `io2` is not included in capture set {any} + | because (io2 : IO^) in an enclosing function is not visible from any in variable myIO. | - | where: ^ refers to a root capability in the type of parameter io2 - | ^² and cap refer to a root capability in the type of variable myIO + | where: ^ refers to a root capability in the type of parameter io2 + | any is a root capability in the type of variable myIO | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23431.scala:12:12 --------------------------------------- @@ -30,13 +30,13 @@ |Found: (io3: IO^'s1) ->{myIO} Unit |Required: IO^ => Unit | - |Note that capability cap is not included in capture set {cap²} - |because cap in an enclosing function is not visible from cap² in variable myIO². + |Note that capability `any` is not included in capture set {any²} + |because any in an enclosing function is not visible from any² in variable myIO². | |where: => refers to a root capability created in anonymous function of type (io1: IO^): Unit when checking argument to parameter op of method withIO - | ^ refers to the universal root capability - | cap is a root capability created in anonymous function of type (io3: IO^'s1): Unit of parameter parameter io3² of method $anonfun - | cap² is a root capability in the type of variable myIO² + | ^ refers to the root capability caps.any + | any is a root capability created in anonymous function of type (io3: IO^'s1): Unit of parameter parameter io3² of method $anonfun + | any² is a root capability in the type of variable myIO² | myIO is a value in an anonymous function in method test | myIO² is a variable in an anonymous function in method test | diff --git a/tests/neg-custom-args/captures/i23582.check b/tests/neg-custom-args/captures/i23582.check index 165b222ae9d2..7c2c4e79d0be 100644 --- a/tests/neg-custom-args/captures/i23582.check +++ b/tests/neg-custom-args/captures/i23582.check @@ -2,11 +2,11 @@ 27 | parReduce(1 to 1000): (x, y) => // error | ^ |Found: (x: Int, y: Int) ->{write, read} Int - |Required: (Int, Int) ->{cap.only[Read]} Int + |Required: (Int, Int) ->{any.only[Read]} Int | - |Note that capability write is not included in capture set {cap.only[Read]}. + |Note that capability `write` is not included in capture set {any.only[Read]}. | - |where: cap is a root capability created in method test when checking argument to parameter op of method parReduce + |where: any is a root capability created in method test when checking argument to parameter op of method parReduce | 28 | write(x) 29 | x + y + read() diff --git a/tests/neg-custom-args/captures/i23582.scala b/tests/neg-custom-args/captures/i23582.scala index 1c3dd84e8458..6eb084d971e9 100644 --- a/tests/neg-custom-args/captures/i23582.scala +++ b/tests/neg-custom-args/captures/i23582.scala @@ -7,14 +7,14 @@ object Levels: class Box[T](acc: T): val access: T = acc - def parReduce(xs: Seq[Int])(op: (Int, Int) ->{cap.only[Read]} Int): Int = xs.reduce(op) + def parReduce(xs: Seq[Int])(op: (Int, Int) ->{any.only[Read]} Int): Int = xs.reduce(op) @main def test = val r: Box[Read^] = ??? val rw: Box[ReadWrite^] = ??? val read: () ->{r.access*} Int = ??? val write: Int ->{rw.access*} Unit = ??? - val checkRead: () ->{cap.only[Read]} Int = read + val checkRead: () ->{any.only[Read]} Int = read //read() // causes error with and without the println below parReduce(1 to 1000): (x, y) => diff --git a/tests/neg-custom-args/captures/i23746.check b/tests/neg-custom-args/captures/i23746.check index d8467cfe1c63..d7a1c58e6adf 100644 --- a/tests/neg-custom-args/captures/i23746.check +++ b/tests/neg-custom-args/captures/i23746.check @@ -1,12 +1,12 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23746.scala:5:2 ----------------------------------------- 5 | () => op.run() // error | ^^^^^^^^^^^^^^ - | Found: () => Unit + | Found: () ->{any} Unit | Required: () -> Unit | - | Note that capability cap is not included in capture set {}. + | Note that capability `any` is not included in capture set {}. | - | where: => and cap refer to a root capability in the type of type X + | where: any is a root capability in the type of type X | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i23746.scala:10:4 ---------------------------------------- @@ -15,6 +15,6 @@ | Found: () ->{a} Unit | Required: () -> Unit | - | Note that capability a is not included in capture set {}. + | Note that capability `a` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i24310.check b/tests/neg-custom-args/captures/i24310.check index e21c7bb7d2dd..f5e2d5153963 100644 --- a/tests/neg-custom-args/captures/i24310.check +++ b/tests/neg-custom-args/captures/i24310.check @@ -1,7 +1,5 @@ -- Error: tests/neg-custom-args/captures/i24310.scala:10:16 ------------------------------------------------------------ 10 | def run() = f() // error <- note the missing update | ^ - | Read-only method run accesses exclusive capability (Matrix.this.f : () => Int); + | Read-only method run accesses exclusive capability `Matrix.this.f`; | method run should be declared an update method to allow this. - | - | where: => refers to a root capability in the type of value f diff --git a/tests/neg-custom-args/captures/i24335.check b/tests/neg-custom-args/captures/i24335.check index 27fc065f6e33..2e434ce744b9 100644 --- a/tests/neg-custom-args/captures/i24335.check +++ b/tests/neg-custom-args/captures/i24335.check @@ -4,7 +4,7 @@ | Found: (C.this.l1 : () ->{C.this.c.io} Unit) | Required: () -> Unit | - | Note that capability C.this.c.io is not included in capture set {}. + | Note that capability `C.this.c.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/i24335.scala:13:7 ------------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/i24667.check b/tests/neg-custom-args/captures/i24667.check index 8085cd270a29..c96b01b8dae0 100644 --- a/tests/neg-custom-args/captures/i24667.check +++ b/tests/neg-custom-args/captures/i24667.check @@ -4,7 +4,7 @@ | Found: (w : O.type) | Required: AnyRef | - | Note that capability c is not included in capture set {}. + | Note that capability `c` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i24667.scala:11:22 --------------------------------------- @@ -13,6 +13,6 @@ | Found: (w : O.type) | Required: Object^{c} | - | Note that capability O is not included in capture set {c}. + | Note that capability `O` is not included in capture set {c}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/implied-ro.check b/tests/neg-custom-args/captures/implied-ro.check index afd2b18fe967..e126457617c3 100644 --- a/tests/neg-custom-args/captures/implied-ro.check +++ b/tests/neg-custom-args/captures/implied-ro.check @@ -1,11 +1,11 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/implied-ro.scala:12:16 ----------------------------------- 12 | val _: C^{} = c // error | ^ - | Found: (c : C^{cap.rd}) + | Found: (c : C^{any.rd}) | Required: C | - | Note that capability cap.rd is not included in capture set {}. + | Note that capability `any.rd` is not included in capture set {}. | - | where: cap is a root capability classified as Unscoped created in value c when constructing instance C + | where: any is a root capability classified as Unscoped created in value c when constructing instance C | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/implied-ro.scala b/tests/neg-custom-args/captures/implied-ro.scala index 765b85af502b..35f3d58d2146 100644 --- a/tests/neg-custom-args/captures/implied-ro.scala +++ b/tests/neg-custom-args/captures/implied-ro.scala @@ -6,7 +6,7 @@ class C: def test = val c = C() - val _: C^{cap.rd} = c - val _: C^{cap.only[Unscoped]} = c - val _: C^{cap.only[Unscoped].rd} = c + val _: C^{any.rd} = c + val _: C^{any.only[Unscoped]} = c + val _: C^{any.only[Unscoped].rd} = c val _: C^{} = c // error diff --git a/tests/neg-custom-args/captures/indirect-avoid.check b/tests/neg-custom-args/captures/indirect-avoid.check index 207889feddd5..63e07ea6212b 100644 --- a/tests/neg-custom-args/captures/indirect-avoid.check +++ b/tests/neg-custom-args/captures/indirect-avoid.check @@ -4,18 +4,18 @@ | Found: Test.LL^{nll} | Required: Test.LL^{ll} | - | Note that capability nll is not included in capture set {ll}. + | Note that capability `nll` is not included in capture set {ll}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/indirect-avoid.scala:26:14 ------------------------------- 26 | val _: LL = x1 // error | ^^ - |Found: (Test.x1 : Test.LL^{cap.rd}) + |Found: (Test.x1 : Test.LL^{any.rd}) |Required: Test.LL | - |Note that capability cap.rd is not included in capture set {}. + |Note that capability `any.rd` is not included in capture set {}. | - |where: cap is a root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{cap².rd, ll} + |where: any is a root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{fresh.rd, ll} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/indirect-avoid.scala:32:4 -------------------------------- @@ -24,14 +24,14 @@ | Found: Test.LL^{nll} | Required: Test.LL^{ll} | - | Note that capability nll is not included in capture set {ll}. + | Note that capability `nll` is not included in capture set {ll}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/indirect-avoid.scala:24:8 ----------------------------------------------------- 24 | val x1 = filterImpl1(LL()) // error | ^ - |value x1 needs an explicit type because it captures a root capability in its type Test.LL^{cap.rd}. + |value x1 needs an explicit type because it captures a root capability in its type Test.LL^{any.rd}. |Fields capturing a root capability need to be given an explicit type unless the capability is already |subsumed by the computed capability of the enclosing class. | - |where: cap is a root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{cap².rd, ll} + |where: any is a root capability created in value x1 when instantiating method filterImpl1's type (ll: Test.LL^): Test.LL^{fresh.rd, ll} diff --git a/tests/neg-custom-args/captures/indirect-avoid.scala b/tests/neg-custom-args/captures/indirect-avoid.scala index 0f3eed7ca32f..22dc8c6e49b7 100644 --- a/tests/neg-custom-args/captures/indirect-avoid.scala +++ b/tests/neg-custom-args/captures/indirect-avoid.scala @@ -22,7 +22,7 @@ object Test: nll val x1 = filterImpl1(LL()) // error - val _: LL^{cap.rd}= x1 + val _: LL^{any.rd}= x1 val _: LL = x1 // error def filterImpl2(ll: LL^): LL^{ll} = diff --git a/tests/neg-custom-args/captures/io.scala b/tests/neg-custom-args/captures/io.scala index 4869a2c89a89..1e4d6bbc21bf 100644 --- a/tests/neg-custom-args/captures/io.scala +++ b/tests/neg-custom-args/captures/io.scala @@ -3,17 +3,17 @@ sealed trait IO: def puts(msg: Any): Unit = println(msg) def test1 = - val IO : IO @retains[caps.cap.type] = new IO {} + val IO : IO @retains[caps.any.type] = new IO {} def foo = {IO; IO.puts("hello") } val x : () -> Unit = () => foo // error: Found: (() -> Unit) retains IO; Required: () -> Unit def test2 = - val IO : IO @retains[caps.cap.type] = new IO {} - def puts(msg: Any, io: IO @retains[caps.cap.type]) = println(msg) + val IO : IO @retains[caps.any.type] = new IO {} + def puts(msg: Any, io: IO @retains[caps.any.type]) = println(msg) def foo() = puts("hello", IO) val x : () -> Unit = () => foo() // error: Found: (() -> Unit) retains IO; Required: () -> Unit -type Capability[T] = T @retains[caps.cap.type] +type Capability[T] = T @retains[caps.any.type] def test3 = val IO : Capability[IO] = new IO {} diff --git a/tests/neg-custom-args/captures/lazyListState.check b/tests/neg-custom-args/captures/lazyListState.check index 65c78d47c040..10800ed30f90 100644 --- a/tests/neg-custom-args/captures/lazyListState.check +++ b/tests/neg-custom-args/captures/lazyListState.check @@ -1,10 +1,10 @@ -- [E164] Declaration Error: tests/neg-custom-args/captures/lazyListState.scala:12:39 ---------------------------------- 12 | final class Cons[A](val head: A, val tail: LazyListIterable[A]^) extends State[A] // error | ^ - | error overriding method tail in trait State of type -> LazyListIterable[A]^{cap}; - | value tail of type LazyListIterable[A]^ has incompatible type + | error overriding method tail in trait State of type -> LazyListIterable[A]^{fresh}; + | value tail of type LazyListIterable[A]^ has incompatible type | - | where: ^ refers to a root capability in the type of value tail - | cap is a root capability associated with the result type of -> LazyListIterable[A²]^² + | where: ^ refers to a root capability in the type of value tail + | fresh is a root capability associated with the result type of -> LazyListIterable[A²]^² | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazylist-global.check b/tests/neg-custom-args/captures/lazylist-global.check index 5b068028133e..4ce655115f87 100644 --- a/tests/neg-custom-args/captures/lazylist-global.check +++ b/tests/neg-custom-args/captures/lazylist-global.check @@ -4,7 +4,7 @@ | Found: lazylists.LazyList[T]^{LazyCons.this.xs} | Required: lazylists.LazyList[T] | - | Note that capability LazyCons.this.xs is not included in capture set {}. + | Note that capability `LazyCons.this.xs` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist-global.scala:39:29 ------------------------------ @@ -13,7 +13,7 @@ |Found: (ref1 : lazylists.LazyCons[Int]{val xs: () ->{lazylists.cap1} lazylists.LazyList[Int]^{}}^{lazylists.cap1}) |Required: lazylists.LazyList[Int] | - |Note that capability lazylists.cap1 is not included in capture set {}. + |Note that capability `lazylists.cap1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist-global.scala:41:36 ------------------------------ @@ -22,7 +22,7 @@ | Found: (ref2 : lazylists.LazyList[Int]^{lazylists.cap2, ref1}) | Required: lazylists.LazyList[Int]^{ref1} | - | Note that capability lazylists.cap2 is not included in capture set {ref1}. + | Note that capability `lazylists.cap2` is not included in capture set {ref1}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist-global.scala:43:36 ------------------------------ @@ -31,24 +31,24 @@ | Found: (ref3 : lazylists.LazyList[Int]^{lazylists.cap2, ref1}) | Required: lazylists.LazyList[Int]^{lazylists.cap2} | - | Note that capability ref1 is not included in capture set {lazylists.cap2}. + | Note that capability `ref1` is not included in capture set {lazylists.cap2}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist-global.scala:45:42 ------------------------------ 45 | val ref4c: LazyList[Int]^{cap1, ref3} = ref4 // error | ^^^^ - | Found: (ref4 : lazylists.LazyList[Int]^{lazylists.cap3, lazylists.cap1, lazylists.cap2}) - | Required: lazylists.LazyList[Int]^{lazylists.cap1, ref3} + | Found: (ref4 : lazylists.LazyList[Int]^{lazylists.cap3, lazylists.cap1, lazylists.cap2}) + | Required: lazylists.LazyList[Int]^{lazylists.cap1, ref3} | - | Note that capability lazylists.cap3 is not included in capture set {lazylists.cap1, ref3}. + | Note that capability `lazylists.cap3` is not included in capture set {lazylists.cap1, ref3}. | | longer explanation available when compiling with `-explain` -- [E164] Declaration Error: tests/neg-custom-args/captures/lazylist-global.scala:22:6 --------------------------------- 22 | def tail: LazyList[Nothing]^ = ??? // error overriding | ^ | error overriding method tail in class LazyList of type -> lazylists.LazyList[Nothing]; - | method tail of type -> lazylists.LazyList[Nothing]^{cap} has incompatible type + | method tail of type -> lazylists.LazyList[Nothing]^{fresh} has incompatible type | - | where: cap is a root capability associated with the result type of -> lazylists.LazyList[Nothing]^ + | where: fresh is a root capability associated with the result type of -> lazylists.LazyList[Nothing]^ | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazylist.check b/tests/neg-custom-args/captures/lazylist.check index 7dc69e879466..743a92cadcc5 100644 --- a/tests/neg-custom-args/captures/lazylist.check +++ b/tests/neg-custom-args/captures/lazylist.check @@ -4,7 +4,7 @@ | Found: lazylists.LazyList[T]^{LazyCons.this.xs} | Required: lazylists.LazyList[T] | - | Note that capability LazyCons.this.xs is not included in capture set {}. + | Note that capability `LazyCons.this.xs` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:35:29 ------------------------------------- @@ -13,7 +13,7 @@ | Found: (ref1 : lazylists.LazyCons[Int]{val xs: () ->{cap1} lazylists.LazyList[Int]^{}}^{cap1}) | Required: lazylists.LazyList[Int] | - | Note that capability cap1 is not included in capture set {}. + | Note that capability `cap1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:37:36 ------------------------------------- @@ -22,7 +22,7 @@ | Found: (ref2 : lazylists.LazyList[Int]^{cap2, ref1}) | Required: lazylists.LazyList[Int]^{ref1} | - | Note that capability cap2 is not included in capture set {ref1}. + | Note that capability `cap2` is not included in capture set {ref1}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:39:36 ------------------------------------- @@ -31,24 +31,24 @@ | Found: (ref3 : lazylists.LazyList[Int]^{cap2, ref1}) | Required: lazylists.LazyList[Int]^{cap2} | - | Note that capability ref1 is not included in capture set {cap2}. + | Note that capability `ref1` is not included in capture set {cap2}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:41:42 ------------------------------------- 41 | val ref4c: LazyList[Int]^{cap1, ref3} = ref4 // error | ^^^^ - | Found: (ref4 : lazylists.LazyList[Int]^{cap3, cap1, cap2}) - | Required: lazylists.LazyList[Int]^{cap1, ref3} + | Found: (ref4 : lazylists.LazyList[Int]^{cap3, cap1, cap2}) + | Required: lazylists.LazyList[Int]^{cap1, ref3} | - | Note that capability cap3 is not included in capture set {cap1, ref3}. + | Note that capability `cap3` is not included in capture set {cap1, ref3}. | | longer explanation available when compiling with `-explain` -- [E164] Declaration Error: tests/neg-custom-args/captures/lazylist.scala:22:6 ---------------------------------------- 22 | def tail: LazyList[Nothing]^ = ??? // error overriding | ^ | error overriding method tail in class LazyList of type -> lazylists.LazyList[Nothing]; - | method tail of type -> lazylists.LazyList[Nothing]^{cap} has incompatible type + | method tail of type -> lazylists.LazyList[Nothing]^{fresh} has incompatible type | - | where: cap is a root capability associated with the result type of -> lazylists.LazyList[Nothing]^ + | where: fresh is a root capability associated with the result type of -> lazylists.LazyList[Nothing]^ | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazylists-exceptions.check b/tests/neg-custom-args/captures/lazylists-exceptions.check index 1ad4ee61ff10..e866374d7748 100644 --- a/tests/neg-custom-args/captures/lazylists-exceptions.check +++ b/tests/neg-custom-args/captures/lazylists-exceptions.check @@ -1,7 +1,7 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylists-exceptions.scala:37:17 ------------------------- 37 | tabulate(10) { i => // error | ^ - | Capability canThrow$1 defined in an enclosing try expression outlives its scope: + | Capability `canThrow$1` defined in an enclosing try expression outlives its scope: | it leaks into outer capture set 's1 of method problem. | The leakage occurred when trying to match the following types: | diff --git a/tests/neg-custom-args/captures/lazylists1.check b/tests/neg-custom-args/captures/lazylists1.check index 717c2f4f57ab..03d290c545a9 100644 --- a/tests/neg-custom-args/captures/lazylists1.check +++ b/tests/neg-custom-args/captures/lazylists1.check @@ -1,9 +1,9 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylists1.scala:25:66 ----------------------------------- 25 | def concat(other: LazyList[A]^{f}): LazyList[A]^{this, f} = ??? : (LazyList[A]^{xs, f}) // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | Found: LazyList[A]^{xs, f} - | Required: LazyList[A]^{Mapped.this, f} + | Found: LazyList[A]^{xs, f} + | Required: LazyList[A]^{Mapped.this, f} | - | Note that capability xs is not included in capture set {Mapped.this, f}. + | Note that capability `xs` is not included in capture set {Mapped.this, f}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazylists2.check b/tests/neg-custom-args/captures/lazylists2.check index c295225f4167..f58989cc5ec5 100644 --- a/tests/neg-custom-args/captures/lazylists2.check +++ b/tests/neg-custom-args/captures/lazylists2.check @@ -4,7 +4,7 @@ | Found: LazyList[B^'s1]^{f, xs} | Required: LazyList[B]^{f} | - | Note that capability xs is not included in capture set {f}. + | Note that capability `xs` is not included in capture set {f}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylists2.scala:33:4 ------------------------------------ @@ -13,24 +13,24 @@ | Found: LazyList[B^'s2]^{f, xs} | Required: LazyList[B]^{xs} | - | Note that capability f is not included in capture set {xs}. + | Note that capability `f` is not included in capture set {xs}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/lazylists2.scala:40:20 -------------------------------------------------------- 40 | def head: B = f(xs.head) // error | ^ - | reference (f : A => B) is not included in the allowed capture set {xs} of the self type of class Mapped + | reference `f` is not included in the allowed capture set {xs} of the self type of class Mapped -- Error: tests/neg-custom-args/captures/lazylists2.scala:41:48 -------------------------------------------------------- 41 | def tail: LazyList[B]^{this}= xs.tail.map(f) // error | ^ - | reference (f : A => B) is not included in the allowed capture set {xs} of the self type of class Mapped + | reference `f` is not included in the allowed capture set {xs} of the self type of class Mapped -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylists2.scala:51:4 ------------------------------------ 51 | new Mapped // error | ^^^^^^^^^^ | Found: LazyList[B^'s3]^{f, xs} | Required: LazyList[B]^{xs} | - | Note that capability f is not included in capture set {xs}. + | Note that capability `f` is not included in capture set {xs}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/lazylists2.scala:60:10 -------------------------------------------------------- @@ -45,6 +45,6 @@ | Found: LazyList[B^'s4]^{f, xs} | Required: LazyList[B] | - | Note that capability f is not included in capture set {}. + | Note that capability `f` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazyref.check b/tests/neg-custom-args/captures/lazyref.check index 8d2002fd858d..fa1e281d99f6 100644 --- a/tests/neg-custom-args/captures/lazyref.check +++ b/tests/neg-custom-args/captures/lazyref.check @@ -4,7 +4,7 @@ | Found: (ref1 : LazyRef[Int]{val elem: () ->{cap1} Int}^{cap1}) | Required: LazyRef[Int] | - | Note that capability cap1 is not included in capture set {}. + | Note that capability `cap1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:22:35 -------------------------------------- @@ -13,7 +13,7 @@ | Found: LazyRef[Int]{val elem: () ->{ref2*} Int}^{ref2} | Required: LazyRef[Int]^{cap2} | - | Note that capability ref2 is not included in capture set {cap2}. + | Note that capability `ref2` is not included in capture set {cap2}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:24:35 -------------------------------------- @@ -22,7 +22,7 @@ | Found: LazyRef[Int]{val elem: () ->{ref3*} Int}^{ref3} | Required: LazyRef[Int]^{ref1} | - | Note that capability ref3 is not included in capture set {ref1}. + | Note that capability `ref3` is not included in capture set {ref1}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:30:35 -------------------------------------- @@ -31,7 +31,7 @@ | Found: LazyRef[Int]{val elem: () ->{ref4*} Int}^{ref4} | Required: LazyRef[Int]^{cap1} | - | Note that capability ref4 is not included in capture set {cap1}. + | Note that capability `ref4` is not included in capture set {cap1}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/lazyref.scala:6:14 ------------------------------------------------------------ diff --git a/tests/neg-custom-args/captures/lazyvals-sep.check b/tests/neg-custom-args/captures/lazyvals-sep.check index 5840fcc00bb5..c232ba8d4654 100644 --- a/tests/neg-custom-args/captures/lazyvals-sep.check +++ b/tests/neg-custom-args/captures/lazyvals-sep.check @@ -27,24 +27,24 @@ 72 | Wrapper(r) // error | ^ |Found: Ref^{TestClass.this.r.rd} - |Required: Ref^ + |Required: Ref^{any} | - |Note that {cap} is an exclusive capture set of the stateful type Ref^, + |Note that {any} is an exclusive capture set of the stateful type Ref^{any}, |it cannot subsume a read-only capture set of the stateful type Ref^{TestClass.this.r.rd}. | - |where: ^ and cap refer to a root capability classified as Unscoped created in lazy value lazyVal8 when checking argument to parameter ref of constructor Wrapper + |where: any is a root capability classified as Unscoped created in lazy value lazyVal8 when checking argument to parameter ref of constructor Wrapper | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals-sep.scala:77:12 --------------------------------- 77 | Wrapper(r) // error | ^ |Found: Ref^{TestClass.this.r.rd} - |Required: Ref^ + |Required: Ref^{any} | - |Note that {cap} is an exclusive capture set of the stateful type Ref^, + |Note that {any} is an exclusive capture set of the stateful type Ref^{any}, |it cannot subsume a read-only capture set of the stateful type Ref^{TestClass.this.r.rd}. | - |where: ^ and cap refer to a root capability classified as Unscoped created in lazy value lazyVal9 when checking argument to parameter ref of constructor Wrapper + |where: any is a root capability classified as Unscoped created in lazy value lazyVal9 when checking argument to parameter ref of constructor Wrapper | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/lazyvals-sep.scala:82:8 ------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/lazyvals-sep.scala b/tests/neg-custom-args/captures/lazyvals-sep.scala index e9a60cfa84b5..79bdd30682cf 100644 --- a/tests/neg-custom-args/captures/lazyvals-sep.scala +++ b/tests/neg-custom-args/captures/lazyvals-sep.scala @@ -12,7 +12,7 @@ class Wrapper(val ref: Ref^) extends Stateful: def compute(): Int = ref.get() update def mutate(x: Int): Unit = ref.set(x) -class WrapperRd(val ref: Ref^{cap.rd}): +class WrapperRd(val ref: Ref^{any.rd}): def compute(): Int = ref.get() class TestClass extends Stateful: @@ -67,12 +67,12 @@ class TestClass extends Stateful: WrapperRd(r) // Test case 8: Wrapper type - exclusive access in initializer - should error - lazy val lazyVal8: Wrapper^{cap, r} = + lazy val lazyVal8: Wrapper^{any, r} = r.set(200) // error Wrapper(r) // error // Test case 9: Wrapper type - non-exclusive access in initializer - should error - lazy val lazyVal9: Wrapper^{cap, r} = + lazy val lazyVal9: Wrapper^{any, r} = r.get() Wrapper(r) // error diff --git a/tests/neg-custom-args/captures/lazyvals.check b/tests/neg-custom-args/captures/lazyvals.check index 190f58d08817..ac90d0bf3b79 100644 --- a/tests/neg-custom-args/captures/lazyvals.check +++ b/tests/neg-custom-args/captures/lazyvals.check @@ -4,7 +4,7 @@ | Found: () ->{console} String | Required: () -> String | - | Note that capability console is not included in capture set {}. + | Note that capability `console` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals.scala:16:30 ------------------------------------- @@ -13,7 +13,7 @@ | Found: () ->{console} String | Required: () ->{x} String | - | Note that capability console is not included in capture set {x}. + | Note that capability `console` is not included in capture set {x}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/lazyvals.scala:16:12 ---------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/lazyvals2.check b/tests/neg-custom-args/captures/lazyvals2.check index 4ff7da32ab51..24428f2e21d8 100644 --- a/tests/neg-custom-args/captures/lazyvals2.check +++ b/tests/neg-custom-args/captures/lazyvals2.check @@ -4,6 +4,6 @@ | Found: () ->{console, io} String | Required: () ->{io} String | - | Note that capability console is not included in capture set {io}. + | Note that capability `console` is not included in capture set {io}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazyvals3.check b/tests/neg-custom-args/captures/lazyvals3.check index 92a257cf384d..0164dae46ac9 100644 --- a/tests/neg-custom-args/captures/lazyvals3.check +++ b/tests/neg-custom-args/captures/lazyvals3.check @@ -1,10 +1,10 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals3.scala:24:52 ------------------------------------ 24 | lazy val od1: (Int ->{ev1,console} Boolean) = (n: Int) => // error | ^ - | Found: (n: Int) ->{console, c} Boolean - | Required: Int ->{ev1, console} Boolean + | Found: (n: Int) ->{console, c} Boolean + | Required: Int ->{ev1, console} Boolean | - | Note that capability c is not included in capture set {ev1, console}. + | Note that capability `c` is not included in capture set {ev1, console}. | 25 | if n == 1 then 26 |... diff --git a/tests/neg-custom-args/captures/lazyvals4.check b/tests/neg-custom-args/captures/lazyvals4.check index fb32fa6f9bdf..1c89bf3978fb 100644 --- a/tests/neg-custom-args/captures/lazyvals4.check +++ b/tests/neg-custom-args/captures/lazyvals4.check @@ -4,7 +4,7 @@ | Found: () ->{t} () -> String | Required: () -> () -> String | - | Note that capability t is not included in capture set {}. + | Note that capability `t` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals4.scala:23:39 ------------------------------------ @@ -13,7 +13,7 @@ | Found: () ->{t} String | Required: () -> String | - | Note that capability t is not included in capture set {}. + | Note that capability `t` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals4.scala:25:39 ------------------------------------ @@ -22,7 +22,7 @@ | Found: () ->{c} String | Required: () ->{c.console} String | - | Note that capability c is not included in capture set {c.console}. + | Note that capability `c` is not included in capture set {c.console}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals4.scala:26:39 ------------------------------------ @@ -31,6 +31,6 @@ | Found: () ->{t} String | Required: () -> String | - | Note that capability t is not included in capture set {}. + | Note that capability `t` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazyvals5.check b/tests/neg-custom-args/captures/lazyvals5.check index eace61039169..3d1a0ee24856 100644 --- a/tests/neg-custom-args/captures/lazyvals5.check +++ b/tests/neg-custom-args/captures/lazyvals5.check @@ -4,7 +4,7 @@ | Found: () ->{t} () ->{io} String | Required: () -> () ->{io} String | - | Note that capability t is not included in capture set {}. + | Note that capability `t` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals5.scala:34:41 ------------------------------------ @@ -13,7 +13,7 @@ | Found: () ->{t} String | Required: () -> String | - | Note that capability t is not included in capture set {}. + | Note that capability `t` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals5.scala:36:41 ------------------------------------ @@ -22,7 +22,7 @@ | Found: () ->{c} String | Required: () ->{c.console} String | - | Note that capability c is not included in capture set {c.console}. + | Note that capability `c` is not included in capture set {c.console}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals5.scala:37:41 ------------------------------------ @@ -31,7 +31,7 @@ | Found: () ->{t} String | Required: () -> String | - | Note that capability t is not included in capture set {}. + | Note that capability `t` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals5.scala:40:28 ------------------------------------ @@ -40,7 +40,7 @@ | Found: () ->{t, c} String | Required: () ->{c} String | - | Note that capability t is not included in capture set {c}. + | Note that capability `t` is not included in capture set {c}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals5.scala:41:30 ------------------------------------ @@ -49,18 +49,18 @@ | Found: () ->{t, c} String | Required: () ->{t} String | - | Note that capability c is not included in capture set {t}. + | Note that capability `c` is not included in capture set {t}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals5.scala:61:55 ------------------------------------ 61 | val v9: () ->{c2.memberLazy, t2.memberLazy} String = () => funky2 // error (but should this be allowed?) | ^^^^^^^^^^^^ - | Found: () ->{t2, c2} String - | Required: () ->{c2.memberLazy, t2.memberLazy²} String + | Found: () ->{t2, c2} String + | Required: () ->{c2.memberLazy, t2.memberLazy²} String | - | Note that capability t2 is not included in capture set {c2.memberLazy, t2.memberLazy²}. + | Note that capability `t2` is not included in capture set {c2.memberLazy, t2.memberLazy²}. | - | where: memberLazy is a lazy value in class Clazz2 - | memberLazy² is a lazy value in trait Trait2 + | where: memberLazy is a lazy value in class Clazz2 + | memberLazy² is a lazy value in trait Trait2 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/lazyvals6.check b/tests/neg-custom-args/captures/lazyvals6.check index 1ce7f1f5515f..1de91cf1b5bb 100644 --- a/tests/neg-custom-args/captures/lazyvals6.check +++ b/tests/neg-custom-args/captures/lazyvals6.check @@ -4,7 +4,7 @@ | Found: (C.this.x : () ->{C.this.io} Unit) | Required: () -> Unit | - | Note that capability C.this.io is not included in capture set {}. + | Note that capability `C.this.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:12:22 ------------------------------------ @@ -13,7 +13,7 @@ | Found: (C.this.l1 : () ->{C.this.c.io} Unit) | Required: () -> Unit | - | Note that capability C.this.c.io is not included in capture set {}. + | Note that capability `C.this.c.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:16:22 ------------------------------------ @@ -22,7 +22,7 @@ | Found: (C.this.l2 : () ->{C.this.io} Unit) | Required: () -> Unit | - | Note that capability C.this.io is not included in capture set {}. + | Note that capability `C.this.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:20:22 ------------------------------------ @@ -31,7 +31,7 @@ | Found: (C.this.s1 : () ->{C.this.c.io} Unit) | Required: () -> Unit | - | Note that capability C.this.c.io is not included in capture set {}. + | Note that capability `C.this.c.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:24:22 ------------------------------------ @@ -40,7 +40,7 @@ | Found: (C.this.s2 : () ->{C.this.io} Unit) | Required: () -> Unit | - | Note that capability C.this.io is not included in capture set {}. + | Note that capability `C.this.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:32:22 ------------------------------------ @@ -49,7 +49,7 @@ | Found: (C.this.l11 : () ->{C.this} Unit) | Required: () -> Unit | - | Note that capability C.this is not included in capture set {}. + | Note that capability `C.this` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:36:22 ------------------------------------ @@ -58,7 +58,7 @@ | Found: (C.this.l12 : () ->{C.this.io} Unit) | Required: () -> Unit | - | Note that capability C.this.io is not included in capture set {}. + | Note that capability `C.this.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:41:22 ------------------------------------ @@ -67,7 +67,7 @@ | Found: (C.this.s11 : () ->{C.this} Unit) | Required: () -> Unit | - | Note that capability C.this is not included in capture set {}. + | Note that capability `C.this` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:45:22 ------------------------------------ @@ -76,7 +76,7 @@ | Found: (C.this.s12 : () ->{C.this.io} Unit) | Required: () -> Unit | - | Note that capability C.this.io is not included in capture set {}. + | Note that capability `C.this.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:50:22 ------------------------------------ @@ -85,7 +85,7 @@ | Found: (x : () ->{io} Unit) | Required: () -> Unit | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyvals6.scala:55:22 ------------------------------------ @@ -94,6 +94,6 @@ | Found: (z : () ->{c.io} Unit) | Required: () -> Unit | - | Note that capability c.io is not included in capture set {}. + | Note that capability `c.io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/leak-problem-2.check b/tests/neg-custom-args/captures/leak-problem-2.check index ddbcb8839fa8..a44e6dccf6bb 100644 --- a/tests/neg-custom-args/captures/leak-problem-2.check +++ b/tests/neg-custom-args/captures/leak-problem-2.check @@ -4,6 +4,6 @@ | Found: Source[T^'s1]^{src1, src2} | Required: Source[T] | - | Note that capability src1 is not included in capture set {}. + | Note that capability `src1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/leaked-curried.check b/tests/neg-custom-args/captures/leaked-curried.check index 5f107b174356..b42ecbb95e88 100644 --- a/tests/neg-custom-args/captures/leaked-curried.check +++ b/tests/neg-custom-args/captures/leaked-curried.check @@ -1,7 +1,7 @@ -- Error: tests/neg-custom-args/captures/leaked-curried.scala:11:10 ---------------------------------------------------- 11 | class Fuzz extends Box, caps.Pure: // error | ^ - | reference cap is not included in the allowed capture set {} of the self type of class Fuzz + | reference `any` is not included in the allowed capture set {} of the self type of class Fuzz | 12 | self => 13 | val get: () ->{} () ->{io} Cap^ = @@ -9,7 +9,7 @@ -- Error: tests/neg-custom-args/captures/leaked-curried.scala:15:10 ---------------------------------------------------- 15 | class Foo extends Box, caps.Pure: // error | ^ - | reference cap is not included in the allowed capture set {} of the self type of class Foo + | reference `any` is not included in the allowed capture set {} of the self type of class Foo | 16 | val get: () ->{} () ->{io} Cap^ = 17 | () => () => io diff --git a/tests/neg-custom-args/captures/leaking-iterators.check b/tests/neg-custom-args/captures/leaking-iterators.check index 9a516cb1a1d9..96895445d27d 100644 --- a/tests/neg-custom-args/captures/leaking-iterators.check +++ b/tests/neg-custom-args/captures/leaking-iterators.check @@ -1,14 +1,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/leaking-iterators.scala:56:16 ---------------------------- 56 | usingLogFile: log => // error | ^ - |Capability log outlives its scope: it leaks into outer capture set 's1 which is owned by method test. + |Capability `log` outlives its scope: it leaks into outer capture set 's1 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (log: java.io.FileOutputStream^'s2) ->'s3 cctest.Iterator[Int]^{log} |Required: java.io.FileOutputStream^ => cctest.Iterator[Int]^'s1 | |where: => refers to a root capability created in method test when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 57 | xs.iterator.map: x => 58 | log.write(x) diff --git a/tests/neg-custom-args/captures/leaky.check b/tests/neg-custom-args/captures/leaky.check index b6fb368aa757..918d4da3a420 100644 --- a/tests/neg-custom-args/captures/leaky.check +++ b/tests/neg-custom-args/captures/leaky.check @@ -4,7 +4,7 @@ | Found: test.runnable.Transform{val fun: (f : Any ->{a} Any)}^{f} | Required: test.runnable.Transform | - | Note that capability f is not included in capture set {}. + | Note that capability `f` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/leaky.scala:24:2 ----------------------------------------- @@ -13,7 +13,7 @@ | Found: test.runnable.Transform{val fun: Any ->{f} Any}^{x} | Required: test.runnable.Transform | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/leaky.scala:31:2 ----------------------------------------- @@ -22,6 +22,6 @@ | Found: test.runnable.Transform{val fun: Any ->{f} Any}^{x} | Required: test.runnable.Transform | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/levels.check b/tests/neg-custom-args/captures/levels.check index 43a96dda25ba..01c8ad08f426 100644 --- a/tests/neg-custom-args/captures/levels.check +++ b/tests/neg-custom-args/captures/levels.check @@ -4,6 +4,6 @@ | Found: (x: String) ->{cap3} String | Required: String -> String | - | Note that capability cap3 is not included in capture set {}. + | Note that capability `cap3` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/linear-buffer-2.scala b/tests/neg-custom-args/captures/linear-buffer-2.scala index d2ed1544fadf..17bc51f6d4c0 100644 --- a/tests/neg-custom-args/captures/linear-buffer-2.scala +++ b/tests/neg-custom-args/captures/linear-buffer-2.scala @@ -1,4 +1,4 @@ -import caps.{cap, Mutable} +import caps.{any, Mutable} import language.experimental.captureChecking class Buffer[T] extends Mutable: diff --git a/tests/neg-custom-args/captures/linear-buffer.check b/tests/neg-custom-args/captures/linear-buffer.check index 302fd2b0db82..80f91ca4c482 100644 --- a/tests/neg-custom-args/captures/linear-buffer.check +++ b/tests/neg-custom-args/captures/linear-buffer.check @@ -1,13 +1,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/linear-buffer.scala:7:29 --------------------------------- 7 | def bar: BadBuffer[T]^ = this // error // error separation | ^^^^ - | Found: BadBuffer[T]^{BadBuffer.this.rd} - | Required: BadBuffer[T]^ + | Found: BadBuffer[T]^{BadBuffer.this.rd} + | Required: BadBuffer[T]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type BadBuffer[T]^, - | it cannot subsume a read-only capture set of the stateful type BadBuffer[T]^{BadBuffer.this.rd}. + | Note that {any} is an exclusive capture set of the stateful type BadBuffer[T]^{any}, + | it cannot subsume a read-only capture set of the stateful type BadBuffer[T]^{BadBuffer.this.rd}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the result type of method bar + | where: any is a root capability classified as Unscoped in the result type of method bar | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/linear-buffer.scala:5:27 ------------------------------------------------------ diff --git a/tests/neg-custom-args/captures/linear-buffer.scala b/tests/neg-custom-args/captures/linear-buffer.scala index 204620b55f7c..9da22b2ddd07 100644 --- a/tests/neg-custom-args/captures/linear-buffer.scala +++ b/tests/neg-custom-args/captures/linear-buffer.scala @@ -1,4 +1,4 @@ -import caps.{cap, Mutable} +import caps.{any, Mutable} import language.experimental.captureChecking class BadBuffer[T] extends Mutable: diff --git a/tests/neg-custom-args/captures/local-mutables-2.check b/tests/neg-custom-args/captures/local-mutables-2.check index bfeccab7928c..b46633631956 100644 --- a/tests/neg-custom-args/captures/local-mutables-2.check +++ b/tests/neg-custom-args/captures/local-mutables-2.check @@ -1,21 +1,21 @@ -- Error: tests/neg-custom-args/captures/local-mutables-2.scala:7:9 ---------------------------------------------------- 7 |def foo() = // error: separation failure | ^ - |Separation failure in method foo's inferred result type (() ->{cap.rd} Int, Int => Unit)^{}. - |One part, () ->{cap.rd} Int, hides capabilities {cap².rd}. - |Another part, Int => Unit, captures capabilities {cap³, cap, cap²}. - |The two sets overlap at {cap of value r}. + |Separation failure in method foo's inferred result type (() ->{any.rd} Int, Int => Unit)^{}. + |One part, () ->{any.rd} Int, hides capabilities {any².rd}. + |Another part, Int => Unit, captures capabilities {any³, any, any²}. + |The two sets overlap at {`any` of value r}. | - |where: => and cap³ refer to a root capability classified as Unscoped in the result type of method foo - | cap is a root capability classified as Unscoped in the type of value r - | cap² is a root capability classified as Unscoped created in value r when constructing instance Ref + |where: => and any³ refer to a root capability classified as Unscoped in the result type of method foo + | any is a root capability classified as Unscoped in the type of value r + | any² is a root capability classified as Unscoped created in value r when constructing instance Ref -- Error: tests/neg-custom-args/captures/local-mutables-2.scala:11:10 -------------------------------------------------- 11 |def foo2() = // error: separation failure | ^ - | Separation failure in method foo2's inferred result type (() ->{cap.rd} Int, Int => Unit)^{}. - | One part, Int => Unit, hides capabilities {cap}. - | Another part, () ->{cap.rd} Int, captures capabilities {cap.rd}. - | The two sets overlap at {cap of variable r}. + | Separation failure in method foo2's inferred result type (() ->{any.rd} Int, Int => Unit)^{}. + | One part, Int => Unit, hides capabilities {any}. + | Another part, () ->{any.rd} Int, captures capabilities {any.rd}. + | The two sets overlap at {`any` of variable r}. | | where: => refers to a root capability classified as Unscoped in the result type of method foo2 - | cap is a root capability classified as Unscoped in the type of variable r + | any is a root capability classified as Unscoped in the type of variable r diff --git a/tests/neg-custom-args/captures/local-mutables.check b/tests/neg-custom-args/captures/local-mutables.check index 7c748fe03d02..4d676f3fba59 100644 --- a/tests/neg-custom-args/captures/local-mutables.check +++ b/tests/neg-custom-args/captures/local-mutables.check @@ -4,7 +4,7 @@ | Found: (getter : () ->{r.rd} Int) | Required: () -> Int | - | Note that capability r.rd is not included in capture set {}. + | Note that capability `r.rd` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/local-mutables.scala:14:22 ------------------------------- @@ -13,23 +13,21 @@ | Found: (setter : () ->{r} Unit) | Required: () -> Unit | - | Note that capability r is not included in capture set {}. + | Note that capability `r` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/local-mutables.scala:22:22 ---------------------------------------------------- 22 | def set(x: Int) = r.set(x) // error | ^ - | Read-only method set accesses exclusive capability (r : Ref^); + | Read-only method set accesses exclusive capability `r`; | method set should be declared an update method to allow this. - | - | where: ^ refers to a root capability classified as Unscoped in the type of value r -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/local-mutables.scala:35:21 ------------------------------- 35 | val _: () -> Int = getter // error | ^^^^^^ | Found: (getter : () ->{r.rd} Int) | Required: () -> Int | - | Note that capability r.rd is not included in capture set {}. + | Note that capability `r.rd` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/local-mutables.scala:39:22 ------------------------------- @@ -38,13 +36,11 @@ | Found: (setter : () ->{r} Unit) | Required: () -> Unit | - | Note that capability r is not included in capture set {}. + | Note that capability `r` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/local-mutables.scala:47:22 ---------------------------------------------------- 47 | def set(x: Int) = r = x // error | ^ - | Read-only method set accesses exclusive capability (r : scala.caps.internal.Var[Int]^); + | Read-only method set accesses exclusive capability `r`; | method set should be declared an update method to allow this. - | - | where: ^ refers to a root capability classified as Unscoped in the type of variable r² diff --git a/tests/neg-custom-args/captures/local-mutables.scala b/tests/neg-custom-args/captures/local-mutables.scala index 756985474dc7..6a34e5eb2940 100644 --- a/tests/neg-custom-args/captures/local-mutables.scala +++ b/tests/neg-custom-args/captures/local-mutables.scala @@ -25,7 +25,7 @@ def test1(): Unit = val c = C() val _: C^{r} = c val d = D() - val _: D^{r, cap} = d + val _: D^{r, any} = d val e = E() val _: E^{r.rd} = e @@ -50,6 +50,6 @@ def test2(): Unit = val c = C() val _: C^{r} = c val d = D() - val _: D^{r, cap} = d + val _: D^{r, any} = d val e = E() val _: E^{r.rd} = e diff --git a/tests/neg-custom-args/captures/lubs.check b/tests/neg-custom-args/captures/lubs.check index eaed760ac8a8..5aec0f19cc46 100644 --- a/tests/neg-custom-args/captures/lubs.check +++ b/tests/neg-custom-args/captures/lubs.check @@ -4,7 +4,7 @@ | Found: (x1 : D^{d1}) | Required: D | - | Note that capability d1 is not included in capture set {}. + | Note that capability `d1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lubs.scala:18:13 ----------------------------------------- @@ -13,7 +13,7 @@ | Found: (x2 : D^{d1}) | Required: D | - | Note that capability d1 is not included in capture set {}. + | Note that capability `d1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lubs.scala:19:13 ----------------------------------------- @@ -22,6 +22,6 @@ | Found: (x3 : D^{d1, d2}) | Required: D | - | Note that capability d1 is not included in capture set {}. + | Note that capability `d1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/matrix.check b/tests/neg-custom-args/captures/matrix.check index 52a532ab8ea2..630affa1118e 100644 --- a/tests/neg-custom-args/captures/matrix.check +++ b/tests/neg-custom-args/captures/matrix.check @@ -2,8 +2,8 @@ 27 | mul(m1, m2, m2) // error: will fail separation checking | ^^ |Separation failure: argument of type Matrix^{m2.rd} - |to method mul: (x: Matrix^{cap.rd}, y: Matrix^{cap.rd}, z: Matrix^): Unit - |corresponds to capture-polymorphic formal parameter y of type Matrix^{cap.rd} + |to method mul: (x: Matrix^{any.rd}, y: Matrix^{any.rd}, z: Matrix^): Unit + |corresponds to capture-polymorphic formal parameter y of type Matrix^{any.rd} |and hides capabilities {m2.rd}. |Some of these overlap with the captures of the third argument with type (m2 : Matrix^). | @@ -13,13 +13,13 @@ | Footprint set of third argument : {m2} | The two sets overlap at : {m2} | - |where: cap is a root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul + |where: any is a root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul -- Error: tests/neg-custom-args/captures/matrix.scala:30:11 ------------------------------------------------------------ 30 | mul1(m1, m2, m2) // error: will fail separation checking | ^^ |Separation failure: argument of type Matrix^{m2.rd} - |to method mul1: (x: Matrix^{cap.rd}, y: Matrix^{cap.rd}, z: Matrix^): Unit - |corresponds to capture-polymorphic formal parameter y of type Matrix^{cap.rd} + |to method mul1: (x: Matrix^{any.rd}, y: Matrix^{any.rd}, z: Matrix^): Unit + |corresponds to capture-polymorphic formal parameter y of type Matrix^{any.rd} |and hides capabilities {m2.rd}. |Some of these overlap with the captures of the third argument with type (m2 : Matrix^). | @@ -29,4 +29,4 @@ | Footprint set of third argument : {m2} | The two sets overlap at : {m2} | - |where: cap is a root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul1 + |where: any is a root capability classified as Unscoped created in method Test when checking argument to parameter y of method mul1 diff --git a/tests/neg-custom-args/captures/matrix.scala b/tests/neg-custom-args/captures/matrix.scala index e473da7edc70..aa42d6ac2b96 100644 --- a/tests/neg-custom-args/captures/matrix.scala +++ b/tests/neg-custom-args/captures/matrix.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any trait Rdr[T]: def get: T @@ -19,7 +19,7 @@ class Matrix(nrows: Int, ncols: Int) extends IMatrix, Mutable: def mul(x: Matrix, y: Matrix, z: Matrix^): Unit = ??? -def mul1(x: Matrix^{cap.rd}, y: Matrix^{cap.rd}, z: Matrix^): Unit = ??? +def mul1(x: Matrix^{any.rd}, y: Matrix^{any.rd}, z: Matrix^): Unit = ??? def Test(c: Object^): Unit = val m1 = Matrix(10, 10) @@ -32,5 +32,5 @@ def Test(c: Object^): Unit = def f2(): Matrix^ = Matrix(10, 10) - val i1: IMatrix^{cap.rd} = m1 - val i2: IMatrix^{cap.rd} = f2() + val i1: IMatrix^{any.rd} = m1 + val i2: IMatrix^{any.rd} = f2() diff --git a/tests/neg-custom-args/captures/mut-iterator.check b/tests/neg-custom-args/captures/mut-iterator.check index 6fdccb96f3c0..743006eb6016 100644 --- a/tests/neg-custom-args/captures/mut-iterator.check +++ b/tests/neg-custom-args/captures/mut-iterator.check @@ -1,10 +1,8 @@ -- Error: tests/neg-custom-args/captures/mut-iterator.scala:9:17 ------------------------------------------------------- 9 | def next() = f(Iterator.this.next()) // error | ^ - | Read-only method next accesses exclusive capability (f : T => U); + | Read-only method next accesses exclusive capability `f`; | method next should be declared an update method to allow this. - | - | where: => refers to a root capability in the type of parameter f -- Error: tests/neg-custom-args/captures/mut-iterator.scala:17:14 ------------------------------------------------------ 17 | current = xs1 // error | ^^^^^^^^^^^^^ @@ -13,17 +11,15 @@ -- Error: tests/neg-custom-args/captures/mut-iterator.scala:22:15 ------------------------------------------------------ 22 | def next() = f(it.next()) // error | ^ - | Read-only method next accesses exclusive capability (f : T => U); + | Read-only method next accesses exclusive capability `f`; | method next should be declared an update method to allow this. - | - | where: => refers to a root capability in the type of parameter f -- Error: tests/neg-custom-args/captures/mut-iterator.scala:7:25 ------------------------------------------------------- 7 | def map[U](f: T => U): Iterator[U] = new Iterator: // error | ^^^^^^^^^^^ - | Separation failure: method map's result type Iterator[U]^{cap.rd} hides non-local this of class trait Iterator. + | Separation failure: method map's result type Iterator[U]^{any.rd} hides non-local this of class trait Iterator. | The access must be in a consume method to allow this. -- Error: tests/neg-custom-args/captures/mut-iterator.scala:20:55 ------------------------------------------------------ 20 |def mappedIterator[T, U](it: Iterator[T]^, f: T => U): Iterator[U] = new Iterator: // error | ^^^^^^^^^^^ - | Separation failure: method mappedIterator's result type Iterator[U]^{cap.rd} hides parameters it and f. + | Separation failure: method mappedIterator's result type Iterator[U]^{any.rd} hides parameters it and f. | The parameters need to be annotated with consume to allow this. diff --git a/tests/neg-custom-args/captures/mut-iterator.scala b/tests/neg-custom-args/captures/mut-iterator.scala index ee38f11600f1..d7ddda5169b9 100644 --- a/tests/neg-custom-args/captures/mut-iterator.scala +++ b/tests/neg-custom-args/captures/mut-iterator.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful, SharedCapability} +import caps.{any, Stateful, SharedCapability} trait Iterator[T] extends Stateful: def hasNext: Boolean @@ -27,6 +27,6 @@ class IO extends SharedCapability: def test(io: IO) = val proc: Int => Int = i => { io.write(i); i * i } listIterator(List(1, 2, 3)).map(proc) - val roit: Iterator[Int]^{cap.rd} = listIterator(List(1, 2, 3)) + val roit: Iterator[Int]^{any.rd} = listIterator(List(1, 2, 3)) val mapped = roit.map(proc) mapped.next() diff --git a/tests/neg-custom-args/captures/mut-iterator2.check b/tests/neg-custom-args/captures/mut-iterator2.check index 4e4febb46ff3..a539d1aaee9f 100644 --- a/tests/neg-custom-args/captures/mut-iterator2.check +++ b/tests/neg-custom-args/captures/mut-iterator2.check @@ -1,17 +1,15 @@ -- Error: tests/neg-custom-args/captures/mut-iterator2.scala:9:26 ------------------------------------------------------ 9 | update def next() = f(Iterator.this.next()) // error | ^^^^^^^^^^^^^ - | Read-only method map accesses exclusive capability (Iterator.this : Iterator[T]^); + | Read-only method map accesses exclusive capability `Iterator.this`; | method map should be declared an update method to allow this. - | - | where: ^ refers to the universal root capability -- Error: tests/neg-custom-args/captures/mut-iterator2.scala:7:25 ------------------------------------------------------ 7 | def map[U](f: T => U): Iterator[U] = new Iterator: // error | ^^^^^^^^^^^ - | Separation failure: method map's result type Iterator[U]^{cap.rd} hides non-local this of class trait Iterator. + | Separation failure: method map's result type Iterator[U]^{any.rd} hides non-local this of class trait Iterator. | The access must be in a consume method to allow this. -- Error: tests/neg-custom-args/captures/mut-iterator2.scala:20:55 ----------------------------------------------------- 20 |def mappedIterator[T, U](it: Iterator[T]^, f: T => U): Iterator[U] = new Iterator: // error | ^^^^^^^^^^^ - | Separation failure: method mappedIterator's result type Iterator[U]^{cap.rd} hides parameters it and f. + | Separation failure: method mappedIterator's result type Iterator[U]^{any.rd} hides parameters it and f. | The parameters need to be annotated with consume to allow this. diff --git a/tests/neg-custom-args/captures/mut-iterator3.scala b/tests/neg-custom-args/captures/mut-iterator3.scala index 350818bf1d9f..942a2c541217 100644 --- a/tests/neg-custom-args/captures/mut-iterator3.scala +++ b/tests/neg-custom-args/captures/mut-iterator3.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful, SharedCapability} +import caps.{any, Stateful, SharedCapability} trait Iterator[T] extends Stateful: def hasNext: Boolean @@ -27,6 +27,6 @@ class IO extends SharedCapability: def test(io: IO) = def proc: Int => Int = i => { io.write(i); i * i } listIterator(List(1, 2, 3)).map(proc) - val roit: Iterator[Int]^{cap.rd} = listIterator(List(1, 2, 3)) + val roit: Iterator[Int]^{any.rd} = listIterator(List(1, 2, 3)) val mapped = roit.map(proc) // error mapped.next() // error diff --git a/tests/neg-custom-args/captures/mut-iterator4-global.scala b/tests/neg-custom-args/captures/mut-iterator4-global.scala index a3b042157fe5..fb512a7f0efc 100644 --- a/tests/neg-custom-args/captures/mut-iterator4-global.scala +++ b/tests/neg-custom-args/captures/mut-iterator4-global.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful, SharedCapability} +import caps.{any, Stateful, SharedCapability} trait Iterator[T] extends Stateful: def hasNext: Boolean @@ -30,6 +30,6 @@ val io: IO = IO() def test() = def proc: Int => Int = i => { io.write(i); i * i } listIterator(List(1, 2, 3)).map(proc) - val roit: Iterator[Int]^{cap.rd} = listIterator(List(1, 2, 3)) + val roit: Iterator[Int]^{any.rd} = listIterator(List(1, 2, 3)) val mapped = roit.map(proc) mapped.next() diff --git a/tests/neg-custom-args/captures/mut-iterator4.check b/tests/neg-custom-args/captures/mut-iterator4.check index bbbca6a04677..d828155e21cb 100644 --- a/tests/neg-custom-args/captures/mut-iterator4.check +++ b/tests/neg-custom-args/captures/mut-iterator4.check @@ -1,19 +1,17 @@ -- Error: tests/neg-custom-args/captures/mut-iterator4.scala:9:26 ------------------------------------------------------ 9 | update def next() = f(Iterator.this.next()) // error | ^^^^^^^^^^^^^ - | Read-only method map accesses exclusive capability (Iterator.this : Iterator[T]^); + | Read-only method map accesses exclusive capability `Iterator.this`; | method map should be declared an update method to allow this. - | - | where: ^ refers to the universal root capability -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mut-iterator4.scala:21:81 -------------------------------- 21 |def mappedIterator[T, U](it: Iterator[T]^, f: T => U): Iterator[U]^{it, f} = new Iterator: // error | ^ - |Found: Iterator[U^'s1]^{it.rd, f, it, cap} + |Found: Iterator[U^'s1]^{it.rd, f, it, any} |Required: Iterator[U]^{it, f} | - |Note that capability cap is not included in capture set {it, f}. + |Note that capability `any` is not included in capture set {it, f}. | - |where: cap is a root capability created in method mappedIterator when constructing instance Object with (Iterator[U]^{cap².rd}) {...} + |where: any is a root capability created in method mappedIterator when constructing instance Object with (Iterator[U]^{any².rd}) {...} | 22 | def hasNext = it.hasNext 23 | update def next() = f(it.next()) diff --git a/tests/neg-custom-args/captures/mut-iterator4.scala b/tests/neg-custom-args/captures/mut-iterator4.scala index 1d6716e5f82d..b822e61adc7e 100644 --- a/tests/neg-custom-args/captures/mut-iterator4.scala +++ b/tests/neg-custom-args/captures/mut-iterator4.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful, SharedCapability} +import caps.{any, Stateful, SharedCapability} trait Iterator[T] extends Stateful: def hasNext: Boolean @@ -28,6 +28,6 @@ class IO extends SharedCapability: def test(io: IO) = def proc: Int => Int = i => { io.write(i); i * i } listIterator(List(1, 2, 3)).map(proc) - val roit: Iterator[Int]^{cap.rd} = listIterator(List(1, 2, 3)) + val roit: Iterator[Int]^{any.rd} = listIterator(List(1, 2, 3)) val mapped = roit.map(proc) mapped.next() diff --git a/tests/neg-custom-args/captures/mut-iterator5.check b/tests/neg-custom-args/captures/mut-iterator5.check index f9aa93e489e2..fcba2ac0e17b 100644 --- a/tests/neg-custom-args/captures/mut-iterator5.check +++ b/tests/neg-custom-args/captures/mut-iterator5.check @@ -6,7 +6,5 @@ -- Error: tests/neg-custom-args/captures/mut-iterator5.scala:16:26 ----------------------------------------------------- 16 | update def next() = Iterator.this.next() // error | ^^^^^^^^^^^^^ - | Read-only method sneakyForeach accesses exclusive capability (Iterator.this : Iterator[T]^); - | method sneakyForeach should be declared an update method to allow this. - | - | where: ^ refers to the universal root capability + | Read-only method sneakyForeach accesses exclusive capability `Iterator.this`; + | method sneakyForeach should be declared an update method to allow this. diff --git a/tests/neg-custom-args/captures/mut-iterator5.scala b/tests/neg-custom-args/captures/mut-iterator5.scala index 65af100c2853..6f0ed8f05e3d 100644 --- a/tests/neg-custom-args/captures/mut-iterator5.scala +++ b/tests/neg-custom-args/captures/mut-iterator5.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful, SharedCapability} +import caps.{any, Stateful, SharedCapability} trait Iterator[T] extends Stateful: def hasNext: Boolean diff --git a/tests/neg-custom-args/captures/mut-widen-empty.check b/tests/neg-custom-args/captures/mut-widen-empty.check index e85b6fd2cff6..8ba4f3bff549 100644 --- a/tests/neg-custom-args/captures/mut-widen-empty.check +++ b/tests/neg-custom-args/captures/mut-widen-empty.check @@ -1,24 +1,24 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mut-widen-empty.scala:12:24 ------------------------------ 12 | val c: Arr[String]^ = b // error | ^ - | Found: (b : Arr[String]^{}) - | Required: Arr[String]^ + | Found: (b : Arr[String]^{}) + | Required: Arr[String]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Arr[String]^, - | it cannot subsume a read-only capture set of the stateful type Arr[String]^{}. + | Note that {any} is an exclusive capture set of the stateful type Arr[String]^{any}, + | it cannot subsume a read-only capture set of the stateful type Arr[String]^{}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the type of value c + | where: any is a root capability classified as Unscoped in the type of value c | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mut-widen-empty.scala:18:26 ------------------------------ 18 | val c: Array[String]^ = b // error | ^ - | Found: (b : Array[String]^{}) - | Required: Array[String]^ + | Found: (b : Array[String]^{}) + | Required: Array[String]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Array[String]^, - | it cannot subsume a read-only capture set of the stateful type Array[String]^{}. + | Note that {any} is an exclusive capture set of the stateful type Array[String]^{any}, + | it cannot subsume a read-only capture set of the stateful type Array[String]^{}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the type of value c + | where: any is a root capability classified as Unscoped in the type of value c | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/mutability.check b/tests/neg-custom-args/captures/mutability.check index 06742900f208..eb6e8d276212 100644 --- a/tests/neg-custom-args/captures/mutability.check +++ b/tests/neg-custom-args/captures/mutability.check @@ -11,22 +11,20 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:10:25 ----------------------------------- 10 | val self2: Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {any} is an exclusive capture set of the stateful type Ref[T]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the type of value self2 + | where: any is a root capability classified as Unscoped in the type of value self2 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:11:13 -------------------------------------------------------- 11 | self2.set(x) // error | ^^^^^^^^^^^^ - | Read-only method sneakyHide accesses exclusive capability (Ref.this : Ref[T]^); + | Read-only method sneakyHide accesses exclusive capability `Ref.this`; | method sneakyHide should be declared an update method to allow this. - | - | where: ^ refers to a root capability classified as Unscoped in the type of class Ref -- Error: tests/neg-custom-args/captures/mutability.scala:14:12 -------------------------------------------------------- 14 | self3().set(x) // error | ^^^^^^^^^^^ @@ -35,23 +33,21 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:15:31 ----------------------------------- 15 | val self4: () => Ref[T]^ = () => this // error | ^^^^^^^^^^ - | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} - | Required: () => Ref[T]^ + | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} + | Required: () => Ref[T]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. + | Note that {any} is an exclusive capture set of the stateful type Ref[T]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. | - | where: => refers to a root capability in the type of value self4 - | ^ and cap refer to a root capability classified as Unscoped in the type of value self4 + | where: => refers to a root capability in the type of value self4 + | any is a root capability classified as Unscoped in the type of value self4 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:16:15 -------------------------------------------------------- 16 | self4().set(x) // error | ^^^^^^^^^^^^^^ - | Read-only method sneakyHide accesses exclusive capability (Ref.this : Ref[T]^); + | Read-only method sneakyHide accesses exclusive capability `Ref.this`; | method sneakyHide should be declared an update method to allow this. - | - | where: ^ refers to a root capability classified as Unscoped in the type of class Ref -- Error: tests/neg-custom-args/captures/mutability.scala:19:12 -------------------------------------------------------- 19 | self5().set(x) // error | ^^^^^^^^^^^ @@ -60,22 +56,20 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:20:27 ----------------------------------- 20 | def self6(): Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {any} is an exclusive capture set of the stateful type Ref[T]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the result type of method self6 + | where: any is a root capability classified as Unscoped in the result type of method self6 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:21:15 -------------------------------------------------------- 21 | self6().set(x) // error | ^^^^^^^^^^^^^^ - | Read-only method sneakyHide accesses exclusive capability (Ref.this : Ref[T]^); + | Read-only method sneakyHide accesses exclusive capability `Ref.this`; | method sneakyHide should be declared an update method to allow this. - | - | where: ^ refers to a root capability classified as Unscoped in the type of class Ref -- Error: tests/neg-custom-args/captures/mutability.scala:25:25 -------------------------------------------------------- 25 | def set(x: T) = this.x.set(x) // error | ^^^^^^^^^^ @@ -94,21 +88,21 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutability.scala:43:29 ----------------------------------- 43 | val r5: () => Ref2[Int]^ = () => ref2 // error | ^^^^^^^^^^ - | Found: () ->{ref2.rd} Ref2[Int]^{ref2} - | Required: () => Ref2[Int]^ + | Found: () ->{ref2.rd} Ref2[Int]^{ref2} + | Required: () => Ref2[Int]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref2[Int]^, - | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. + | Note that {any} is an exclusive capture set of the stateful type Ref2[Int]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. | - | where: => refers to a root capability in the type of value r5 - | ^ and cap refer to a root capability classified as Unscoped in the type of value r5 + | where: => refers to a root capability in the type of value r5 + | any is a root capability classified as Unscoped in the type of value r5 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutability.scala:46:9 --------------------------------------------------------- 46 | r6().x.set(33) // error | ^^^^^^^^^^ - | Cannot call update method set of Ref[Int]^{cap.rd} - | since its capture set {cap.rd} is read-only. + | Cannot call update method set of Ref[Int]^{any.rd} + | since its capture set {any.rd} is read-only. -- Error: tests/neg-custom-args/captures/mutability.scala:10:15 -------------------------------------------------------- 10 | val self2: Ref[T]^ = this // error // error separation | ^^^^^^^ diff --git a/tests/neg-custom-args/captures/mutvars.check b/tests/neg-custom-args/captures/mutvars.check index fb9136658f29..289b4e314519 100644 --- a/tests/neg-custom-args/captures/mutvars.check +++ b/tests/neg-custom-args/captures/mutvars.check @@ -11,13 +11,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:9:25 --------------------------------------- 9 | val self2: Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {any} is an exclusive capture set of the stateful type Ref[T]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the type of value self2 + | where: any is a root capability classified as Unscoped in the type of value self2 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:13:16 ----------------------------------------------------------- @@ -28,14 +28,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:14:31 -------------------------------------- 14 | val self4: () => Ref[T]^ = () => this // error | ^^^^^^^^^^ - | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} - | Required: () => Ref[T]^ + | Found: () ->{Ref.this.rd} Ref[T^'s1]^{Ref.this.rd} + | Required: () => Ref[T]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. + | Note that {any} is an exclusive capture set of the stateful type Ref[T]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref[T^'s1]^{Ref.this.rd}. | - | where: => refers to a root capability in the type of value self4 - | ^ and cap refer to a root capability classified as Unscoped in the type of value self4 + | where: => refers to a root capability in the type of value self4 + | any is a root capability classified as Unscoped in the type of value self4 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:18:16 ----------------------------------------------------------- @@ -46,13 +46,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:19:27 -------------------------------------- 19 | def self6(): Ref[T]^ = this // error // error separation | ^^^^ - | Found: Ref[T]^{Ref.this.rd} - | Required: Ref[T]^ + | Found: Ref[T]^{Ref.this.rd} + | Required: Ref[T]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref[T]^, - | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. + | Note that {any} is an exclusive capture set of the stateful type Ref[T]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref[T]^{Ref.this.rd}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the result type of method self6 + | where: any is a root capability classified as Unscoped in the result type of method self6 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:24:29 ----------------------------------------------------------- @@ -73,21 +73,21 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/mutvars.scala:41:29 -------------------------------------- 41 | val r5: () => Ref2[Int]^ = () => ref2 // error | ^^^^^^^^^^ - | Found: () ->{ref2.rd} Ref2[Int]^{ref2} - | Required: () => Ref2[Int]^ + | Found: () ->{ref2.rd} Ref2[Int]^{ref2} + | Required: () => Ref2[Int]^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref2[Int]^, - | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. + | Note that {any} is an exclusive capture set of the stateful type Ref2[Int]^{any}, + | it cannot subsume a read-only capture set of the stateful type Ref2[Int]^{ref2}. | - | where: => refers to a root capability in the type of value r5 - | ^ and cap refer to a root capability classified as Unscoped in the type of value r5 + | where: => refers to a root capability in the type of value r5 + | any is a root capability classified as Unscoped in the type of value r5 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/mutvars.scala:44:13 ----------------------------------------------------------- 44 | r6().x.fld = 33 // error | ^^^^^^^^^^^^^^^ - | Cannot assign to field fld of Ref[Int]^{cap.rd} - | since its capture set {cap.rd} is read-only. + | Cannot assign to field fld of Ref[Int]^{any.rd} + | since its capture set {any.rd} is read-only. -- Error: tests/neg-custom-args/captures/mutvars.scala:9:15 ------------------------------------------------------------ 9 | val self2: Ref[T]^ = this // error // error separation | ^^^^^^^ diff --git a/tests/neg-custom-args/captures/nested-classes-2.check b/tests/neg-custom-args/captures/nested-classes-2.check index 7337c8f6c8ab..91c4ab9e482c 100644 --- a/tests/neg-custom-args/captures/nested-classes-2.check +++ b/tests/neg-custom-args/captures/nested-classes-2.check @@ -4,8 +4,8 @@ | Found: cc1.C2{val y1: () ->{cc2*} Unit; val y2: (() => Unit) ->{cc2*} Unit}^{cc2} | Required: cc1.C2^{cc1, x1, x2} | - | Note that capability cc2 is not included in capture set {cc1, x1, x2}. + | Note that capability `cc2` is not included in capture set {cc1, x1, x2}. | - | where: => refers to the universal root capability + | where: => refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/nestedclass.check b/tests/neg-custom-args/captures/nestedclass.check index 89a94b89d8d9..9066b58370d2 100644 --- a/tests/neg-custom-args/captures/nestedclass.check +++ b/tests/neg-custom-args/captures/nestedclass.check @@ -4,6 +4,6 @@ | Found: (xs : C^{cap1}) | Required: C | - | Note that capability cap1 is not included in capture set {}. + | Note that capability `cap1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/nicolas1.check b/tests/neg-custom-args/captures/nicolas1.check index d44f681e219f..1529600778a7 100644 --- a/tests/neg-custom-args/captures/nicolas1.check +++ b/tests/neg-custom-args/captures/nicolas1.check @@ -4,9 +4,9 @@ | Found: (contextual$1: Rand^'s1) ?->{head, tail*} A^'s2 | Required: (Rand^) ?->{head} A | - | Note that capability tail* is not included in capture set {head}. + | Note that capability `tail*` is not included in capture set {head}. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any | 11 | all(nextInt(all.length)) | diff --git a/tests/neg-custom-args/captures/nicolas2.check b/tests/neg-custom-args/captures/nicolas2.check index 1b8d23c24bda..a07303636fd4 100644 --- a/tests/neg-custom-args/captures/nicolas2.check +++ b/tests/neg-custom-args/captures/nicolas2.check @@ -1,7 +1,7 @@ -- Warning: tests/neg-custom-args/captures/nicolas2.scala:9:53 --------------------------------------------------------- 9 |def oneOf[A](head: Rand ?=> A, tail: (Rand ?=> A)*): Rand ?->{head, tail*} A = | ^^^^^^^^^^^^^^^^^^^^^^^ - | Reach capability tail* in function result refers to parameter tail. + | Reach capability `tail*` in function result refers to parameter tail. | To avoid errors of the form "Local reach capability tail* leaks into capture scope ..." | you should replace the reach capability with a new capset variable in method oneOf. -- Error: tests/neg-custom-args/captures/nicolas2.scala:11:5 ----------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/non-local-consume.scala b/tests/neg-custom-args/captures/non-local-consume.scala index 81915a54246f..78cbe4871bc7 100644 --- a/tests/neg-custom-args/captures/non-local-consume.scala +++ b/tests/neg-custom-args/captures/non-local-consume.scala @@ -1,4 +1,4 @@ -import caps.{cap, Mutable} +import caps.{any, Mutable} import language.experimental.captureChecking class Buffer extends Mutable diff --git a/tests/neg-custom-args/captures/object-uses.check b/tests/neg-custom-args/captures/object-uses.check index 47f15f679e33..d68f41267182 100644 --- a/tests/neg-custom-args/captures/object-uses.check +++ b/tests/neg-custom-args/captures/object-uses.check @@ -1,7 +1,7 @@ -- Error: tests/neg-custom-args/captures/object-uses.scala:12:22 ------------------------------------------------------- 12 | Console.println(g.toString) // error | ^ - | reference (A.this.g : test.File^) is not included in the allowed capture set {A.this.f} + | reference `A.this.g` is not included in the allowed capture set {A.this.f} | of the enclosing object B in class A -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/object-uses.scala:15:18 ---------------------------------- 15 | val _: Object = b // error @@ -9,6 +9,6 @@ | Found: (A.this.b : A.this.B.type) | Required: Object | - | Note that capability A.this.f is not included in capture set {}. + | Note that capability `A.this.f` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/outer-var.check b/tests/neg-custom-args/captures/outer-var.check index 70a6c96d2f89..a377602e3b0e 100644 --- a/tests/neg-custom-args/captures/outer-var.check +++ b/tests/neg-custom-args/captures/outer-var.check @@ -4,7 +4,7 @@ | Found: (q : () => Unit) | Required: () ->{p, q²} Unit | - | Note that capability q is not included in capture set {p, q²}. + | Note that capability `q` is not included in capture set {p, q²}. | | where: => refers to a root capability in the type of parameter q | q is a parameter in method inner @@ -14,23 +14,23 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:13:9 ------------------------------------- 13 | x = (q: Proc) // error | ^^^^^^^ - | Found: () => Unit + | Found: () ->{any} Unit | Required: () ->{p, q} Unit | - | Note that capability cap is not included in capture set {p, q}. + | Note that capability `any` is not included in capture set {p, q}. | - | where: => and cap refer to a root capability created in method inner + | where: any is a root capability created in method inner | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:14:9 ------------------------------------- 14 | y = (q: Proc) // error | ^^^^^^^ - | Found: () => Unit + | Found: () ->{any} Unit | Required: () ->{p} Unit | - | Note that capability cap cannot be included in capture set {p} of variable y. + | Note that capability `any` cannot be included in capture set {p} of variable y. | - | where: => and cap refer to a root capability created in method inner + | where: any is a root capability created in method inner | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-var.scala:15:8 ------------------------------------- @@ -39,7 +39,7 @@ | Found: (q : () => Unit) | Required: () ->{p} Unit | - | Note that capability q cannot be included in capture set {p} of variable y. + | Note that capability `q` cannot be included in capture set {p} of variable y. | | where: => refers to a root capability in the type of parameter q | diff --git a/tests/neg-custom-args/captures/path-patmat-should-be-pos.scala b/tests/neg-custom-args/captures/path-patmat-should-be-pos.scala index 5f434a21cc8b..43a47da6e78f 100644 --- a/tests/neg-custom-args/captures/path-patmat-should-be-pos.scala +++ b/tests/neg-custom-args/captures/path-patmat-should-be-pos.scala @@ -1,8 +1,8 @@ -import caps.cap +import caps.any class It[A] -class Filter[A](val underlying: It[A]^, val p: A ->{cap, underlying} Boolean) extends It[A] +class Filter[A](val underlying: It[A]^, val p: A ->{any, underlying} Boolean) extends It[A] object Filter: def apply[A](underlying: It[A]^, p: A => Boolean): Filter[A]^{underlying, p} = underlying match diff --git a/tests/neg-custom-args/captures/paths-complex-consume.scala b/tests/neg-custom-args/captures/paths-complex-consume.scala index 9c1deb031387..057787e4aba7 100644 --- a/tests/neg-custom-args/captures/paths-complex-consume.scala +++ b/tests/neg-custom-args/captures/paths-complex-consume.scala @@ -1,6 +1,6 @@ import language.experimental.captureChecking import language.experimental.separationChecking -import caps.cap +import caps.any import scala.caps.Stateful // Create a deeper nesting structure diff --git a/tests/neg-custom-args/captures/paths-derivedcaps-consume.scala b/tests/neg-custom-args/captures/paths-derivedcaps-consume.scala index 9320fd6d932a..7edbc129d6fd 100644 --- a/tests/neg-custom-args/captures/paths-derivedcaps-consume.scala +++ b/tests/neg-custom-args/captures/paths-derivedcaps-consume.scala @@ -15,7 +15,7 @@ class A2(consume val b: B^) extends Stateful: update def bar() = b.foo() class A3(consume var b: B^) extends Stateful: update def bar() = b.foo() -class A4(consume val b: A2^{cap.only[Foo]}) extends Stateful: // FIXME needs to be classified as Foo, too +class A4(consume val b: A2^{any.only[Foo]}) extends Stateful: // FIXME needs to be classified as Foo, too update def bar() = b.b.foo() // Test: Access nested fields (suffix paths) after consume @@ -31,9 +31,9 @@ def testSuffixPaths = val b4: B^ = B(c) val a22 = A2(b4) //val a4 = A4(a22) // FIXME should work? - val b5: B^{cap.only[Foo]} = B(c) + val b5: B^{any.only[Foo]} = B(c) val a5 = A(b5) - val b6: B^{cap.only[Foo]} = B(c) + val b6: B^{any.only[Foo]} = B(c) val a222 = A2(b6) //val a6 = A4(a222) // FIXME should work? diff --git a/tests/neg-custom-args/captures/reaches.check b/tests/neg-custom-args/captures/reaches.check index 89ec6941cea0..629170370f05 100644 --- a/tests/neg-custom-args/captures/reaches.check +++ b/tests/neg-custom-args/captures/reaches.check @@ -1,123 +1,123 @@ --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:20:13 -------------------------------------- -20 | usingFile: f => // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:22:13 -------------------------------------- +22 | usingFile: f => // error | ^ |Found: (f: File^'s1) ->{cur} Unit |Required: File^ => Unit | - |Note that capability cap is not included in capture set {C}. + |Note that capability `any` is not included in capture set {C}. | |where: => refers to a root capability created in method runAll0 when checking argument to parameter f of method usingFile - | ^ refers to the universal root capability - | cap is a root capability created in anonymous function of type (f: File^'s1): Unit of parameter parameter f² of method $anonfun + | ^ refers to the root capability caps.any + | any is a root capability created in anonymous function of type (f: File^'s1): Unit of parameter parameter f² of method $anonfun | -21 | cur = (() => f.write()) :: Nil +23 | cur = (() => f.write()) :: Nil | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:30:13 -------------------------------------- -30 | usingFile: f => // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:32:13 -------------------------------------- +32 | usingFile: f => // error | ^ |Found: (f: File^'s2) ->{cur} Unit |Required: File^ => Unit | - |Note that capability cap cannot be included in capture set {C} of value cur. + |Note that capability `any` cannot be included in capture set {C} of value cur. | |where: => refers to a root capability created in method runAll1 when checking argument to parameter f of method usingFile - | ^ refers to the universal root capability - | cap is a root capability created in anonymous function of type (f: File^'s2): Unit of parameter parameter f² of method $anonfun + | ^ refers to the root capability caps.any + | any is a root capability created in anonymous function of type (f: File^'s2): Unit of parameter parameter f² of method $anonfun | -31 | cur.set: -32 | (() => f.write()) :: Nil +33 | cur.set: +34 | (() => f.write()) :: Nil | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:52:27 -------------------------------------- -52 | val id: Id[Proc, Proc] = new Id[Proc, () -> Unit] // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:54:27 -------------------------------------- +54 | val id: Id[Proc, Proc] = new Id[Proc, () -> Unit] // error | ^^^^^^^^^^^^^^^^^^^^^^^^ - | Found: Id[() => Unit, () -> Unit]^'s3 - | Required: Id[() =>² Unit, () =>³ Unit] + | Found: Id[() ->{any} Unit, () -> Unit]^'s3 + | Required: Id[() ->{any²} Unit, () => Unit] | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value id. + | Note that capability `any²` is not included in capture set {any} + | because any² is not visible from any in value id. | - | where: => and cap² refer to a root capability created in value id - | =>² and cap refer to the universal root capability - | =>³ refers to a root capability in the type of value id + | where: => refers to a root capability in the type of value id + | any is a root capability created in value id + | any² is the root capability caps.any | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:57:27 -------------------------------------- -57 | val id: File^ -> File^ = x => x // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:59:27 -------------------------------------- +59 | val id: File^ -> File^ = x => x // error | ^^^^^^ - | Found: (x: File^) ->'s4 File^² - | Required: File^ -> File^³ + | Found: (x: File^) ->'s4 File^{fresh} + | Required: File^ -> File^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value id. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value id. | - | where: ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: File^): File^² - | ^³ and cap² refer to a root capability in the type of value id + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value id + | fresh is a root capability associated with the result type of (x: File^): File^{fresh} | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:68:27 -------------------------------------- -68 | val f1: File^{id*} = id(f) // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:71:27 -------------------------------------- +71 | val f1: File^{id*} = id(f) // error | ^^^^^ - |Found: File^ + |Found: File^{any} |Required: File^{id*} | - |Note that capability cap is not included in capture set {id*}. + |Note that capability `any` is not included in capture set {id*}. | - |where: ^ and cap refer to a root capability created in value f1 when instantiating method apply's type (x: File^²): File^³ + |where: any is a root capability created in value f1 when instantiating method apply's type (x: File^): File^{fresh} | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:85:10 -------------------------------------- -85 | ps.map((x, y) => compose1(x, y)) // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:88:10 -------------------------------------- +88 | ps.map((x, y) => compose1(x, y)) // error | ^^^^^^^^^^^^^^^^^^^^^^^ |Found: (x$1: (A^ ->'s5 A^'s6, A^ ->'s7 A^'s8)^'s9) ->'s10 A^'s11 ->'s12 A^'s13 |Required: ((A ->{ps*} A, A ->{ps*} A)) => A^'s14 ->'s15 A^'s16 | - |Note that capability ps* cannot be included in capture set {} of value x. + |Note that capability `ps*` cannot be included in capture set {} of value x. | |where: => refers to a root capability created in method mapCompose when checking argument to parameter f of method map - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:88:10 -------------------------------------- -88 | ps.map((x, y) => compose1(x, y)) // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:91:10 -------------------------------------- +91 | ps.map((x, y) => compose1(x, y)) // error | ^^^^^^^^^^^^^^^^^^^^^^^ |Found: (x$1: (A^ ->'s17 A^'s18, A^ ->'s19 A^'s20)^'s21) ->'s22 A^'s23 ->'s24 A^'s25 |Required: ((A ->{C} A, A ->{C} A)) => A^'s26 ->'s27 A^'s28 | - |Note that capability C cannot be included in capture set {} of value x. + |Note that capability `C` cannot be included in capture set {} of value x. | |where: => refers to a root capability created in method mapCompose2 when checking argument to parameter f of method map - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` --- Error: tests/neg-custom-args/captures/reaches.scala:37:31 ----------------------------------------------------------- -37 | val next: () => Unit = cur.head // error, use +-- Error: tests/neg-custom-args/captures/reaches.scala:39:31 ----------------------------------------------------------- +39 | val next: () => Unit = cur.head // error, use | ^^^^^^^^ | Local reach capability xs* leaks into capture scope of method runAll2. | You could try to abstract the capabilities referred to by xs* in a capset variable. --- Error: tests/neg-custom-args/captures/reaches.scala:44:35 ----------------------------------------------------------- -44 | val next: () => Unit = cur.get.head // error // error +-- Error: tests/neg-custom-args/captures/reaches.scala:46:35 ----------------------------------------------------------- +46 | val next: () => Unit = cur.get.head // error // error | ^^^^^^^^^^^^ | Local reach capability xs* leaks into capture scope of method runAll3. | You could try to abstract the capabilities referred to by xs* in a capset variable. --- Error: tests/neg-custom-args/captures/reaches.scala:60:36 ----------------------------------------------------------- -60 | val leaked = usingFile[File^{id*}]: f => // error: separation +-- Error: tests/neg-custom-args/captures/reaches.scala:62:36 ----------------------------------------------------------- +62 | val leaked = usingFile[File^{id*}]: f => // error: separation | ^ - | Local cap created in type of parameter x leaks into capture scope of an enclosing function + | Local any created in type of parameter x leaks into capture scope of an enclosing function | - | where: cap is a root capability created in value id of parameter parameter x of method $anonfun + | where: any is a root capability created in value id of parameter parameter x of method $anonfun | -61 | val f1: File^{id*} = id(f) -62 | f1 --- Error: tests/neg-custom-args/captures/reaches.scala:42:9 ------------------------------------------------------------ -42 | val cur = Ref[List[Proc]](xs) // error +63 | val f1: File^{id*} = id(f) +64 | f1 +-- Error: tests/neg-custom-args/captures/reaches.scala:44:9 ------------------------------------------------------------ +44 | val cur = Ref[List[Proc]](xs) // error | ^ | Separation failure: value cur's inferred type Ref[List[() => Unit]^{}]^ hides parameter xs. | The parameter needs to be annotated with consume to allow this. --- Error: tests/neg-custom-args/captures/reaches.scala:44:17 ----------------------------------------------------------- -44 | val next: () => Unit = cur.get.head // error // error +-- Error: tests/neg-custom-args/captures/reaches.scala:46:17 ----------------------------------------------------------- +46 | val next: () => Unit = cur.get.head // error // error | ^^^^^^^^^^ | Separation failure: value next's type () => Unit hides parameter xs. | The parameter needs to be annotated with consume to allow this. diff --git a/tests/neg-custom-args/captures/reaches.scala b/tests/neg-custom-args/captures/reaches.scala index 77ba64fbbc60..c81dcaf24ced 100644 --- a/tests/neg-custom-args/captures/reaches.scala +++ b/tests/neg-custom-args/captures/reaches.scala @@ -1,3 +1,5 @@ +import caps.fresh + class File: def write(): Unit = ??? @@ -62,7 +64,8 @@ def attack2 = f1 def attack3 = - val id: (x: File^) -> File^ = x => x // was error, now OK + val id: (x: File^) -> File^{fresh} = x => x // was error, now OK + val id2: File^ -> File^{fresh} = x => x // now also OK val leaked = usingFile[File^{id*}]: f => val f1: File^{id*} = id(f) // error diff --git a/tests/neg-custom-args/captures/reaches2.check b/tests/neg-custom-args/captures/reaches2.check index 6d8acec2f565..d9de8595df39 100644 --- a/tests/neg-custom-args/captures/reaches2.check +++ b/tests/neg-custom-args/captures/reaches2.check @@ -4,6 +4,6 @@ | Found: (x$1: (A^'s1 ->{ps*} A^'s2, A^'s3 ->{ps*} A^'s4)^'s5) ->{ps*} A^'s6 ->{ps*} A^'s7 | Required: ((A ->{ps*} A, A ->{ps*} A)) -> A^'s6 ->{ps*} A^'s7 | - | Note that capability ps* is not included in capture set {}. + | Note that capability `ps*` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/read-only-use.check b/tests/neg-custom-args/captures/read-only-use.check index 9973009e796f..e2c6dcab6678 100644 --- a/tests/neg-custom-args/captures/read-only-use.check +++ b/tests/neg-custom-args/captures/read-only-use.check @@ -4,7 +4,7 @@ | Found: (f : () ->{r.rd} Int) | Required: () -> Int | - | Note that capability r.rd is not included in capture set {}. + | Note that capability `r.rd` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/read-only-use.scala:26:21 -------------------------------- @@ -13,7 +13,7 @@ | Found: (g : () ->{r2.x.rd} Int) | Required: () -> Int | - | Note that capability r2.x.rd is not included in capture set {}. + | Note that capability `r2.x.rd` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/read-only-use.scala:31:21 -------------------------------- @@ -22,6 +22,6 @@ | Found: (h : () ->{r3.xx.rd} Int) | Required: () -> Int | - | Note that capability r3.xx.rd is not included in capture set {}. + | Note that capability `r3.xx.rd` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/readOnly.check b/tests/neg-custom-args/captures/readOnly.check index dd6c60c474cd..f41a54bcf567 100644 --- a/tests/neg-custom-args/captures/readOnly.check +++ b/tests/neg-custom-args/captures/readOnly.check @@ -4,7 +4,7 @@ | Found: (getA : () ->{a.rd} Int) | Required: () -> Int | - | Note that capability a.rd is not included in capture set {}. + | Note that capability `a.rd` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/readOnly.scala:17:23 ------------------------------------- @@ -13,7 +13,7 @@ | Found: (putA : Int ->{a} Unit) | Required: Int -> Unit | - | Note that capability a is not included in capture set {}. + | Note that capability `a` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/readOnly.scala:20:23 ---------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/readOnly.scala b/tests/neg-custom-args/captures/readOnly.scala index 1c8a2bbc351e..d333721ad758 100644 --- a/tests/neg-custom-args/captures/readOnly.scala +++ b/tests/neg-custom-args/captures/readOnly.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref(init: Int) extends Mutable: private var current = init @@ -16,7 +16,7 @@ def Test(c: Object^) = val putA = (x: Int) => a.put(x) val _: Int -> Unit = putA // error - def setMax(x: Ref^{cap.rd}, y: Ref^{cap.rd}, z: Ref^{cap.rd}) = + def setMax(x: Ref^{any.rd}, y: Ref^{any.rd}, z: Ref^{any.rd}) = val doit = () => z.put(x.get max y.get) // error val _: () ->{x.rd, y.rd, z} Unit = doit doit() diff --git a/tests/neg-custom-args/captures/real-try.check b/tests/neg-custom-args/captures/real-try.check index bcc5b3db7e01..ec86afb24b03 100644 --- a/tests/neg-custom-args/captures/real-try.check +++ b/tests/neg-custom-args/captures/real-try.check @@ -8,7 +8,7 @@ 14 | try // error | ^ | The result of `try` cannot have type () => Unit since - | that type captures the root capability `cap`. + | that type captures the root capability `any`. | This is often caused by a locally generated exception capability leaking as part of its result. | | where: => refers to a root capability classified as Control in the type of given instance canThrow$1 @@ -19,7 +19,7 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/real-try.scala:21:4 -------------------------------------- 21 | () => foo(1) // error | ^^^^^^^^^^^^ - | Capability canThrow$2 defined in an enclosing try expression outlives its scope: + | Capability `canThrow$2` defined in an enclosing try expression outlives its scope: | it leaks into outer capture set 's1 of value x. | The leakage occurred when trying to match the following types: | @@ -30,7 +30,7 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/real-try.scala:27:4 -------------------------------------- 27 | () => Cell(foo(1)) // error | ^^^^^^^^^^^^^^^^^^ - | Capability canThrow$3 defined in an enclosing try expression outlives its scope: + | Capability `canThrow$3` defined in an enclosing try expression outlives its scope: | it leaks into outer capture set 's2 of value y. | The leakage occurred when trying to match the following types: | @@ -41,7 +41,7 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/real-try.scala:33:8 -------------------------------------- 33 | Cell(() => foo(1)) // error | ^^^^^^^^^^^^^^^^^^ - | Capability canThrow$4 defined in an enclosing try expression outlives its scope: + | Capability `canThrow$4` defined in an enclosing try expression outlives its scope: | it leaks into outer capture set 's5 of value b. | The leakage occurred when trying to match the following types: | diff --git a/tests/neg-custom-args/captures/ref-with-file.check b/tests/neg-custom-args/captures/ref-with-file.check index 7df3ab5e8e5f..52b265d8e661 100644 --- a/tests/neg-custom-args/captures/ref-with-file.check +++ b/tests/neg-custom-args/captures/ref-with-file.check @@ -4,12 +4,12 @@ |Found: (f: File^'s1) ->'s2 Ref[File^'s3]^ |Required: (f: File^²) => Ref[File^'s4]^'s5 | - |Note that capability cap cannot be included in capture set {} of value r. + |Note that capability `any` cannot be included in capture set {} of value r. | |where: => refers to a root capability created in method Test when checking argument to parameter op of method withFile | ^ refers to a root capability classified as Unscoped in the type of value r - | ^² refers to the universal root capability - | cap is a root capability created in anonymous function of type (f: File^'s1): Ref[File^'s3]^ of parameter parameter f² of method $anonfun + | ^² refers to the root capability caps.any + | any is a root capability created in anonymous function of type (f: File^'s1): Ref[File^'s3]^ of parameter parameter f² of method $anonfun | 19 | val r = Ref(f) 20 | r @@ -21,11 +21,11 @@ |Found: (f: File^'s6) ->'s7 (??? : -> Nothing) |Required: (f: File^) => Nothing | - |Note that capability cap cannot be included in capture set {} of value r. + |Note that capability `any` cannot be included in capture set {} of value r. | |where: => refers to a root capability created in method Test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability - | cap is a root capability created in anonymous function of type (f: File^'s6): (??? : -> Nothing) of parameter parameter f² of method $anonfun + | ^ refers to the root capability caps.any + | any is a root capability created in anonymous function of type (f: File^'s6): (??? : -> Nothing) of parameter parameter f² of method $anonfun | 22 | val r = Ref(f) 23 | ??? @@ -34,14 +34,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/ref-with-file.scala:25:18 -------------------------------- 25 | withFileAndRef: (f, r: Ref[String]^) => // error | ^ - |Capability cap outlives its scope: it leaks into outer capture set 's8 which is owned by method Test. + |Capability `any` outlives its scope: it leaks into outer capture set 's8 which is owned by method Test. |The leakage occurred when trying to match the following types: | - |Found: (f: File^'s9, r: Ref[String]^) ->'s10 Ref[String]^ - |Required: (f: File^, r: Ref[String]^) => Ref[String]^'s8 + |Found: (f: File^'s9, r: Ref[String]^{any}) ->'s10 Ref[String]^{any} + |Required: (f: File^{any}, r: Ref[String]^{any}) => Ref[String]^'s8 | - |where: => refers to a root capability created in method Test when checking argument to parameter op of method withFileAndRef - | ^ and cap refer to the universal root capability + |where: => refers to a root capability created in method Test when checking argument to parameter op of method withFileAndRef + | any is the root capability caps.any | 26 | r.put(f.read()) 27 | r diff --git a/tests/neg-custom-args/captures/reference-cc.check b/tests/neg-custom-args/captures/reference-cc.check index 37442a4641ce..9ba16fc96889 100644 --- a/tests/neg-custom-args/captures/reference-cc.check +++ b/tests/neg-custom-args/captures/reference-cc.check @@ -1,27 +1,27 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reference-cc.scala:44:29 --------------------------------- 44 | val later = usingLogFile { file => () => file.write(0) } // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |Capability file outlives its scope: it leaks into outer capture set 's1 which is owned by value later. + |Capability `file` outlives its scope: it leaks into outer capture set 's1 which is owned by value later. |The leakage occurred when trying to match the following types: | |Found: (file: java.io.FileOutputStream^'s2) ->'s3 () ->{file} Unit |Required: java.io.FileOutputStream^ => () ->'s1 Unit | |where: => refers to a root capability created in value later when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reference-cc.scala:47:25 --------------------------------- 47 | val xs = usingLogFile: f => // error | ^ - |Capability f outlives its scope: it leaks into outer capture set 's4 which is owned by value xs. + |Capability `f` outlives its scope: it leaks into outer capture set 's4 which is owned by value xs. |The leakage occurred when trying to match the following types: | |Found: (f: java.io.FileOutputStream^'s5) ->'s6 LzyList[Int]^{f} |Required: java.io.FileOutputStream^ => LzyList[Int]^'s4 | |where: => refers to a root capability created in value xs when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 48 | LzyList(1, 2, 3).map { x => f.write(x); x * x } | @@ -30,11 +30,11 @@ 58 | try () => xs.map(f).sum // error TODO improve error message | ^^^^^^^^^^^^^^^^^^^ |Found: () ->{canThrow$1} Double - |Required: () => Double + |Required: () ->{any} Double | - |Note that capability canThrow$1 is not included in capture set {cap} - |because (canThrow$1 : CanThrow[LimitExceeded]) in an enclosing try expression is not visible from cap in an enclosing function. + |Note that capability `canThrow$1` is not included in capture set {any} + |because (canThrow$1 : CanThrow[LimitExceeded]) in an enclosing try expression is not visible from any in method escaped. | - |where: => and cap refer to a root capability created in anonymous function of type (using erased x$1: CanThrow[LimitExceeded]): () => Double when instantiating expected result type () ->{cap²} Double of function literal + |where: any is a root capability in the result type of method escaped | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/restrict-subsumes.scala b/tests/neg-custom-args/captures/restrict-subsumes.scala index 71d4df5f06ba..6b06939c9c2d 100644 --- a/tests/neg-custom-args/captures/restrict-subsumes.scala +++ b/tests/neg-custom-args/captures/restrict-subsumes.scala @@ -1,4 +1,4 @@ -import caps.{cap, Classifier, SharedCapability} +import caps.{any, Classifier, SharedCapability} trait Read extends SharedCapability, Classifier trait Write extends SharedCapability, Classifier @@ -6,7 +6,7 @@ trait Write extends SharedCapability, Classifier trait A extends Read trait B extends Write -def weird(f: () ->{cap.only[Read]} Unit) = ??? +def weird(f: () ->{any.only[Read]} Unit) = ??? def test(x: A^, y: B^) = val g = () => println(x) diff --git a/tests/neg-custom-args/captures/ro-mut-conformance.check b/tests/neg-custom-args/captures/ro-mut-conformance.check index 3011ca7738d8..4a89a2eaef63 100644 --- a/tests/neg-custom-args/captures/ro-mut-conformance.check +++ b/tests/neg-custom-args/captures/ro-mut-conformance.check @@ -4,22 +4,22 @@ | Cannot call update method set of a | since its capture set {a} is read-only. -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:12:21 --------------------------- -12 | val t: Ref^{cap} = a // error // error separation +12 | val t: Ref^{any} = a // error // error separation | ^ - | Found: (a : Ref) - | Required: Ref^ + | Found: (a : Ref) + | Required: Ref^{any} | - | Note that {cap} is an exclusive capture set of the stateful type Ref^, - | it cannot subsume a read-only capture set of the stateful type (a : Ref). + | Note that {any} is an exclusive capture set of the stateful type Ref^{any}, + | it cannot subsume a read-only capture set of the stateful type (a : Ref). | - | Note that capability cap².rd is not included in capture set {cap}. + | Note that capability `any².rd` is not included in capture set {any}. | - | where: ^ and cap refer to a root capability classified as Unscoped in the type of value t - | cap² is a root capability classified as Unscoped in the type of parameter a + | where: any is a root capability classified as Unscoped in the type of value t + | any² is a root capability classified as Unscoped in the type of parameter a | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/ro-mut-conformance.scala:12:9 ------------------------------------------------- -12 | val t: Ref^{cap} = a // error // error separation +12 | val t: Ref^{any} = a // error // error separation | ^^^^^^^^^ | Separation failure: value t's type Ref^ hides parameter a. | The parameter needs to be annotated with consume to allow this. diff --git a/tests/neg-custom-args/captures/ro-mut-conformance.scala b/tests/neg-custom-args/captures/ro-mut-conformance.scala index 019deaf0165b..1fb19daa21aa 100644 --- a/tests/neg-custom-args/captures/ro-mut-conformance.scala +++ b/tests/neg-custom-args/captures/ro-mut-conformance.scala @@ -6,10 +6,10 @@ class Ref extends IRef, Mutable: private var _data: Int = 0 def get: Int = _data update def set(x: Int): Unit = _data = x -def test1(a: Ref^{cap.rd}): Unit = +def test1(a: Ref^{any.rd}): Unit = a.set(42) // error -def test2(a: Ref^{cap.rd}): Unit = - val t: Ref^{cap} = a // error // error separation - def b: Ref^{cap.rd} = ??? - val i: IRef^{cap} = b // ok, no added privilege from `cap` on an IRef +def test2(a: Ref^{any.rd}): Unit = + val t: Ref^{any} = a // error // error separation + def b: Ref^{any.rd} = ??? + val i: IRef^{any} = b // ok, no added privilege from `any` on an IRef t.set(42) \ No newline at end of file diff --git a/tests/neg-custom-args/captures/scope-extrude-mut.check b/tests/neg-custom-args/captures/scope-extrude-mut.check index d529a81f2d8e..a96b03cf343c 100644 --- a/tests/neg-custom-args/captures/scope-extrude-mut.check +++ b/tests/neg-custom-args/captures/scope-extrude-mut.check @@ -2,12 +2,12 @@ 10 | a = a1 // error | ^^ | Found: (a1 : A^) - | Required: A^² + | Required: A^{any} | - | Note that capability a1 is not included in capture set {cap} - | because (a1 : A^) in method b is not visible from cap in variable a. + | Note that capability `a1` is not included in capture set {any} + | because (a1 : A^) in method b is not visible from any in variable a. | - | where: ^ refers to a root capability in the type of value a1 - | ^² and cap refer to a root capability in the type of variable a + | where: ^ refers to a root capability in the type of value a1 + | any is a root capability in the type of variable a | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/scope-extrusions.check b/tests/neg-custom-args/captures/scope-extrusions.check index 11a7a4302163..548496938560 100644 --- a/tests/neg-custom-args/captures/scope-extrusions.check +++ b/tests/neg-custom-args/captures/scope-extrusions.check @@ -2,134 +2,134 @@ 10 | v = x // error | ^ | Found: (x : IO) - | Required: IO^ + | Required: IO^{any} | - | Note that capability x is not included in capture set {cap} - | because (x : IO) in method f1 is not visible from cap in variable v. + | Note that capability `x` is not included in capture set {any} + | because (x : IO) in method f1 is not visible from any in variable v. | - | where: ^ and cap refer to a root capability classified as SharedCapability in the type of variable v + | where: any is a root capability classified as SharedCapability in the type of variable v | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:11:8 ------------------------------ 11 | w = g // error | ^ | Found: () ->{x} Unit - | Required: () => Unit + | Required: () ->{any} Unit | - | Note that capability x is not included in capture set {cap} - | because (x : IO) in method f1 is not visible from cap in variable w. + | Note that capability `x` is not included in capture set {any} + | because (x : IO) in method f1 is not visible from any in variable w. | - | where: => and cap refer to a root capability in the type of variable w + | where: any is a root capability in the type of variable w | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:20:11 ----------------------------- 20 | withFile(io => io) // error | ^^^^^^^^ - |Capability io outlives its scope: it leaks into outer capture set 's1 which is owned by method test. + |Capability `io` outlives its scope: it leaks into outer capture set 's1 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (io: IO^'s2) ->'s3 IO^{io} |Required: IO^ => IO^'s1 | |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:21:11 ----------------------------- 21 | withFile(id) // error | ^^ - |Capability x outlives its scope: it leaks into outer capture set 's4 which is owned by method test. + |Capability `x` outlives its scope: it leaks into outer capture set 's4 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (x: IO^) ->'s5 IO^{x} |Required: IO^ => IO^'s4 | |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:22:11 ----------------------------- 22 | withFile(x => id(x)) // error | ^^^^^^^^^^ - |Capability x outlives its scope: it leaks into outer capture set 's6 which is owned by method test. + |Capability `x` outlives its scope: it leaks into outer capture set 's6 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (x: IO^'s7) ->'s8 IO^{x} |Required: IO^ => IO^'s6 | |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:23:11 ----------------------------- -23 | withFile(id2) // error, note mentions cap since we never have a more specific include failure +23 | withFile(id2) // error, note mentions any since we never have a more specific include failure | ^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's9 which is owned by method test. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's9 which is owned by method test. |The leakage occurred when trying to match the following types: | - |Found: (x: IO^) ->'s10 IO^² + |Found: (x: IO^) ->'s10 IO^{fresh²} |Required: IO^ => IO^'s9 | - |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability - | ^² refers to a root capability associated with the result type of (x: IO^): IO^² - | cap is a root capability associated with the result type of (x: IO^): IO^'s9 + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: IO^): IO^'s9 + | fresh² is a root capability associated with the result type of (x: IO^): IO^{fresh²} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:24:11 ----------------------------- -24 | withFile(x => id2(x)) // error, note mentions cap since we never have a more specific include failure +24 | withFile(x => id2(x)) // error, note mentions any since we never have a more specific include failure | ^^^^^^^^^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's11 which is owned by method test. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's11 which is owned by method test. |The leakage occurred when trying to match the following types: | - |Found: (x: IO^'s12) ->'s13 IO^ - |Required: IO^² => IO^'s11 + |Found: (x: IO^'s12) ->'s13 IO^{fresh²} + |Required: IO^ => IO^'s11 | - |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to a root capability associated with the result type of (x: IO^'s12): IO^ - | ^² refers to the universal root capability - | cap is a root capability associated with the result type of (x: IO^²): IO^'s11 + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: IO^): IO^'s11 + | fresh² is a root capability associated with the result type of (x: IO^'s12): IO^{fresh²} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:25:11 ----------------------------- -25 | withFile(identity) // error, note mentions cap since we never have a more specific include failure +25 | withFile(identity) // error, note mentions any since we never have a more specific include failure | ^^^^^^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's14 which is owned by method test. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's14 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (x: IO^'s15) ->'s16 IO^'s17 |Required: IO^ => IO^'s14 | - |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability - | cap is a root capability associated with the result type of (x: IO^): IO^'s14 + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: IO^): IO^'s14 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:26:11 ----------------------------- -26 | withFile(x => identity(x)) // error, note mentions cap since we never have a more specific include failure +26 | withFile(x => identity(x)) // error, note mentions any since we never have a more specific include failure | ^^^^^^^^^^^^^^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's18 which is owned by method test. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's18 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (x: IO^'s19) ->'s20 IO^'s21 |Required: IO^ => IO^'s18 | - |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability - | cap is a root capability associated with the result type of (x: IO^): IO^'s18 + |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: IO^): IO^'s18 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:28:12 ----------------------------- 28 | withFile: io => // error | ^ - |Capability io outlives its scope: it leaks into outer capture set 's22 which is owned by method test. + |Capability `io` outlives its scope: it leaks into outer capture set 's22 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (io: IO^'s23) ->'s24 () ->{io} Unit |Required: IO^ => () ->'s22 Unit | |where: => refers to a root capability created in method test when checking argument to parameter op of method withFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 29 | () => println(io) | @@ -137,28 +137,28 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:31:21 ----------------------------- 31 | val f2: IO => IO = (x: IO) => x // error | ^^^^^^^^^^^^ - | Found: (x: IO^) ->'s25 IO^{x} - | Required: IO^ => IO^² + | Found: (x: IO^) ->'s25 IO^{x} + | Required: IO^ => IO^{any} | - | Note that capability x is not included in capture set {cap} - | because (x : IO) is not visible from cap in value f2. + | Note that capability `x` is not included in capture set {any} + | because (x : IO) is not visible from any in value f2. | - | where: => refers to a root capability in the type of value f2 - | ^ refers to the universal root capability - | ^² and cap refer to a root capability classified as SharedCapability in the type of value f2 + | where: => refers to a root capability in the type of value f2 + | ^ refers to the root capability caps.any + | any is a root capability classified as SharedCapability in the type of value f2 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scope-extrusions.scala:33:21 ----------------------------- 33 | val f4: IO => IO = f3 // error | ^^ - | Found: (f3 : (x$0: IO) ->{} IO^{x$0}) - | Required: IO^ => IO^² + | Found: (f3 : (x$0: IO) ->{} IO^{x$0}) + | Required: IO^ => IO^{any} | - | Note that capability x$0 is not included in capture set {cap} - | because (x$0 : IO) is not visible from cap in value f4. + | Note that capability `x$0` is not included in capture set {any} + | because (x$0 : IO) is not visible from any in value f4. | - | where: => refers to a root capability in the type of value f4 - | ^ refers to the universal root capability - | ^² and cap refer to a root capability classified as SharedCapability in the type of value f4 + | where: => refers to a root capability in the type of value f4 + | ^ refers to the root capability caps.any + | any is a root capability classified as SharedCapability in the type of value f4 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/scope-extrusions.scala b/tests/neg-custom-args/captures/scope-extrusions.scala index 8ad3bb36d3a4..accd5cdc28a2 100644 --- a/tests/neg-custom-args/captures/scope-extrusions.scala +++ b/tests/neg-custom-args/captures/scope-extrusions.scala @@ -20,10 +20,10 @@ def test(io: IO): Unit = withFile(io => io) // error withFile(id) // error withFile(x => id(x)) // error - withFile(id2) // error, note mentions cap since we never have a more specific include failure - withFile(x => id2(x)) // error, note mentions cap since we never have a more specific include failure - withFile(identity) // error, note mentions cap since we never have a more specific include failure - withFile(x => identity(x)) // error, note mentions cap since we never have a more specific include failure + withFile(id2) // error, note mentions any since we never have a more specific include failure + withFile(x => id2(x)) // error, note mentions any since we never have a more specific include failure + withFile(identity) // error, note mentions any since we never have a more specific include failure + withFile(x => identity(x)) // error, note mentions any since we never have a more specific include failure withFile: io => // error () => println(io) diff --git a/tests/neg-custom-args/captures/scoped-caps-global.scala b/tests/neg-custom-args/captures/scoped-caps-global.scala index 6ff371f55656..6d5cb29b254c 100644 --- a/tests/neg-custom-args/captures/scoped-caps-global.scala +++ b/tests/neg-custom-args/captures/scoped-caps-global.scala @@ -1,30 +1,34 @@ +import caps.fresh class A class B class S extends caps.SharedCapability +import caps.fresh val io: Object^ = ??? -def test(): Unit = - val f: (x: A^) -> B^ = ??? +def test(io: Object^): Unit = + val f: (x: A^) -> B^{fresh} = ??? val g: A^ -> B^ = f // error - val _: (y: A^) -> B^ = f - val _: (x: A^) -> B^ = g // error + + val _: (y: A^) -> B^{fresh} = f + val _: (x: A^) -> B^{fresh} = g // error val _: A^ -> B^ = f // error val _: A^ -> B^ = g val _: A^ -> B^ = x => g(x) // error: g is no longer pure, since it contains the ^ of B - val _: (x: A^) -> B^ = x => f(x) // now OK, was error: existential in B cannot subsume `x` since `x` is not shared + val _: (x: A^) -> B^{fresh} = x => f(x) // now OK, was error: existential in B cannot subsume `x` since `x` is not shared val h: S -> B^ = ??? - val _: (x: S) -> B^ = h // error: direct conversion fails - val _: (x: S) -> B^ = (x: S) => h(x) // eta expansion is ok + val _: (x: S) -> B^{fresh} = h // error: direct conversion fails + val _: (x: S) -> B^{fresh} = (x: S) => h(x) // eta expansion is ok val h2: S -> S = ??? - val _: (x: S) -> S = h2 // direct conversion OK for shared S - val _: (x: S) -> S = (x: S) => h2(x) // eta conversion is also OK + val _: (x: S) -> S^{fresh} = h2 // direct conversion OK for shared S + val _: (x: S) -> S^{fresh} = (x: S) => h2(x) // eta conversion is also OK - val j: (x: S) -> B^ = ??? - val _: (x: S) -> B^ = j - val _: (x: S) -> B^ = x => j(x) + val j: (x: S) -> B^{fresh} = ??? + val _: (x: S) -> B^{fresh} = j + val _: (x: S) -> B^ = x => j(x) // error + val _: (x: S) -> B^{fresh} = x => j(x) // ok val _: S -> B^ = j // error val _: S -> B^ = x => j(x) // error diff --git a/tests/neg-custom-args/captures/scoped-caps.check b/tests/neg-custom-args/captures/scoped-caps.check index 87095fe2cbaa..a6cc56e24ac4 100644 --- a/tests/neg-custom-args/captures/scoped-caps.check +++ b/tests/neg-custom-args/captures/scoped-caps.check @@ -1,93 +1,111 @@ --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:7:20 ----------------------------------- -7 | val g: A^ -> B^ = f // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:8:20 ----------------------------------- +8 | val g: A^ -> B^ = f // error | ^ - | Found: (f : (x: A^) -> B^²) - | Required: A^ -> B^³ + | Found: (f : (x: A^) -> B^{fresh}) + | Required: A^ -> B^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value g. + | Note that capability `fresh²` is not included in capture set {any} + | because fresh² is not visible from any in value g. | - | where: ^ and cap refer to the universal root capability - | ^² refers to a root capability associated with the result type of (x: A^): B^² - | ^³ and cap² refer to a root capability in the type of value g + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value g + | fresh is a root capability associated with the result type of (x: A^): B^{fresh} + | fresh² is the root capability caps.fresh | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:9:25 ----------------------------------- -9 | val _: (x: A^) -> B^ = g // error - | ^ - | Found: A^ -> B^{g*} - | Required: (x: A^) -> B^² - | - | Note that capability g* is not included in capture set {cap}. - | - | where: ^ and cap refer to the universal root capability - | ^² refers to a root capability associated with the result type of (x: A^): B^² - | - | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:10:20 ---------------------------------- -10 | val _: A^ -> B^ = f // error - | ^ - | Found: (f : (x: A^) -> B^²) - | Required: A^ -> B^³ +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:11:32 ---------------------------------- +11 | val _: (x: A^) -> B^{fresh} = g // error + | ^ + | Found: A^ -> B^{g*} + | Required: (x: A^) -> B^{fresh} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value _$3. + | Note that capability `g*` is not included in capture set {fresh²}. | - | where: ^ and cap refer to the universal root capability - | ^² refers to a root capability associated with the result type of (x: A^): B^² - | ^³ and cap² refer to a root capability in the type of value _$3 + | where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: A^): B^{fresh} + | fresh² is the root capability caps.fresh | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:12:20 ---------------------------------- -12 | val _: A^ -> B^ = x => g(x) // error: g is no longer pure, since it contains the ^ of B +12 | val _: A^ -> B^ = f // error + | ^ + | Found: (f : (x: A^) -> B^{fresh}) + | Required: A^ -> B^{any} + | + | Note that capability `fresh²` is not included in capture set {any} + | because fresh² is not visible from any in value _$3. + | + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value _$3 + | fresh is a root capability associated with the result type of (x: A^): B^{fresh} + | fresh² is the root capability caps.fresh + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:15:20 ---------------------------------- +15 | val _: A^ -> B^ = x => g(x) // error: g is no longer pure, since it contains the ^ of B | ^^^^^^^^^ - | Found: (x: A^) ->'s1 B^² - | Required: A^ -> B^³ + | Found: (x: A^) ->'s1 B^{fresh} + | Required: A^ -> B^{any} + | + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value _$6. + | + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value _$6 + | fresh is a root capability associated with the result type of (x: A^): B^{fresh} + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:19:31 ---------------------------------- +19 | val _: (x: S) -> B^{fresh} = h // error: direct conversion fails + | ^ + | Found: S^ -> B^{h*} + | Required: (x: S^) -> B^{fresh} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value _$5. + | Note that capability `h*` is not included in capture set {fresh²}. | - | where: ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: A^): B^² - | ^³ and cap² refer to a root capability in the type of value _$5 + | where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: S^): B^{fresh} + | fresh² is the root capability caps.fresh | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:16:24 ---------------------------------- -16 | val _: (x: S) -> B^ = h // error: direct conversion fails - | ^ - | Found: S^ -> B^{h*} - | Required: (x: S^) -> B^² +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:28:30 ---------------------------------- +28 | val _: (x: S) -> B^ = x => j(x) // error + | ^^^^ + |Found: B^{any} + |Required: B^{any²} | - | Note that capability h* is not included in capture set {cap}. + |Note that capability `any` is not included in capture set {any²} + |because any in an enclosing function is not visible from any² in value _$13. | - | where: ^ and cap refer to the universal root capability - | ^² refers to a root capability associated with the result type of (x: S^): B^² + |where: any is a root capability created in anonymous function of type (x: S): B^ when instantiating method apply's type (x: S^): B^{fresh} + | any² is a root capability in the type of value _$13 | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:26:19 ---------------------------------- -26 | val _: S -> B^ = j // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:30:19 ---------------------------------- +30 | val _: S -> B^ = j // error | ^ - | Found: (j : (x: S) -> B^) - | Required: S^² -> B^³ + | Found: (j : (x: S) -> B^{fresh}) + | Required: S^ -> B^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value _$13. + | Note that capability `fresh²` is not included in capture set {any} + | because fresh² is not visible from any in value _$15. | - | where: ^ refers to a root capability associated with the result type of (x: S^²): B^ - | ^² and cap refer to the universal root capability - | ^³ and cap² refer to a root capability in the type of value _$13 + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value _$15 + | fresh is a root capability associated with the result type of (x: S^): B^{fresh} + | fresh² is the root capability caps.fresh | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:27:25 ---------------------------------- -27 | val _: S -> B^ = x => j(x) // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:31:25 ---------------------------------- +31 | val _: S -> B^ = x => j(x) // error | ^^^^ - |Found: B^ - |Required: B^² + |Found: B^{any} + |Required: B^{any²} | - |Note that capability cap is not included in capture set {cap²} - |because cap in an enclosing function is not visible from cap² in value _$14. + |Note that capability `any` is not included in capture set {any²} + |because any in an enclosing function is not visible from any² in value _$16. | - |where: ^ and cap refer to a root capability created in anonymous function of type (x: S): B^³ when instantiating method apply's type (x: S^³): B^⁴ - | ^² and cap² refer to a root capability in the type of value _$14 + |where: any is a root capability created in anonymous function of type (x: S): B^ when instantiating method apply's type (x: S^): B^{fresh} + | any² is a root capability in the type of value _$16 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/scoped-caps.scala b/tests/neg-custom-args/captures/scoped-caps.scala index 1f985040c2ca..c433e673ba18 100644 --- a/tests/neg-custom-args/captures/scoped-caps.scala +++ b/tests/neg-custom-args/captures/scoped-caps.scala @@ -1,28 +1,32 @@ class A class B class S extends caps.SharedCapability +import caps.fresh def test(io: Object^): Unit = - val f: (x: A^) -> B^ = ??? + val f: (x: A^) -> B^{fresh} = ??? val g: A^ -> B^ = f // error - val _: (y: A^) -> B^ = f - val _: (x: A^) -> B^ = g // error + + val _: (y: A^) -> B^{fresh} = f + val _: (x: A^) -> B^{fresh} = g // error val _: A^ -> B^ = f // error + val _: A^ -> B^{fresh} = f // ok val _: A^ -> B^ = g val _: A^ -> B^ = x => g(x) // error: g is no longer pure, since it contains the ^ of B - val _: (x: A^) -> B^ = x => f(x) // now OK, was error: existential in B cannot subsume `x` since `x` is not shared + val _: (x: A^) -> B^{fresh} = x => f(x) // now OK, was error: existential in B cannot subsume `x` since `x` is not shared val h: S -> B^ = ??? - val _: (x: S) -> B^ = h // error: direct conversion fails - val _: (x: S) -> B^ = (x: S) => h(x) // eta expansion is ok + val _: (x: S) -> B^{fresh} = h // error: direct conversion fails + val _: (x: S) -> B^{fresh} = (x: S) => h(x) // eta expansion is ok val h2: S -> S = ??? - val _: (x: S) -> S = h2 // direct conversion OK for shared S - val _: (x: S) -> S = (x: S) => h2(x) // eta conversion is also OK + val _: (x: S) -> S^{fresh} = h2 // direct conversion OK for shared S + val _: (x: S) -> S^{fresh} = (x: S) => h2(x) // eta conversion is also OK - val j: (x: S) -> B^ = ??? - val _: (x: S) -> B^ = j - val _: (x: S) -> B^ = x => j(x) + val j: (x: S) -> B^{fresh} = ??? + val _: (x: S) -> B^{fresh} = j + val _: (x: S) -> B^ = x => j(x) // error + val _: (x: S) -> B^{fresh} = x => j(x) // ok val _: S -> B^ = j // error val _: S -> B^ = x => j(x) // error diff --git a/tests/neg-custom-args/captures/scoped-caps2.check b/tests/neg-custom-args/captures/scoped-caps2.check index f7d6d762a23c..e32a72dc94de 100644 --- a/tests/neg-custom-args/captures/scoped-caps2.check +++ b/tests/neg-custom-args/captures/scoped-caps2.check @@ -1,69 +1,70 @@ --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:5:23 ---------------------------------- -5 | val _: (x: C) => C = b // error - | ^ - | Found: (b : C => C) - | Required: (x: C^) =>² C^² +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:6:31 ---------------------------------- +6 | val _: (x: C) => C^{fresh} = b // error + | ^ + | Found: (b : C ->{any} C) + | Required: (x: C^) ->{any²} C^{fresh} | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability `any` is not included in capture set {any²}. | - | where: => and cap refer to a root capability in the type of value b - | =>² and cap² refer to a root capability in the type of value _$1 - | ^ refers to the universal root capability - | ^² refers to a root capability associated with the result type of (x: C^): C^² + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value b + | any² is a root capability in the type of value _$1 + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:6:18 ---------------------------------- -6 | val _: C => C = a // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:7:18 ---------------------------------- +7 | val _: C => C = a // error | ^ - | Found: (a : (x: C) => C) - | Required: C^ =>² C^² + | Found: (a : (x: C) ->{any} C) + | Required: C^ ->{any²} C^² | - | Note that capability cap is not included in capture set {cap²}. + | Note that capability `any` is not included in capture set {any²}. | - | where: => and cap refer to a root capability in the type of value a - | =>² and cap² refer to a root capability in the type of value _$2 - | ^ refers to the universal root capability - | ^² refers to a root capability classified as SharedCapability in the type of value _$2 + | where: ^ refers to the root capability caps.any + | ^² refers to a root capability classified as SharedCapability in the type of value _$2 + | any is a root capability in the type of value a + | any² is a root capability in the type of value _$2 | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:8:18 ---------------------------------- -8 | val _: C => C = (x: C) => a(x) // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:9:18 ---------------------------------- +9 | val _: C => C = (x: C) => a(x) // error | ^^^^^^^^^^^^^^ - | Found: (x: C^) ->{a} C^² - | Required: C^ => C^³ + | Found: (x: C^) ->{a} C^{fresh} + | Required: C^ => C^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value _$4. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value _$4. | - | where: => refers to a root capability in the type of value _$4 - | ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: C^): C^² - | ^³ and cap² refer to a root capability classified as SharedCapability in the type of value _$4 + | where: => refers to a root capability in the type of value _$4 + | ^ refers to the root capability caps.any + | any is a root capability classified as SharedCapability in the type of value _$4 + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:14:18 --------------------------------- -14 | val _: C -> C = a // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:15:18 --------------------------------- +15 | val _: C -> C = a // error | ^ - | Found: (a : (x: C) -> C) - | Required: C^ -> C^² + | Found: (a : (x: C) -> C) + | Required: C^ -> C^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value _$6. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value _$6. | - | where: ^ and cap refer to the universal root capability - | ^² and cap² refer to a root capability classified as SharedCapability in the type of value _$6 + | where: ^ refers to the root capability caps.any + | any is a root capability classified as SharedCapability in the type of value _$6 + | fresh is the root capability caps.fresh | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:16:29 --------------------------------- -16 | val _: C -> C = (x: C) => a(x) // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:17:29 --------------------------------- +17 | val _: C -> C = (x: C) => a(x) // error | ^^^^ - |Found: C^ - |Required: C^² + |Found: C^{any} + |Required: C^{any²} | - |Note that capability cap is not included in capture set {cap²} - |because cap in an enclosing function is not visible from cap² in value _$8. + |Note that capability `any` is not included in capture set {any²} + |because any in an enclosing function is not visible from any² in value _$8. | - |where: ^ and cap refer to a root capability classified as SharedCapability created in anonymous function of type (x: C): C when instantiating method apply's type (x: C^³): C^⁴ - | ^² and cap² refer to a root capability classified as SharedCapability in the type of value _$8 + |where: any is a root capability classified as SharedCapability created in anonymous function of type (x: C): C when instantiating method apply's type (x: C^): C^{fresh} + | any² is a root capability classified as SharedCapability in the type of value _$8 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/scoped-caps2.scala b/tests/neg-custom-args/captures/scoped-caps2.scala index 751ad9bdc9c0..a33d814158fa 100644 --- a/tests/neg-custom-args/captures/scoped-caps2.scala +++ b/tests/neg-custom-args/captures/scoped-caps2.scala @@ -1,17 +1,18 @@ +import caps.fresh class C extends caps.SharedCapability def test1(c: C) = - val a: (x: C) => C = ??? + val a: (x: C) => C^{fresh} = ??? val b: C => C = ??? - val _: (x: C) => C = b // error + val _: (x: C) => C^{fresh} = b // error val _: C => C = a // error - val _: (x: C) => C = (x: C) => (b(x): C) // OK + val _: (x: C) => C^{fresh} = (x: C) => (b(x): C) // OK val _: C => C = (x: C) => a(x) // error def test2(c: C) = - val a: (x: C) -> C = ??? + val a: (x: C) -> C^{fresh} = ??? val b: C -> C = ??? - val _: (x: C) -> C = b // OK + val _: (x: C) -> C^{fresh} = b // OK val _: C -> C = a // error - val _: (x: C) -> C = (x: C) => b(x) // ok + val _: (x: C) -> C^{fresh} = (x: C) => b(x) // ok val _: C -> C = (x: C) => a(x) // error diff --git a/tests/neg-custom-args/captures/sep-box.scala b/tests/neg-custom-args/captures/sep-box.scala index 218505b8c2ca..9328a41b5a01 100644 --- a/tests/neg-custom-args/captures/sep-box.scala +++ b/tests/neg-custom-args/captures/sep-box.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any abstract class LIST[+T]: def isEmpty: Boolean diff --git a/tests/neg-custom-args/captures/sep-compose.check b/tests/neg-custom-args/captures/sep-compose.check index f95169c26f96..d1f8b6057c2d 100644 --- a/tests/neg-custom-args/captures/sep-compose.check +++ b/tests/neg-custom-args/captures/sep-compose.check @@ -2,7 +2,7 @@ 32 | seq3(f)(f) // error | ^ |Separation failure: argument of type (f : () ->{a} Unit) - |to method seq3: (x: () => Unit)(y: () ->{a, cap} Unit): Unit + |to method seq3: (x: () => Unit)(y: () ->{a, any} Unit): Unit |corresponds to capture-polymorphic formal parameter x of type () => Unit |and hides capabilities {f}. |Some of these overlap with the captures of the second argument with type (f : () ->{a} Unit). @@ -18,7 +18,7 @@ 33 | seq4(f)(f) // error | ^ |Separation failure: argument of type (f : () ->{a} Unit) - |to method seq4: (x: () ->{a, cap} Unit)(y: () => Unit): Unit + |to method seq4: (x: () ->{a, any} Unit)(y: () => Unit): Unit |corresponds to capture-polymorphic formal parameter y of type () => Unit |and hides capabilities {f}. |Some of these overlap with the captures of the first argument with type (f : () ->{a} Unit). @@ -50,7 +50,7 @@ 35 | seq6(f, f) // error | ^ |Separation failure: argument of type (f : () ->{a} Unit) - |to method seq6: (x: () => Unit, y: () ->{a, cap} Unit): Unit + |to method seq6: (x: () => Unit, y: () ->{a, any} Unit): Unit |corresponds to capture-polymorphic formal parameter x of type () => Unit |and hides capabilities {f}. |Some of these overlap with the captures of the second argument with type (f : () ->{a} Unit). @@ -66,7 +66,7 @@ 36 | seq7(f, f) // error | ^ |Separation failure: argument of type (f : () ->{a} Unit) - |to method seq7: (x: () ->{a, cap} Unit, y: () => Unit): Unit + |to method seq7: (x: () ->{a, any} Unit, y: () => Unit): Unit |corresponds to capture-polymorphic formal parameter y of type () => Unit |and hides capabilities {f}. |Some of these overlap with the captures of the first argument with type (f : () ->{a} Unit). diff --git a/tests/neg-custom-args/captures/sep-compose.scala b/tests/neg-custom-args/captures/sep-compose.scala index cfa3318b315f..3def4ed47219 100644 --- a/tests/neg-custom-args/captures/sep-compose.scala +++ b/tests/neg-custom-args/captures/sep-compose.scala @@ -1,26 +1,26 @@ -import caps.cap +import caps.any -def seq1(x: () => Unit, y: () ->{x, cap} Unit): Unit = +def seq1(x: () => Unit, y: () ->{x, any} Unit): Unit = x(); y() -def seq2(x: () => Unit)(y: () ->{x, cap} Unit): Unit = +def seq2(x: () => Unit)(y: () ->{x, any} Unit): Unit = x(); y() -def seq5(x: () ->{cap} Unit)(y: () => Unit): Unit = +def seq5(x: () ->{any} Unit)(y: () => Unit): Unit = x(); y() def test(io: Object^, a: Object^{io}): Unit = - def seq3(x: () => Unit)(y: () ->{a, cap} Unit): Unit = + def seq3(x: () => Unit)(y: () ->{a, any} Unit): Unit = x(); y() - def seq4(x: () ->{a, cap} Unit)(y: () => Unit): Unit = + def seq4(x: () ->{a, any} Unit)(y: () => Unit): Unit = x(); y() - def seq6(x: () => Unit, y: () ->{a, cap} Unit): Unit = + def seq6(x: () => Unit, y: () ->{a, any} Unit): Unit = x(); y() - def seq7(x: () ->{a, cap} Unit, y: () => Unit): Unit = + def seq7(x: () ->{a, any} Unit, y: () => Unit): Unit = x(); y() def seq8(x: () => Unit)(y: () ->{a} Unit): Unit = diff --git a/tests/neg-custom-args/captures/sep-consume.scala b/tests/neg-custom-args/captures/sep-consume.scala index 403106d0ba0d..3f99f9ca69dc 100644 --- a/tests/neg-custom-args/captures/sep-consume.scala +++ b/tests/neg-custom-args/captures/sep-consume.scala @@ -11,11 +11,11 @@ case class Pair[+A, +B](fst: A, snd: B) // require f and g to be non-interfering def par(f: () => Unit, g: () => Unit): Unit = ??? -def bad(consume op: () ->{cap.rd} Unit): () => Unit = op +def bad(consume op: () ->{any.rd} Unit): () => Unit = op def test2(consume x: Ref^): Unit = val f: () ->{x.rd} Unit = () => x.get - val rx: () => Unit = bad(f) // hides x.rd in the resulting `cap` + val rx: () => Unit = bad(f) // hides x.rd in the resulting `any` x.put(42) // error x.get // ok rd/rd par(rx, () => x.put(42)) // error diff --git a/tests/neg-custom-args/captures/sep-counter.check b/tests/neg-custom-args/captures/sep-counter.check index ecd5063e21dc..d67e0a2e9569 100644 --- a/tests/neg-custom-args/captures/sep-counter.check +++ b/tests/neg-custom-args/captures/sep-counter.check @@ -2,11 +2,11 @@ 12 | def mkCounter(): Pair[Ref^, Ref^] = // error | ^^^^^^^^^^^^^^^^ | Separation failure in method mkCounter's result type Pair[Ref^, Ref^²]. - | One part, Ref^, hides capabilities {c, cap, cap²}. + | One part, Ref^, hides capabilities {c, any, any²}. | Another part, Ref^², captures capabilities {c}. | The two sets overlap at {c}. | | where: ^ refers to a root capability classified as Unscoped in the result type of method mkCounter | ^² refers to a root capability classified as Unscoped in the result type of method mkCounter - | cap is a root capability classified as Unscoped in the type of value c - | cap² is a root capability classified as Unscoped created in value c when constructing instance Ref + | any is a root capability classified as Unscoped in the type of value c + | any² is a root capability classified as Unscoped created in value c when constructing instance Ref diff --git a/tests/neg-custom-args/captures/sep-counter.scala b/tests/neg-custom-args/captures/sep-counter.scala index a2df6cd0e62d..5547ac46ee3f 100644 --- a/tests/neg-custom-args/captures/sep-counter.scala +++ b/tests/neg-custom-args/captures/sep-counter.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref extends Mutable: var x = 0 diff --git a/tests/neg-custom-args/captures/sep-curried-par.check b/tests/neg-custom-args/captures/sep-curried-par.check index b9b2603cb6e6..7cbcf6e8ee6f 100644 --- a/tests/neg-custom-args/captures/sep-curried-par.check +++ b/tests/neg-custom-args/captures/sep-curried-par.check @@ -1,14 +1,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/sep-curried-par.scala:23:32 ------------------------------ -23 | val bar = (p1: () => Unit) => (p2: () ->{p1, cap} Unit) => par(p1, p2) // error, but error message could be better +23 | val bar = (p1: () => Unit) => (p2: () ->{p1, any} Unit) => par(p1, p2) // error, but error message could be better | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | Capability p1 defined in an enclosing function outlives its scope: + | Capability `p1` defined in an enclosing function outlives its scope: | it leaks into outer capture set 's1 which is owned by value bar. | The leakage occurred when trying to match the following types: | - | Found: (p2: () ->{p1, cap} Unit) ->{p1} Unit + | Found: (p2: () ->{p1, any} Unit) ->{p1} Unit | Required: (() ->'s2 Unit) ->'s1 Unit | - | where: cap is the universal root capability + | where: any is the root capability caps.any | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/sep-curried-par.scala:6:48 ---------------------------------------------------- diff --git a/tests/neg-custom-args/captures/sep-curried-par.scala b/tests/neg-custom-args/captures/sep-curried-par.scala index a1f4e54ac1a0..6004e7c613a9 100644 --- a/tests/neg-custom-args/captures/sep-curried-par.scala +++ b/tests/neg-custom-args/captures/sep-curried-par.scala @@ -1,7 +1,7 @@ -import caps.cap +import caps.any def par(p1: () => Unit, p2: () => Unit) = () -def seq(p1: () => Unit, p2: () ->{cap, p1} Unit) = () +def seq(p1: () => Unit, p2: () ->{any, p1} Unit) = () def parCurriedBad(p1: () => Unit): (() => Unit) => Unit = // error: consume failure (p2: () => Unit) => par(p1, p2) @@ -17,10 +17,10 @@ def test(c: () => Unit) = parCurriedBad(p)(p) // ok, but parCurriedBad ill-typed parCurried(p)(p) // error: consume failure - val foo = (p1: () => Unit) => (p2: () ->{c, cap} Unit) => par(p1, p2) + val foo = (p1: () => Unit) => (p2: () ->{c, any} Unit) => par(p1, p2) foo(c)(c) // error: separation - val bar = (p1: () => Unit) => (p2: () ->{p1, cap} Unit) => par(p1, p2) // error, but error message could be better + val bar = (p1: () => Unit) => (p2: () ->{p1, any} Unit) => par(p1, p2) // error, but error message could be better bar(c)(c) diff --git a/tests/neg-custom-args/captures/sep-curried.check b/tests/neg-custom-args/captures/sep-curried.check index 06fd4cef0ad0..e59c7438c75a 100644 --- a/tests/neg-custom-args/captures/sep-curried.check +++ b/tests/neg-custom-args/captures/sep-curried.check @@ -1,12 +1,12 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/sep-curried.scala:48:43 ---------------------------------- 48 | val f: (y: Ref[Int]^{a}) ->{a} Unit = foo(a) // error | ^^^^^^ - | Found: (y: Ref[Int]^) ->{a} Unit + | Found: (y: Ref[Int]^{any}) ->{a} Unit | Required: (y: Ref[Int]^{a}) ->{a} Unit | - | Note that capability a is not included in capture set {cap}. + | Note that capability `a` is not included in capture set {any}. | - | where: ^ and cap refer to the universal root capability + | where: any is the root capability caps.any | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/sep-curried.scala:16:6 -------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/sep-list.scala b/tests/neg-custom-args/captures/sep-list.scala index b5c379a1e3c7..4c6187ff74fc 100644 --- a/tests/neg-custom-args/captures/sep-list.scala +++ b/tests/neg-custom-args/captures/sep-list.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any abstract class LIST[+T]: def isEmpty: Boolean diff --git a/tests/neg-custom-args/captures/sep-pairs-2.scala b/tests/neg-custom-args/captures/sep-pairs-2.scala index ca166c95bb76..3fb8d422c6a2 100644 --- a/tests/neg-custom-args/captures/sep-pairs-2.scala +++ b/tests/neg-custom-args/captures/sep-pairs-2.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref extends Mutable: var x = 0 diff --git a/tests/neg-custom-args/captures/sep-pairs-global.scala b/tests/neg-custom-args/captures/sep-pairs-global.scala index 48c6aaf72918..81545e92dc91 100644 --- a/tests/neg-custom-args/captures/sep-pairs-global.scala +++ b/tests/neg-custom-args/captures/sep-pairs-global.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref extends Mutable: var x = 0 diff --git a/tests/neg-custom-args/captures/sep-pairs-unboxed.check b/tests/neg-custom-args/captures/sep-pairs-unboxed.check index fc007e05260b..aeabb4192707 100644 --- a/tests/neg-custom-args/captures/sep-pairs-unboxed.check +++ b/tests/neg-custom-args/captures/sep-pairs-unboxed.check @@ -45,7 +45,7 @@ | Hidden footprint of current argument : {two.fst} | Capture set of second argument : {two*} | Footprint set of second argument : {two*} - | The two sets overlap at : {cap of a new instance of class Pair} + | The two sets overlap at : {`any` of a new instance of class Pair} | |where: ^ refers to a root capability classified as Unscoped in the type of value fst | ^² refers to a root capability classified as Unscoped created in value twisted when checking argument to parameter fst of constructor PairPair @@ -53,7 +53,7 @@ 47 | val twisted = swapped(two, two.snd) // error | ^^^^^^^ |Separation failure: argument of type (two.snd : Ref^) - |to method swapped: (@consume x: Pair^, @consume y: Ref^): PairPair^ + |to method swapped: (@consume x: Pair^, @consume y: Ref^): PairPair^{fresh} |corresponds to capture-polymorphic formal parameter y of type Ref^² |and hides capabilities {two.snd}. |Some of these overlap with the captures of the first argument with type (two : Pair{val fst: Ref^; val snd: Ref^}^). @@ -62,7 +62,7 @@ | Hidden footprint of current argument : {two.snd} | Capture set of first argument : {two*} | Footprint set of first argument : {two*} - | The two sets overlap at : {cap of a new instance of class Pair} + | The two sets overlap at : {`any` of a new instance of class Pair} | |where: ^ refers to a root capability classified as Unscoped in the type of value snd | ^² refers to a root capability classified as Unscoped created in value twisted when checking argument to parameter y of method swapped diff --git a/tests/neg-custom-args/captures/sep-pairs-unboxed.scala b/tests/neg-custom-args/captures/sep-pairs-unboxed.scala index 22b8bf9e1d19..45e293429fe9 100644 --- a/tests/neg-custom-args/captures/sep-pairs-unboxed.scala +++ b/tests/neg-custom-args/captures/sep-pairs-unboxed.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref extends Mutable: var x = 0 diff --git a/tests/neg-custom-args/captures/sep-pairs.check b/tests/neg-custom-args/captures/sep-pairs.check index 2af59556d78f..60bce844d759 100644 --- a/tests/neg-custom-args/captures/sep-pairs.check +++ b/tests/neg-custom-args/captures/sep-pairs.check @@ -12,21 +12,21 @@ 13 |def bad: Pair[Ref^, Ref^] = // error: overlap at r1*, r0 | ^^^^^^^^^^^^^^^^ | Separation failure in method bad's result type Pair[Ref^, Ref^²]. - | One part, Ref^, hides capabilities {r1*, cap, cap², r0}. + | One part, Ref^, hides capabilities {r1*, any, any², r0}. | Another part, Ref^², captures capabilities {r1*, r0}. | The two sets overlap at {r1*, r0}. | | where: ^ refers to a root capability classified as Unscoped in the result type of method bad | ^² refers to a root capability classified as Unscoped in the result type of method bad - | cap is a root capability classified as Unscoped in the type of value r1 - | cap² is a root capability classified as Unscoped in the type of value r1 + | any is a root capability classified as Unscoped in the type of value r1 + | any² is a root capability classified as Unscoped in the type of value r1 -- Error: tests/neg-custom-args/captures/sep-pairs.scala:43:18 --------------------------------------------------------- 43 | val sameToPair: Pair[Ref^, Ref^] = Pair(fstSame, sndSame) // error | ^^^^^^^^^^^^^^^^ | Separation failure in value sameToPair's type Pair[Ref^, Ref^²]. | One part, Ref^, hides capabilities {fstSame}. | Another part, Ref^², captures capabilities {sndSame, same.snd*}. - | The two sets overlap at {cap of value same}. + | The two sets overlap at {`any` of value same}. | | where: ^ refers to a root capability classified as Unscoped in the type of value sameToPair | ^² refers to a root capability classified as Unscoped in the type of value sameToPair diff --git a/tests/neg-custom-args/captures/sep-pairs.scala b/tests/neg-custom-args/captures/sep-pairs.scala index 0a8635f3ea63..4cf029492b47 100644 --- a/tests/neg-custom-args/captures/sep-pairs.scala +++ b/tests/neg-custom-args/captures/sep-pairs.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref extends Mutable: var x = 0 diff --git a/tests/neg-custom-args/captures/sep-use.scala b/tests/neg-custom-args/captures/sep-use.scala index ec661b15fedc..7a902df266be 100644 --- a/tests/neg-custom-args/captures/sep-use.scala +++ b/tests/neg-custom-args/captures/sep-use.scala @@ -1,4 +1,4 @@ -import caps.cap +import caps.any def test1(consume io: Object^): Unit = diff --git a/tests/neg-custom-args/captures/sep-use2.check b/tests/neg-custom-args/captures/sep-use2.check index 30063f1f5110..528f29115a0d 100644 --- a/tests/neg-custom-args/captures/sep-use2.check +++ b/tests/neg-custom-args/captures/sep-use2.check @@ -1,49 +1,49 @@ --- Error: tests/neg-custom-args/captures/sep-use2.scala:5:10 ----------------------------------------------------------- -5 | def cc: Object^ = c // error +-- Error: tests/neg-custom-args/captures/sep-use2.scala:4:10 ----------------------------------------------------------- +4 | def cc: Object^ = c // error | ^^^^^^^ | Separation failure: method cc's result type Object^ hides non-local parameter c --- Error: tests/neg-custom-args/captures/sep-use2.scala:13:8 ----------------------------------------------------------- -13 | { f(c) } // error +-- Error: tests/neg-custom-args/captures/sep-use2.scala:12:8 ----------------------------------------------------------- +12 | { f(c) } // error | ^ | Separation failure: Illegal access to {c} which is hidden by the previous definition | of method cc with result type Object^. | This type hides capabilities {c} | | where: ^ refers to a root capability in the result type of method cc --- Error: tests/neg-custom-args/captures/sep-use2.scala:16:10 ---------------------------------------------------------- -16 | def cc: Object^ = c // error +-- Error: tests/neg-custom-args/captures/sep-use2.scala:15:10 ---------------------------------------------------------- +15 | def cc: Object^ = c // error | ^^^^^^^ | Separation failure: method cc's result type Object^ hides non-local parameter c --- Error: tests/neg-custom-args/captures/sep-use2.scala:18:6 ----------------------------------------------------------- -18 | { f(cc) } // error +-- Error: tests/neg-custom-args/captures/sep-use2.scala:17:6 ----------------------------------------------------------- +17 | { f(cc) } // error | ^ | Separation failure: Illegal access to {c} which is hidden by the previous definition | of method cc with result type Object^. | This type hides capabilities {c} | | where: ^ refers to a root capability in the result type of method cc --- Error: tests/neg-custom-args/captures/sep-use2.scala:20:6 ----------------------------------------------------------- -20 | { f(c) } // error // error +-- Error: tests/neg-custom-args/captures/sep-use2.scala:19:6 ----------------------------------------------------------- +19 | { f(c) } // error // error | ^ | Separation failure: Illegal access to {c} which is hidden by the previous definition | of method cc with result type Object^. | This type hides capabilities {c} | | where: ^ refers to a root capability in the result type of method cc --- Error: tests/neg-custom-args/captures/sep-use2.scala:20:8 ----------------------------------------------------------- -20 | { f(c) } // error // error +-- Error: tests/neg-custom-args/captures/sep-use2.scala:19:8 ----------------------------------------------------------- +19 | { f(c) } // error // error | ^ | Separation failure: Illegal access to {c} which is hidden by the previous definition | of method cc with result type Object^. | This type hides capabilities {c} | | where: ^ refers to a root capability in the result type of method cc --- Error: tests/neg-custom-args/captures/sep-use2.scala:24:8 ----------------------------------------------------------- -24 | { f(c) } // error +-- Error: tests/neg-custom-args/captures/sep-use2.scala:23:8 ----------------------------------------------------------- +23 | { f(c) } // error | ^ |Separation failure: argument of type (c : Object^) - |to a function of type Object^ ->{f} Object^{f*} - |corresponds to capture-polymorphic formal parameter v1 of type Object^² + |to a function of type Object^ ->{c} Object^{fresh} + |corresponds to capture-polymorphic formal parameter x$0 of type Object^² |and hides capabilities {c}. |Some of these overlap with the captures of the function prefix. | @@ -54,18 +54,13 @@ | The two sets overlap at : {c} | |where: ^ refers to a root capability in the type of parameter c - | ^² refers to a root capability created in value x4 when checking argument to parameter v1 of method apply --- Error: tests/neg-custom-args/captures/sep-use2.scala:23:10 ---------------------------------------------------------- -23 | val x4: Object^ = // error: ^ hides f*, needs consume - | ^^^^^^^ - | Separation failure: value x4's type Object^ hides parameter f. - | The parameter needs to be annotated with consume to allow this. --- Error: tests/neg-custom-args/captures/sep-use2.scala:28:8 ----------------------------------------------------------- -28 | { f(c) } // error + | ^² refers to a root capability created in value x4 when checking argument to parameter x$0 of method apply +-- Error: tests/neg-custom-args/captures/sep-use2.scala:27:8 ----------------------------------------------------------- +27 | { f(c) } // error | ^ |Separation failure: argument of type (c : Object^) - |to a function of type Object^ ->{f} Object^{f*} - |corresponds to capture-polymorphic formal parameter v1 of type Object^² + |to a function of type Object^ ->{c} Object^{fresh} + |corresponds to capture-polymorphic formal parameter x$0 of type Object^² |and hides capabilities {c}. |Some of these overlap with the captures of the function prefix. | @@ -76,9 +71,4 @@ | The two sets overlap at : {c} | |where: ^ refers to a root capability in the type of parameter c - | ^² refers to a root capability created in value x4 when checking argument to parameter v1 of method apply --- Error: tests/neg-custom-args/captures/sep-use2.scala:27:10 ---------------------------------------------------------- -27 | val x4: Object^ = // error: ^ hides f* which refers to c, so c needs consume - | ^^^^^^^ - | Separation failure: value x4's type Object^ hides parameter c. - | The parameter needs to be annotated with consume to allow this. + | ^² refers to a root capability created in value x4 when checking argument to parameter x$0 of method apply diff --git a/tests/neg-custom-args/captures/sep-use2.scala b/tests/neg-custom-args/captures/sep-use2.scala index 6cc80b899d87..e4c3a48bcd69 100644 --- a/tests/neg-custom-args/captures/sep-use2.scala +++ b/tests/neg-custom-args/captures/sep-use2.scala @@ -1,7 +1,6 @@ +import caps.fresh - - -def test1(consume c: Object^, f: (x: Object^) => Object^) = +def test1(consume c: Object^, f: (x: Object^) => Object^{fresh}) = def cc: Object^ = c // error val x1 = { f(cc) } // ok @@ -12,19 +11,19 @@ def test1(consume c: Object^, f: (x: Object^) => Object^) = val x4: Object^ = { f(c) } // error -def test2(consume c: Object^, f: (x: Object^) ->{c} Object^) = +def test2(consume c: Object^, f: (x: Object^) ->{c} Object^{fresh}) = def cc: Object^ = c // error val x1 = { f(cc) } // error val x4: Object^ = // ^ hides just c, since the Object^ in the result of `f` is existential { f(c) } // error // error -def test3(consume c: Object^, f: Object^ ->{c} Object^) = - val x4: Object^ = // error: ^ hides f*, needs consume +def test3(consume c: Object^, f: Object^ ->{c} Object^{fresh}) = + val x4: Object^ = // was error: ^ hides f*, needs consume, now OK once we use fresh { f(c) } // error -def test4(c: Object^, consume f: Object^ ->{c} Object^) = - val x4: Object^ = // error: ^ hides f* which refers to c, so c needs consume +def test4(c: Object^, consume f: Object^ ->{c} Object^{fresh}) = + val x4: Object^ = // was error: ^ hides f* which refers to c, so c needs consume, now OK now OK once we use fresh { f(c) } // error diff --git a/tests/neg-custom-args/captures/sepchecks.scala b/tests/neg-custom-args/captures/sepchecks.scala index f84c80da9c54..57f01c88d48d 100644 --- a/tests/neg-custom-args/captures/sepchecks.scala +++ b/tests/neg-custom-args/captures/sepchecks.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any trait Rdr[T]: @@ -21,12 +21,12 @@ def Test(c: Object^): Unit = val putA = (x: Int) => a.put(x) val _: Int ->{a} Unit = putA - def setMax(x: Ref[Int]^{cap.rd}, y: Ref[Int]^{cap.rd}, z: Ref[Int]^{cap}) = + def setMax(x: Ref[Int]^{any.rd}, y: Ref[Int]^{any.rd}, z: Ref[Int]^{any}) = val doit = () => z.put(x.get max y.get) val _: () ->{x.rd, y.rd, z} Unit = doit doit() - def setMax2(x: Rdr[Int]^{cap.rd}, y: Rdr[Int]^{cap.rd}, z: Ref[Int]^{cap}) = ??? + def setMax2(x: Rdr[Int]^{any.rd}, y: Rdr[Int]^{any.rd}, z: Ref[Int]^{any}) = ??? setMax2(aa, aa, b) setMax2(a, aa, b) @@ -41,7 +41,7 @@ def Test(c: Object^): Unit = def apply(i: Int, j: Int): Double = arr(i)(j) update def update(i: Int, j: Int, x: Double): Unit = arr(i)(j) = x - def mul(x: IMatrix^{cap.rd}, y: IMatrix^{cap.rd}, z: Matrix^): Matrix^ = ??? + def mul(x: IMatrix^{any.rd}, y: IMatrix^{any.rd}, z: Matrix^): Matrix^ = ??? val m1 = Matrix(10, 10) val m2 = Matrix(10, 10) diff --git a/tests/neg-custom-args/captures/sepchecks4.scala b/tests/neg-custom-args/captures/sepchecks4.scala index 285c5405e215..b829e0d9bff8 100644 --- a/tests/neg-custom-args/captures/sepchecks4.scala +++ b/tests/neg-custom-args/captures/sepchecks4.scala @@ -1,4 +1,4 @@ -import caps.cap +import caps.any import language.future import language.experimental.captureChecking diff --git a/tests/neg-custom-args/captures/sepchecks5.scala b/tests/neg-custom-args/captures/sepchecks5.scala index 82b7f17108f0..3cc4a60280c0 100644 --- a/tests/neg-custom-args/captures/sepchecks5.scala +++ b/tests/neg-custom-args/captures/sepchecks5.scala @@ -1,4 +1,4 @@ -import caps.cap +import caps.any import language.future import language.experimental.captureChecking diff --git a/tests/neg-custom-args/captures/simple-using.check b/tests/neg-custom-args/captures/simple-using.check index 05179ef80418..6a73c826aed2 100644 --- a/tests/neg-custom-args/captures/simple-using.check +++ b/tests/neg-custom-args/captures/simple-using.check @@ -1,13 +1,13 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/simple-using.scala:8:17 ---------------------------------- 8 | usingLogFile { f => () => f.write(2) } // error | ^^^^^^^^^^^^^^^^^^^^^ - |Capability f outlives its scope: it leaks into outer capture set 's1 which is owned by method test. + |Capability `f` outlives its scope: it leaks into outer capture set 's1 which is owned by method test. |The leakage occurred when trying to match the following types: | |Found: (f: java.io.FileOutputStream^'s2) ->'s3 () ->{f} Unit |Required: java.io.FileOutputStream^ => () ->'s1 Unit | |where: => refers to a root capability created in method test when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/stack-alloc.scala b/tests/neg-custom-args/captures/stack-alloc.scala index f1e9465fd975..fc4686f142d7 100644 --- a/tests/neg-custom-args/captures/stack-alloc.scala +++ b/tests/neg-custom-args/captures/stack-alloc.scala @@ -10,7 +10,7 @@ class Test extends caps.Stateful: if nextFree >= stack.size then stack.append(new Pooled) val pooled = stack(nextFree) nextFree = nextFree + 1 - val ret = op(using caps.cap)(pooled) + val ret = op(using caps.any)(pooled) nextFree = nextFree - 1 ret diff --git a/tests/neg-custom-args/captures/try.check b/tests/neg-custom-args/captures/try.check index 14a07b055ddc..605f6e2c38c2 100644 --- a/tests/neg-custom-args/captures/try.check +++ b/tests/neg-custom-args/captures/try.check @@ -2,14 +2,14 @@ 24 | (x: CanThrow[Exception]) => x // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |Found: (x: CT[Exception]^) ->'s1 CT[Exception]^{x} - |Required: CT[Exception]^ => CT[Exception]^² + |Required: CT[Exception]^ => CT[Exception]^{any} | - |Note that capability x is not included in capture set {cap} - |because (x : CT[Exception]^) is not visible from cap in value a. + |Note that capability `x` is not included in capture set {any} + |because (x : CT[Exception]^) is not visible from any in value a. | - |where: => refers to a root capability created in value a when checking argument to parameter op of method handle - | ^ refers to the universal root capability - | ^² and cap refer to a root capability created in value a + |where: => refers to a root capability created in value a when checking argument to parameter op of method handle + | ^ refers to the root capability caps.any + | any is a root capability created in value a | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:30:4 ------------------------------------------- @@ -18,23 +18,23 @@ |Found: (x: CT[Exception]^) ->'s2 () ->{x} Nothing |Required: CT[Exception]^ => () -> Nothing | - |Note that capability x is not included in capture set {}. + |Note that capability `x` is not included in capture set {}. | |where: => refers to a root capability created in value b when checking argument to parameter op of method handle - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:36:4 ------------------------------------------- 36 | (x: CanThrow[Exception]) => // error | ^ - |Capability x outlives its scope: it leaks into outer capture set 's3 which is owned by value xx. + |Capability `x` outlives its scope: it leaks into outer capture set 's3 which is owned by value xx. |The leakage occurred when trying to match the following types: | |Found: (x: CT[Exception]^) ->'s4 () ->{x} Int |Required: CT[Exception]^ => () ->'s3 Int | |where: => refers to a root capability created in value xx when checking argument to parameter op of method handle - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 37 | () => 38 | raise(new Exception)(using x) @@ -44,14 +44,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:48:2 ------------------------------------------- 48 | (x: CanThrow[Exception]) => // error | ^ - |Capability x outlives its scope: it leaks into outer capture set 's5 which is owned by value global. + |Capability `x` outlives its scope: it leaks into outer capture set 's5 which is owned by value global. |The leakage occurred when trying to match the following types: | |Found: (x: CT[Exception]^) ->'s6 () ->{x} Int |Required: CT[Exception]^ => () ->'s5 Int | |where: => refers to a root capability created in value global when checking argument to parameter op of method handle - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | 49 | () => 50 | raise(new Exception)(using x) diff --git a/tests/neg-custom-args/captures/try.scala b/tests/neg-custom-args/captures/try.scala index af8d2d2fdf70..e17210d8230b 100644 --- a/tests/neg-custom-args/captures/try.scala +++ b/tests/neg-custom-args/captures/try.scala @@ -2,8 +2,8 @@ import annotation.retains import language.experimental.erasedDefinitions class CT[E <: Exception] -type CanThrow[E <: Exception] = CT[E] @retains[caps.cap.type] -type Top = Any @retains[caps.cap.type] +type CanThrow[E <: Exception] = CT[E] @retains[caps.any.type] +type Top = Any @retains[caps.any.type] infix type throws[R, E <: Exception] = (erased CanThrow[E]) ?=> R diff --git a/tests/neg-custom-args/captures/try3.scala b/tests/neg-custom-args/captures/try3.scala index 880d20ef16a0..b3b1a3e6b910 100644 --- a/tests/neg-custom-args/captures/try3.scala +++ b/tests/neg-custom-args/captures/try3.scala @@ -6,7 +6,7 @@ type Top = Any^ def handle[E <: Exception, T <: Top](op: (lcap: caps.Capability) ?-> CT[E]^{lcap} ?=> T)(handler: E => T): T = val x: CT[E] = ??? - try op(using caps.cap)(using x) + try op(using caps.any)(using x) catch case ex: E => handler(ex) def raise[E <: Exception](ex: E)(using CanThrow[E]): Nothing = diff --git a/tests/neg-custom-args/captures/unscoped-classifier-global.scala b/tests/neg-custom-args/captures/unscoped-classifier-global.scala index bf71745710e6..ef8630f08a93 100644 --- a/tests/neg-custom-args/captures/unscoped-classifier-global.scala +++ b/tests/neg-custom-args/captures/unscoped-classifier-global.scala @@ -20,4 +20,4 @@ def test() = val b = B() val d = D() // ok (?) - val _: D^{cap.only[Unscoped]} = d + val _: D^{any.only[Unscoped]} = d diff --git a/tests/neg-custom-args/captures/unscoped-classifier.check b/tests/neg-custom-args/captures/unscoped-classifier.check index be7132a7c2f5..c6dca46257f3 100644 --- a/tests/neg-custom-args/captures/unscoped-classifier.check +++ b/tests/neg-custom-args/captures/unscoped-classifier.check @@ -1,19 +1,17 @@ -- Error: tests/neg-custom-args/captures/unscoped-classifier.scala:5:8 ------------------------------------------------- 5 |class A(a: Async) extends caps.Unscoped // error but msg could be better | ^ - | reference (A.this.a : Async) is not included in the allowed capture set {cap} of the self type of class A + | reference `A.this.a` is not included in the allowed capture set {any} of the self type of class A | - | where: cap is a root capability classified as Unscoped in the type of class A + | where: any is a root capability classified as Unscoped in the type of class A -- Error: tests/neg-custom-args/captures/unscoped-classifier.scala:10:8 ------------------------------------------------ 10 |class C(f: () => Unit) extends caps.Unscoped // error but msg could be better | ^ - | reference (C.this.f : () => Unit) is not included in the allowed capture set {cap} of the self type of class C + | reference `C.this.f` is not included in the allowed capture set {any} of the self type of class C | - | where: cap is a root capability classified as Unscoped in the type of class C + | where: any is a root capability classified as Unscoped in the type of class C -- Error: tests/neg-custom-args/captures/unscoped-classifier.scala:17:15 ----------------------------------------------- 17 | def gg() = g() // error but msg could be better | ^ - | Read-only method gg accesses exclusive capability (g : () => Unit); + | Read-only method gg accesses exclusive capability `g`; | method gg should be declared an update method to allow this. - | - | where: => refers to a root capability in the type of parameter g diff --git a/tests/neg-custom-args/captures/unscoped-classifier.scala b/tests/neg-custom-args/captures/unscoped-classifier.scala index 4fd94efa56ec..0506d69ec5de 100644 --- a/tests/neg-custom-args/captures/unscoped-classifier.scala +++ b/tests/neg-custom-args/captures/unscoped-classifier.scala @@ -18,4 +18,4 @@ def test(g: () => Unit) = val b = B() val d = D() // ok (?) - val _: D^{cap.only[Unscoped]} = d + val _: D^{any.only[Unscoped]} = d diff --git a/tests/neg-custom-args/captures/unsound-reach-4.check b/tests/neg-custom-args/captures/unsound-reach-4.check index 0a98ed8e7e9f..96c401d31c99 100644 --- a/tests/neg-custom-args/captures/unsound-reach-4.check +++ b/tests/neg-custom-args/captures/unsound-reach-4.check @@ -2,30 +2,30 @@ 16 |class Bar extends Foo[File^]: // error | ^^^^^^^^^^ | Type variable X of trait Foo cannot be instantiated to File^ since - | that type captures the root capability `cap`. + | that type captures the root capability `any`. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/unsound-reach-4.scala:20:29 ------------------------------ 20 | val backdoor: Foo[File^] = new Bar // error (follow-on, since the parent Foo[File^] of bar is illegal). | ^^^^^^^ | Found: Bar^'s1 - | Required: Foo[File^] + | Required: Foo[File^{any}] | - | Note that capability cap is not included in capture set {cap²} - | because cap in class Bar is not visible from cap² in value backdoor. + | Note that capability `any²` is not included in capture set {any} + | because any² in class Bar is not visible from any in value backdoor. | - | where: ^ and cap² refer to a root capability in the type of value backdoor - | cap is a root capability created in class Bar + | where: any is a root capability in the type of value backdoor + | any² is a root capability created in class Bar | | longer explanation available when compiling with `-explain` -- [E164] Declaration Error: tests/neg-custom-args/captures/unsound-reach-4.scala:17:6 --------------------------------- 17 | def use(consume x: F): File^ = x // error consume override | ^ | error overriding method use in trait Foo of type (x: File^): File^²; - | method use of type (@consume x: File^): File^³ has incompatible type + | method use of type (@consume x: File^): File^{fresh} has incompatible type | - | where: ^ refers to the universal root capability - | ^² refers to a root capability created in class Bar - | ^³ refers to a root capability associated with the result type of (@consume x: File^): File^³ + | where: ^ refers to the root capability caps.any + | ^² refers to a root capability created in class Bar + | fresh is a root capability associated with the result type of (@consume x: File^): File^{fresh} | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/unsound-reach-6.check b/tests/neg-custom-args/captures/unsound-reach-6.check index 4f72a93d3015..8d981ec944e7 100644 --- a/tests/neg-custom-args/captures/unsound-reach-6.check +++ b/tests/neg-custom-args/captures/unsound-reach-6.check @@ -4,7 +4,7 @@ | Found: (x : () ->{ys*} Unit) | Required: () -> Unit | - | Note that capability ys* is not included in capture set {}. + | Note that capability `ys*` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/unsound-reach-6.scala:21:22 ------------------------------ @@ -13,7 +13,7 @@ | Found: (x : () ->{io} Unit) | Required: () -> Unit | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/unsound-reach-6.scala:7:13 ---------------------------------------------------- diff --git a/tests/neg-custom-args/captures/unsound-reach.check b/tests/neg-custom-args/captures/unsound-reach.check index ad0e9ee7a8e1..63faff101a2c 100644 --- a/tests/neg-custom-args/captures/unsound-reach.check +++ b/tests/neg-custom-args/captures/unsound-reach.check @@ -2,32 +2,32 @@ 9 |class Bar extends Foo[File^]: // error | ^^^^^^^^^^ | Type variable X of trait Foo cannot be instantiated to File^ since - | that type captures the root capability `cap`. + | that type captures the root capability `any`. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/unsound-reach.scala:18:31 -------------------------------- 18 | val backdoor: Foo[File^] = new Bar // error | ^^^^^^^ | Found: Bar^'s1 - | Required: Foo[File^] + | Required: Foo[File^{any}] | - | Note that capability cap is not included in capture set {cap²} - | because cap in class Bar is not visible from cap² in value backdoor. + | Note that capability `any²` is not included in capture set {any} + | because any² in class Bar is not visible from any in value backdoor. | - | where: ^ and cap² refer to a root capability in the type of value backdoor - | cap is a root capability created in class Bar + | where: any is a root capability in the type of value backdoor + | any² is a root capability created in class Bar | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/unsound-reach.scala:27:32 -------------------------------- 27 | val backdoor: Foo2[File^] = new Bar2 // error | ^^^^^^^^ | Found: Bar2^'s2 - | Required: Foo2[File^] + | Required: Foo2[File^{any}] | - | Note that capability cap is not included in capture set {cap²} - | because cap in class Bar2 is not visible from cap² in value backdoor. + | Note that capability `any²` is not included in capture set {any} + | because any² in class Bar2 is not visible from any in value backdoor. | - | where: ^ and cap² refer to a root capability in the type of value backdoor - | cap is a root capability created in class Bar2 + | where: any is a root capability in the type of value backdoor + | any² is a root capability created in class Bar2 | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/use-alternatives.scala b/tests/neg-custom-args/captures/use-alternatives.scala index 7a6845e66e1a..adeb7f1348d9 100644 --- a/tests/neg-custom-args/captures/use-alternatives.scala +++ b/tests/neg-custom-args/captures/use-alternatives.scala @@ -1,5 +1,5 @@ import language.experimental.captureChecking -import caps.{cap, use} +import caps.{any, use} def foo1(@use xs: List[() => Unit]): Unit = // error var x: () ->{xs*} Unit = xs.head diff --git a/tests/neg-custom-args/captures/use-capset.check b/tests/neg-custom-args/captures/use-capset.check index dddf9a785603..a85ae3907fa1 100644 --- a/tests/neg-custom-args/captures/use-capset.check +++ b/tests/neg-custom-args/captures/use-capset.check @@ -4,7 +4,7 @@ | Found: (h : () ->{io} Unit) | Required: () -> Unit | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/use-capset.scala:13:50 ----------------------------------- @@ -13,7 +13,7 @@ | Found: (h2 : () ->{} List[Object^{io}] ->{io} Object^{io}) | Required: () -> List[Object^{io}] -> Object^{io} | - | Note that capability io is not included in capture set {}. + | Note that capability `io` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/use-capset.scala:5:49 --------------------------------------------------------- diff --git a/tests/neg-custom-args/captures/uses.check b/tests/neg-custom-args/captures/uses.check index 5ada150ddf79..2fe1efcbd5e7 100644 --- a/tests/neg-custom-args/captures/uses.check +++ b/tests/neg-custom-args/captures/uses.check @@ -4,7 +4,7 @@ | Found: (d : D^{y}) | Required: D | - | Note that capability y is not included in capture set {}. + | Note that capability `y` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/uses.scala:13:22 ----------------------------------------- @@ -13,7 +13,7 @@ | Found: (f : () ->{x} Unit) | Required: () -> Unit | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/uses.scala:18:34 ----------------------------------------- @@ -22,7 +22,7 @@ | Found: () ->{x, y} () ->{y} Unit | Required: () ->{x} () ->{y} Unit | - | Note that capability y is not included in capture set {x}. + | Note that capability `y` is not included in capture set {x}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/uses.scala:19:28 ----------------------------------------- @@ -31,6 +31,6 @@ | Found: () ->{x, y} () ->{y} Unit | Required: () -> () -> Unit | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/usingLogFile.check b/tests/neg-custom-args/captures/usingLogFile.check index 3fe0db17fe0c..506d15f7b1bd 100644 --- a/tests/neg-custom-args/captures/usingLogFile.check +++ b/tests/neg-custom-args/captures/usingLogFile.check @@ -1,52 +1,68 @@ +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/usingLogFile.scala:11:35 --------------------------------- +11 | private val later = usingLogFile { f => () => f.write(0) } // error + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + |Found: (local: scala.caps.Capability^) ?->'s1 java.io.FileOutputStream ->{fresh} () ->'s2 Unit + |Required: (local²: scala.caps.Capability^) ?-> java.io.FileOutputStream ->{any} () ->'s2 Unit + | + |Note that capability `fresh` is not included in capture set {any} + |because fresh is not visible from any in value later. + | + |where: ^ refers to the root capability caps.any + | any is a root capability created in value later when checking argument to parameter op of method usingLogFile + | fresh is a root capability associated with the result type of (using local: scala.caps.Capability^): java.io.FileOutputStream ->{fresh} () ->'s2 Unit + | local is a reference to a value parameter + | local² is a reference to a value parameter + | + | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/usingLogFile.scala:22:29 --------------------------------- 22 | val later = usingLogFile { f => () => f.write(0) } // error | ^^^^^^^^^^^^^^^^^^^^^ - |Capability f outlives its scope: it leaks into outer capture set 's1 which is owned by value later. + |Capability `f` outlives its scope: it leaks into outer capture set 's3 which is owned by value later. |The leakage occurred when trying to match the following types: | - |Found: (f: java.io.FileOutputStream^'s2) ->'s3 () ->{f} Unit - |Required: java.io.FileOutputStream^ => () ->'s1 Unit + |Found: (f: java.io.FileOutputStream^'s4) ->'s5 () ->{f} Unit + |Required: java.io.FileOutputStream^ => () ->'s3 Unit | |where: => refers to a root capability created in value later when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/usingLogFile.scala:27:38 --------------------------------- 27 | private val later2 = usingLogFile { f => Cell(() => f.write(0)) } // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |Capability f outlives its scope: it leaks into outer capture set 's4 which is owned by value later2. + |Capability `f` outlives its scope: it leaks into outer capture set 's6 which is owned by value later2. |The leakage occurred when trying to match the following types: | - |Found: (f: java.io.FileOutputStream^'s5) ->'s6 Test2.Cell[() ->{f} Unit]^'s7 - |Required: java.io.FileOutputStream^ => Test2.Cell[() ->'s4 Unit]^'s8 + |Found: (f: java.io.FileOutputStream^'s7) ->'s8 Test2.Cell[() ->{f} Unit]^'s9 + |Required: java.io.FileOutputStream^ => Test2.Cell[() ->'s6 Unit]^'s10 | |where: => refers to a root capability created in value later2 when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/usingLogFile.scala:43:33 --------------------------------- 43 | val later = usingFile("out", f => (y: Int) => xs.foreach(x => f.write(x + y))) // error | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |Capability f outlives its scope: it leaks into outer capture set 's9 which is owned by value later. + |Capability `f` outlives its scope: it leaks into outer capture set 's11 which is owned by value later. |The leakage occurred when trying to match the following types: | - |Found: (f: java.io.OutputStream^'s10) ->'s11 Int ->{f} Unit - |Required: java.io.OutputStream^ => Int ->'s9 Unit + |Found: (f: java.io.OutputStream^'s12) ->'s13 Int ->{f} Unit + |Required: java.io.OutputStream^ => Int ->'s11 Unit | |where: => refers to a root capability created in value later when checking argument to parameter op of method usingFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/usingLogFile.scala:52:6 ---------------------------------- 52 | usingLogger(_, l => () => l.log("test"))) // error after checking mapping scheme | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |Capability _$1 outlives its scope: it leaks into outer capture set 's12 which is owned by value later. + |Capability `_$1` outlives its scope: it leaks into outer capture set 's14 which is owned by value later. |The leakage occurred when trying to match the following types: | - |Found: (_$1: java.io.OutputStream^'s13) ->'s14 () ->{_$1} Unit - |Required: java.io.OutputStream^ => () ->'s12 Unit + |Found: (_$1: java.io.OutputStream^'s15) ->'s16 () ->{_$1} Unit + |Required: java.io.OutputStream^ => () ->'s14 Unit | |where: => refers to a root capability created in value later when checking argument to parameter op of method usingFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/usingLogFile.scala b/tests/neg-custom-args/captures/usingLogFile.scala index 17603d5309b3..6e059e793f1e 100644 --- a/tests/neg-custom-args/captures/usingLogFile.scala +++ b/tests/neg-custom-args/captures/usingLogFile.scala @@ -4,11 +4,11 @@ object Test1: def usingLogFile[T](op: (local: caps.Capability) ?-> FileOutputStream => T): T = val logFile = FileOutputStream("log") - val result = op(using caps.cap)(logFile) + val result = op(using caps.any)(logFile) logFile.close() result - private val later = usingLogFile { f => () => f.write(0) } // OK, `f` has global lifetime + private val later = usingLogFile { f => () => f.write(0) } // error later() object Test2: diff --git a/tests/neg-custom-args/captures/var-access.check b/tests/neg-custom-args/captures/var-access.check index 63028ba807cc..536cd7202ca0 100644 --- a/tests/neg-custom-args/captures/var-access.check +++ b/tests/neg-custom-args/captures/var-access.check @@ -4,7 +4,7 @@ | Found: (f : () ->{a.rd} Int) | Required: () -> Int | - | Note that capability a.rd is not included in capture set {}. + | Note that capability `a.rd` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/var-access.scala:12:22 ----------------------------------- @@ -13,6 +13,6 @@ | Found: (g : () ->{a} Unit) | Required: () -> Unit | - | Note that capability a is not included in capture set {}. + | Note that capability `a` is not included in capture set {}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/vars-simple.check b/tests/neg-custom-args/captures/vars-simple.check index 1cd12195566a..a80b4a0712ea 100644 --- a/tests/neg-custom-args/captures/vars-simple.check +++ b/tests/neg-custom-args/captures/vars-simple.check @@ -1,12 +1,12 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars-simple.scala:15:9 ----------------------------------- 15 | a = (g: String => String) // error | ^^^^^^^^^^^^^^^^^^^ - | Found: String => String + | Found: String ->{any} String | Required: String ->{cap1, cap2} String | - | Note that capability cap is not included in capture set {cap1, cap2}. + | Note that capability `any` is not included in capture set {cap1, cap2}. | - | where: => and cap refer to a root capability created in method scope + | where: any is a root capability created in method scope | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars-simple.scala:16:8 ----------------------------------- @@ -15,7 +15,7 @@ | Found: (x: String) ->{cap3} String | Required: String ->{cap1, cap2} String | - | Note that capability cap3 is not included in capture set {cap1, cap2}. + | Note that capability `cap3` is not included in capture set {cap1, cap2}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars-simple.scala:17:12 ---------------------------------- @@ -24,6 +24,6 @@ | Found: List[String ->{cap3} String] | Required: List[String ->{cap1, cap2} String] | - | Note that capability cap3 is not included in capture set {cap1, cap2}. + | Note that capability `cap3` is not included in capture set {cap1, cap2}. | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/vars.check b/tests/neg-custom-args/captures/vars.check index f5584538025a..4e26686b3f5a 100644 --- a/tests/neg-custom-args/captures/vars.check +++ b/tests/neg-custom-args/captures/vars.check @@ -4,7 +4,7 @@ | Found: (z : () ->{cap1, x.rd} String) | Required: () -> String | - | Note that capability cap1 is not included in capture set {}. + | Note that capability `cap1` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars.scala:14:24 ----------------------------------------- @@ -13,7 +13,7 @@ | Found: (z2 : () ->{x} Unit) | Required: () -> Unit | - | Note that capability x is not included in capture set {}. + | Note that capability `x` is not included in capture set {}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars.scala:25:8 ------------------------------------------ @@ -22,7 +22,7 @@ | Found: (x: String) ->{cap3} String | Required: String ->{cap1} String | - | Note that capability cap3 cannot be included in capture set {cap1} of variable a. + | Note that capability `cap3` cannot be included in capture set {cap1} of variable a. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars.scala:26:8 ------------------------------------------ @@ -31,7 +31,7 @@ | Found: (x: String) ->{cap3} String | Required: String ->{cap1} String | - | Note that capability cap3 cannot be included in capture set {cap1} of variable a. + | Note that capability `cap3` cannot be included in capture set {cap1} of variable a. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars.scala:28:12 ----------------------------------------- @@ -40,21 +40,21 @@ | Found: List[String ->{cap3} String] | Required: List[String ->{cap1, cap2} String] | - | Note that capability cap3 is not included in capture set {cap1, cap2}. + | Note that capability `cap3` is not included in capture set {cap1, cap2}. | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars.scala:37:10 ----------------------------------------- 37 | local { cap3 => // error | ^ - | Capability cap3 outlives its scope: it leaks into outer capture set {cap3²} which is owned by method test. - | The leakage occurred when trying to match the following types: + | Capability `cap3` outlives its scope: it leaks into outer capture set {cap3²} which is owned by method test. + | The leakage occurred when trying to match the following types: | - | Found: (cap3: CC^) ->'s1 String ->{cap3} String - | Required: CC^ -> String ->{cap3²} String + | Found: (cap3: CC^) ->'s1 String ->{cap3} String + | Required: CC^ -> String ->{cap3²} String | - | where: ^ refers to the universal root capability - | cap3 is a reference to a value parameter - | cap3² is a parameter in an anonymous function in method test + | where: ^ refers to the root capability caps.any + | cap3 is a reference to a value parameter + | cap3² is a parameter in an anonymous function in method test | 38 | def g(x: String): String = if cap3 == cap3 then "" else "a" 39 | g diff --git a/tests/neg-custom-args/captures/widen-reach.check b/tests/neg-custom-args/captures/widen-reach.check index e37c371f6db2..d2e18bcccc88 100644 --- a/tests/neg-custom-args/captures/widen-reach.check +++ b/tests/neg-custom-args/captures/widen-reach.check @@ -2,21 +2,21 @@ 8 |trait Bar extends Foo[IO^]: // error | ^^^^^^^^ | Type variable T of trait Foo cannot be instantiated to IO^ since - | that type captures the root capability `cap`. + | that type captures the root capability `any`. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/widen-reach.scala:9:24 ----------------------------------- 9 | val foo: IO^ -> IO^ = x => x // error | ^^^^^^ - | Found: (x: IO^) ->'s1 IO^² - | Required: IO^ -> IO^³ + | Found: (x: IO^) ->'s1 IO^{fresh} + | Required: IO^ -> IO^{any} | - | Note that capability cap is not included in capture set {cap²} - | because cap is not visible from cap² in value foo. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value foo. | - | where: ^ refers to the universal root capability - | ^² and cap refer to a root capability associated with the result type of (x: IO^): IO^² - | ^³ and cap² refer to a root capability in the type of value foo + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value foo + | fresh is a root capability associated with the result type of (x: IO^): IO^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/widen-reach.scala:13:26 ---------------------------------- @@ -25,9 +25,9 @@ | Found: IO^ ->{x*} IO^{x*} | Required: IO^ -> IO^² | - | Note that capability x* is not included in capture set {}. + | Note that capability `x*` is not included in capture set {}. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any | ^² refers to a root capability in the type of value y2 | | longer explanation available when compiling with `-explain` @@ -37,8 +37,8 @@ | Found: IO^ ->{x*} IO^{x*} | Required: IO^ -> IO^{x*} | - | Note that capability x* is not included in capture set {}. + | Note that capability `x*` is not included in capture set {}. | - | where: ^ refers to the universal root capability + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/withFile.check b/tests/neg-custom-args/captures/withFile.check index 8e67504f6f8e..4e641e28132c 100644 --- a/tests/neg-custom-args/captures/withFile.check +++ b/tests/neg-custom-args/captures/withFile.check @@ -1,57 +1,57 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:14:38 ------------------------------------- 14 | private val later1 = usingLogFile { f => () => f.write() } // error | ^^^^^^^^^^^^^^^^^^^^ - |Capability f outlives its scope: it leaks into outer capture set 's1 which is owned by value later1. + |Capability `f` outlives its scope: it leaks into outer capture set 's1 which is owned by value later1. |The leakage occurred when trying to match the following types: | |Found: (f: Test2.File^'s2) ->'s3 () ->{f} Unit |Required: Test2.File^ => () ->'s1 Unit | |where: => refers to a root capability created in value later1 when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:15:38 ------------------------------------- 15 | private val later2 = usingLogFile { f => Box(f) } // error | ^^^^^^^^^^^ - |Capability cap outlives its scope: it leaks into outer capture set 's4 which is owned by value later2. + |Capability `fresh` outlives its scope: it leaks into outer capture set 's4 which is owned by value later2. |The leakage occurred when trying to match the following types: | |Found: (f: Test2.File^'s5) ->'s6 Test2.Box[Test2.File^'s7]^'s8 |Required: Test2.File^ => Test2.Box[Test2.File^'s4]^'s9 | - |where: => refers to a root capability created in value later2 when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability - | cap is a root capability associated with the result type of (f: Test2.File^): Test2.Box[Test2.File^'s4]^'s9 + |where: => refers to a root capability created in value later2 when checking argument to parameter op of method usingLogFile + | ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (f: Test2.File^): Test2.Box[Test2.File^'s4]^'s9 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:17:4 -------------------------------------- 17 | f => () => f.write() // error | ^^^^^^^^^^^^^^^^^^^^ |Found: (f: Test2.File^'s10) ->'s11 () ->{f} Unit - |Required: Test2.File^ => () =>² Unit + |Required: Test2.File^ => () ->{any} Unit | - |Note that capability f is not included in capture set {cap} - |because (f : Test2.File^'s10) is not visible from cap in value later3. + |Note that capability `f` is not included in capture set {any} + |because (f : Test2.File^'s10) is not visible from any in value later3. | - |where: => refers to a root capability created in value later3 when checking argument to parameter op of method usingLogFile - | =>² and cap refer to a root capability created in value later3 - | ^ refers to the universal root capability + |where: => refers to a root capability created in value later3 when checking argument to parameter op of method usingLogFile + | ^ refers to the root capability caps.any + | any is a root capability created in value later3 | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:19:4 -------------------------------------- 19 | f => Box(f) // error | ^^^^^^^^^^^ |Found: (f: Test2.File^'s12) ->'s13 Test2.Box[Test2.File^'s14]^'s15 - |Required: Test2.File^ => Test2.Box[Test2.File^²] + |Required: Test2.File^ => Test2.Box[Test2.File^{any}] | - |Note that capability cap is not included in capture set {cap²} - |because cap is not visible from cap² in value later4. + |Note that capability `fresh` is not included in capture set {any} + |because fresh is not visible from any in value later4. | - |where: => refers to a root capability created in value later4 when checking argument to parameter op of method usingLogFile - | ^ refers to the universal root capability - | ^² and cap² refer to a root capability created in value later4 - | cap is a root capability associated with the result type of (f: Test2.File^'s12): Test2.Box[Test2.File^'s14]^'s15 + |where: => refers to a root capability created in value later4 when checking argument to parameter op of method usingLogFile + | ^ refers to the root capability caps.any + | any is a root capability created in value later4 + | fresh is a root capability associated with the result type of (f: Test2.File^'s12): Test2.Box[Test2.File^'s14]^'s15 | | longer explanation available when compiling with `-explain` -- Error: tests/neg-custom-args/captures/withFile.scala:16:20 ---------------------------------------------------------- diff --git a/tests/new/test.scala b/tests/new/test.scala index 00174769a0f0..337db46de50f 100644 --- a/tests/new/test.scala +++ b/tests/new/test.scala @@ -1 +1,4 @@ -object Test +trait FileSystem: + def read(): Unit +def process(fs: FileSystem^): Unit = + val f: () -> Unit = () => fs.read() // Error: fs cannot flow into {} \ No newline at end of file diff --git a/tests/patmat/optionless.scala b/tests/patmat/optionless.scala index 9afc43062caa..cb8e3ebdf0a7 100644 --- a/tests/patmat/optionless.scala +++ b/tests/patmat/optionless.scala @@ -7,11 +7,11 @@ object Ident1 { trait Cap object Ident2 { - def unapply(tree: Tree)(implicit cap: Cap): Ident = ??? + def unapply(tree: Tree)(implicit any: Cap): Ident = ??? } object Ident3 { - def unapply(tree: Tree)(implicit cap: Cap): Option[Ident] = ??? + def unapply(tree: Tree)(implicit any: Cap): Option[Ident] = ??? } diff --git a/tests/pos-custom-args/captures/boxmap-paper.scala b/tests/pos-custom-args/captures/boxmap-paper.scala index 436132280d40..b9223b21b411 100644 --- a/tests/pos-custom-args/captures/boxmap-paper.scala +++ b/tests/pos-custom-args/captures/boxmap-paper.scala @@ -1,4 +1,4 @@ -import caps.cap +import caps.any type Cell_orig[+T] = [K] -> (T => K) -> K @@ -19,13 +19,13 @@ def map[A, B](c: Cell[A])(f: A => B): Cell[B] def pureMap[A, B](c: Cell[A])(f: A -> B): Cell[B] = c[Cell[B]]((x: A) => cell(f(x))) -def lazyMap[A, B](c: Cell[A])(f: A ->{cap.rd} B): () ->{f} Cell[B] +def lazyMap[A, B](c: Cell[A])(f: A ->{any.rd} B): () ->{f} Cell[B] = () => c[Cell[B]]((x: A) => cell(f(x))) trait IO: def print(s: String): Unit -def test(io: IO^{cap.rd}) = +def test(io: IO^{any.rd}) = val loggedOne: () ->{io} Int = () => { io.print("1"); 1 } diff --git a/tests/pos-custom-args/captures/byname.scala b/tests/pos-custom-args/captures/byname.scala index ca1d02fb45dc..36d63cd7bd7f 100644 --- a/tests/pos-custom-args/captures/byname.scala +++ b/tests/pos-custom-args/captures/byname.scala @@ -1,5 +1,5 @@ import annotation.retainsByName -import caps.cap +import caps.any class CC type Cap = CC^ @@ -7,7 +7,7 @@ class I def test(cap1: Cap, cap2: Cap): I^{cap1} = def f() = if cap1 == cap1 then I() else I() - def h(x: ->{cap} I) = x + def h(x: ->{any} I) = x h(f()) // OK def hh(x: -> I @retainsByName[cap1.type]) = x h(f()) diff --git a/tests/pos-custom-args/captures/cap-paramlist8-desugared.scala b/tests/pos-custom-args/captures/cap-paramlist8-desugared.scala index 15b829646c65..1c47bbd19a3d 100644 --- a/tests/pos-custom-args/captures/cap-paramlist8-desugared.scala +++ b/tests/pos-custom-args/captures/cap-paramlist8-desugared.scala @@ -1,14 +1,14 @@ import language.experimental.captureChecking - import caps.cap + import caps.any trait Ctx[T >: Nothing <: Any]() extends Object def test: Unit = { - val x: Any^{cap} = ??? - val y: Any^{cap} = ??? + val x: Any^{any} = ??? + val y: Any^{any} = ??? object O { - val z: Any^{cap} = ??? + val z: Any^{any} = ??? } val baz3: Int -> [C^ >: caps.CapSet <: caps.CapSet^, @@ -16,7 +16,7 @@ caps.CapSet^{C, x}] => () -> [F^ >: caps.CapSet^{x, y} <: caps.CapSet^{C, E}] => (x: Int) -> (Ctx[F]) ?-> Int = (i: Int) => [ - C^ >: _root_.scala.caps.CapSet <: _root_.scala.caps.CapSet^{cap}, + C^ >: _root_.scala.caps.CapSet <: _root_.scala.caps.CapSet^{any}, D^ >: _root_.scala.caps.CapSet <: _root_.scala.caps.CapSet^{C}, E^ >: _root_.scala.caps.CapSet <: _root_.scala.caps.CapSet^{C, x}] => () => [ diff --git a/tests/pos-custom-args/captures/cap-paramlists4.scala b/tests/pos-custom-args/captures/cap-paramlists4.scala index 179da36ef1ed..8a9a18f34e89 100644 --- a/tests/pos-custom-args/captures/cap-paramlists4.scala +++ b/tests/pos-custom-args/captures/cap-paramlists4.scala @@ -1,6 +1,6 @@ import language.experimental.captureChecking trait Foo[U^, V^, W^]: - type C = {caps.cap} - type D = {caps.cap} + type C = {caps.any} + type D = {caps.any} type E >: {V,W} <: {U} \ No newline at end of file diff --git a/tests/pos-custom-args/captures/caps-universal.scala b/tests/pos-custom-args/captures/caps-universal.scala index 6555062395c4..2537b1e4bd18 100644 --- a/tests/pos-custom-args/captures/caps-universal.scala +++ b/tests/pos-custom-args/captures/caps-universal.scala @@ -1,7 +1,7 @@ import annotation.retains val foo: Int => Int = x => x -val bar: (Int -> Int) @retains[caps.cap.type] = foo +val bar: (Int -> Int) @retains[caps.any.type] = foo val baz: Int => Int = bar diff --git a/tests/pos-custom-args/captures/capt-depfun.scala b/tests/pos-custom-args/captures/capt-depfun.scala index 359c49e9110f..d71e9b3b9746 100644 --- a/tests/pos-custom-args/captures/capt-depfun.scala +++ b/tests/pos-custom-args/captures/capt-depfun.scala @@ -1,7 +1,7 @@ import annotation.retains class C -type Cap = C @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] type T = (x: Cap) -> STR @retains[x.type] @@ -11,7 +11,7 @@ class STR(s: String) val aa: ((x: Cap) -> STR @retains[x.type]) = (x: Cap) => STR("") -def f(consume y: Cap, z: Cap): STR @retains[caps.cap.type] = +def f(consume y: Cap, z: Cap): STR @retains[caps.any.type] = val a: ((x: Cap) -> STR @retains[x.type]) = (x: Cap) => STR("") val b = a(y) val c: STR @retains[y.type] = b diff --git a/tests/pos-custom-args/captures/capt-depfun2.scala b/tests/pos-custom-args/captures/capt-depfun2.scala index 0affafa8bb48..95f80771d12c 100644 --- a/tests/pos-custom-args/captures/capt-depfun2.scala +++ b/tests/pos-custom-args/captures/capt-depfun2.scala @@ -1,7 +1,7 @@ import annotation.retains class C -type Cap = C @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] class Arr[T] diff --git a/tests/pos-custom-args/captures/capt0.scala b/tests/pos-custom-args/captures/capt0.scala index ea535bbd433e..50f1da2f8c55 100644 --- a/tests/pos-custom-args/captures/capt0.scala +++ b/tests/pos-custom-args/captures/capt0.scala @@ -3,5 +3,5 @@ object Test: def test() = val x: Any^ = "abc" val y: Object @scala.annotation.retains[x.type] = ??? - val z: Object @scala.annotation.retains[x.type | caps.cap.type] = y: Object @annotation.retains[x.type] + val z: Object @scala.annotation.retains[x.type | caps.any.type] = y: Object @annotation.retains[x.type] diff --git a/tests/pos-custom-args/captures/capt2.scala b/tests/pos-custom-args/captures/capt2.scala index 7690b892d120..cd4ed06c0fb0 100644 --- a/tests/pos-custom-args/captures/capt2.scala +++ b/tests/pos-custom-args/captures/capt2.scala @@ -1,6 +1,6 @@ import annotation.retains class C -type Cap = C @retains[caps.cap.type] +type Cap = C @retains[caps.any.type] def test1() = val y: C^ = C() diff --git a/tests/pos-custom-args/captures/cc-dep-param.scala b/tests/pos-custom-args/captures/cc-dep-param.scala index 5fd634de9040..37e7f5c4df41 100644 --- a/tests/pos-custom-args/captures/cc-dep-param.scala +++ b/tests/pos-custom-args/captures/cc-dep-param.scala @@ -1,9 +1,9 @@ import language.experimental.captureChecking -import caps.cap +import caps.any trait Foo[T] def test(): Unit = - val a: Foo[Int]^{cap.rd} = ??? + val a: Foo[Int]^{any.rd} = ??? val useA: () ->{a} Unit = ??? def foo[X](x: Foo[X]^, op: () ->{x} Unit): Unit = ??? foo(a, useA) diff --git a/tests/pos-custom-args/captures/cc-expand.scala b/tests/pos-custom-args/captures/cc-expand.scala index 15529ad07ceb..f53bdc8a6c00 100644 --- a/tests/pos-custom-args/captures/cc-expand.scala +++ b/tests/pos-custom-args/captures/cc-expand.scala @@ -5,7 +5,7 @@ object Test: class B class C class CTC - type CT = CTC @retains[caps.cap.type] + type CT = CTC @retains[caps.any.type] def test(ct: CT, dt: CT) = diff --git a/tests/pos-custom-args/captures/cc-poly-varargs.scala b/tests/pos-custom-args/captures/cc-poly-varargs.scala index b6c270d35cc7..fce60a9cbfc2 100644 --- a/tests/pos-custom-args/captures/cc-poly-varargs.scala +++ b/tests/pos-custom-args/captures/cc-poly-varargs.scala @@ -3,7 +3,7 @@ import language.experimental.separationChecking abstract class Source[+T] extension[T](src: Source[T]^) - def transformValuesWith[U](f: (T -> U)^{src, caps.cap}): Source[U]^{src, f} = ??? + def transformValuesWith[U](f: (T -> U)^{src, caps.any}): Source[U]^{src, f} = ??? def race[T, D^](sources: Source[T]^{D}*): Source[T]^{D} = ??? diff --git a/tests/pos-custom-args/captures/check-override-typebounds-2.scala b/tests/pos-custom-args/captures/check-override-typebounds-2.scala index 308ed779f6f1..b40baf256a5b 100644 --- a/tests/pos-custom-args/captures/check-override-typebounds-2.scala +++ b/tests/pos-custom-args/captures/check-override-typebounds-2.scala @@ -3,10 +3,10 @@ import language.experimental.captureChecking class Capbility trait A: - type T <: Capbility^{caps.cap.rd} + type T <: Capbility^{caps.any.rd} class B extends A: - type T = C^{caps.cap.rd} + type T = C^{caps.any.rd} class C extends Capbility diff --git a/tests/neg-custom-args/captures/closure-avoidance.scala b/tests/pos-custom-args/captures/closure-avoidance.scala similarity index 54% rename from tests/neg-custom-args/captures/closure-avoidance.scala rename to tests/pos-custom-args/captures/closure-avoidance.scala index 78747d7a3239..83725cb4df71 100644 --- a/tests/neg-custom-args/captures/closure-avoidance.scala +++ b/tests/pos-custom-args/captures/closure-avoidance.scala @@ -1,3 +1,4 @@ +import caps.fresh trait A trait B @@ -6,11 +7,11 @@ def test = val b: B^ = ??? b - val f1: A^ => B^ = (a: A^) => // error -- can we make this work as for f2? + val f1: A^ => B^{fresh} = (a: A^) => // OK val b: B^ = ??? b - val f2: (x: A^) => B^ = (a: A^) => + val f2: (x: A^) => B^{fresh} = (a: A^) => val b: B^ = ??? b // ok @@ -20,11 +21,11 @@ def test = val test = g - val g1: A^ => B^ = (a: A^) => // error -- can we make this work as for g2? + val g1: A^ => B^{fresh} = (a: A^) => // OK println("") (??? : B^) - val g2: (x: A^) => B^ = (a: A^) => + val g2: (x: A^) => B^{fresh} = (a: A^) => println("") (??? : B^) // ok diff --git a/tests/pos-custom-args/captures/closure-result-typing.scala b/tests/pos-custom-args/captures/closure-result-typing.scala index fe8efff9861d..27d98b130295 100644 --- a/tests/pos-custom-args/captures/closure-result-typing.scala +++ b/tests/pos-custom-args/captures/closure-result-typing.scala @@ -1,2 +1,3 @@ +import caps.fresh def test(c: Object^): Unit = - val y: (x: Object^{c}) -> Object^ = x => x + val y: (x: Object^{c}) -> Object^{fresh} = x => x diff --git a/tests/pos-custom-args/captures/ctest.scala b/tests/pos-custom-args/captures/ctest.scala index 62aa77fec0a5..5bcd9375b4de 100644 --- a/tests/pos-custom-args/captures/ctest.scala +++ b/tests/pos-custom-args/captures/ctest.scala @@ -1,7 +1,8 @@ +import caps.fresh class C type Cap = C^ class S def f(y: Cap) = - val a: ((x: Cap) -> S^) = (x: Cap) => S() \ No newline at end of file + val a: ((x: Cap) -> S^{fresh}) = (x: Cap) => S() \ No newline at end of file diff --git a/tests/pos-custom-args/captures/deep-adapt.scala b/tests/pos-custom-args/captures/deep-adapt.scala index 2a27763f53fa..d08008e02707 100644 --- a/tests/pos-custom-args/captures/deep-adapt.scala +++ b/tests/pos-custom-args/captures/deep-adapt.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any trait Rdr[T]: def get: T @@ -14,10 +14,10 @@ class Swap[+A, +B](x: A, y: B) extends Pair[B, A](y, x) def Test(c: Object^): Unit = val refs = List(Ref(1), Ref(2)) - val rdrs: List[Ref[Int]^{cap.rd}] = refs - val rdrs2: Seq[Ref[Int]^{cap.rd}] = refs + val rdrs: List[Ref[Int]^{any.rd}] = refs + val rdrs2: Seq[Ref[Int]^{any.rd}] = refs val swapped = Swap(Ref(1), Ref("hello")) - val _: Swap[Ref[Int]^{cap.rd}, Ref[String]^{cap.rd}] = swapped - val _: Pair[Ref[String]^{cap.rd}, Ref[Int]^{cap.rd}] @unchecked = swapped + val _: Swap[Ref[Int]^{any.rd}, Ref[String]^{any.rd}] = swapped + val _: Pair[Ref[String]^{any.rd}, Ref[Int]^{any.rd}] @unchecked = swapped diff --git a/tests/pos-custom-args/captures/dotty-experimental.scala b/tests/pos-custom-args/captures/dotty-experimental.scala index 813c9b5920c1..585670a9f09e 100644 --- a/tests/pos-custom-args/captures/dotty-experimental.scala +++ b/tests/pos-custom-args/captures/dotty-experimental.scala @@ -3,6 +3,6 @@ import language.experimental.captureChecking object test { - val x: caps.Capability = caps.cap + val x: caps.Capability = caps.any } diff --git a/tests/pos-custom-args/captures/erased-methods.scala b/tests/pos-custom-args/captures/erased-methods.scala index 43347c6d9172..3c7ee447d499 100644 --- a/tests/pos-custom-args/captures/erased-methods.scala +++ b/tests/pos-custom-args/captures/erased-methods.scala @@ -1,6 +1,7 @@ import language.experimental.saferExceptions import language.experimental.erasedDefinitions import language.experimental.captureChecking +import caps.fresh class Ex1 extends Exception("Ex1") class Ex2 extends Exception("Ex2") @@ -12,8 +13,8 @@ def foo8a(i: Int) = def foo9a(i: Int) : (erased x$0: CanThrow[Ex3]) ?=> (erased x$1: CanThrow[Ex2]) - ?=> (erased x$2: CanThrow[Ex1]) - ?=> Unit + ?->{fresh} (erased x$2: CanThrow[Ex1]) + ?->{fresh} Unit = (erased x$1: CanThrow[Ex3]) ?=> (erased x$2: CanThrow[Ex2]) ?=> (erased x$3: CanThrow[Ex1]) diff --git a/tests/pos-custom-args/captures/erased-methods2-shared.scala b/tests/pos-custom-args/captures/erased-methods2-shared.scala index 24e42dae4322..7f5d26b8a31f 100644 --- a/tests/pos-custom-args/captures/erased-methods2-shared.scala +++ b/tests/pos-custom-args/captures/erased-methods2-shared.scala @@ -1,6 +1,7 @@ import language.experimental.saferExceptions import language.experimental.erasedDefinitions import language.experimental.captureChecking +import caps.fresh class Ex1 extends Exception("Ex1") class Ex2 extends Exception("Ex2") @@ -16,7 +17,7 @@ def foo8a(i: Int) = def foo9a(i: Int) : (x$1: CT[Ex3]^) ?=> (x$2: CT[Ex2]^) - ?=> Unit + ?->{fresh} Unit = (x$1: CT[Ex3]^) // error ?=> (x$2: CT[Ex2]^) ?=> @@ -26,8 +27,8 @@ def foo9a(i: Int) def foo10a(i: Int) : (erased x$0: CT[Ex3]^) ?=> (erased x$1: CT[Ex2]^) - ?=> (erased x$2: CT[Ex1]^) - ?=> Unit + ?->{fresh} (erased x$2: CT[Ex1]^) + ?->{fresh} Unit = (erased x$1: CT[Ex3]^) // error ?=> (erased x$2: CT[Ex2]^) ?=> (erased x$3: CT[Ex1]^) diff --git a/tests/pos-custom-args/captures/eta-expansions.scala b/tests/pos-custom-args/captures/eta-expansions.scala index 09c369d47ba6..bd9c1f200395 100644 --- a/tests/pos-custom-args/captures/eta-expansions.scala +++ b/tests/pos-custom-args/captures/eta-expansions.scala @@ -1,6 +1,10 @@ +import caps.* + class Cap extends caps.SharedCapability def test(d: Cap) = + def m(x: Cap^): Cap^ = x + val f: (x: Cap^) -> Cap^{fresh} = m // simple eta expansion def map2(xs: List[Int])(f: Int => Int): List[Int] = xs.map(f) val f1 = map2 // capture polymorphic implicit eta expansion val f2c: List[Int] => (Int => Int) => List[Int] = f1 diff --git a/tests/pos-custom-args/captures/filter-iterable.scala b/tests/pos-custom-args/captures/filter-iterable.scala index c8e80af4cd73..edfedc0b1c2d 100644 --- a/tests/pos-custom-args/captures/filter-iterable.scala +++ b/tests/pos-custom-args/captures/filter-iterable.scala @@ -1,10 +1,10 @@ -import caps.cap +import caps.any class It[A] -class Filter[A](val underlying: It[A]^, val p: A ->{cap, underlying} Boolean) extends It[A] +class Filter[A](val underlying: It[A]^, val p: A ->{any, underlying} Boolean) extends It[A] object Filter: - def apply[A](underlying: It[A]^, p: A => Boolean): Filter[A]^{cap, p, underlying} = + def apply[A](underlying: It[A]^, p: A => Boolean): Filter[A]^{any, p, underlying} = underlying match case filter: Filter[A]^ => val x = new Filter(filter.underlying, a => filter.p(a) && p(a)) diff --git a/tests/pos-custom-args/captures/i15749.scala b/tests/pos-custom-args/captures/i15749.scala index 8b4c77602439..ef17edb8b12a 100644 --- a/tests/pos-custom-args/captures/i15749.scala +++ b/tests/pos-custom-args/captures/i15749.scala @@ -12,9 +12,9 @@ class Foo[T](val x: T) type BoxedLazyVal[T, C^] = Foo[LazyVal[T, C]] /* def force[A, C^](v: BoxedLazyVal[A, C]): A = - // Γ ⊢ v.x : □ {cap} U -> A + // Γ ⊢ v.x : □ {any} U -> A v.x(u) // should be error: (unbox v.x)(u), where (unbox v.x) should be untypable, now ok */ def force[A, C^](v: Foo[U ->{C} A]): A = - // Γ ⊢ v.x : □ {cap} U -> A + // Γ ⊢ v.x : □ {any} U -> A v.x(u) // should be error: (unbox v.x)(u), where (unbox v.x) should be untypable, now ok \ No newline at end of file diff --git a/tests/pos-custom-args/captures/i15749a.scala b/tests/pos-custom-args/captures/i15749a.scala index 19e919798fd9..0babfd627a45 100644 --- a/tests/pos-custom-args/captures/i15749a.scala +++ b/tests/pos-custom-args/captures/i15749a.scala @@ -1,4 +1,4 @@ -import caps.cap +import caps.any import caps.use @@ -7,17 +7,17 @@ object u extends Unit type Top = Any^ -class Wrapper[+T](val value: [X] -> (op: T ->{cap} X) -> X) +class Wrapper[+T](val value: [X] -> (op: T ->{any} X) -> X) def test = def wrapper[T](x: T): Wrapper[T] = Wrapper: - [X] => (op: T ->{cap} X) => op(x) + [X] => (op: T ->{any} X) => op(x) - def strictMap[A <: Top, B <: Top, C^](mx: Wrapper[A])(f: A ->{cap, C} B): Wrapper[B] = + def strictMap[A <: Top, B <: Top, C^](mx: Wrapper[A])(f: A ->{any, C} B): Wrapper[B] = mx.value((x: A) => wrapper(f(x))) - def force[A](thunk: Unit ->{cap} A): A = thunk(u) + def force[A](thunk: Unit ->{any} A): A = thunk(u) def forceWrapper[A, C^](mx: Wrapper[Unit ->{C} A]): Wrapper[A] = strictMap[Unit ->{C} A, A, C](mx)(t => force[A](t)) // was error when Wrapper was an alias type diff --git a/tests/pos-custom-args/captures/i19751.scala b/tests/pos-custom-args/captures/i19751.scala index 3450535308a5..d1db9c772226 100644 --- a/tests/pos-custom-args/captures/i19751.scala +++ b/tests/pos-custom-args/captures/i19751.scala @@ -1,12 +1,12 @@ import language.experimental.captureChecking -import caps.{cap, Shared, SharedCapability} +import caps.{any, Shared, SharedCapability} trait Ptr[A] trait Scope extends caps.SharedCapability: def allocate(size: Int): Ptr[Unit]^{this} object Scope: - def confined[A](fn: Scope ?->{cap.only[Shared]} A): A = + def confined[A](fn: Scope ?->{any.only[Shared]} A): A = val scope = new Scope: def allocate(size: Int) = new Ptr[Unit] {} fn(using scope) diff --git a/tests/pos-custom-args/captures/i20237-explicit.scala b/tests/pos-custom-args/captures/i20237-explicit.scala index 16b52266bc1b..c81a1b178178 100644 --- a/tests/pos-custom-args/captures/i20237-explicit.scala +++ b/tests/pos-custom-args/captures/i20237-explicit.scala @@ -4,10 +4,10 @@ class Cap extends caps.SharedCapability: def use[T](body: Cap => T) = body(this) class Box[T](body: Cap => T): - def open(cap: Cap) = cap.use(body) + def open(any: Cap) = any.use(body) object Box: - def make[T](body: Cap => T)(cap: Cap): Box[T]^{body} = Box(x => body(x)) + def make[T](body: Cap => T)(any: Cap): Box[T]^{body} = Box(x => body(x)) def main = val givenCap: Cap = new Cap diff --git a/tests/pos-custom-args/captures/i20237.scala b/tests/pos-custom-args/captures/i20237.scala index 80618141998c..5434738fb2bf 100644 --- a/tests/pos-custom-args/captures/i20237.scala +++ b/tests/pos-custom-args/captures/i20237.scala @@ -8,7 +8,7 @@ class Cap2 extends caps.SharedCapability: def use[T](body: Cap2 => T) = body(this) class Box[T](body: Cap ?=> T): - inline def open(using cap: Cap) = cap.use(body) + inline def open(using any: Cap) = any.use(body) object Box: def make[T](body: Cap ?=> T)(using Cap): Box[T]^{body} = Box(body) diff --git a/tests/pos-custom-args/captures/i21868.scala b/tests/pos-custom-args/captures/i21868.scala index b0d83efc03ca..f35e6341b24b 100644 --- a/tests/pos-custom-args/captures/i21868.scala +++ b/tests/pos-custom-args/captures/i21868.scala @@ -12,5 +12,5 @@ trait Abstract1: def f(): U^{C} trait Abstract2: - type C^ <: {cap} + type C^ <: {any} def f(): U^{C} \ No newline at end of file diff --git a/tests/pos-custom-args/captures/i23170.scala b/tests/pos-custom-args/captures/i23170.scala index 886761a74e6e..259a8d219532 100644 --- a/tests/pos-custom-args/captures/i23170.scala +++ b/tests/pos-custom-args/captures/i23170.scala @@ -2,7 +2,7 @@ import caps.* trait A -extension (a: A^{cap.rd}) +extension (a: A^{any.rd}) def await = () -def awaitA[C^ <: {cap.rd}](a: A^{C}) = a.await \ No newline at end of file +def awaitA[C^ <: {any.rd}](a: A^{C}) = a.await \ No newline at end of file diff --git a/tests/pos-custom-args/captures/i24137.scala b/tests/pos-custom-args/captures/i24137.scala index 5a2699fd3d7a..7ec552bca07f 100644 --- a/tests/pos-custom-args/captures/i24137.scala +++ b/tests/pos-custom-args/captures/i24137.scala @@ -1,10 +1,10 @@ //< using options -Ycc-verbose -import caps.{cap, Shared, SharedCapability} +import caps.{any, Shared, SharedCapability} import caps.unsafe.untrackedCaptures open class A -class B(elem1: A^{cap.only[Shared]}, elem2: A^{cap.only[Shared]}): - @untrackedCaptures private var curElem: A^ = elem1 // problem is curElem contibutes cap to B(). +class B(elem1: A^{any.only[Shared]}, elem2: A^{any.only[Shared]}): + @untrackedCaptures private var curElem: A^ = elem1 // problem is curElem contibutes any to B(). def next() = curElem = elem2 diff --git a/tests/pos-custom-args/captures/mark-free-ro.scala b/tests/pos-custom-args/captures/mark-free-ro.scala index 698155fae410..4d505af5e372 100644 --- a/tests/pos-custom-args/captures/mark-free-ro.scala +++ b/tests/pos-custom-args/captures/mark-free-ro.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful} +import caps.{any, Stateful} import caps.unsafe.untrackedCaptures class Test extends Stateful: @@ -7,7 +7,7 @@ class Test extends Stateful: class FreshCtx(level: Int) extends Stateful: this: FreshCtx^ => def detached: Boolean = - val c: FreshCtx^{cap.rd} = ctxStack(level) + val c: FreshCtx^{any.rd} = ctxStack(level) (c eq this) def detached2 = ctxStack(level) eq this diff --git a/tests/pos-custom-args/captures/matrix.scala b/tests/pos-custom-args/captures/matrix.scala index 11c314fa6e51..e00c98f86101 100644 --- a/tests/pos-custom-args/captures/matrix.scala +++ b/tests/pos-custom-args/captures/matrix.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any trait Rdr[T]: def get: T @@ -19,7 +19,7 @@ class Matrix(nrows: Int, ncols: Int) extends IMatrix, Mutable: def mul(x: Matrix, y: Matrix, z: Matrix^): Unit = ??? -def mul1(x: Matrix^{cap.rd}, y: Matrix^{cap.rd}, z: Matrix^): Unit = ??? +def mul1(x: Matrix^{any.rd}, y: Matrix^{any.rd}, z: Matrix^): Unit = ??? def Test(c: Object^): Unit = val m1 = Matrix(10, 10) @@ -29,5 +29,5 @@ def Test(c: Object^): Unit = def f2(): Matrix^ = Matrix(10, 10) - val i1: IMatrix^{cap.rd} = m1 - val i2: IMatrix^{cap.rd} = f2() + val i1: IMatrix^{any.rd} = m1 + val i2: IMatrix^{any.rd} = f2() diff --git a/tests/pos-custom-args/captures/mut-iterator.scala b/tests/pos-custom-args/captures/mut-iterator.scala index a07bc205cfc1..023b777f6ba9 100644 --- a/tests/pos-custom-args/captures/mut-iterator.scala +++ b/tests/pos-custom-args/captures/mut-iterator.scala @@ -1,4 +1,4 @@ -import caps.{cap, Stateful, SharedCapability} +import caps.{any, Stateful, SharedCapability} trait Iterator[T] extends Stateful: def hasNext: Boolean diff --git a/tests/pos-custom-args/captures/mutable-capturing-sharable.scala b/tests/pos-custom-args/captures/mutable-capturing-sharable.scala index ec63d1ada2b0..c2fdd8359208 100644 --- a/tests/pos-custom-args/captures/mutable-capturing-sharable.scala +++ b/tests/pos-custom-args/captures/mutable-capturing-sharable.scala @@ -3,7 +3,7 @@ import language.experimental.separationChecking import caps.* class Logger extends SharedCapability: def log(msg: String): Unit = () -class TracedRef(logger: Logger^{cap.only[SharedCapability]}) extends Stateful: +class TracedRef(logger: Logger^{any.only[SharedCapability]}) extends Stateful: private var _data: Int = 0 update def set(newValue: Int): Unit = logger.log("set") diff --git a/tests/pos-custom-args/captures/mutable-hiding-shared.scala b/tests/pos-custom-args/captures/mutable-hiding-shared.scala index daf46e583305..46ab6a83f1eb 100644 --- a/tests/pos-custom-args/captures/mutable-hiding-shared.scala +++ b/tests/pos-custom-args/captures/mutable-hiding-shared.scala @@ -15,5 +15,5 @@ class Ref(init: Int)(using l: Logger) extends Stateful: def test = given l: Logger = Logger() - val r: Ref^{cap.rd} = Ref(3) + val r: Ref^{any.rd} = Ref(3) r.get() diff --git a/tests/pos-custom-args/captures/overrides.scala b/tests/pos-custom-args/captures/overrides.scala index ac5b9cd9ddc4..af3a3f653879 100644 --- a/tests/pos-custom-args/captures/overrides.scala +++ b/tests/pos-custom-args/captures/overrides.scala @@ -1,4 +1,4 @@ -import caps.cap +import caps.any abstract class Foo: def foo: () => Unit = () => () diff --git a/tests/pos-custom-args/captures/reach-in-results-shared.scala b/tests/pos-custom-args/captures/reach-in-results-shared.scala index cd625810af37..fe2a59e3c60b 100644 --- a/tests/pos-custom-args/captures/reach-in-results-shared.scala +++ b/tests/pos-custom-args/captures/reach-in-results-shared.scala @@ -1,16 +1,16 @@ import language.experimental.captureChecking -import caps.{cap, Shared, SharedCapability} +import caps.{any, Shared, SharedCapability} class IO extends SharedCapability class C def test(io: IO^): Unit = - val f = (x: () ->{cap.only[Shared]} IO^) => x() - val g = (x: () ->{cap.only[Shared]} IO^{cap.only[Shared]}) => x() - val h = (x: () ->{cap.only[Shared]} C^{cap.only[Shared]}) => x() + val f = (x: () ->{any.only[Shared]} IO^) => x() + val g = (x: () ->{any.only[Shared]} IO^{any.only[Shared]}) => x() + val h = (x: () ->{any.only[Shared]} C^{any.only[Shared]}) => x() /* - val _: (x: () ->{cap.only[Shared]} IO^) => IO^{x} = (x: () ->{cap.only[Shared]} IO^) => f(x) - val _: (x: () ->{cap.only[Shared]} IO^) => IO^{x} = f//(x: () => IO^) => f(x) + val _: (x: () ->{any.only[Shared]} IO^) => IO^{x} = (x: () ->{any.only[Shared]} IO^) => f(x) + val _: (x: () ->{any.only[Shared]} IO^) => IO^{x} = f//(x: () => IO^) => f(x) def g(x: IO^ => IO^) = x(io) def h(x: (y: IO^) => IO^) = x(io) diff --git a/tests/pos-custom-args/captures/reach-in-results.scala b/tests/pos-custom-args/captures/reach-in-results.scala index 7a2e77c214f9..d25cdacb36c6 100644 --- a/tests/pos-custom-args/captures/reach-in-results.scala +++ b/tests/pos-custom-args/captures/reach-in-results.scala @@ -1,13 +1,13 @@ import language.experimental.captureChecking -import caps.{cap, Shared} +import caps.{any, Shared} class IO def test(io: IO^): Unit = - val f = (x: () ->{cap.only[Shared]} IO^{cap.only[Shared]}) => x() + val f = (x: () ->{any.only[Shared]} IO^{any.only[Shared]}) => x() - val _: (x: () ->{cap.only[Shared]} IO^{cap.only[Shared]}) => IO^{x} = (x: () ->{cap.only[Shared]} IO^{cap.only[Shared]}) => f(x) - val _: (x: () ->{cap.only[Shared]} IO^{cap.only[Shared]}) => IO^{x} = f//(x: () => IO^) => f(x) + val _: (x: () ->{any.only[Shared]} IO^{any.only[Shared]}) => IO^{x} = (x: () ->{any.only[Shared]} IO^{any.only[Shared]}) => f(x) + val _: (x: () ->{any.only[Shared]} IO^{any.only[Shared]}) => IO^{x} = f//(x: () => IO^) => f(x) /* val f = (x: () => IO^) => x() val _: (x: () => IO^) => IO^{x} = (x: () => IO^) => f(x) diff --git a/tests/pos-custom-args/captures/reaches.scala b/tests/pos-custom-args/captures/reaches.scala index 18d86b6f5def..9cf4d4098545 100644 --- a/tests/pos-custom-args/captures/reaches.scala +++ b/tests/pos-custom-args/captures/reaches.scala @@ -37,7 +37,7 @@ def cons(x: Proc, xs: List[Proc]): List[() ->{x, xs*} Unit] = def addOneProc(consume xs: List[Proc]): List[Proc] = val x: Proc = () => println("hello") val result: List[() ->{x, xs*} Unit] = x :: xs - result // OK, we can widen () ->{x, xs*} Unit to cap here. + result // OK, we can widen () ->{x, xs*} Unit to any here. def compose1[A, B, C](f: A => B, g: B => C): A ->{f, g} C = z => g(f(z)) diff --git a/tests/pos-custom-args/captures/restrict-subsumes.scala b/tests/pos-custom-args/captures/restrict-subsumes.scala index 8061f907e69a..23572613e016 100644 --- a/tests/pos-custom-args/captures/restrict-subsumes.scala +++ b/tests/pos-custom-args/captures/restrict-subsumes.scala @@ -1,10 +1,10 @@ -import caps.{cap, Classifier, SharedCapability} +import caps.{any, Classifier, SharedCapability} trait Read extends SharedCapability, Classifier trait A extends Read -def weird(f: () ->{cap.only[Read]} Unit) = ??? +def weird(f: () ->{any.only[Read]} Unit) = ??? def test(x: A^) = val g = () => println(x) diff --git a/tests/pos-custom-args/captures/ro-array.scala b/tests/pos-custom-args/captures/ro-array.scala index 708331ca547d..65e392213fcf 100644 --- a/tests/pos-custom-args/captures/ro-array.scala +++ b/tests/pos-custom-args/captures/ro-array.scala @@ -11,7 +11,7 @@ class Async extends SharedCapability def f[T](x: T): T & Pure = x.asInstanceOf[T & Pure] def test = - def x(async: Async): Arr[String]^{cap.rd} = + def x(async: Async): Arr[String]^{any.rd} = val y = Arr[String](async, 10) for i <- 0 to 10 do y.set(i, "A") diff --git a/tests/pos-custom-args/captures/scoped-caps.scala b/tests/pos-custom-args/captures/scoped-caps.scala index f266cc65a30b..9ae9df851ae4 100644 --- a/tests/pos-custom-args/captures/scoped-caps.scala +++ b/tests/pos-custom-args/captures/scoped-caps.scala @@ -1,12 +1,13 @@ +import caps.fresh class A class B class S extends caps.SharedCapability def test(io: Object^): Unit = val h2: S -> S = ??? - val _: (x: S) -> S = h2 // direct conversion OK for shared S - val _: (x: S) -> S = (x: S) => h2(x) // eta expansion also ok - val _: (x: S) -> S = + val _: (x: S) -> S^{fresh} = h2 // direct conversion OK for shared S + val _: (x: S) -> S^{fresh} = (x: S) => h2(x) // eta expansion also ok + val _: (x: S) -> S^{fresh} = (x: S) => val y = h2(x) // eta expansion OK y diff --git a/tests/pos-custom-args/captures/sep-compose.scala b/tests/pos-custom-args/captures/sep-compose.scala index 3a56bd789282..ad0d809b05f8 100644 --- a/tests/pos-custom-args/captures/sep-compose.scala +++ b/tests/pos-custom-args/captures/sep-compose.scala @@ -1,10 +1,10 @@ -import caps.cap +import caps.any -def seq1(x: () => Unit, y: () ->{x, cap} Unit): Unit = +def seq1(x: () => Unit, y: () ->{x, any} Unit): Unit = x(); y() -def seq2(x: () => Unit)(y: () ->{x, cap} Unit): Unit = +def seq2(x: () => Unit)(y: () ->{x, any} Unit): Unit = x(); y() def test(io: Object^, a: Object^{io}): Unit = diff --git a/tests/pos-custom-args/captures/sep-eq.scala b/tests/pos-custom-args/captures/sep-eq.scala index 94a64cc0c8f4..9c413d6a06ce 100644 --- a/tests/pos-custom-args/captures/sep-eq.scala +++ b/tests/pos-custom-args/captures/sep-eq.scala @@ -1,12 +1,12 @@ import caps.Mutable -import caps.cap +import caps.any extension (x: Object^) - infix def eql (y: Object^{x, cap}): Boolean = x eq y + infix def eql (y: Object^{x, any}): Boolean = x eq y -def eql1(x: Object^, y: Object^{x, cap}): Boolean = x eql y -def eql2(x: Object^)(y: Object^{x, cap}): Boolean = x eql y +def eql1(x: Object^, y: Object^{x, any}): Boolean = x eql y +def eql2(x: Object^)(y: Object^{x, any}): Boolean = x eql y class LLI extends Object: this: LLI^ => diff --git a/tests/pos-custom-args/captures/sep-pairs.scala b/tests/pos-custom-args/captures/sep-pairs.scala index ad22df412e0d..0bf677668122 100644 --- a/tests/pos-custom-args/captures/sep-pairs.scala +++ b/tests/pos-custom-args/captures/sep-pairs.scala @@ -1,5 +1,5 @@ import caps.Mutable -import caps.cap +import caps.any class Ref extends Mutable: var x = 0 diff --git a/tests/pos-custom-args/captures/shared-capability.scala b/tests/pos-custom-args/captures/shared-capability.scala index 78214dc15348..6640474a45d6 100644 --- a/tests/pos-custom-args/captures/shared-capability.scala +++ b/tests/pos-custom-args/captures/shared-capability.scala @@ -6,6 +6,6 @@ class Async extends SharedCapability def test1(a: Async): Object^ = a // OK -def test2(a: Async^): Object^ = a // also OK since Async^ means Async^{cap.only[SharedCaoability]} +def test2(a: Async^): Object^ = a // also OK since Async^ means Async^{any.only[SharedCaoability]} diff --git a/tests/pos-custom-args/captures/try.scala b/tests/pos-custom-args/captures/try.scala index c88c842babc5..acaff8e2fd1d 100644 --- a/tests/pos-custom-args/captures/try.scala +++ b/tests/pos-custom-args/captures/try.scala @@ -2,7 +2,7 @@ import annotation.retains import language.experimental.erasedDefinitions class CT[E <: Exception] -type CanThrow[E <: Exception] = CT[E] @retains[caps.cap.type] +type CanThrow[E <: Exception] = CT[E] @retains[caps.any.type] infix type throws[R, E <: Exception] = (erased CanThrow[E]) ?-> R diff --git a/tests/pos-custom-args/captures/unsafe-captures.scala b/tests/pos-custom-args/captures/unsafe-captures.scala index 1a40b4174f6e..af6e9d3c295c 100644 --- a/tests/pos-custom-args/captures/unsafe-captures.scala +++ b/tests/pos-custom-args/captures/unsafe-captures.scala @@ -2,7 +2,7 @@ import annotation.unchecked.uncheckedCaptures import caps.unsafe.untrackedCaptures class LL[+A] private (@untrackedCaptures private var lazyState: (() => LL.State[A]^) @uncheckedCaptures): - private val res = lazyState() // without unchecked captures we get a van't unbox cap error + private val res = lazyState() // without unchecked captures we get a van't unbox any error object LL: diff --git a/tests/pos-custom-args/captures/use-alternatives.scala b/tests/pos-custom-args/captures/use-alternatives.scala index 73a3fb725035..90c52db6a07d 100644 --- a/tests/pos-custom-args/captures/use-alternatives.scala +++ b/tests/pos-custom-args/captures/use-alternatives.scala @@ -1,5 +1,5 @@ import language.experimental.captureChecking -import caps.{cap, use} +import caps.{any, use} def foo[C^](xs: List[() ->{C} Unit]): Unit = var x: () ->{C} Unit = xs.head diff --git a/tests/pos-special/stdlib/Test2.scala b/tests/pos-special/stdlib/Test2.scala index e0d9a1491516..fd1ce4e1f590 100644 --- a/tests/pos-special/stdlib/Test2.scala +++ b/tests/pos-special/stdlib/Test2.scala @@ -6,7 +6,7 @@ import caps.unsafe.unsafeAssumeSeparate object Test { - def seqOps(xs: Seq[Int]) = { // try with Seq[Int]^{cap} + def seqOps(xs: Seq[Int]) = { // try with Seq[Int]^{any} val strPlusInt: (String, Int) => String = _ + _ val intPlusStr: (Int, String) => String = _ + _ val isEven: Int => Boolean = _ % 2 == 0 diff --git a/tests/pos/caps-universal.scala b/tests/pos/caps-universal.scala index fc9942c2a99a..05e814b148ed 100644 --- a/tests/pos/caps-universal.scala +++ b/tests/pos/caps-universal.scala @@ -3,7 +3,7 @@ import annotation.retains val id: Int -> Int = (x: Int) => x val foo: Int => Int = id -val bar: (Int -> Int) @retains[caps.cap.type] = foo +val bar: (Int -> Int) @retains[caps.any.type] = foo diff --git a/tests/pos/cc-use-alternatives.scala b/tests/pos/cc-use-alternatives.scala index fcfff817a819..5501250abff6 100644 --- a/tests/pos/cc-use-alternatives.scala +++ b/tests/pos/cc-use-alternatives.scala @@ -1,7 +1,7 @@ //> using options -source 3.7 import language.experimental.captureChecking // no separation checking -import caps.{cap, use} +import caps.{any, use} def foo1(@use xs: List[() => Unit]): Unit = var x: () ->{xs*} Unit = xs.head diff --git a/tests/run-custom-args/captures/colltest5/CollectionStrawManCC5_1.scala b/tests/run-custom-args/captures/colltest5/CollectionStrawManCC5_1.scala index 67ba4bf01984..8c2a587959b4 100644 --- a/tests/run-custom-args/captures/colltest5/CollectionStrawManCC5_1.scala +++ b/tests/run-custom-args/captures/colltest5/CollectionStrawManCC5_1.scala @@ -5,7 +5,7 @@ import Predef.{augmentString as _, wrapString as _, *} import scala.reflect.ClassTag import annotation.unchecked.{uncheckedVariance, uncheckedCaptures} import annotation.tailrec -import caps.cap +import caps.any import caps.unsafe.{unsafeAssumeSeparate, untrackedCaptures} import language.experimental.captureChecking @@ -33,7 +33,7 @@ object CollectionStrawMan5 { /** Base trait for instances that can construct a collection from an iterable */ trait FromIterable { type C[X] <: Iterable[X]^ - def fromIterable[B](it: Iterable[B]^{this, cap}): C[B]^{it} + def fromIterable[B](it: Iterable[B]^{this, any}): C[B]^{it} } type FromIterableOf[+CC[X] <: Iterable[X]^] = FromIterable { @@ -64,7 +64,7 @@ object CollectionStrawMan5 { trait SeqFactory extends IterableFactory { type C[X] <: Seq[X] - def fromIterable[B](it: Iterable[B]^{this, cap}): C[B] + def fromIterable[B](it: Iterable[B]^{this, any}): C[B] } /** Base trait for strict collections */ @@ -108,7 +108,7 @@ object CollectionStrawMan5 { with IterablePolyTransforms[A] with IterableMonoTransforms[A] { // sound bcs of VarianceNote type Repr = C[A] @uncheckedVariance - protected def fromLikeIterable(coll: Iterable[A] @uncheckedVariance ^ {this, cap}): Repr @uncheckedVariance ^{coll} = + protected def fromLikeIterable(coll: Iterable[A] @uncheckedVariance ^ {this, any}): Repr @uncheckedVariance ^{coll} = fromIterable(coll) } @@ -137,7 +137,7 @@ object CollectionStrawMan5 { this: IterableMonoTransforms[A]^ => type Repr protected def coll: Iterable[A]^{this} - protected def fromLikeIterable(coll: Iterable[A] @uncheckedVariance ^ {this, cap}): Repr^{coll} + protected def fromLikeIterable(coll: Iterable[A] @uncheckedVariance ^ {this, any}): Repr^{coll} def filter(p: A => Boolean): Repr^{this, p} = fromLikeIterable(View.Filter(coll, p)) def partition(p: A => Boolean): (Repr^{this, p}, Repr^{this, p}) = { @@ -156,7 +156,7 @@ object CollectionStrawMan5 { this: IterablePolyTransforms[A]^ => type C[A] protected def coll: Iterable[A]^{this} - def fromIterable[B](coll: Iterable[B]^{this, cap}): C[B]^{coll} + def fromIterable[B](coll: Iterable[B]^{this, any}): C[B]^{coll} def map[B](f: A => B): C[B]^{this, f} = fromIterable(View.Map(coll, f)) def flatMap[B](f: A => IterableOnce[B]^): C[B]^{this, f} = fromIterable(View.FlatMap(coll, f)) def ++[B >: A](xs: IterableOnce[B]^): C[B]^{this, xs} = fromIterable(View.Concat(coll, xs)) @@ -410,7 +410,7 @@ object CollectionStrawMan5 { this: View[A]^ => type C[X] = View[X]^{this} override def view: this.type = this - override def fromIterable[B](c: Iterable[B]^{this, cap}): View[B]^{this, c} = { + override def fromIterable[B](c: Iterable[B]^{this, any}): View[B]^{this, c} = { c match { case c: View[B] => c case _ => View.fromIterator(c.iterator) @@ -533,7 +533,7 @@ object CollectionStrawMan5 { } -1 } - def filter(p: A ->{cap, this} Boolean): Iterator[A]^{this, p} = new Iterator[A] { + def filter(p: A ->{any, this} Boolean): Iterator[A]^{this, p} = new Iterator[A] { @untrackedCaptures private var hd: A = compiletime.uninitialized @untrackedCaptures private var hdDefined: Boolean = false diff --git a/tests/run-custom-args/captures/colltest5/Test_2.scala b/tests/run-custom-args/captures/colltest5/Test_2.scala index 2bde8cb5a885..49fc89284644 100644 --- a/tests/run-custom-args/captures/colltest5/Test_2.scala +++ b/tests/run-custom-args/captures/colltest5/Test_2.scala @@ -6,7 +6,7 @@ object Test { import colltest5.strawman.collections.* import CollectionStrawMan5.* - def seqOps(xs: Seq[Int]) = { // try with Seq[Int]^{cap} + def seqOps(xs: Seq[Int]) = { // try with Seq[Int]^{any} val strPlusInt: (String, Int) => String = _ + _ val intPlusStr: (Int, String) => String = _ + _ val isEven: Int => Boolean = _ % 2 == 0 diff --git a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala index 4cfb23e229ac..e54332a74d4f 100644 --- a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala +++ b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala @@ -43,8 +43,10 @@ val experimentalDefinitionInLibrary = Set( "scala.caps.Read", "scala.caps.internal", "scala.caps.internal$", - "scala.caps.cap", - "scala.caps.cap$", + "scala.caps.any", + "scala.caps.any$", + "scala.caps.fresh", + "scala.caps.fresh$", "scala.caps.unsafe", "scala.caps.unsafe$", "scala.caps.use", @@ -52,6 +54,7 @@ val experimentalDefinitionInLibrary = Set( "scala.caps.package$package$.freeze", "scala.caps.package$package$.Exclusive", "scala.caps.package$package$.Shared", + "scala.caps.package$package$.cap", //// New feature: Macro annotations "scala.annotation.MacroAnnotation", From 97ce2b9c9cb31664e536c33cae3062fcd9c60efd Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 15 Jan 2026 16:39:40 +0100 Subject: [PATCH 3/3] Fixes to maps in Setup - Drop ToResultInResults - Move its functionality to separate methods in Setup - Implement dealias suppression logic for capset arguments. This is needed to be able to express referring with `fresh` to enclosing method types that don't immediately have the type containing the `fresh` as their result type. # Conflicts: # tests/neg/i20481.check --- .../src/dotty/tools/dotc/cc/CCState.scala | 25 +-- .../src/dotty/tools/dotc/cc/Capability.scala | 96 ++--------- .../src/dotty/tools/dotc/cc/CaptureOps.scala | 47 +++--- .../src/dotty/tools/dotc/cc/CaptureSet.scala | 28 ++-- .../dotty/tools/dotc/cc/CheckCaptures.scala | 2 +- compiler/src/dotty/tools/dotc/cc/Setup.scala | 154 ++++++++++-------- .../dotty/tools/dotc/core/Substituters.scala | 9 +- .../dotty/tools/dotc/core/TypeComparer.scala | 6 +- .../src/dotty/tools/dotc/core/Types.scala | 18 +- .../tools/dotc/printing/PlainPrinter.scala | 2 +- .../captures/capt-depfun.check | 9 +- .../captures/cc-existential-conformance.check | 68 ++++---- .../captures/cc-existential-conformance.scala | 6 +- .../captures/existential-mapping.check | 95 +++++------ .../captures/existential-mapping.scala | 2 +- .../captures/outer-fresh.check | 44 +++++ .../captures/outer-fresh.scala | 20 +++ .../captures/refine-reach-shallow.check | 69 ++++++++ .../captures/refine-reach-shallow.scala | 3 +- .../captures/scoped-caps.check | 59 ++++--- .../captures/scoped-caps2.check | 2 +- .../captures/sep-curried-par.check | 2 +- .../captures/closure-avoidance.scala | 1 - .../captures/infer-exists.scala | 6 +- .../{test.scala => ref-of-proc.scala} | 0 25 files changed, 427 insertions(+), 346 deletions(-) create mode 100644 tests/neg-custom-args/captures/outer-fresh.check create mode 100644 tests/neg-custom-args/captures/outer-fresh.scala create mode 100644 tests/neg-custom-args/captures/refine-reach-shallow.check rename tests/pos-custom-args/captures/{test.scala => ref-of-proc.scala} (100%) diff --git a/compiler/src/dotty/tools/dotc/cc/CCState.scala b/compiler/src/dotty/tools/dotc/cc/CCState.scala index 12af5d2fdf6a..4bb2e4816b35 100644 --- a/compiler/src/dotty/tools/dotc/cc/CCState.scala +++ b/compiler/src/dotty/tools/dotc/cc/CCState.scala @@ -23,22 +23,23 @@ class CCState: // ------ BiTypeMap adjustment ----------------------- - private var myMapFutureElems = true + private var myMapVars = true - /** When mapping a capture set with a BiTypeMap, should we create a BiMapped set + /** When mapping a capture set variable with a BiTypeMap, should we create a BiMapped set * so that future elements can also be mapped, and elements added to the BiMapped - * are back-propagated? Turned off when creating capture set variables for the - * first time, since we then do not want to change the binder to the original type - * without capture sets when back propagating. Error case where this shows: - * pos-customargs/captures/lists.scala, method m2c. + * are back-propagated? Or should we return the capture set as is? Turned off when + * creating capture set variables for the first time, since we then do not want to + * change the binder to the original type without capture sets when back propagating. + * Error cases where this shows: pos-customargs/captures/lists.scala, method m2c, and + * pos-customargs/captures/infer-exists.scala, */ - def mapFutureElems(using Context) = myMapFutureElems + def mapVars(using Context) = myMapVars - /** Don't map future elements in this `op` */ - inline def withoutMappedFutureElems[T](op: => T)(using Context): T = - val saved = mapFutureElems - myMapFutureElems = false - try op finally myMapFutureElems = saved + /** Don't map capset variables with BiTypeMaps during this `op` */ + inline def withNoVarsMapped[T](op: => T)(using Context): T = + val saved = mapVars + myMapVars = false + try op finally myMapVars = saved // ------ Iteration count of capture checking run diff --git a/compiler/src/dotty/tools/dotc/cc/Capability.scala b/compiler/src/dotty/tools/dotc/cc/Capability.scala index 92d8b3d2c999..736d4a256e54 100644 --- a/compiler/src/dotty/tools/dotc/cc/Capability.scala +++ b/compiler/src/dotty/tools/dotc/cc/Capability.scala @@ -1058,16 +1058,14 @@ object Capabilities: case t @ CapturingType(_, _) => mapOver(t) case t @ AnnotatedType(parent, ann: RetainingAnnotation) - if ann.isStrict && ann.toCaptureSet.containsGlobalCapDerivs => + if ann.isStrict && ann.toCaptureSet.elems.exists(_.core.isInstanceOf[GlobalCap]) => // Applying `this` can cause infinite recursion in some cases during printing. // scalac -Xprint:all tests/pos/i23885/S_1.scala tests/pos/i23885/S_2.scala mapOver(CapturingType(this(parent), ann.toCaptureSet)) case t @ AnnotatedType(parent, ann) => t.derivedAnnotatedType(this(parent), ann) case t @ defn.RefinedFunctionOf(mt) => - if ccConfig.newScheme - then t.derivedRefinedType(refinedInfo = mapOver(mt)) - else t + t.derivedRefinedType(refinedInfo = mapOver(mt)) case _ => mapFollowingAliases(t) @@ -1100,11 +1098,11 @@ object Capabilities: /** Maps caps.any to LocalCap instances. GlobalToLocalCap is a BiTypeMap since we don't want to * freeze a set when it is mapped. On the other hand, we do not want LocalCap * values to flow back to caps.any since that would fail disallowRootCapability - * tests elsewhere. We therefore use `withoutMappedFutureElems` to prevent + * tests elsewhere. We therefore use `withNoVarsMapped` to prevent * the map being installed for future use. */ def globalCapToLocal(tp: Type, origin: Origin)(using Context): Type = - ccState.withoutMappedFutureElems: + ccState.withNoVarsMapped: GlobalCapToLocal(origin)(tp) /** Maps all LocalCap instances to caps.any */ @@ -1220,36 +1218,26 @@ object Capabilities: class ToResult(localResType: Type, mt: MethodicType, sym: Symbol, fail: Message => Unit)(using Context) extends CapMap: - def apply(t: Type) = t match - case defn.FunctionNOf(args, res, contextual) if t.typeSymbol.name.isImpureFunction && !(ccConfig.newScheme) => - if variance > 0 then - super.mapOver: - defn.FunctionNOf(args, res, contextual) - .capturing(ResultCap(mt).singletonCaptureSet) - else mapOver(t) - case _ => - mapOver(t) + def apply(t: Type) = mapOver(t) override def mapCapability(c: Capability, deep: Boolean) = c match - case c: (LocalCap | GlobalCap) => + case c: LocalCap => if variance > 0 then - c match - case c: LocalCap => - if sym.isAnonymousFunction && c.classifier.derivesFrom(defn.Caps_Unscoped) then - c - else if sym.exists && !c.ccOwner.isContainedIn(sym.skipAnonymousOwners) then - //println(i"not mapping $c with ${c.ccOwner} in $sym") - c - else - ResultCap(mt).setOrigin(c) - case _ => - if c == GlobalFresh || !(ccConfig.newScheme) then ResultCap(mt) else c + if sym.isAnonymousFunction && c.classifier.derivesFrom(defn.Caps_Unscoped) then + c + else if sym.exists && !c.ccOwner.isContainedIn(sym.skipAnonymousOwners) then + //println(i"not mapping $c with ${c.ccOwner} in $sym") + c + else + ResultCap(mt).setOrigin(c) else if variance == 0 then fail(em"""$localResType captures the root capability `any` in invariant position. - |This capability cannot be converted to an existential in the result type of a function.""") - // we accept variance < 0, and leave the `any` as it is + |This capability cannot be converted to a fresh capability in the result type of a function.""") + // we accept variance < 0, and leave the `any` as it is c c + case GlobalFresh if variance > 0 => + ResultCap(mt) // if variance <= 0 we leave the fresh to be flagged later case _ => super.mapCapability(c, deep) @@ -1282,54 +1270,4 @@ object Capabilities: */ def toResult(tp: Type, mt: MethodicType, sym: Symbol, fail: Message => Unit)(using Context): Type = ToResult(tp, mt, sym, fail)(tp) - - /** Map global roots in function results to result roots. Also, - * map roots in the types of def methods that are parameterless - * or have only type parameters. - */ - def toResultInResults(sym: Symbol, fail: Message => Unit, keepAliases: Boolean = false)(tp: Type)(using Context): Type = - val m = new TypeMap with FollowAliasesMap: - def apply(t: Type): Type = t match - case rt @ defn.RefinedFunctionOf(mt) => - rt.derivedRefinedType(refinedInfo = - if rt.isInstanceOf[InferredRefinedType] - then mapOver(mt) // Don't map to Result for dependent function types created from non-dependent ones in inferred types - else apply(mt)) - case t @ AppliedType(tycon, args) - if defn.isNonRefinedFunction(t) && args.last.containsFresh && ccConfig.newScheme => - // Convert to dependent function so that we have a binder for `fresh` in result type. - apply( - depFun(args.init, args.last, - isContextual = defn.isContextFunctionClass(tycon.classSymbol))) - case t: MethodType if variance > 0 && t.marksExistentialScope => - val t1 = mapOver(t).asInstanceOf[MethodType] - t1.derivedLambdaType(resType = toResult(t1.resType, t1, sym, fail)) - case CapturingType(parent, refs) => - t.derivedCapturingType(this(parent), refs) - case t: (LazyRef | TypeVar) => - mapConserveSuper(t) - case _ => - try - if keepAliases then mapOver(t) - else mapFollowingAliases(t) - catch case ex: AssertionError => - println(i"error while mapping $t") - throw ex - m(tp) match - case tp1: ExprType if sym.is(Method, butNot = Accessor) => - // Map the result of parameterless `def` methods. - tp1.derivedExprType(toResult(tp1.resType, tp1, sym, fail)) - case tp1: PolyType if !tp1.resType.isInstanceOf[MethodicType] => - // Map also the result type of method with only type parameters. - // This way, the `^` in the following method will be mapped to a `ResultCap`: - // ``` - // object Buffer: - // def empty[T]: Buffer[T]^ - // ``` - // This is more desirable than interpreting `^` as a `^{any}` at the level of `Buffer.empty` - // in most cases. - tp1.derivedLambdaType(resType = toResult(tp1.resType, tp1, sym, fail)) - case tp1 => tp1 - end toResultInResults - end Capabilities diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala index 861ae1e027a7..997334f7d4fc 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala @@ -105,7 +105,12 @@ extension (tp: Type) /** A list of capabilities of a retained set. */ def retainedElements(using Context): List[Capability] = - retainedElementsRaw.map(_.toCapability) + retainedElementsRaw.flatMap: elem => + elem match + case CapturingType(parent, refs) if parent.derivesFrom(defn.Caps_CapSet) => + refs.elems.toList + case _ => + elem.toCapability :: Nil /** Is this type a Capability that can be tracked? * This is true for @@ -456,20 +461,31 @@ extension (tp: Type) tp end withReachCaptures - /** Does this type contain no-flip covariant occurrences of `any`? */ - def containsCap(using Context): Boolean = - val acc = new TypeAccumulator[Boolean]: + private def containsGlobal(c: GlobalCap, directly: Boolean)(using Context): Boolean = + val search = new TypeAccumulator[Boolean]: def apply(x: Boolean, t: Type) = - x - || variance > 0 && t.dealiasKeepAnnots.match - case t @ CapturingType(p, cs) if cs.containsGlobalCapDerivs => + if x then true + else if variance <= 0 then false + else if directly && defn.isFunctionSymbol(t.typeSymbol) then false + else t match + case CapturingType(_, refs) if refs.elems.exists(_.core == c) => true case t @ AnnotatedType(parent, ann) => // Don't traverse annotations, which includes capture sets this(x, parent) case _ => foldOver(x, t) - acc(false, tp) + search(false, tp) + + /** Does this type contain no-flip covariant occurrences of `any`? */ + def containsGlobalAny(using Context): Boolean = + containsGlobal(GlobalAny, directly = false) + + /** Does `tp` contain contain no-flip covariant occurrences of `fresh` directly, + * which are not in the result of some function type? + */ + def containsGlobalFreshDirectly(using Context): Boolean = + containsGlobal(GlobalFresh, directly = true) def refinedOverride(name: Name, rinfo: Type)(using Context): Type = RefinedType.precise(tp, name, rinfo) @@ -502,20 +518,7 @@ extension (tp: Type) if tp.isArrayUnderStrictMut then defn.Caps_Unscoped else tp.classSymbols.map(_.classifier).foldLeft(defn.AnyClass)(leastClassifier) - /** Does `tp` contain a `fresh` directly, which is not in the result of some function type? - */ - def containsFresh(using Context): Boolean = - val search = new TypeAccumulator[Boolean]: - def apply(x: Boolean, tp: Type): Boolean = - if x then true - else if defn.isFunctionType(tp) then false - else tp match - case CapturingType(parent, refs) => - refs.elems.exists(_.core == GlobalFresh) || apply(x, parent) - case _ => foldOver(x, tp) - search(false, tp) - -extension (tp: MethodType) +extension (tp: MethodOrPoly) /** A method marks an existential scope unless it is the prefix of a curried method */ def marksExistentialScope(using Context): Boolean = !tp.resType.isInstanceOf[MethodOrPoly] diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala index 67502f119d4c..57ad2237917b 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala @@ -143,9 +143,6 @@ sealed abstract class CaptureSet extends Showable: case _: LocalCap => true case _ => false - final def containsGlobalCapDerivs(using Context) = - elems.exists(_.core.isInstanceOf[GlobalCap]) - final def isReadOnly(using Context): Boolean = elems.forall(_.isReadOnly) @@ -392,9 +389,13 @@ sealed abstract class CaptureSet extends Showable: /** Capture set obtained by applying `tm` to all elements of the current capture set * and joining the results. If the current capture set is a variable we handle this as * follows: - * - If the map is a BiTypeMap, the same transformation is applied to all - * future additions of new elements. We try to fuse with previous maps to - * avoid long paths of BiTypeMapped sets. + * - If the map is a BiTypeMap, and CCState.mapVars is true, + * the same transformation is applied to all future additions of new elements. + * We try to fuse with previous maps to avoid long paths of BiTypeMapped sets. + * - If the map is a BiTypeMap, and CCState.mapVars is false, + * we return the original capture set. In this case any elements that are + * already in the set must be invariant under the mapping. This mode is + * necessary for bootstrap when we create capset variables the first time. * - If the map is some other map that maps the current set of elements * to itself, return the current var. We implicitly assume that the map * will also map any elements added in the future to themselves. This assumption @@ -410,7 +411,7 @@ sealed abstract class CaptureSet extends Showable: if isConst then if mappedElems == elems then this else Const(mappedElems) - else if ccState.mapFutureElems then + else if ccState.mapVars then def unfused = if debugVars then try BiMapped(asVar, tm, mappedElems) @@ -423,7 +424,9 @@ sealed abstract class CaptureSet extends Showable: case Some(fused: BiTypeMap) => BiMapped(self.source, fused, mappedElems) case _ => unfused case _ => unfused - else this + else + assert(mappedElems == elems) + this case tm: IdentityCaptRefMap => this case tm: AvoidMap if this.isInstanceOf[HiddenSet] => @@ -928,7 +931,7 @@ object CaptureSet: this else if isUniversal || computingApprox then universal - else if containsGlobalCapDerivs && isReadOnly then + else if elems.exists(_.core == GlobalAny) && isReadOnly then shared else computingApprox = true @@ -1091,8 +1094,8 @@ object CaptureSet: // ----------- Longest path recording ------------------------- - /** Summarize for set displaying in a path */ - def summarize: String = getClass.toString + /** Summarize set when displaying a propagation path */ + def summarize(using Context): String = getClass.toString /** The length of the path of DerivedVars ending in this set */ def pathLength: Int = source match @@ -1132,7 +1135,6 @@ object CaptureSet: try reporting.trace(i"prop backwards $elem from $this # $id to $source # ${source.id} via $summarize"): source.tryInclude(bimap.inverse.mapCapability(elem), this) - .showing(i"propagating new elem $elem backward from $this/$id to $source = $result", captDebug) catch case ex: AssertionError => println(i"fail while prop backwards tryInclude $elem of ${elem.getClass} from $this # $id / ${this.summarize} to $source # ${source.id}") throw ex @@ -1151,7 +1153,7 @@ object CaptureSet: override def isMaybeSet: Boolean = bimap.isInstanceOf[MaybeMap] override def toString = s"BiMapped$id($source, elems = $elems)" - override def summarize = bimap.getClass.toString + override def summarize(using Context) = bimap.summarize override def repr(using Context): Name = source.repr end BiMapped diff --git a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala index ff233f771a6c..cebdf5d68d45 100644 --- a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala +++ b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala @@ -880,7 +880,7 @@ class CheckCaptures extends Recheck, SymTransformer: // See [[MethodTypeCompanion.adaptParamInfo]]. capt.println(i"charging deep capture set of $arg: ${argType} = ${argType.deepCaptureSet}") markFree(argType.deepCaptureSet, arg) - if formal.containsCap then + if formal.containsGlobalAny then sepCheckFormals(arg) = instantiatedFormal argType diff --git a/compiler/src/dotty/tools/dotc/cc/Setup.scala b/compiler/src/dotty/tools/dotc/cc/Setup.scala index 5b7b2331c5e6..d9d3c6745add 100644 --- a/compiler/src/dotty/tools/dotc/cc/Setup.scala +++ b/compiler/src/dotty/tools/dotc/cc/Setup.scala @@ -189,6 +189,20 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: else symd end transformSym + /** Apply toResult to the return types of def methods, so that local `any` capabilties + * are mapped to `fresh` in the return type of the resulting methodic types. + */ + def toResultInReturnType(sym: Symbol, fail: Message => Unit)(tp: Type)(using Context): Type = tp match + case tp: ExprType if sym.is(Method, butNot = Accessor) => + // Map the result of parameterless `def` methods. + tp.derivedExprType(toResult(tp.resType, tp, sym, fail)) + case tp: MethodOrPoly => + tp.derivedLambdaType(resType = + if tp.marksExistentialScope + then toResult(tp.resType, tp, sym, fail) + else toResultInReturnType(sym, fail)(tp.resType)) + case _ => tp + private trait SetupTypeMap extends FollowAliasesMap: private var isTopLevel = true @@ -221,12 +235,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: case AppliedType(`tycon`, args0) => args0.last ne args.last case _ => false if expand then - val (fn: RefinedType) = depFun( - args.init, args.last, - isContextual = defn.isContextFunctionClass(tycon.classSymbol)) - .showing(i"add function refinement $tp ($tycon, ${args.init}, ${args.last}) --> $result", capt) - .runtimeChecked - RefinedType.inferred(fn.parent, fn.refinedName, fn.refinedInfo) + depFun( + args.init, args.last, + isContextual = defn.isContextFunctionClass(tycon.classSymbol) + ).showing(i"add function refinement $tp ($tycon, ${args.init}, ${args.last}) --> $result", capt) else tp case _ => tp @@ -318,10 +330,9 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: apply(parent) case tp: TypeLambda => // Don't recurse into parameter bounds, just cleanup any stray retains annotations - ccState.withoutMappedFutureElems: - tp.derivedLambdaType( - paramInfos = tp.paramInfos.mapConserve(_.dropAllRetains.bounds), - resType = this(tp.resType)) + tp.derivedLambdaType( + paramInfos = tp.paramInfos.mapConserve(_.dropAllRetains.bounds), + resType = this(tp.resType)) case tp @ RefinedType(parent, rname, rinfo) => val saved = refiningNames refiningNames += rname @@ -336,10 +347,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: end mapInferred try - val tp1 = mapInferred(inCaptureRefinement = false)(tp) - val tp2 = toResultInResults(NoSymbol, _ => assert(false))(tp1) - if tp2 ne tp then capt.println(i"expanded inferred in ${ctx.owner}: $tp --> $tp1 --> $tp2") - tp2 + ccState.withNoVarsMapped: + mapInferred(inCaptureRefinement = false)(tp) + .tap: tp1 => + if tp1 ne tp then capt.println(i"expanded inferred in ${ctx.owner}: $tp --> $tp1") catch case ex: AssertionError => println(i"error while mapping inferred $tp") throw ex @@ -373,12 +384,9 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: tp.derivedTypeBounds(stripImpliedCaptureSet(tp.lo), stripImpliedCaptureSet(tp.hi)) case _ => tp - object toCapturing extends DeepTypeMap, SetupTypeMap: + object toCapturing extends DeepTypeMap, SetupTypeMap { override def toString = "transformExplicitType" - var keepFunAliases = true - var keptFunAliases = false - /** Expand $throws aliases. This is hard-coded here since $throws aliases in stdlib * are defined with `?=>` rather than `?->`. * We also have to add a capture set to the last expanded throws alias. I.e. @@ -418,21 +426,42 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: case _ => tp - /** Map references to capability classes C to C^{any}, or (if Mutable) - * tp C^{any.rd}. Normalize captures and map to dependent functions. + /** If `t` is an alias of some other proper type, map the alias. If that + * gives a different type, return that type otherwise return `t` itself. + * Always return `t` itself if it is a type constructor. */ - def defaultApply(t: Type) = - if t.derivesFromCapability - && t.typeParams.isEmpty - && !t.isSingleton - && (!sym.isConstructor || (t ne tp.finalResultType)) - // Don't add ^ to result types of class constructors deriving from Capability + def mappedDealias(t: Type) = + val t1 = t.dealiasKeepAnnotsAndOpaques + if (t1 ne t) && !t1.isLambdaSub + // We have to exclude higher-kinded type aliases since these might undermine + // the no-aliasing strategy. E.g. for + // + // type G[cs^] = () -> A^{cs} + // + // we don't want to dealias G[{fresh}], but if we can de-alias type constructors + // then G gets dealiased to `[cs^] =>> () => A^{cs}` and then G[{fresh}] gets + // mapped to `() => A^{fresh}` by beta reduction rule. Test case in outer-fresh.scala. then - normalizeCaptures(mapOver(t)) match - case t1 @ CapturingType(_, _) => t1 - case t1 => CapturingType(t1, CaptureSet.CSImpliedByCapability(t1, sym, variance), boxed = false) - else normalizeCaptures(mapFollowingAliases(t)) + val t2 = apply(t1) + if t2 ne t1 then t2 + else t + else t + def mapAndMaybeDealias(t: Type): Type = mapOver(t) match + case t1 @ AppliedType(tycon, args) + if defn.isNonRefinedFunction(t1) && args.last.containsGlobalFreshDirectly => + // Convert to dependent function so that we have a binder for `fresh` in result type. + apply( + depFun(args.init, args.last, + isContextual = defn.isContextFunctionClass(tycon.classSymbol))) + case t1 @ CapturingType(parent, refs) => + t1.derivedCapturingType(stripImpliedCaptureSet(mapAndMaybeDealias(parent)), refs) + case t1 => + if t1.containsGlobalFreshDirectly then t1 else mappedDealias(t1) + + /** Map references to capability classes C to C^{any}, or (if Mutable) + * tp C^{any.rd}. Normalize captures and map to dependent functions. + */ def innerApply(t: Type) = t match case t @ CapturingType(parent, refs) => @@ -455,45 +484,37 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: else t.derivedAnnotatedType(this(parent), ann) case throwsAlias(res, exc) => this(expandThrowsAlias(res, exc, Nil)) - case t @ AppliedType(tycon, args) - if defn.isNonRefinedFunction(t) - && !defn.isFunctionSymbol(t.typeSymbol) && (t.dealias ne tp) => - if keepFunAliases then - // Hold off with dealising and expand in a second pass. - // This is necessary to bind ResultCap instances to the right method binder. - keptFunAliases = true - mapOver(t) - else - // In the second pass, map the alias - apply(t.dealias) + case t: MethodType if variance > 0 && t.marksExistentialScope => + val t1 = mapOver(t).asInstanceOf[MethodType] + if t1.resType.containsGlobalFreshDirectly then + t1.derivedLambdaType(resType = mappedDealias(toResult(t1.resType, t1, sym, fail))) + else t1 + case t: (LazyRef | TypeVar) => + mapConserveSuper(t) case t => - defaultApply(t) - end toCapturing - - def transform(tp: Type): Type = - val tp1 = toCapturing(tp) - val tp2 = toResultInResults(sym, fail, toCapturing.keepFunAliases)(tp1) - val snd = if toCapturing.keepFunAliases then "" else " 2nd time" - if tp2 ne tp then capt.println(i"expanded explicit$snd in ${ctx.owner}: $tp --> $tp1 --> $tp2") - tp2 - - val tp1 = transform(tp) - val tp2 = - if toCapturing.keptFunAliases then - toCapturing.keepFunAliases = false - transform(tp1) - else tp1 - val tp3 = - if sym.isType then stripImpliedCaptureSet(tp2) - else tp2 - if tp3.containsFresh then + val t1 = normalizeCaptures(mapAndMaybeDealias(t)) + if t.derivesFromCapability + && t.typeParams.isEmpty + && !t.isSingleton + && (!sym.isConstructor || (t ne tp.finalResultType)) + // Don't add ^ to result types of class constructors deriving from Capability + then t1 match + case t1 @ CapturingType(_, _) => t1 + case t1 => CapturingType(t1, CaptureSet.CSImpliedByCapability(t1, sym, variance), boxed = false) + else t1 + } + + val tp1 = toCapturing(tp) + if tp1 ne tp then capt.println(i"expanded explicit in ${ctx.owner}: $tp --> $tp1") + val tp2 = if sym.isType then stripImpliedCaptureSet(tp1) else tp1 + if tp2.containsGlobalFreshDirectly then fail( - em"""`fresh` occurs outside function result in $tp3. + em"""`fresh` occurs outside function result in $tp2. | |The `fresh` capability may only be used in the result of a function type, |following a function arrow such as `=>` or `->`.""") - globalCapToLocal(tp3, Origin.InDecl(sym)) + globalCapToLocal(tp2, Origin.InDecl(sym)) end transformExplicitType /** Update info of `sym` for CheckCaptures phase only */ @@ -687,11 +708,12 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: if signatureChanges then val paramSymss = sym.paramSymss def newInfo(using Context) = // will be run in this or next phase - toResultInResults(sym, report.error(_, tree.srcPos)): - if sym.is(Method) then + def fail(msg: Message) = report.error(msg, tree.srcPos) + if sym.is(Method) then + toResultInReturnType(sym, fail): inContext(ctx.withOwner(sym)): paramsToCap(paramSymss, methodType(paramSymss, localReturnType)) - else tree.tpt.nuType + else tree.tpt.nuType if tree.tpt.isInstanceOf[InferredTypeTree] && !sym.is(Param) && !sym.is(ParamAccessor) then diff --git a/compiler/src/dotty/tools/dotc/core/Substituters.scala b/compiler/src/dotty/tools/dotc/core/Substituters.scala index bedc6876adad..f3964d9a467c 100644 --- a/compiler/src/dotty/tools/dotc/core/Substituters.scala +++ b/compiler/src/dotty/tools/dotc/core/Substituters.scala @@ -1,7 +1,7 @@ package dotty.tools.dotc package core -import Types.*, Symbols.*, Contexts.* +import Types.*, Symbols.*, Contexts.*, Decorators.i import cc.Capabilities.{Capability, ResultCap} /** Substitution operations on types. See the corresponding `subst` and @@ -166,8 +166,8 @@ object Substituters: final class SubstBindingMap[BT <: BindingType](val from: BT, val to: BT)(using Context) extends DeepTypeMap, BiTypeMap { def apply(tp: Type): Type = subst(tp, from, to, this)(using mapCtx) override def mapCapability(c: Capability, deep: Boolean = false) = c match - case c @ ResultCap(binder: MethodType) if binder eq from => - c.derivedResult(to.asInstanceOf[MethodType]) + case c @ ResultCap(binder) if binder eq from => + c.derivedResult(to.asInstanceOf[MethodicType]) case _ => super.mapCapability(c, deep) @@ -176,6 +176,9 @@ object Substituters: if next.from eq to then Some(SubstBindingMap(from, next.to)) else Some(SubstBindingsMap(Array(from, next.from), Array(to, next.to))) case _ => None + + override def summarize(using Context) = i"SubstBinding[$from --> $to]" + def inverse = SubstBindingMap(to, from) } diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 4f9ec4942634..ec442cc909b2 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -695,7 +695,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling else tp1w.widenDealias match case tp1: RefinedType => - return isSubInfo(tp1.refinedInfo, tp2.refinedInfo) + return + try isSubInfo(tp1.refinedInfo, tp2.refinedInfo) + catch case ex: AssertionError => + println(i"error while subInfo ${tp1.refinedInfo} <:< ${tp2.refinedInfo}") + throw ex case _ => end if diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index b0aeb4c6ce2e..b5f17ba2f633 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3336,15 +3336,6 @@ object Types extends TypeUtils { override def newLikeThis(parent: Type, refinedName: Name, refinedInfo: Type)(using Context): Type = PreciseRefinedType(parent, refinedName, refinedInfo) - /** Used for refined function types created at cc/Setup that come from original - * generic function types. Function types of this class don't get their result - * captures mapped from LocalCaps to ResultCaps with toResult. - */ - class InferredRefinedType(parent: Type, refinedName: Name, refinedInfo: Type) - extends RefinedType(parent, refinedName, refinedInfo): - override def newLikeThis(parent: Type, refinedName: Name, refinedInfo: Type)(using Context): Type = - InferredRefinedType(parent, refinedName, refinedInfo) - object RefinedType { @tailrec def make(parent: Type, names: List[Name], infos: List[Type])(using Context): Type = if (names.isEmpty) parent @@ -3358,10 +3349,6 @@ object Types extends TypeUtils { def precise(parent: Type, name: Name, info: Type)(using Context): RefinedType = assert(!ctx.erasedTypes) unique(new PreciseRefinedType(parent, name, info)).checkInst - - def inferred(parent: Type, name: Name, info: Type)(using Context): RefinedType = - assert(!ctx.erasedTypes) - unique(new InferredRefinedType(parent, name, info)).checkInst } /** A recursive type. Instances should be constructed via the companion object. @@ -6278,6 +6265,11 @@ object Types extends TypeUtils { /** Fuse with another map */ def fuse(next: BiTypeMap)(using Context): Option[TypeMap] = None + /** A summarization to be used to describe capture sets resulting from this map + * in cc diagnostics. + */ + def summarize(using Context): String = getClass.toString + end BiTypeMap /** A typemap that follows non-opaque aliases and keeps their transformed diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 2353bb55939e..6730a0d8f7bc 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -480,7 +480,7 @@ class PlainPrinter(_ctx: Context) extends Printer { // ResultCap does not prefer to a prefix in that type "" case n => "outer_" * n ++ "fresh" - vbleText ~ Str(hashStr(c.binder)).provided(printDebug) ~ Str(idStr).provided(showUniqueIds) + vbleText ~ Str(idStr).provided(showUniqueIds) ~ Str(hashStr(c.binder)).provided(showUniqueIds | printDebug) case c: LocalCap => val idStr = if showUniqueIds then s"#${c.rootId}" else "" def classified = diff --git a/tests/neg-custom-args/captures/capt-depfun.check b/tests/neg-custom-args/captures/capt-depfun.check index 584521752b03..f15ed1b36dad 100644 --- a/tests/neg-custom-args/captures/capt-depfun.check +++ b/tests/neg-custom-args/captures/capt-depfun.check @@ -1,12 +1,11 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt-depfun.scala:11:43 ---------------------------------- 11 | val dc: ((Str^{y, z}) => Str^{y, z}) = ac(g()) // error | ^^^^^^^ - |Found: Str^{} => Str^{y, z} - |Required: Str^{y, z} =>² Str^{y, z} + | Found: Str^{} ->{ac*} Str^{y, z} + | Required: Str^{y, z} => Str^{y, z} | - |Note that capability `y` is not included in capture set {}. + | Note that capability `y` is not included in capture set {}. | - |where: => refers to a root capability created in value dc when instantiating method apply's type (x: C^): Str^{x} ->{fresh} Str^{x} - | =>² refers to a root capability in the type of value dc + | where: => refers to a root capability in the type of value dc | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/cc-existential-conformance.check b/tests/neg-custom-args/captures/cc-existential-conformance.check index c73b04c74588..a74d76864071 100644 --- a/tests/neg-custom-args/captures/cc-existential-conformance.check +++ b/tests/neg-custom-args/captures/cc-existential-conformance.check @@ -1,49 +1,47 @@ --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:8:24 -------------------- -8 | val y: A -> Fun[B^] = x // error - | ^ - | Found: (x : A -> (x²: A) -> B^{fresh}) - | Required: A -> A -> B^{any} - | - | Note that capability `any²` is not included in capture set {any} - | because any² is not visible from any in value y. - | - | where: any is a root capability in the type of value y - | any² is the root capability caps.any - | fresh is a root capability associated with the result type of (x²: A): B^{fresh} - | x is a value in method test - | x² is a reference to a value parameter - | - | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:9:29 -------------------- -9 | val z: A -> (x: A) -> B^ = y // error - | ^ - | Found: A -> A -> B^{y*} - | Required: A -> (x: A) -> B^ - | - | Note that capability `y*` is not included in capture set {any}. - | - | where: ^ refers to a root capability in the type of value z - | any is the root capability caps.any - | - | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:13:19 ------------------- -13 | val y: Fun[B^] = x // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:10:24 ------------------- +10 | val y: A -> Fun[B^] = x // error + | ^ + | Found: (x : A -> (x²: A) -> B^{fresh}) + | Required: A -> A -> B^{any} + | + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value y. + | + | where: any is a root capability in the type of value y + | fresh is a root capability associated with the result type of (x²: A): B^{fresh} + | x is a value in method test + | x² is a reference to a value parameter + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:11:29 ------------------- +11 | val z: A -> (x: A) -> B^ = y // error + | ^ + | Found: A -> A -> B^{y*} + | Required: A -> (x: A) -> B^ + | + | Note that capability `y*` is not included in capture set {any}. + | + | where: ^ refers to a root capability in the type of value z + | any is the root capability caps.any + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:15:19 ------------------- +15 | val y: Fun[B^] = x // error | ^ | Found: (x : (x²: A) -> B^{fresh}) | Required: A -> B^{any} | - | Note that capability `any²` is not included in capture set {any} - | because any² is not visible from any in value y. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value y. | | where: any is a root capability in the type of value y - | any² is the root capability caps.any | fresh is a root capability associated with the result type of (x²: A): B^{fresh} | x is a value in method test2 | x² is a reference to a value parameter | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:14:24 ------------------- -14 | val z: (x: A) -> B^ = y // error +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:16:24 ------------------- +16 | val z: (x: A) -> B^ = y // error | ^ | Found: A -> B^{y*} | Required: (x: A) -> B^ diff --git a/tests/neg-custom-args/captures/cc-existential-conformance.scala b/tests/neg-custom-args/captures/cc-existential-conformance.scala index 107570cc5019..854bf3a3a1d1 100644 --- a/tests/neg-custom-args/captures/cc-existential-conformance.scala +++ b/tests/neg-custom-args/captures/cc-existential-conformance.scala @@ -1,14 +1,16 @@ +import caps.fresh + class A class B type Fun[T] = A -> T def test() = - val x: A -> (x: A) -> B^ = ??? + val x: A -> (x: A) -> B^{fresh} = ??? val y: A -> Fun[B^] = x // error val z: A -> (x: A) -> B^ = y // error def test2() = - val x: (x: A) -> B^ = ??? + val x: (x: A) -> B^{fresh} = ??? val y: Fun[B^] = x // error val z: (x: A) -> B^ = y // error diff --git a/tests/neg-custom-args/captures/existential-mapping.check b/tests/neg-custom-args/captures/existential-mapping.check index 33817e395e7e..a16629dd2ac8 100644 --- a/tests/neg-custom-args/captures/existential-mapping.check +++ b/tests/neg-custom-args/captures/existential-mapping.check @@ -1,20 +1,12 @@ --- Error: tests/neg-custom-args/captures/existential-mapping.scala:46:10 ----------------------------------------------- -46 | val z2: (x: A^) => Array[C^] = ??? // error - | ^^^^^^^^^^^^^^^^^^^^ - | Array[C^]^{any.rd} captures the root capability `any` in invariant position. - | This capability cannot be converted to an existential in the result type of a function. - | - | where: ^ and any refer to the root capability caps.any -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:9:25 --------------------------- 9 | val _: (x: C^) -> C = x1 // error | ^^ - | Found: (x1 : (x: C^) -> C^{fresh}) - | Required: (x: C^) -> C + | Found: (x: C^) -> C^{x1*} + | Required: (x: C^) -> C | - | Note that capability `fresh` is not included in capture set {}. + | Note that capability `x1*` is not included in capture set {}. | - | where: ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:12:20 -------------------------- @@ -31,13 +23,12 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:15:30 -------------------------- 15 | val _: A^ -> (x: C^) -> C = x3 // error | ^^ - | Found: (x3 : A^ -> (x: C^) -> C^{fresh}) - | Required: A^ -> (x: C^) -> C + | Found: A^ -> (x: C^) -> C^{x3*} + | Required: A^ -> (x: C^) -> C | - | Note that capability `fresh` is not included in capture set {}. + | Note that capability `x3*` is not included in capture set {}. | - | where: ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:18:25 -------------------------- @@ -54,40 +45,36 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:21:30 -------------------------- 21 | val _: A^ -> (x: C^) -> C = x5 // error | ^^ - | Found: (x5 : A^ -> (x: C^) -> C^{fresh}) - | Required: A^ -> (x: C^) -> C + | Found: A^ -> (x: C^) -> C^{x5*} + | Required: A^ -> (x: C^) -> C | - | Note that capability `fresh` is not included in capture set {}. + | Note that capability `x5*` is not included in capture set {}. | - | where: ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:24:30 -------------------------- 24 | val _: A^ -> (x: C^) => C = x6 // error | ^^ - | Found: A^ -> (x: C^) ->{x6*} C^{fresh} - | Required: A^ -> (x: C^) => C + | Found: A^ -> (x: C^) ->{x6*} C^{x6*} + | Required: A^ -> (x: C^) => C | - | Note that capability `fresh` is not included in capture set {}. + | Note that capability `x6*` is not included in capture set {}. | - | where: => refers to a root capability in the type of value _$6 - | ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: => refers to a root capability in the type of value _$6 + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:27:25 -------------------------- 27 | val _: (x: C^) => C = y1 // error | ^^ - | Found: (y1 : (x: C^) ->{any} C^{fresh}) - | Required: (x: C^) ->{any²} C + | Found: (x: C^) ->{y1} C^{y1*} + | Required: (x: C^) => C | - | Note that capability `any` is not included in capture set {any²}. + | Note that capability `y1*` is not included in capture set {}. | - | where: ^ refers to the root capability caps.any - | any is a root capability in the type of value y1 - | any² is a root capability in the type of value _$7 - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: => refers to a root capability in the type of value _$7 + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:30:20 -------------------------- @@ -105,15 +92,14 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:33:30 -------------------------- 33 | val _: A^ => (x: C^) => C = y3 // error | ^^ - | Found: A^ ->{y3} (x: C^) ->{y3*} C^{fresh} - | Required: A^ => (x: C^) =>² C + | Found: A^ ->{y3} (x: C^) ->{y3*} C^{y3*} + | Required: A^ => (x: C^) =>² C | - | Note that capability `fresh` is not included in capture set {}. + | Note that capability `y3*` is not included in capture set {}. | - | where: => refers to a root capability in the type of value _$9 - | =>² refers to a root capability in the type of value _$9 - | ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: => refers to a root capability in the type of value _$9 + | =>² refers to a root capability in the type of value _$9 + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:36:25 -------------------------- @@ -132,28 +118,25 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:39:30 -------------------------- 39 | val _: A^ => (x: C^) -> C = y5 // error | ^^ - | Found: (y5 : A^ ->{any} (x: C^) -> C^{fresh}) - | Required: A^ ->{any²} (x: C^) -> C + | Found: A^ ->{y5} (x: C^) -> C^{y5*} + | Required: A^ => (x: C^) -> C | - | Note that capability `any` is not included in capture set {any²}. + | Note that capability `y5*` is not included in capture set {}. | - | where: ^ refers to the root capability caps.any - | any is a root capability in the type of value y5 - | any² is a root capability in the type of value _$11 - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: => refers to a root capability in the type of value _$11 + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/existential-mapping.scala:42:30 -------------------------- 42 | val _: A^ => (x: C^) => C = y6 // error | ^^ - | Found: A^ ->{y6} (x: C^) ->{y6*} C^{fresh} - | Required: A^ => (x: C^) =>² C + | Found: A^ ->{y6} (x: C^) ->{y6*} C^{y6*} + | Required: A^ => (x: C^) =>² C | - | Note that capability `fresh` is not included in capture set {}. + | Note that capability `y6*` is not included in capture set {}. | - | where: => refers to a root capability in the type of value _$12 - | =>² refers to a root capability in the type of value _$12 - | ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: C^): C^{fresh} + | where: => refers to a root capability in the type of value _$12 + | =>² refers to a root capability in the type of value _$12 + | ^ refers to the root capability caps.any | | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/existential-mapping.scala b/tests/neg-custom-args/captures/existential-mapping.scala index 3543ef27037f..c0078043d5b3 100644 --- a/tests/neg-custom-args/captures/existential-mapping.scala +++ b/tests/neg-custom-args/captures/existential-mapping.scala @@ -43,5 +43,5 @@ def Test = val z1: A^ => Array[C^] = ??? // ok - val z2: (x: A^) => Array[C^] = ??? // error + val z2: (x: A^) => Array[C^] = ??? // ok diff --git a/tests/neg-custom-args/captures/outer-fresh.check b/tests/neg-custom-args/captures/outer-fresh.check new file mode 100644 index 000000000000..4f53e7b775cf --- /dev/null +++ b/tests/neg-custom-args/captures/outer-fresh.check @@ -0,0 +1,44 @@ +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-fresh.scala:11:43 ---------------------------------- +11 | val _: (s: String) -> (t: String) -> A = x // error + | ^ + |Found: (s: String) -> (t: String) -> A^{outer_fresh} + |Required: (s: String) -> (t: String) -> A + | + |Note that capability `fresh` is not included in capture set {}. + | + |where: fresh and outer_fresh refer to a root capability associated with the result type of (s: String): (t: String) -> A^{outer_fresh} + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-fresh.scala:14:43 ---------------------------------- +14 | val _: (s: String) -> (t: String) -> A = y // error + | ^ + |Found: (Test.y : (s: String) -> (t: String) -> A^{outer_fresh}) + |Required: (s: String) -> (t: String) -> A + | + |Note that capability `fresh` is not included in capture set {}. + | + |where: fresh and outer_fresh refer to a root capability associated with the result type of (s: String): (t: String) -> A^{outer_fresh} + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-fresh.scala:17:34 ---------------------------------- +17 | val _: () -> (t: String) -> A = z // error + | ^ + |Found: () -> (t: String) -> A^{outer_fresh} + |Required: () -> (t: String) -> A + | + |Note that capability `fresh` is not included in capture set {}. + | + |where: fresh and outer_fresh refer to a root capability associated with the result type of (): (t: String) -> A^{outer_fresh} + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/outer-fresh.scala:20:34 ---------------------------------- +20 | val _: () -> (t: String) -> A = z2 // error + | ^^ + |Found: (Test.z2 : () -> (t: String) -> A^{outer_fresh}) + |Required: () -> (t: String) -> A + | + |Note that capability `fresh` is not included in capture set {}. + | + |where: fresh and outer_fresh refer to a root capability associated with the result type of (): (t: String) -> A^{outer_fresh} + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/outer-fresh.scala b/tests/neg-custom-args/captures/outer-fresh.scala new file mode 100644 index 000000000000..caf3721694db --- /dev/null +++ b/tests/neg-custom-args/captures/outer-fresh.scala @@ -0,0 +1,20 @@ +import caps.fresh + +class A + +object Test: + + type F[X] = (t: String) -> X + type G[cs^] = (t: String) -> A^{cs} + + val x: (s: String) -> F[A^{fresh}] = ??? + val _: (s: String) -> (t: String) -> A = x // error + + val y: (s: String) -> G[{fresh}] = ??? + val _: (s: String) -> (t: String) -> A = y // error + + val z: () -> F[A^{fresh}] = ??? + val _: () -> (t: String) -> A = z // error + + val z2: () -> G[{fresh}] = ??? + val _: () -> (t: String) -> A = z2 // error \ No newline at end of file diff --git a/tests/neg-custom-args/captures/refine-reach-shallow.check b/tests/neg-custom-args/captures/refine-reach-shallow.check new file mode 100644 index 000000000000..1326ee68790c --- /dev/null +++ b/tests/neg-custom-args/captures/refine-reach-shallow.check @@ -0,0 +1,69 @@ +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/refine-reach-shallow.scala:5:22 -------------------------- +5 | val f: IO^ => IO^ = x => x // error + | ^^^^^^ + | Found: (x: IO^'s1) ->'s2 IO^{x} + | Required: IO^ => IO^{any} + | + | Note that capability `x` is not included in capture set {any} + | because (x : IO^'s1) is not visible from any in value f. + | + | where: => refers to a root capability in the type of value f + | ^ refers to the root capability caps.any + | any is a root capability in the type of value f + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/refine-reach-shallow.scala:10:38 ------------------------- +10 | val g: [R] -> (IO^{f*} => R) -> R = f // error // error + | ^ + | Found: (f : [R] => (x$1: IO^{any} ->{any} R) -> R) + | Required: [R] => (x$1: IO^{f*} ->{any} R) -> R + | + | Note that capability `any` is not included in capture set {f*}. + | + | where: any is the root capability caps.any + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/refine-reach-shallow.scala:13:38 ------------------------- +13 | val g: [R] -> (IO^{f*} -> R) -> R = f // error // error + | ^ + | Found: (f : [R] => (x$1: IO^{any} -> R) -> R) + | Required: [R] => (x$1: IO^{f*} -> R) -> R + | + | Note that capability `any` is not included in capture set {f*}. + | + | where: any is the root capability caps.any + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/refine-reach-shallow.scala:19:40 ------------------------- +19 | val g: [R] -> (IO^ -> R) -> IO^{f*} = f // error + | ^ + | Found: (f : [R] => (x$1: IO^ -> R) -> IO^{fresh}) + | Required: [R] => (x$1: IO^ -> R) -> IO^{f*} + | + | Note that capability `fresh` is not included in capture set {f*}. + | + | where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x$1: IO^ -> R): IO^{fresh} + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/refine-reach-shallow.scala:20:40 ------------------------- +20 | val h: [R] -> (IO^{f*} -> R) -> IO^ = f // error + | ^ + | Found: (f : [R] => (x$1: IO^{any} -> R) -> IO^{fresh}) + | Required: [R] => (x$1: IO^{f*} -> R) -> IO^ + | + | Note that capability `any` is not included in capture set {f*}. + | + | where: ^ refers to a root capability in the type of value h + | any is the root capability caps.any + | fresh is a root capability associated with the result type of (x$1: IO^{any} -> R): IO^{fresh} + | + | longer explanation available when compiling with `-explain` +-- Error: tests/neg-custom-args/captures/refine-reach-shallow.scala:10:13 ---------------------------------------------- +10 | val g: [R] -> (IO^{f*} => R) -> R = f // error // error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | f* cannot be tracked since its deep capture set is empty +-- Error: tests/neg-custom-args/captures/refine-reach-shallow.scala:13:13 ---------------------------------------------- +13 | val g: [R] -> (IO^{f*} -> R) -> R = f // error // error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | f* cannot be tracked since its deep capture set is empty diff --git a/tests/neg-custom-args/captures/refine-reach-shallow.scala b/tests/neg-custom-args/captures/refine-reach-shallow.scala index dda865a85891..fc84e015e7ac 100644 --- a/tests/neg-custom-args/captures/refine-reach-shallow.scala +++ b/tests/neg-custom-args/captures/refine-reach-shallow.scala @@ -1,4 +1,5 @@ import language.experimental.captureChecking +import caps.fresh trait IO def test1(): Unit = val f: IO^ => IO^ = x => x // error @@ -14,6 +15,6 @@ def test4(): Unit = val xs: List[IO^] = ??? val ys: List[IO^{xs*}] = xs // ok def test5(): Unit = - val f: [R] -> (IO^ -> R) -> IO^ = ??? + val f: [R] -> (IO^ -> R) -> IO^{fresh} = ??? val g: [R] -> (IO^ -> R) -> IO^{f*} = f // error val h: [R] -> (IO^{f*} -> R) -> IO^ = f // error diff --git a/tests/neg-custom-args/captures/scoped-caps.check b/tests/neg-custom-args/captures/scoped-caps.check index a6cc56e24ac4..241ff790abff 100644 --- a/tests/neg-custom-args/captures/scoped-caps.check +++ b/tests/neg-custom-args/captures/scoped-caps.check @@ -4,26 +4,26 @@ | Found: (f : (x: A^) -> B^{fresh}) | Required: A^ -> B^{any} | - | Note that capability `fresh²` is not included in capture set {any} - | because fresh² is not visible from any in value g. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value g. | - | where: ^ refers to the root capability caps.any - | any is a root capability in the type of value g - | fresh is a root capability associated with the result type of (x: A^): B^{fresh} - | fresh² is the root capability caps.fresh + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value g + | fresh is a root capability associated with the result type of (x: A^): B^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:11:32 ---------------------------------- 11 | val _: (x: A^) -> B^{fresh} = g // error | ^ - | Found: A^ -> B^{g*} - | Required: (x: A^) -> B^{fresh} + |Found: A^ -> B^{g*} + |Required: (x: A^) -> B^{fresh} | - | Note that capability `g*` is not included in capture set {fresh²}. + |Note that capability `g*` is not included in capture set {fresh} + |because `fresh`, which is existentially bound in B^{fresh²}, cannot subsume `g*` since that capability is not a SharedCapability. | - | where: ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: A^): B^{fresh} - | fresh² is the root capability caps.fresh + |where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: A^): B^{fresh} + | fresh² is the root capability caps.fresh | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:12:20 ---------------------------------- @@ -32,13 +32,12 @@ | Found: (f : (x: A^) -> B^{fresh}) | Required: A^ -> B^{any} | - | Note that capability `fresh²` is not included in capture set {any} - | because fresh² is not visible from any in value _$3. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value _$3. | - | where: ^ refers to the root capability caps.any - | any is a root capability in the type of value _$3 - | fresh is a root capability associated with the result type of (x: A^): B^{fresh} - | fresh² is the root capability caps.fresh + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value _$3 + | fresh is a root capability associated with the result type of (x: A^): B^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:15:20 ---------------------------------- @@ -58,14 +57,15 @@ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:19:31 ---------------------------------- 19 | val _: (x: S) -> B^{fresh} = h // error: direct conversion fails | ^ - | Found: S^ -> B^{h*} - | Required: (x: S^) -> B^{fresh} + |Found: S^ -> B^{h*} + |Required: (x: S^) -> B^{fresh} | - | Note that capability `h*` is not included in capture set {fresh²}. + |Note that capability `h*` is not included in capture set {fresh} + |because `fresh`, which is existentially bound in B^{fresh²}, cannot subsume `h*` since that capability is not a SharedCapability. | - | where: ^ refers to the root capability caps.any - | fresh is a root capability associated with the result type of (x: S^): B^{fresh} - | fresh² is the root capability caps.fresh + |where: ^ refers to the root capability caps.any + | fresh is a root capability associated with the result type of (x: S^): B^{fresh} + | fresh² is the root capability caps.fresh | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:28:30 ---------------------------------- @@ -87,13 +87,12 @@ | Found: (j : (x: S) -> B^{fresh}) | Required: S^ -> B^{any} | - | Note that capability `fresh²` is not included in capture set {any} - | because fresh² is not visible from any in value _$15. + | Note that capability `fresh` is not included in capture set {any} + | because fresh is not visible from any in value _$15. | - | where: ^ refers to the root capability caps.any - | any is a root capability in the type of value _$15 - | fresh is a root capability associated with the result type of (x: S^): B^{fresh} - | fresh² is the root capability caps.fresh + | where: ^ refers to the root capability caps.any + | any is a root capability in the type of value _$15 + | fresh is a root capability associated with the result type of (x: S^): B^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps.scala:31:25 ---------------------------------- diff --git a/tests/neg-custom-args/captures/scoped-caps2.check b/tests/neg-custom-args/captures/scoped-caps2.check index e32a72dc94de..eeb9b944c450 100644 --- a/tests/neg-custom-args/captures/scoped-caps2.check +++ b/tests/neg-custom-args/captures/scoped-caps2.check @@ -52,7 +52,7 @@ | | where: ^ refers to the root capability caps.any | any is a root capability classified as SharedCapability in the type of value _$6 - | fresh is the root capability caps.fresh + | fresh is a root capability associated with the result type of (x: C^): C^{fresh} | | longer explanation available when compiling with `-explain` -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/scoped-caps2.scala:17:29 --------------------------------- diff --git a/tests/neg-custom-args/captures/sep-curried-par.check b/tests/neg-custom-args/captures/sep-curried-par.check index 7cbcf6e8ee6f..cad59407e069 100644 --- a/tests/neg-custom-args/captures/sep-curried-par.check +++ b/tests/neg-custom-args/captures/sep-curried-par.check @@ -2,7 +2,7 @@ 23 | val bar = (p1: () => Unit) => (p2: () ->{p1, any} Unit) => par(p1, p2) // error, but error message could be better | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Capability `p1` defined in an enclosing function outlives its scope: - | it leaks into outer capture set 's1 which is owned by value bar. + | it leaks into outer capture set 's1 of value bar. | The leakage occurred when trying to match the following types: | | Found: (p2: () ->{p1, any} Unit) ->{p1} Unit diff --git a/tests/pos-custom-args/captures/closure-avoidance.scala b/tests/pos-custom-args/captures/closure-avoidance.scala index 83725cb4df71..ffbd6edc99ea 100644 --- a/tests/pos-custom-args/captures/closure-avoidance.scala +++ b/tests/pos-custom-args/captures/closure-avoidance.scala @@ -28,4 +28,3 @@ def test = val g2: (x: A^) => B^{fresh} = (a: A^) => println("") (??? : B^) // ok - diff --git a/tests/pos-custom-args/captures/infer-exists.scala b/tests/pos-custom-args/captures/infer-exists.scala index 3f959e273bbc..150afcd4bef8 100644 --- a/tests/pos-custom-args/captures/infer-exists.scala +++ b/tests/pos-custom-args/captures/infer-exists.scala @@ -1,12 +1,14 @@ import language.experimental.captureChecking +import caps.fresh class C extends caps.SharedCapability class D def test1 = - val a: (x: C) -> C = ??? + val a: (x: C) -> C^{fresh} = ??? val b = a def test2 = - val a: (x: D^) -> D^ = ??? + val a: (x: D^) -> D^{fresh} = ??? val b = a + diff --git a/tests/pos-custom-args/captures/test.scala b/tests/pos-custom-args/captures/ref-of-proc.scala similarity index 100% rename from tests/pos-custom-args/captures/test.scala rename to tests/pos-custom-args/captures/ref-of-proc.scala