From e8fbff18c648514bf919f16e1a2647657496bc47 Mon Sep 17 00:00:00 2001 From: HarrisL2 Date: Thu, 19 Dec 2024 19:41:16 -0500 Subject: [PATCH] Fix explicit null matching issue --- compiler/src/dotty/tools/dotc/core/TypeComparer.scala | 1 - compiler/src/dotty/tools/dotc/core/Types.scala | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) 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