There are several scenarios in which the flow analysis implementation
needs to be careful to mark variables as "not definitely unassigned",
even though they are not definitely assigned. These scenarios are
handled by the implementation but not yet properly spec'ed. Prior to
updating the spec, I wanted to make sure we had adequate test cases.
Change-Id: Id3f82279e0686f9cccfabd834396f05b8b28bcab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153825
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
These tests verify the scope over which a variable can become
de-promoted due conservative modeling of demotion. The conservative
model of demotion is used for loops, closures, switch statements, and
try blocks.
The implementation of flow analysis already passes these tests. I
will shortly be making a spec clarification that brings the spec in
line with the implementation.
Change-Id: I22a5584a808169fa228c2972c25844c432916c06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152920
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
* Setting the nonNullAsserts flag in the bootstrapping logic will
enable/disable failing when a null value is passed to a non-nullable
method parameter when running with weak null safety.
* Move the --null-assertions from VM options to the shared options in
the test and use it to set the flag in DDC the entry point.
* Configure other backends to ignore the flag.
Change-Id: Ia2670514bed7fa981564e99b85d74f6bae6dd9fc
Fixes: https://github.com/dart-lang/sdk/issues/42404
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151306
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
These tests all are or import legacy libraries, so are no longer
supported in NNBD strong mode. Adding Requirements=nnbd-weak tells the
test runner to skip that test when running in strong mode.
I deleted mixed_bottom_type_strong_test.dart entirely since it seems to
be specific to strong mode but is a legacy library. It is no longer
meaningful and there is already a corresponding weak test.
Change-Id: I5a8ec93114ad29abc3d12e356eeb7bf9efd3e1c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148234
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
All these tests now pass in both weak and strong mode, except for
relation_subclass_test and typedef_reflected_type_test. For those 2
tests I fixed the compile time error and now they have the same runtime
errors in both weak and strong mode (they were already failing at
runtime in weak mode).
Change-Id: If0157f811fffcf72a12ce6690ac0568c8f4419a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144343
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Fix several issues causing spurious errors in the top_merge tests and
remove one test file for which there is not a sensible resolution of
the issues.
Change-Id: Ia7fcdc02c0461980bae99cdbdc78bfac18d3efb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142887
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
The rule NNBD_TOP_MERGE(S*,T) = NNBD_TOP_MERGE(S,T) and the converse
imply that when a legacy member signature and a null-safe member
signature are brought together by two different superinterfaces,
the null-safe signature prevails (so the legacy signature is ignored).
This CL makes adjustments to 'legacy_resolves_conflict_3_test.dart'
to match this. Note that this means that a class like DiB3 has a
member signature `int Function(int) get a` even though it inherits an
implementation with signature `int? Function(int?) get a`, so we may
have to make such classes an error. [Edit: Based on the notion of
a 'class implementation', which is consolidated in the same sense as
the class interface, but which records the concrete member
declarations available in superclasses, with the declaration in the
nearest superclass prevailing over declarations in more remote ones,
the conflict disappears in the usual way: The class implementation
of a legacy class is legacy-erased. So there are no errors for those
classes after all.]
Change-Id: Ie72e6b80064764fa722304f32bee5e9188710a2c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142372
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Johnni Winther noted that several classes in
'legacy_resolves_conflict_3_lib2.dart' must be flagged as errors,
because they have incorrect override relationships between declarations
in the class and a the member signatures of a direct superinterface.
This CL moves those classes out of
'legacy_resolves_conflict_3_lib2.dart' and into
'logacy_resolves_conflict_3_error_test.dart',
such that they are only in scope in the library that expects compile-
time errors. Adjusted other libraries to stop referring to these
classes, and marked the classes with the expected errors.
Change-Id: Ia40f56efcb3dea17e60652dd8a2bbb892f89e5b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142142
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Updates Mar 19, for better precision in tests (that is, catching
more bugs):
Added tests where `r.m(null).isEven` is used
to near-verify that the receiver `r` implements `A<int*>`:
With `A<int>` it's an error to pass `null`, and with `A<int?>`
it is an error to invoke `isEven`.
Added '1_error' test to detect that `r.m(null).isEven` is a
compile-time error in cases where the receiver has a different
member signature for `m`.
Added '3_error' test to detect that it is a compile-time error to assign
'D().a' to a specific type, for many `D`. This helps catching the
situation where the member signature of `a` is legacy: if that were
true then this test will fail because there is no error).
Change-Id: If6abafbadb51dcb04d13876b577d15c74bf47ccc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139817
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Non-nullable and optional method arguments need default values. Embedded
the generic type argument into a List as an easy way to create a default
value.
Change-Id: Ib171c272c75b114447d356d423c45dc9aeff9bb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139160
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>