Skip to content

Commit e8fbff1

Browse files
committed
Fix explicit null matching issue
1 parent 090dbf4 commit e8fbff1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
970970
def isNullable(tp: Type): Boolean = tp.dealias match
971971
case tp: TypeRef =>
972972
val tpSym = tp.symbol
973-
!tpSym.isPrimitiveValueClass ||
974973
tpSym.isNullableClass
975974
case tp: TermRef =>
976975
// https://scala-lang.org/files/archive/spec/2.13/03-types.html#singleton-types

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,8 @@ object Types extends TypeUtils {
11931193
*/
11941194
def matches(that: Type)(using Context): Boolean = {
11951195
record("matches")
1196-
TypeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes)
1196+
withoutMode(Mode.SafeNulls)(
1197+
TypeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes))
11971198
}
11981199

11991200
/** This is the same as `matches` except that it also matches => T with T and

0 commit comments

Comments
 (0)