Skip to content

Commit cc9c90a

Browse files
committed
Include type lambdas in the simple types for provablyDisjoint.
I discovered that it is necessary for some existing, reasonable use cases of `provablyDisjoint`.
1 parent 17fe545 commit cc9c90a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

content/match-types-spec.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ A "simple type" is one of:
324324
* `p.C.x` where `C` is an `enum` class and `x` is one of its value `case`s
325325
* `X₁ & X₂` where `X₁` and `X₂` are both simple types
326326
* `X₁ | X₂` where `X₁` and `X₂` are both simple types
327+
* `[...ai] =>> X₁` where `X₁` is a simple type
327328

328329
We define `⌈X⌉` a function from a full Scala type to a simple type.
329330
Intuitively, it returns the "smallest" simple type that is a supertype of `X`.
@@ -332,7 +333,7 @@ It is defined as follows:
332333
* `⌈X⌉ = X` if `X` is a simple type
333334
* `⌈X⌉ = ⌈U⌉` if `X` is a stable type but not a simple type and its underlying type is `U`
334335
* `⌈X⌉ = ⌈H⌉` if `X` is a non-class type designator with upper bound `H`
335-
* `⌈X⌉ = AnyKind` if `X` is a type lambda
336+
* `⌈X⌉ = ⌈η(X)⌉` if `X` is a polymorphic class type designator, where `η(X)` is its eta-expansion
336337
* `⌈X⌉ = ⌈Y⌉` if `X` is a match type that reduces to `Y`
337338
* `⌈X⌉ = ⌈H⌉` if `X` is a match type that does not reduce and `H` is its upper bound
338339
* `⌈X[...Ti]⌉ = ⌈Y⌉` where `Y` is the beta-reduction of `X[...Ti]` if `X` is a type lambda
@@ -342,6 +343,7 @@ It is defined as follows:
342343
* `⌈{ α => X } = ⌈X⌉⌉`
343344
* `⌈X₁ & X₂⌉ = ⌈X₁⌉ & ⌈X₂⌉`
344345
* `⌈X₁ | X₂⌉ = ⌈X₁⌉ | ⌈X₂⌉`
346+
* `⌈[...ai] =>> X₁⌉ = [...ai] =>> ⌈X₁]⌉`
345347

346348
The following properties hold about `⌈X⌉` (we have paper proofs for those):
347349

@@ -375,6 +377,16 @@ Most rules go by pair, which makes the whole relation symmetric:
375377
* An intersection type is disjoint from another type if at least one of its parts is disjoint from that type:
376378
* `S ⋔ T1 & T2` if `S ⋔ T1` or `S ⋔ T2`
377379
* `S1 & S2 ⋔ T` if `S1 ⋔ T` or `S1 ⋔ T`
380+
* A type lambda is disjoint from any other type that is not a type lambda with the same number of parameters:
381+
* `[...ai] =>> S1 ⋔ q.D.y`
382+
* `[...ai] =>> S1 ⋔ d`
383+
* `[...ai] =>> S1 ⋔ q.D[...Ti]`
384+
* `p.C.x ⋔ [...bi] =>> T1`
385+
* `c ⋔ [...bi] =>> T1`
386+
* `p.C[...Si] ⋔ [...bi] =>> T1`
387+
* `[a1, ..., an] =>> S1 ⋔ [b1, ..., bm] =>> T1` if `m != n`
388+
* Two type lambdas with the same number of type parameters are disjoint if their result types are disjoint:
389+
* `[a1, ..., an] =>> S1 ⋔ [b1, ..., bn] =>> T1` if `S1 ⋔ T1`
378390
* An `enum` value case is disjoint from any other `enum` value case (identified by either not being in the same `enum` class, or having a different name):
379391
* `p.C.x ⋔ q.D.y` if `C != D` or `x != y` (recall: these are enum value cases)
380392
* Two literal types are disjoint if they are different:
@@ -395,6 +407,7 @@ Most rules go by pair, which makes the whole relation symmetric:
395407

396408
It is worth noting that this definition disregards prefixes entirely.
397409
`p.C` and `q.C` are never provably disjoint, even if `p` could be proven disjoint from `q`.
410+
It also disregards type members.
398411

399412
We have a proof sketch of the following property for ``:
400413

0 commit comments

Comments
 (0)