Skip to content

gate Null <: TermRef under safeNulls for consistency with TypeRef - #26943

Draft
olhotak wants to merge 1 commit into
scala:mainfrom
dotty-staging:gate-null-subtype-termref-safenulls
Draft

olhotak wants to merge 1 commit into
scala:mainfrom
dotty-staging:gate-null-subtype-termref-safenulls

Conversation

@olhotak

@olhotak olhotak commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

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

scala3/docs/_spec/03-types.md

Lines 1497 to 1499 in 1077009

- `´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

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.

Have you relied on LLM-based tools in this contribution?

No

How was the solution tested?

No new tests yet. The PR is to check whether existing CI still passes and for discussion.

See also #26941

@olhotak

olhotak commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

cc @noti0na1

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.
@olhotak
olhotak force-pushed the gate-null-subtype-termref-safenulls branch from 79f7101 to 809cb99 Compare September 8, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant