Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
// val x: String = null.asInstanceOf[String]
// if (x == null) {} // error: x is non-nullable
// if (x.asInstanceOf[String|Null] == null) {} // ok
cls1 == defn.NullClass && cls1 == cls2
if cls1 == defn.NullClass || cls2 == defn.NullClass then cls1 == cls2
else cls1 == defn.NothingClass || cls2 == defn.NothingClass
else if cls1 == defn.NullClass then
cls1 == cls2 || cls2.derivesFrom(defn.ObjectClass)
else if cls2 == defn.NullClass then
Expand Down
16 changes: 16 additions & 0 deletions tests/explicit-nulls/pos/i21392.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//> using options -language:strictEquality

import scala.collection.LinearSeq

def foo[T](a: LinearSeq[T]) = a match
case Nil => -1
case head +: tail => head

enum Foo derives CanEqual:
case Bar
case Baz(x: String)


def foo(a: Foo) = a match
case Foo.Bar => -1
case _ => 0
Loading