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
108108 EnumDef ::= id ClassConstr [`extends' [ConstrApps]]
109109 [nl] `{’ EnumCaseStat {semi EnumCaseStat} `}’
110110
111- 2 . Cases of enums are defined as follows:
111+ 2 . Cases of enums are defined as follows:
112112
113113 EnumCaseStat ::= {Annotation [nl]} {Modifier} EnumCase
114114 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:
3535 url : docs/reference/auto-parameter-tupling.html
3636 - title : Named Type Arguments
3737 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
3844 - title : Dropped Features
3945 subsection :
4046 - title : DelayedInit
You can’t perform that action at this time.
0 commit comments