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 @@ -770,7 +770,7 @@ object PatternMatcher {
770
770
val expectedClass = expectedTp.dealias.classSymbol.asClass
771
771
ExplicitOuter .ensureOuterAccessors(expectedClass)
772
772
scrutinee.ensureConforms(expectedTp)
773
- .outerSelect(1 , expectedOuter.tpe.widen )
773
+ .outerSelect(1 , expectedClass.owner.typeRef )
774
774
.select(defn.Object_eq )
775
775
.appliedTo(expectedOuter)
776
776
}
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