File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed
library/src/scala/runtime Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ object LazyVals {
4545
4646 /* ------------- Start of public API ------------- */
4747
48- sealed trait LazyValControlState
48+ // This trait extends Serializable to fix #16806 that caused a race condition
49+ sealed trait LazyValControlState extends Serializable
4950
5051 /**
5152 * Used to indicate the state of a lazy val that is being
Original file line number Diff line number Diff line change 1+ Success
2+ Success
Original file line number Diff line number Diff line change 1+ // scalajs: --skip
2+ import java .util .concurrent .Semaphore
3+
4+ object Repro {
5+
6+ case object DFBit
7+ final class DFError extends Exception (" " )
8+ final class DFType [+ T ](val value : T | DFError ) extends AnyVal
9+
10+ def asIR (dfType : DFType [DFBit .type ]): DFBit .type = dfType.value match
11+ case dfTypeIR : DFBit .type => dfTypeIR
12+ case err : DFError => throw new DFError
13+
14+ object Holder {
15+ val s = new Semaphore (1 , false )
16+ final lazy val Bit = {
17+ s.release()
18+ new DFType [DFBit .type ](DFBit )
19+ }
20+ }
21+
22+ @ main
23+ def Test =
24+ val a = new Thread () {
25+ override def run (): Unit =
26+ Holder .s.acquire()
27+ val x = Holder .Bit .value
28+ assert(x.isInstanceOf [DFBit .type ])
29+ println(" Success" )
30+ }
31+ val b = new Thread () {
32+ override def run (): Unit =
33+ Holder .s.acquire()
34+ val x = Holder .Bit .value
35+ assert(x.isInstanceOf [DFBit .type ])
36+ println(" Success" )
37+ }
38+ a.start()
39+ b.start()
40+ a.join(300 )
41+ b.join(300 )
42+ }
You can’t perform that action at this time.
0 commit comments