diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index ca2df327851e..03f4e3e86a8e 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -970,7 +970,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling def isNullable(tp: Type): Boolean = tp.dealias match case tp: TypeRef => val tpSym = tp.symbol - !tpSym.isPrimitiveValueClass || tpSym.isNullableClass case tp: TermRef => // https://scala-lang.org/files/archive/spec/2.13/03-types.html#singleton-types diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index ab3b44847e18..884a71e23339 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1193,7 +1193,8 @@ object Types extends TypeUtils { */ def matches(that: Type)(using Context): Boolean = { record("matches") - TypeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes) + withoutMode(Mode.SafeNulls)( + TypeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes)) } /** This is the same as `matches` except that it also matches => T with T and