Skip to content

Commit 978d4e4

Browse files
committed
Spec tweak: redefine designator types in terms of memberType.
And better define what a "type definition" is.
1 parent 8e65a2c commit 978d4e4

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

docs/_spec/03-types.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,19 @@ To each type constructor corresponds an _inferred type parameter clause_ which i
154154
- For a [polymorphic class type](#type-designators), the type parameter clause of the referenced class definition.
155155
- For a non-class [type designator](#type-designators), the inferred clause of its upper bound.
156156

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+
157170
## Types
158171

159172
### Type Lambdas
@@ -216,27 +229,24 @@ Named designators refer to *member* definitions of a non-empty prefix:
216229
#### Term Designators
217230

218231
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´)`.
221234

222235
All term designators are concrete types.
223236
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`.
224237
Otherwise, the designator denotes the singleton set only containing ´v´.
225238

226-
A term designator referring to a term definition `v` is a stable type if and only if `v` is a `val` definition.
227-
228239
#### Type Designators
229240

230241
A type designator ´p.C´ referring to a _class_ definition (including traits and hidden object classes) is a _class type_.
231242
If the class is monomorphic, the type designator is a value type denoting the set of instances of ´C´ or any of its subclasses.
232243
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.
234245

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).
240250

241251
### Parameterized Types
242252

0 commit comments

Comments
 (0)