Skip to content

Commit 254f23e

Browse files
committed
Spec: Replace volatility of types by the realizability concept.
1 parent a99f0b6 commit 254f23e

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

docs/_spec/03-types.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,25 +1197,28 @@ The application `foo((x: Int) => x.toString)` [resolves](06-expressions.html#ove
11971197
- `Int => String` is compatible to `ToString` -- when expecting a value of type `ToString`, you may pass a function literal from `Int` to `String`, as it will be SAM-converted to said function;
11981198
- `ToString` is not compatible to `Int => String` -- when expecting a function from `Int` to `String`, you may not pass a `ToString`.
11991199

1200-
## Volatile Types
1200+
## Realizability
12011201

1202-
Type volatility approximates the possibility that a type parameter or abstract type instance of a type does not have any non-null values.
1203-
A value member of a volatile type cannot appear in a [path](#paths).
1202+
A type ´T´ is _realizable_ if and only if it is inhabited by non-null values.
1203+
It is defined as:
12041204

1205-
A type is _volatile_ if it falls into one of four categories:
1205+
- A term designator ´p.x´ with underlying type ´U´ is realizable if ´p´ is ´\epsilon´ or a package ref or a realizable type and
1206+
- `memberType(´p´, ´x´)` has the stable flag, or
1207+
- the type returned by `memberType(´p´, ´x´)` is realizable.
1208+
- A stable type that is not a term designator is realizable.
1209+
- Another type ´T´ is realizable if
1210+
- ´T´ is concrete, and
1211+
- ´T´ has good bounds.
12061212

1207-
A compound type `´T_1´ with ... with ´T_n´ {´R\,´}` is volatile if one of the following three conditions hold.
1213+
A concrete type ´T´ has good bounds if all of the following apply:
12081214

1209-
1. One of ´T_2, ..., T_n´ is a type parameter or abstract type, or
1210-
1. ´T_1´ is an abstract type and either the refinement ´R´ or a type ´T_j´ for ´j > 1´ contributes an abstract member to the compound type, or
1211-
1. one of ´T_1, ..., T_n´ is a singleton type.
1215+
- all its non-class type members have good bounds, i.e., their bounds ´L´ and ´H´ are such that ´L <: H´,
1216+
- all its type refinements have good bounds, and
1217+
- for all base classes ´C´ of ´T´:
1218+
- `baseType(´T´, ´C´)` is defined with some result ´p.C[T_1, ..., T_n]´, and
1219+
- for all ´i \in \{ 1, ..., n \}´, ´T_i´ is a real type or (when it is a wildcard type argument) it has good bounds.
12121220

1213-
Here, a type ´S´ _contributes an abstract member_ to a type ´T´ if ´S´ contains an abstract member that is also a member of ´T´.
1214-
A refinement ´R´ contributes an abstract member to a type ´T´ if ´R´ contains an abstract declaration which is also a member of ´T´.
1215-
1216-
A type designator is volatile if it is an alias of a volatile type, or if it designates a type parameter or abstract type that has a volatile type as its upper bound.
1217-
1218-
A singleton type `´p´.type` is volatile, if the underlying type of path ´p´ is volatile.
1221+
Note: it is possible for `baseType(´T´, ´C´)` not to be defined because of the `meet` computation, which may fail to merge prefixes and/or invariant type arguments.
12191222

12201223
## Type Erasure
12211224

0 commit comments

Comments
 (0)