You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reporting a specification bug in this repo is fine!
However, the current version of the specification does not include null safety, and the example is correct for pre-null-safety Dart.
Parts of a new version of the language specification that introduces null safety are under review. This new version includes a fix for this example (and for a few thousand other things ;-). The corrected program looks like this:
classA {
noSuchMethod(covariantNever n) => n;
}
voidmain() {
dynamic d =A();
d.foo(42); // Dynamic type error when invoking noSuchMethod.
}
It may seem silly to have a formal parameter whose type is Never (because it's never possible to successfully pass any actual argument to that parameter), but the point is still the same: We get a dynamic error because the given argument does not satisfy the typing requirement associated with the formal parameter, we don't get an infinite loop where each invocation of noSuchMethod directly causes another invocation of noSuchMethod.
Parts of the null-safety update is under review in #2023 and #2052, but the null-safety update consists of several additional parts, so it will take a while before everything has been landed (and this particular change is neither part of 2023 nor part of 2052).
Until then, please take the null safety specification into account as well as the language specification, in order to see how the language with null safety is defined.
Thanks!
Your reply is very helpful for me.
I forgot the type 'Never' before. I will firstly go to make a more totally understanding about null-safety via null safety specification before learning the specification. Thank you again!
before is the code in specification, below is the fact in my ide
My dart version shows as below,
Dart SDK version: 2.15.1 (stable) (Tue Dec 14 13:32:21 2021 +0100) on "macos_x64"
The text was updated successfully, but these errors were encountered: