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

Unified Diff: pkg/compiler/lib/src/inferrer/type_graph_inferrer.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/inferrer/type_graph_inferrer.dart
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
index 2b63c0c7d61c5e7939722eac8b3cebaae9f6f773..f13911a702765a61a054a78285944d458402c893 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
@@ -27,6 +27,8 @@ import '../native/native.dart' as native;
import '../tree/tree.dart' as ast
show DartString,
Node,
+ Send,
+ SendSet,
TryStatement;
import '../types/types.dart'
show ContainerTypeMask,
@@ -248,9 +250,13 @@ class TypeInformationSystem extends TypeSystem<TypeInformation> {
return info.type != selector.mask;
}
- TypeInformation refineReceiver(Selector selector, TypeInformation receiver) {
+ TypeInformation refineReceiver(Selector selector, TypeInformation receiver,
+ bool isConditional) {
if (receiver.type.isExact) return receiver;
TypeMask otherType = compiler.world.allFunctions.receiverType(selector);
+ // Conditional sends (a?.b) can still narrow the possible types of `a`,
+ // however, we still need to consider that `a` may be null.
+ if (isConditional) otherType = otherType.nullable();
sra1 2015/05/22 21:17:28 Only do this if receiver type is nullable. "Hello"
Siggi Cherem (dart-lang) 2015/05/22 22:36:08 Done.
// If this is refining to nullable subtype of `Object` just return
// the receiver. We know the narrowing is useless.
if (otherType.isNullable && otherType.containsAll(classWorld)) {

Powered by Google App Engine
This is Rietveld 408576698