-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nnbd: can we make opt-out null safety == disabled null safety? #807
Comments
Based on https://github.com/dart-lang/language/pull/805/files#r373136879, we can update the semantics of generic function subtyping for everyone rather than track additional state. This is a breaking change, but I'd be surprised if anyone were actually hitting this corner case, and it shouldn't introduce any unsoundness. Normalization is likewise slightly breaking - subtyping shouldn't be affected given the change to generic function subtyping, but eager normalization means that error messages, etc. may change if they previously contained a non-normalized type. The normalization document only specifies an NNBD version of normalization, but it should be straightforward to implement something equivalent for legacy - we can omit the cases for |
As I see it, and correct me if I'm wrong, enabling NNBD is a whole-program operation. Without the experiment flag, we use the current semantics and no NNBD types. So, there should be no interaction between NNBD-on code and NNBD-off code, only between legacy and null-safe code when NNBD is on. |
@lrhn: This distinction doesn't work in practice. When compiling the platform dill with support for NNBD, the NNBD types will be part of the generated AST. This means that all computation must take the existence of NNBD types into account and the only specified way of dealing with such types outside of opt-in semantics is the opt-out semantics of weak mode. |
I think Siggi is concerned about the fact that using normalization and mutual subtyping in opted out code is technically a breaking change. |
For dart-lang/language#807 Change-Id: Ife86fa35fda20347437391d742a4432518d7898a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135350 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Is there more to do here? |
I think this is pretty much done. |
I'm starting to be concerned of the additional complexity from having to track 3 states on our implementations: whether nnbd is enabled, opt-out, or opt-in.
We have a very detailed specification of opt-out and opt-in, but no specification what it means to mix nnbd disabled code with opt-in code or opt-out code. We could try to specify it, but I wonder whether it is worth it. Instead, it might be simpler if we can equate opt-out and disabled.
This means releasing upfront a few breaking changes from null safety (hopefully small). For example:
FutureOr
terms. Front-ends may also be affected on interesection types (to the extend that they are supported)Object
vsFutureOr<Object>
), but may change the behavior of other subtype checks.I'd love to hear your thoughts.
/cc @fishythefish @johnniwinther
The text was updated successfully, but these errors were encountered: