forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi16806.scala
42 lines (37 loc) · 1019 Bytes
/
i16806.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.concurrent.Semaphore
import scala.runtime.LazyVals.Evaluating
object Repro {
case object DFBit
final class DFError extends Exception("")
final class DFType[+T](val value: T | DFError) extends AnyVal
def asIR(dfType: DFType[DFBit.type]): DFBit.type = dfType.value match
case dfTypeIR: DFBit.type => dfTypeIR
case err: DFError => throw new DFError
object Holder {
val s = new Semaphore(1, false)
final lazy val Bit = {
s.release()
new DFType[DFBit.type](DFBit)
}
}
@main
def Test =
val a = new Thread() {
override def run(): Unit =
Holder.s.acquire()
val x = Holder.Bit.value
assert(!x.isInstanceOf[Evaluating.type])
println("Success")
}
val b = new Thread() {
override def run(): Unit =
Holder.s.acquire()
val x = Holder.Bit.value
assert(!x.isInstanceOf[Evaluating.type])
println("Success")
}
a.start()
b.start()
a.join(300)
b.join(300)
}