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
Remainder of the Spec updates about removals (#16841)
This is the rest of the work I (Sporarum) did on the Spec
about feature removals.
It is not in individual PRs, but still follows the other principles
outlined in
#16839 and in
`docs/_spec/README.md`.
@@ -490,16 +489,6 @@ In addition, Unicode escape sequences of the form `\uxxxx`, where each `x` is a
490
489
491
490
It is a compile time error if a backslash character in a character or string literal does not start a valid escape sequence.
492
491
493
-
### Symbol literals
494
-
495
-
```ebnf
496
-
symbolLiteral ::= ‘'’ plainid
497
-
```
498
-
499
-
A symbol literal `'x` is deprecated shorthand for the expression `scala.Symbol("x")`.
500
-
501
-
The `apply` method of `Symbol`'s companion object caches weak references to `Symbol`s, thus ensuring that identical symbol literals are equivalent with respect to reference equality.
502
-
503
492
## Whitespace and Comments
504
493
505
494
Tokens may be separated by whitespace characters and/or comments.
A class member definition ´m´ that overrides some other method ´m'´ in a base class of ´C´ may leave out the return type, even if it is recursive.
690
-
In this case, the return type ´R'´ of the overridden method ´m'´, seen as a member of ´C´, is taken as the return type of ´m´ for each recursive invocation of ´m´.
691
-
That way, a type ´R´ for the right-hand side of ´m´ can be determined, which is then taken as the return type of ´m´.
692
-
Note that ´R´ may be different from ´R'´, as long as ´R´ conforms to ´R'´.
615
+
In this case, whether or not `m` is recursive, its return type will be the return type of ´m'´.
Copy file name to clipboardExpand all lines: docs/_spec/05-classes-and-objects.md
+1-62
Original file line number
Diff line number
Diff line change
@@ -96,16 +96,6 @@ If this is not a template of a trait, then its _evaluation_ consists of the foll
96
96
Mixin-evaluation happens in reverse order of occurrence in the linearization.
97
97
- Finally, the statement sequence ´\mathit{stats}\,´ is evaluated.
98
98
99
-
###### Delayed Initialization
100
-
This statement sequence constitutes the initialization code for an object or class after the superclass constructor invocation and the mixin-evaluation of the template's base classes as described above.
101
-
Normally, this code is passed to a special hook, inaccessible to user code, which simply executes it.
102
-
103
-
However, in objects and classes (but not traits) which extend `scala.DelayedInit`, the initialization code is passed to a `delayedInit` method which can be overridden to implement arbitrary semantics.
104
-
105
-
```scala
106
-
defdelayedInit(body: =>Unit):Unit
107
-
```
108
-
109
99
### Constructor Invocations
110
100
111
101
```ebnf
@@ -305,57 +295,6 @@ It is a static error if the inheritance closure of a class type consists of an i
305
295
306
296
[^kennedy]: Kennedy, Pierce. [On Decidability of Nominal Subtyping with Variance.](https://research.microsoft.com/pubs/64041/fool2007.pdf) in FOOL 2007
A template may start with an _early field definition_ clause, which serves to define certain field values before the supertype constructor is called.
316
-
In a template
317
-
318
-
```scala
319
-
{ val ´p_1´: ´T_1´ = ´e_1´
320
-
...
321
-
val ´p_n´: ´T_n´ = ´e_n´
322
-
} with ´sc´ with ´mt_1´ with ´mt_n´ { ´\mathit{stats}´ }
323
-
```
324
-
325
-
The initial pattern definitions of ´p_1 , \ldots , p_n´ are called _early definitions_.
326
-
They define fields which form part of the template.
327
-
Every early definition must define at least one variable.
328
-
329
-
An early definition is type-checked and evaluated in the scope which is in effect just before the template being defined, augmented by any type parameters of the enclosing class and by any early definitions preceding the one being defined.
330
-
In particular, any reference to `this` in an early definition refers to the identity of `this` just outside the template.
331
-
Consequently, it is impossible for an early definition to refer to the object being constructed by the template, or to refer to one of its fields and methods, except for any other preceding early definition in the same section.
332
-
Furthermore, references to preceding early definitions always refer to the value that's defined there and do not take into account overriding definitions.
333
-
In other words, a block of early definitions is evaluated exactly as if it were a local block containing a number of value definitions.
334
-
335
-
Early definitions are evaluated before the superclass constructor of the template is called, in the order they are defined.
336
-
337
-
###### Example
338
-
Early definitions are particularly useful for traits, which do not have normal constructor parameters.
339
-
Example:
340
-
341
-
```scala
342
-
traitGreeting {
343
-
valname:String
344
-
valmsg="How are you, "+name
345
-
}
346
-
classCextends {
347
-
valname="Bob"
348
-
} withGreeting {
349
-
println(msg)
350
-
}
351
-
```
352
-
353
-
In the code above, the field `name` is initialized before the constructor of `Greeting` is called.
354
-
Therefore, field `msg` in class `Greeting` is properly initialized to `"How are you, Bob"`.
355
-
356
-
If `name` had been initialized instead in `C`'s normal class body, it would be initialized after the constructor of `Greeting`.
357
-
In that case, `msg` would be initialized to `"How are you, <null>"`.
358
-
359
298
## Modifiers
360
299
361
300
```ebnf
@@ -602,7 +541,7 @@ A constructor expression is either a self constructor invocation `this(´\mathit
602
541
The self constructor invocation must construct a generic instance of the class.
603
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.
604
543
605
-
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 and by any [early definitions](#early-definitions) of the enclosing template.
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.
606
545
The rest of the constructor expression is type-checked and evaluated as a method body in the current class.
607
546
608
547
If there are auxiliary constructors of a class ´C´, they form together with ´C´'s primary [constructor](#class-definitions) an overloaded constructor definition.
0 commit comments