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
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ Non-value types capture properties of identifiers that [are not values](#non-val
45
45
For example, a [type constructor](#type-constructors) does not directly specify a type of values.
46
46
However, when a type constructor is applied to the correct type arguments, it yields a proper type, which may be a value type.
47
47
48
-
Non-value types are expressed indirectly in Scala.
48
+
Non-value types are expressed indirectly in Scala.
49
49
E.g., a method type is described by writing down a method signature, which in itself is not a real type, although it gives rise to a corresponding [method type](#method-types).
50
50
Type constructors are another example, as one can write `type Swap[m[_, _], a,b] = m[b, a]`, but there is no syntax to write the corresponding anonymous type function directly.
51
51
@@ -130,7 +130,7 @@ SimpleType ::= StableId
130
130
```
131
131
132
132
A _type designator_ refers to a named value type.
133
-
It can be simple or qualified.
133
+
It can be simple or qualified.
134
134
All such type designators are shorthands for type projections.
135
135
136
136
Specifically, the unqualified type name ´t´ where ´t´ is bound in some class, object, or package ´C´ is taken as a shorthand for
@@ -306,14 +306,14 @@ RefineStat ::= Dcl
306
306
|
307
307
```
308
308
309
-
A _compound type_ ´T_1´ `with` ... `with` ´T_n \\{ R \\}´ represents objects with members as given in the component types ´T_1, ..., T_n´ and the refinement ´\\{ R \\}´.
309
+
A _compound type_ ´T_1´ `with` ... `with` ´T_n \\{ R \\}´ represents objects with members as given in the component types ´T_1, ..., T_n´ and the refinement ´\\{ R \\}´.
310
310
A refinement ´\\{ R \\}´ contains declarations and type definitions.
311
311
If a declaration or definition overrides a declaration or definition in one of the component types ´T_1, ..., T_n´, the usual rules for [overriding](05-classes-and-objects.html#overriding) apply; otherwise the declaration or definition is said to be “structural” [^2].
312
312
313
313
[^2]: A reference to a structurally defined member (method call or access to a value or variable) may generate binary code that is significantly slower than an equivalent code to a non-structural member.
314
314
315
-
Within a method declaration in a structural refinement, the type of any value parameter may only refer to type parameters or abstract types that are contained inside the refinement.
316
-
That is, it must refer either to a type parameter of the method itself, or to a type definition within the refinement.
315
+
Within a method declaration in a structural refinement, the type of any value parameter may only refer to type parameters or abstract types that are contained inside the refinement.
316
+
That is, it must refer either to a type parameter of the method itself, or to a type definition within the refinement.
317
317
This restriction does not apply to the method's result type.
318
318
319
319
If no refinement is given, the empty refinement is implicitly added, i.e. ´T_1´ `with` ... `with` ´T_n´ is a shorthand for ´T_1´ `with` ... `with` ´T_n \\{\\}´.
@@ -382,7 +382,7 @@ Function types associate to the right, e.g. ´S \Rightarrow T \Rightarrow R´ is
382
382
Function types are [covariant](04-basic-declarations-and-definitions.md#variance-annotations) in their result type and [contravariant](04-basic-declarations-and-definitions.md#variance-annotations) in their argument types.
383
383
384
384
Function types are shorthands for class types that define an `apply` method.
385
-
Specifically, the ´n´-ary function type ´(T_1, ..., T_n) \Rightarrow R´ is a shorthand for the class type `Function´_n´[´T_1´, ..., ´T_n´, ´R´]`.
385
+
Specifically, the ´n´-ary function type ´(T_1, ..., T_n) \Rightarrow R´ is a shorthand for the class type `Function´_n´[´T_1´, ..., ´T_n´, ´R´]`.
386
386
In particular ´() \Rightarrow R´ is a shorthand for class type `Function´_0´[´R´]`.
387
387
388
388
Such class types behave as if they were instances of the following trait:
@@ -396,7 +396,7 @@ Their exact supertype and implementation can be consulted in the [function class
396
396
397
397
## Non-Value Types
398
398
399
-
The types explained in the following do not denote sets of values, nor do they appear explicitly in programs.
399
+
The types explained in the following do not denote sets of values, nor do they appear explicitly in programs.
400
400
They are introduced in this report as the internal types of defined identifiers.
Copy file name to clipboardExpand all lines: docs/_spec/04-basic-declarations-and-definitions.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,7 @@ final val x = e
79
79
```
80
80
81
81
where `e` is a [constant expression](06-expressions.html#constant-expressions).
82
-
The `final` modifier must be present and no type annotation may be given.
82
+
The `final` modifier must be present and no type annotation may be given.
83
83
References to the constant value `x` are themselves treated as constant expressions; in the generated code they are replaced by the definition's right-hand side `e`.
84
84
85
85
Value definitions can alternatively have a [pattern](08-pattern-matching.html#patterns) as left-hand side.
Type parameters appear in type definitions, class definitions, and method definitions.
312
312
In this section we consider only type parameter definitions with lower bounds `>: ´L´` and upper bounds `<: ´U´` whereas a discussion of context bounds `: ´U´` and view bounds `<% ´U´` is deferred to [here](07-implicits.html#context-bounds-and-view-bounds).
313
313
314
-
The most general form of a proper type parameter is
314
+
The most general form of a proper type parameter is
315
315
`´@a_1 ... @a_n´ ´\pm´ ´t´ >: ´L´ <: ´U´`.
316
316
Here, ´L´, and ´U´ are lower and upper bounds that constrain possible type arguments for the parameter.
317
317
It is a compile-time error if ´L´ does not conform to ´U´.
Copy file name to clipboardExpand all lines: docs/_spec/05-classes-and-objects.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -538,7 +538,7 @@ These are defined by constructor definitions of the form `def this(´\mathit{ps}
538
538
Such a definition introduces an additional constructor for the enclosing class, with parameters as given in the formal parameter lists ´\mathit{ps}_1 , ..., \mathit{ps}_n´, and whose evaluation is defined by the constructor expression ´e´.
539
539
The scope of each formal parameter is the subsequent parameter sections and the constructor expression ´e´.
540
540
A constructor expression is either a self constructor invocation `this(´\mathit{args}_1´)...(´\mathit{args}_n´)` or a block which begins with a self constructor invocation.
541
-
The self constructor invocation must construct a generic instance of the class.
541
+
The self constructor invocation must construct a generic instance of the class.
542
542
I.e. if the class in question has name ´C´ and type parameters `[´\mathit{tps}\,´]`, then a self constructor invocation must generate an instance of `´C´[´\mathit{tps}\,´]`; it is not permitted to instantiate formal type parameters.
543
543
544
544
The signature and the self constructor invocation of a constructor definition are type-checked and evaluated in the scope which is in effect at the point of the enclosing class definition, augmented by any type parameters of the enclosing class.
A _for loop_`for (´\mathit{enums}\,´) ´e´` executes expression ´e´ for each binding generated by the enumerators ´\mathit{enums}´.
716
+
A _for loop_`for (´\mathit{enums}\,´) ´e´` executes expression ´e´ for each binding generated by the enumerators ´\mathit{enums}´.
717
717
A _for comprehension_`for (´\mathit{enums}\,´) yield ´e´` evaluates expression ´e´ for each binding generated by the enumerators ´\mathit{enums}´ and collects the results.
718
718
An enumerator sequence always starts with a generator; this can be followed by further generators, value definitions, or guards.
@@ -500,7 +500,7 @@ Each case consists of a (possibly guarded) pattern ´p_i´ and a block ´b_i´.
500
500
Each ´p_i´ might be complemented by a guard `if ´e´` where ´e´ is a boolean expression.
501
501
The scope of the pattern variables in ´p_i´ comprises the pattern's guard and the corresponding block ´b_i´.
502
502
503
-
Let ´T´ be the type of the selector expression ´e´ and let ´a_1, ..., a_m´ be the type parameters of all methods enclosing the pattern matching expression.
503
+
Let ´T´ be the type of the selector expression ´e´ and let ´a_1, ..., a_m´ be the type parameters of all methods enclosing the pattern matching expression.
504
504
For every ´a_i´, let ´L_i´ be its lower bound and ´U_i´ be its higher bound.
505
505
Every pattern ´p \in \{p_1,, ..., p_n\}´ can be typed in two ways.
506
506
First, it is attempted to type ´p´ with ´T´ as its expected type.
@@ -566,7 +566,7 @@ def eval[T](t: Term[T]): T = t match {
566
566
567
567
Note that the evaluator makes crucial use of the fact that type parameters of enclosing methods can acquire new bounds through pattern matching.
568
568
569
-
For instance, the type of the pattern in the second case, `Succ(u)`, is `Int`.
569
+
For instance, the type of the pattern in the second case, `Succ(u)`, is `Int`.
570
570
It conforms to the selector type `T` only if we assume an upper and lower bound of `Int` for `T`.
571
571
Under the assumption `Int <: T <: Int` we can also verify that the type right hand side of the second case, `Int` conforms to its expected type, `T`.
0 commit comments