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
caseclassA(a: Int)
caseclassB(b: Int)
caseclassC(c: Int)
vala= (A(1):A) match {
caseA(_) =>"OK"caseB(_) =>"NOT OK"// Compiler Error: this case is unreachable since class A and class B are unrelated
}
valb= (A(1):A|B) match {
caseA(_) =>"OK"caseB(_) =>"OK"caseC(_) =>"NOT OK"// No Compiler Error
}
Output
[error] |caseB(_) =>"NOT OK"
[error] |^
[error] |thiscase is unreachable since classA and classB are unrelated
Expectation
The compiler should also yield an unreachable code error for the second match statement when trying to match on C since it's not related to type A | B.
The text was updated successfully, but these errors were encountered:
Minimized code
Output
Expectation
The compiler should also yield an unreachable code error for the second match statement when trying to match on
C
since it's not related to typeA | B
.The text was updated successfully, but these errors were encountered: