Skip to content

Commit 809cb99

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 f9dfa90 commit 809cb99

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
@@ -1036,10 +1036,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
10361036
// scala.AnyRef [Scala 3: which scala.Null conforms to], the type denotes the set of values consisting
10371037
// of null and the value denoted by p (i.e., the value v for which v eq p). [Otherwise,] the type
10381038
// denotes the set consisting of only the value denoted by p.
1039-
!ctx.explicitNulls && isNullable(tp.underlying) && tp.isStable
1039+
!ctx.mode.is(Mode.SafeNulls) && isNullable(tp.underlying) && tp.isStable
10401040
case tp: ThisType =>
10411041
// Same as above; this.type is also a singleton type in spec language
1042-
!ctx.explicitNulls && isNullable(tp.underlying)
1042+
!ctx.mode.is(Mode.SafeNulls) && isNullable(tp.underlying)
10431043
case tp: RefinedOrRecType => isNullable(tp.parent)
10441044
case tp: AppliedType => isNullable(tp.tycon)
10451045
case AndType(tp1, tp2) => isNullable(tp1) && isNullable(tp2)

0 commit comments

Comments
 (0)