File tree 2 files changed +20
-1
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -771,7 +771,7 @@ object PatternMatcher {
771
771
val expectedClass = expectedTp.dealias.classSymbol.asClass
772
772
ExplicitOuter .ensureOuterAccessors(expectedClass)
773
773
scrutinee.ensureConforms(expectedTp)
774
- .outerSelect(1 , expectedOuter.tpe.widen )
774
+ .outerSelect(1 , expectedClass.owner.typeRef )
775
775
.select(defn.Object_eq )
776
776
.appliedTo(expectedOuter)
777
777
}
Original file line number Diff line number Diff line change
1
+ trait Common {
2
+ case class Data (a : String )
3
+ }
4
+ object O1 extends Common
5
+ object O2 extends Common
6
+
7
+ object Test {
8
+ def main (args : Array [String ]): Unit = {
9
+
10
+ val data = O2 .Data (" test" )
11
+
12
+ // Runtime error: java.lang.ClassCastException: O2$ cannot be cast to O1$
13
+ data match {
14
+ case O1 .Data (s) => println(" O1 data" )
15
+ case O2 .Data (s) => println(" O2 data" )
16
+ case _ => println(" Unknown" )
17
+ }
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments