-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 39667. Use flow analysis in IfElement.
Bug: #39667 Change-Id: I4528869a8d39d1b27c0cdf21ab20173bdb0efbc4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127482 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Paul Berry <paulberry@google.com>
- Loading branch information
Showing
3 changed files
with
135 additions
and
9 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/if_element.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
void list_if_notNull_then_else_left(int? x) { | ||
[if (null != x) /*nonNullable*/ x else x]; | ||
} | ||
|
||
void list_if_notNull_then_else_right(int? x) { | ||
[if (x != null) /*nonNullable*/ x else x]; | ||
} | ||
|
||
void list_if_notNull_thenExit_left(int? x) { | ||
[if (null != x) throw 42, x]; | ||
} | ||
|
||
void list_if_notNull_thenExit_right(int? x) { | ||
[if (x != null) throw 42, x]; | ||
} | ||
|
||
void list_if_null_then_else_left(int? x) { | ||
[if (null == x) x else /*nonNullable*/ x ]; | ||
} | ||
|
||
void list_if_null_then_else_right(int? x) { | ||
[if (x == null) x else /*nonNullable*/ x ]; | ||
} | ||
|
||
void list_if_null_thenExit_left(int? x) { | ||
[if (null == x) throw 42, /*nonNullable*/ x]; | ||
} | ||
|
||
void list_if_null_thenExit_right(int? x) { | ||
[if (x == null) throw 42, /*nonNullable*/ x]; | ||
} | ||
|
||
map_if_notNull_then_else_left(int? x) { | ||
return {if (null != x) /*nonNullable*/ x: /*nonNullable*/ x else x: x}; | ||
} | ||
|
||
map_if_notNull_then_else_right(int? x) { | ||
return {if (x != null) /*nonNullable*/ x: /*nonNullable*/ x else x: x}; | ||
} | ||
|
||
map_if_notNull_thenExit_left(int? x) { | ||
return {if (null != x) throw 42: 0, x: x}; | ||
} | ||
|
||
map_if_notNull_thenExit_right(int? x) { | ||
return {if (x != null) throw 42: 0, x: x}; | ||
} | ||
|
||
map_if_null_then_else_left(int? x) { | ||
return {if (null == x) x: x else /*nonNullable*/ x: /*nonNullable*/ x }; | ||
} | ||
|
||
map_if_null_then_else_right(int? x) { | ||
return {if (x == null) x: x else /*nonNullable*/ x: /*nonNullable*/ x }; | ||
} | ||
|
||
map_if_null_thenExit_left(int? x) { | ||
return {if (null == x) throw 42: 0, /*nonNullable*/ x: /*nonNullable*/ x }; | ||
} | ||
|
||
map_if_null_thenExit_right(int? x) { | ||
return {if (x == null) throw 42: 0, /*nonNullable*/ x: /*nonNullable*/ x }; | ||
} | ||
|
||
set_if_notNull_then_else_left(int? x) { | ||
return {if (null != x) /*nonNullable*/ x else x}; | ||
} | ||
|
||
set_if_notNull_then_else_right(int? x) { | ||
return {if (x != null) /*nonNullable*/ x else x}; | ||
} | ||
|
||
set_if_notNull_thenExit_left(int? x) { | ||
return {if (null != x) throw 42, x}; | ||
} | ||
|
||
set_if_notNull_thenExit_right(int? x) { | ||
return {if (x != null) throw 42, x}; | ||
} | ||
|
||
set_if_null_then_else_left(int? x) { | ||
return {if (null == x) x else /*nonNullable*/ x }; | ||
} | ||
|
||
set_if_null_then_else_right(int? x) { | ||
return {if (x == null) x else /*nonNullable*/ x }; | ||
} | ||
|
||
set_if_null_thenExit_left(int? x) { | ||
return {if (null == x) throw 42, /*nonNullable*/ x}; | ||
} | ||
|
||
set_if_null_thenExit_right(int? x) { | ||
return {if (x == null) throw 42, /*nonNullable*/ x}; | ||
} | ||
|
||
class C { | ||
C.constructor_if_then_else(int? x) { | ||
[if (x == null) x else /*nonNullable*/ x ]; | ||
} | ||
|
||
void method_if_then_else(int? x) { | ||
[if (x == null) x else /*nonNullable*/ x ]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters