This allows more migration tool unit tests to be simplified so that
they don't have to refer to ConstraintVariable objects directly
anymore.
In order to make this work, a few other changes were also necessary:
- Make a derived class for NullabilityNodes that arise from
conditional expressions.
- Add a getter to reveal whether a NullabilityNode is known a priori
to be non-nullable.
Change-Id: I8a68b627ce9e807a50d371369985f52848903a2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100922
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Previously, this class held on to a ConstraintVariable indicating
whether a null check should be inserted. Now it holds on to
NullabilityNodes indicating whether the source and destination of an
assignment are nullable, and it can infer from this whether a null
check needs to be inserted.
This paves the way for removing the old constraint solving logic in
favor of a more direct nullability propagation approach using
nullability nodes.
Change-Id: I96b95c400ed40bd12f9c9dcbb4c09a69849e51c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100885
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This should make it easier to refactor the migration logic without
having to change tests too much.
Note that there is a minor loss of test coverage: in
test_functionInvocation_parameter_fromLocalParameter, we no longer
verify that non-null intent is sufficent to force a check to occur.
This is ok, because in future CLs, we will be simplifying the logic
for deciding when to add null checks so that it occurs precisely when
it's necessary to avoid a type mismatch. Once that change has been
made, the correct behavior with non-null intent will happen
automatically.
Change-Id: I087c5c800fae3defa5b68380f05da40700af1359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100793
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
And change clients of the scanner (within the SDK) to use it.
Long term, it would be better to store the FeatureSet object directly
in the Scanner and remove the existing flags `enableGtGt` and
`enableNonNullable`. However there are analyzer clients that
currently use these flags. So for now, we simply plumb in the
FeatureSet as a new way of setting AstBuilder flags. Once we've
updated clients to use FeatureSet, we'll publish a breaking version of
the analyzer that removes the old flag API.
Change-Id: I9e662f4ed45668d9acd4f56e42d7d8dae6180d48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99975
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Previously, a valid web socket connection would use the following URI:
`ws://127.0.0.1/ws`
Now, by default, the VM service requires a connection to be made with a
URI similar to the following:
`ws://127.0.0.1:8181/Ug_U0QVsqFs=/ws`
where `Ug_U0QVsqFs` is an authentication code generated and shared by the
service.
This behavior can be disabled with the `--disable-service-auth-codes`
flag.
Change-Id: I288aac58e3ba9d35dca8071f3f7e7a073896c271
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98433
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Noteworthy that this issue was flagged by an attempt to convert flutter (https://github.com/flutter/flutter/pull/30784). Specifically, the assist here was throw a Bad Element exception:
set fakeResults(Map<String, List<ProcessResult>> value) {
_fakeResults = <String, List<ProcessResult>>{};
for (String key in value.keys) {
_fakeResults[key] = <ProcessResult>[]
..addAll(value[key] ?? <ProcessResult>[ProcessResult(0, 0, '', '')]);
}
}
Change-Id: Icec80f14160cf9ba28a4e8e39935f469e762b39f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98985
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
This CL adds the following new members to NullabilityNode:
- A `debugSuffix` getter, to retrieve a string representation of a
nullability node for debugging test failures.
- An `isAlwaysNullable` getter, to determine whether a NullabilityNode
is known, by construction, to always be nullable.
- An `isNullable` getter, to determine whether constraint solving
assigned the nullability node to be nullable.
With these new members, the two constraint variables inside the
NullabilityNode class (`nullabile` and `_nonNullIntent`) are only
referred to from within the NullabilityNode class itself, and in
tests.
Change-Id: I0f51aa2834a885fb13c6bbfe7d68cd517b65724a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98982
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The code that accomplishes this is non-obvious (it relies on the fact
that we use the same constraint variable to track the nullability of
such parameters as to track their optional-ness), so it's worth having
specific tests for.
Change-Id: Ia2ccfca6ffe3f8050f14b3849e80a0e721cc143f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98961
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
With this CL, the NullabilityNode class is now used for the following
purposes:
- In ConditionalDiscard, to keep track of when branches of "if"
statements should be discarded.
- To track the nullability relationships implied by an assignment.
- To track the nullability implied by an optional parameter that lacks
a default value.
- In _ConditionInfo, to keep track of how assert statements imply
non-null intent.
Change-Id: Ieb05bb569258a3d16720c127a3f6038f805304c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98960
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>