Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: pkg/compiler/lib/src/resolution/send_resolver.dart

Issue 1151163004: Implementation of null-aware operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/resolution/send_resolver.dart
diff --git a/pkg/compiler/lib/src/resolution/send_resolver.dart b/pkg/compiler/lib/src/resolution/send_resolver.dart
index 77e35827ceb1f87252eb1e1ca789da3b51221940..0346cdc73161142326787b3c585b15b044f5df43 100644
--- a/pkg/compiler/lib/src/resolution/send_resolver.dart
+++ b/pkg/compiler/lib/src/resolution/send_resolver.dart
@@ -224,6 +224,8 @@ abstract class SendResolverMixin {
return const LogicalAndStructure();
} else if (operatorText == '||') {
return const LogicalOrStructure();
+ } else if (operatorText == '??') {
+ return const IfNullStructure();
}
}
@@ -510,7 +512,10 @@ abstract class SendResolverMixin {
} else {
return new StaticAccess.superMethod(element);
}
- } else if (node.isOperator) {
+ } else if (node.isOperator || node.isConditional) {
+ // Conditional sends (e?.x) are treated as dynamic property reads because
+ // they are equivalent to do ((a) => a == null ? null : a.x)(e). If `e` is
+ // a type `A`, this is equivalent to write `(A).x`.
return new DynamicAccess.dynamicProperty(node.receiver);
Johnni Winther 2015/05/22 12:39:49 Add a TODO for me to maybe add a DynamicAccess.con
Siggi Cherem (dart-lang) 2015/05/22 19:49:54 Done.
} else if (Elements.isClosureSend(node, element)) {
if (element == null) {

Powered by Google App Engine
This is Rietveld 408576698