-
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.
[dart2js] Add --interop-null-assertions.
This CL adds a new --interop-null-assertions flag (cf. --native-null-assertions) with the goal of validating that JS interop APIs with non-nullable static return types do not return null values. This flag is currently disabled by default but is intended to assist in sound null safety migrations. In general, we don't guarantee type soundness of package:js interop since users can write incorrect static types which are not backed by any runtime checks. However, it is likely that during the null safety migration, some interop APIs which should have been made nullable weren't. Therefore, we want to offer some additional (but limited) checking for this case. For static invocations of functions with non-nullable return types, we can simply perform a null check on the result of the call. For instance methods (which could be invoked virtually/dynamically), we want to perform a null check on the return value in the callee (the interceptor method) itself when possible. It's possible for multiple interop bindings to share the same interceptor method. We produce a null check in the interceptor method body if all the methods have non-nullable return types. Otherwise, we insert checks at callsites when appropriate. Change-Id: Ifd155d7f8326152b6d57d61199e0b7973c4a1211 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369784 Reviewed-by: Sigmund Cherem <[email protected]> Commit-Queue: Mayank Patke <[email protected]>
- Loading branch information
1 parent
bb66bd9
commit ca3e67a
Showing
20 changed files
with
1,010 additions
and
81 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.