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
=== What steps will reproduce the problem? ===
Have two traits, one of which has an abstract method. Write a pattern-match expression, as below, where you first match trait A (with a pattern guard), then trait B, then trait A again. If you pass in an object that extends both A and B, and does NOT pass the boolean guard, the second match is skipped and the third match is selected. If you remove the first match (with the pattern guard) the behavior is as expected.
Basically, the presence of one failing match is causing the following match to fail, which it shouldn't.
Welcome to Scala version 2.9.0.RC1 (JavaHotSpot(TM) 64-BitServerVM, Java1.6.0_24).
Type in expressions to have them evaluated.
Type:help for more information.
scala> {
|traitFoo {
|defi:Int| }
|traitBar||caseclassSpam(i: Int) extendsFoowithBar||defmatchParent(p:Any) = p match {
|case f:Fooif f.i ==1=>1|case _:Bar=>2|case _:Foo=>3| }
|| matchParent(Spam(3))
| }
res0:Int=3
scala> {
|traitFoo {
|defi:Int| }
|traitBar||caseclassSpam(i: Int) extendsFoowithBar||defmatchParent(p:Any) = p match {
|case _:Bar=>2|case _:Foo=>3| }
|| matchParent(Spam(3))
| }
res1:Int=2
=== What is the expected behavior? ===
Both of the above expressions should resolve to 2.
=== What do you see instead? ===
The first expression resolves to 3, skipping the second match.
=== What versions of the following are you using? ===
Scala: 2.9.0.RC1 (also occurs in 2.8.1)
Java: 1.6.0_24
Operating system: OS X 10.6.7
The text was updated successfully, but these errors were encountered:
It appears the generated code branches on whether it's an instance of "Foo" first, only branching based on the guard after it's determined it will match one of the "Foo" cases.
=== What steps will reproduce the problem? ===
Have two traits, one of which has an abstract method. Write a pattern-match expression, as below, where you first match trait A (with a pattern guard), then trait B, then trait A again. If you pass in an object that extends both A and B, and does NOT pass the boolean guard, the second match is skipped and the third match is selected. If you remove the first match (with the pattern guard) the behavior is as expected.
Basically, the presence of one failing match is causing the following match to fail, which it shouldn't.
=== What is the expected behavior? ===
Both of the above expressions should resolve to 2.
=== What do you see instead? ===
The first expression resolves to 3, skipping the second match.
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: