Commit 7436b97
[flow analysis] Allow non-cascaded field accesses to participate in field promotion.
The way this is accomplished is that in
`_FlowAnalysisImpl.nullAwareAccess_rightBegin`, any expression
reference associated with the target of the null-aware access is
restored, and the corresponding SSA node is associated with the guard
variable (if any). These changes ensure that if the null-aware access
is a property get, the subsequent call to `propertyGet` will pick up
the appropriate SSA node, so it will be able to locate the promotion
key for the property.
This functionality is only enabled when the language feature
`sound-flow-analysis` is enabled.
To prevent test regressions, a few related changes need to be made at
the same time:
- `_FlowAnalysisImpl.nullAwareAccess_end` is changed so that it clears
any expression info or expression reference that was associated with
the null-aware access expression. This prevents flow analysis
information from being erroneously propagated out of a null-aware
expression, which would have led to assertion failures when
analyzing null-aware expressions inside of conditional
expressions. This wasn't previously a problem because the expression
reference used to be consumed by
`_FlowAnalysisImpl.nullAwareAccess_rightBegin`, preventing further
expression references and expression infos from being recorded
further along in the null-aware access.
- The test framework in `mini_ast.dart` is fixed so that `!` is
considered to participate in null shorting. This was a bug in the
test framework that wasn't previously caught because it happened not
to produce any test failures.
- The analyzer's method `PostfixExpressionResolver._resolveNullCheck`
is changed so that it calls `nonNullAssert_end` before terminating
null-aware access. Previously, the order was swapped, causing
`nullAwareAccess_end` to be called before `nonNullAssert_end` when
analyzing expressions like `a?.b!`. This used to be benign, but now
that non-cascaded field accesses participate in field promotion,
flow analysis needs the methods to be called in the correct order.
Fixes dart-lang/language#4344.
Bug: dart-lang/language#4344
Change-Id: I523be1b4be1af3f68654a745187a546728c878fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427820
Commit-Queue: Paul Berry <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>1 parent 6d62d9a commit 7436b97
File tree
7 files changed
+214
-8
lines changed- pkg
- analyzer/lib/src/dart/resolver
- front_end/lib/src/type_inference
- tests/language
- inference_update_2
- sound_flow_analysis
7 files changed
+214
-8
lines changedLines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5926 | 5926 | | |
5927 | 5927 | | |
5928 | 5928 | | |
| 5929 | + | |
| 5930 | + | |
| 5931 | + | |
| 5932 | + | |
| 5933 | + | |
5929 | 5934 | | |
5930 | 5935 | | |
5931 | 5936 | | |
| |||
5955 | 5960 | | |
5956 | 5961 | | |
5957 | 5962 | | |
| 5963 | + | |
| 5964 | + | |
| 5965 | + | |
| 5966 | + | |
| 5967 | + | |
| 5968 | + | |
| 5969 | + | |
| 5970 | + | |
| 5971 | + | |
5958 | 5972 | | |
5959 | 5973 | | |
5960 | 5974 | | |
| |||
5967 | 5981 | | |
5968 | 5982 | | |
5969 | 5983 | | |
5970 | | - | |
| 5984 | + | |
5971 | 5985 | | |
5972 | 5986 | | |
5973 | 5987 | | |
| |||
Lines changed: 103 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11885 | 11885 | | |
11886 | 11886 | | |
11887 | 11887 | | |
| 11888 | + | |
| 11889 | + | |
| 11890 | + | |
| 11891 | + | |
| 11892 | + | |
| 11893 | + | |
| 11894 | + | |
| 11895 | + | |
| 11896 | + | |
| 11897 | + | |
| 11898 | + | |
| 11899 | + | |
| 11900 | + | |
| 11901 | + | |
| 11902 | + | |
| 11903 | + | |
| 11904 | + | |
| 11905 | + | |
| 11906 | + | |
| 11907 | + | |
| 11908 | + | |
| 11909 | + | |
| 11910 | + | |
| 11911 | + | |
| 11912 | + | |
| 11913 | + | |
| 11914 | + | |
| 11915 | + | |
| 11916 | + | |
| 11917 | + | |
| 11918 | + | |
| 11919 | + | |
| 11920 | + | |
| 11921 | + | |
| 11922 | + | |
| 11923 | + | |
| 11924 | + | |
| 11925 | + | |
| 11926 | + | |
| 11927 | + | |
| 11928 | + | |
| 11929 | + | |
| 11930 | + | |
| 11931 | + | |
| 11932 | + | |
| 11933 | + | |
| 11934 | + | |
| 11935 | + | |
| 11936 | + | |
| 11937 | + | |
| 11938 | + | |
| 11939 | + | |
| 11940 | + | |
| 11941 | + | |
| 11942 | + | |
| 11943 | + | |
| 11944 | + | |
| 11945 | + | |
| 11946 | + | |
| 11947 | + | |
| 11948 | + | |
| 11949 | + | |
| 11950 | + | |
| 11951 | + | |
| 11952 | + | |
| 11953 | + | |
| 11954 | + | |
| 11955 | + | |
| 11956 | + | |
| 11957 | + | |
| 11958 | + | |
| 11959 | + | |
| 11960 | + | |
| 11961 | + | |
| 11962 | + | |
| 11963 | + | |
| 11964 | + | |
| 11965 | + | |
| 11966 | + | |
| 11967 | + | |
| 11968 | + | |
| 11969 | + | |
| 11970 | + | |
| 11971 | + | |
| 11972 | + | |
| 11973 | + | |
| 11974 | + | |
| 11975 | + | |
| 11976 | + | |
| 11977 | + | |
| 11978 | + | |
| 11979 | + | |
| 11980 | + | |
| 11981 | + | |
| 11982 | + | |
| 11983 | + | |
| 11984 | + | |
| 11985 | + | |
| 11986 | + | |
| 11987 | + | |
| 11988 | + | |
| 11989 | + | |
| 11990 | + | |
11888 | 11991 | | |
11889 | 11992 | | |
11890 | 11993 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6520 | 6520 | | |
6521 | 6521 | | |
6522 | 6522 | | |
6523 | | - | |
| 6523 | + | |
| 6524 | + | |
| 6525 | + | |
| 6526 | + | |
| 6527 | + | |
6524 | 6528 | | |
6525 | 6529 | | |
6526 | 6530 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
239 | 238 | | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9637 | 9637 | | |
9638 | 9638 | | |
9639 | 9639 | | |
| 9640 | + | |
| 9641 | + | |
| 9642 | + | |
9640 | 9643 | | |
9641 | 9644 | | |
9642 | 9645 | | |
| |||
Lines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
| |||
Lines changed: 83 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
0 commit comments