You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_spec/03-types.md
+20-10Lines changed: 20 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -154,6 +154,19 @@ To each type constructor corresponds an _inferred type parameter clause_ which i
154
154
- For a [polymorphic class type](#type-designators), the type parameter clause of the referenced class definition.
155
155
- For a non-class [type designator](#type-designators), the inferred clause of its upper bound.
156
156
157
+
### Type Definitions
158
+
159
+
A _type definition_ ´D´ represents the right-hand-side of a `type` declaration or the bounds of a type parameter.
160
+
It is either:
161
+
162
+
- a type alias of the form ´= U´, or
163
+
- an abstract type definition with bounds ´>: L <: H´.
164
+
165
+
All type definitions have a lower bound ´L´ and an upper bound ´H´, which are types.
166
+
For type aliases, ´L = H = U´.
167
+
168
+
The type definition of a type parameter is never a type alias.
169
+
157
170
## Types
158
171
159
172
### Type Lambdas
@@ -216,27 +229,24 @@ Named designators refer to *member* definitions of a non-empty prefix:
216
229
#### Term Designators
217
230
218
231
A term designator ´p.x´ referring to a term definition `t` has an _underlying type_ ´U´.
219
-
If `t`is a member of some class ´C´ with _declared type_`T`, then ´p´ must be a type prefix, and the underlying type ´U´ of ´p.x´ is [`asSeenFrom`](#as-seen-from)`(´T´, ´C´, ´p´)`.
220
-
Otherwise, the underlying type ´U´ is the _declared type_ of `t`.
232
+
If ´p = \epsilon´ or ´p´ is a package ref, the underlying type ´U´ is the _declared type_of `t` and ´p.x´ is a stable type if an only if `t`is a `val` or `object` definition.
233
+
Otherwise, the underlying type ´U´ and whether ´p.x´ is a stable type are determined by [`memberType`](#member-type)`(´p´, ´x´)`.
221
234
222
235
All term designators are concrete types.
223
236
If `scala.Null ´<: U´`, the term designator denotes the set of values consisting of `null` and the value denoted by ´t´, i.e., the value ´v´ for which `t eq v`.
224
237
Otherwise, the designator denotes the singleton set only containing ´v´.
225
238
226
-
A term designator referring to a term definition `v` is a stable type if and only if `v` is a `val` definition.
227
-
228
239
#### Type Designators
229
240
230
241
A type designator ´p.C´ referring to a _class_ definition (including traits and hidden object classes) is a _class type_.
231
242
If the class is monomorphic, the type designator is a value type denoting the set of instances of ´C´ or any of its subclasses.
232
243
Otherwise it is a type constructor with the same type parameters as the class definition.
233
-
All class types are concrete types.
244
+
All class types are concrete, non-stable types.
234
245
235
-
If a type designator ´p.T´ is not a class type, it refers to a type definition `T` (a type parameter or a `type` declaration) and has an _underlying type definition_.
236
-
The type definition can be an _abstract type definition_ with bounds ´>: L <: H´, or an alias ´U´ (in which case ´U´ also acts as lower and higher bound).
237
-
If `T` is a member of some class ´C´ with _declared type definition_ ´D´, the underlying type definition of ´p.T´ is [`asSeenFrom`](#as-seen-from)`(´D´, ´C´, ´p´)`.
238
-
Otherwise, it is the _declared type definition_ of `T`.
239
-
A non-class type designator is concrete if and only if its underlying type definition is an alias ´U´ and ´U´ is itself concrete.
246
+
If a type designator ´p.T´ is not a class type, it refers to a type definition `T` (a type parameter or a `type` declaration) and has an _underlying [type definition](#type-definitions)_.
247
+
If ´p = \epsilon´ or ´p´ is a package ref, the underlying type definition is the _declared type definition_ of `T`.
248
+
Otherwise, it is determined by [`memberType`](#member-type)`(´p´, ´T´)`.
249
+
A non-class type designator is concrete (resp. stable) if and only if its underlying type definition is an alias ´U´ and ´U´ is itself concrete (resp. stable).
0 commit comments