Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 77f2603

Browse files
vsmenoncommit-bot@chromium.org
authored andcommitted
[dartdevc] preliminary nnbd support
For analyzer backend only: * Implements `x!` * Uses non-null type info where possible to elide null checks. * Does not yet reify. No hurry on this - starting to look at what's there. Some notes: * NNBD doesn't seem to be exposed directly on DartType yet. * x!.y doesn't seem to parse - need to write (x!).y. * Can't run existing tests yet - `package:expect`, etc., have NNBD errors. Change-Id: I58c24c950d00f3a40d789d4a7adf049786977c50 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103040 Commit-Queue: Vijay Menon <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 0e5d18f commit 77f2603

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/dev_compiler/lib/src/analyzer/code_generator.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5038,6 +5038,11 @@ class CodeGenerator extends Object
50385038
var op = node.operator;
50395039
var expr = node.operand;
50405040

5041+
if (op.type == TokenType.BANG) {
5042+
// If the expression is non-nullable already, this is a no-op.
5043+
return isNullable(expr) ? notNull(expr) : _visitExpression(expr);
5044+
}
5045+
50415046
var dispatchType = getStaticType(expr);
50425047
if (jsTypeRep.unaryOperationIsPrimitive(dispatchType)) {
50435048
if (!isNullable(expr)) {

0 commit comments

Comments
 (0)