File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ The changes are specified below as deltas with respect to the Scala syntax given
108
108
EnumDef ::= id ClassConstr [`extends' [ConstrApps]]
109
109
[nl] `{’ EnumCaseStat {semi EnumCaseStat} `}’
110
110
111
- 2 . Cases of enums are defined as follows:
111
+ 2 . Cases of enums are defined as follows:
112
112
113
113
EnumCaseStat ::= {Annotation [nl]} {Modifier} EnumCase
114
114
EnumCase ::= `case' (EnumClassDef | ObjectDef | ids)
Original file line number Diff line number Diff line change
1
+ ---
2
+ layout : doc-page
3
+ title : Changed: Lazy Vals and @volatile
4
+ ---
5
+
6
+ Lazy val initialization no longer guarantees safe publishing. This change was done
7
+ to avid the performance overhead of thread synchonization because many lazy vals are only used in a single-threaded context.
8
+
9
+ To get back safe publishing you need to annotate a lazy val with ` @volatile ` . In
10
+
11
+ @volatile lazy val x = expr
12
+
13
+ it is guaranteed that readers of a lazy val will see the value of ` x `
14
+ once it is assigned.
15
+
16
+ The [ ScalaFix] ( https://scalacenter.github.io/scalafix/ ) rewrite tool
17
+ as well as Dotty's own ` -migration ` option will rewrite all normal
18
+ lazy vals to volatile ones in order to keep their semantics compatible
19
+ with current Scala's.
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ sidebar:
35
35
url : docs/reference/auto-parameter-tupling.html
36
36
- title : Named Type Arguments
37
37
url : docs/reference/named-typeargs.html
38
+ - title : Changed Features
39
+ subsection :
40
+ - title : Volatile Lazy Vals
41
+ url : docs/reference/changed/lazy-vals.md
42
+ - title : Structural Types
43
+ url : docs/reference/changed/structural-types.md
38
44
- title : Dropped Features
39
45
subsection :
40
46
- title : DelayedInit
You can’t perform that action at this time.
0 commit comments