File tree 2 files changed +18
-1
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -187,7 +187,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
187
187
// val x: String = null.asInstanceOf[String]
188
188
// if (x == null) {} // error: x is non-nullable
189
189
// if (x.asInstanceOf[String|Null] == null) {} // ok
190
- cls1 == defn.NullClass && cls1 == cls2
190
+ if cls1 == defn.NullClass || cls2 == defn.NullClass then cls1 == cls2
191
+ else cls1 == defn.NothingClass || cls2 == defn.NothingClass
191
192
else if cls1 == defn.NullClass then
192
193
cls1 == cls2 || cls2.derivesFrom(defn.ObjectClass )
193
194
else if cls2 == defn.NullClass then
Original file line number Diff line number Diff line change
1
+ //> using options -language:strictEquality
2
+
3
+ import scala .collection .LinearSeq
4
+
5
+ def foo [T ](a : LinearSeq [T ]) = a match
6
+ case Nil => - 1
7
+ case head +: tail => head
8
+
9
+ enum Foo derives CanEqual :
10
+ case Bar
11
+ case Baz (x : String )
12
+
13
+
14
+ def foo (a : Foo ) = a match
15
+ case Foo .Bar => - 1
16
+ case _ => 0
You can’t perform that action at this time.
0 commit comments