Skip to content

Commit 79f7101

Browse files
committed
gate Null <: TermRef under safeNulls for consistency with TypeRef
The spec for conformance currently says: ``` - `´S =´ scala.Null` and: - ´T = q.C[T_1, ..., T_n]´ with ´n \geq 0´ and ´C´ does not derive from `scala.AnyVal` and ´C´ is not the hidden class of an `object`, or - ´T = q.x´ is a term designator with underlying type ´U´ and `scala.Null ´<: U´`, or ``` https://github.com/scala/scala3/blob/10770098fb9cbdef238fc677979a19a5bfb5ba7c/docs/_spec/03-types.md?plain=1#L1497-L1499 Under explicit nulls, the former is changed only in a safe-nulls context, but the latter is changed even in unsafe nulls. This change gates both under safe-nulls for consistency.
1 parent 1077009 commit 79f7101

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
10371037
// scala.AnyRef [Scala 3: which scala.Null conforms to], the type denotes the set of values consisting
10381038
// of null and the value denoted by p (i.e., the value v for which v eq p). [Otherwise,] the type
10391039
// denotes the set consisting of only the value denoted by p.
1040-
!ctx.explicitNulls && isNullable(tp.underlying) && tp.isStable
1040+
!ctx.mode.is(Mode.SafeNulls) && isNullable(tp.underlying) && tp.isStable
10411041
case tp: ThisType =>
10421042
// Same as above; this.type is also a singleton type in spec language
1043-
!ctx.explicitNulls && isNullable(tp.underlying)
1043+
!ctx.mode.is(Mode.SafeNulls) && isNullable(tp.underlying)
10441044
case tp: RefinedOrRecType => isNullable(tp.parent)
10451045
case tp: AppliedType => isNullable(tp.tycon)
10461046
case AndType(tp1, tp2) => isNullable(tp1) && isNullable(tp2)

0 commit comments

Comments
 (0)