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

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..1c28ffcd05a678c2b1f97362a9855f0666a104a5 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,15 @@ 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 && receiver.type.isNullable) {
+ otherType = otherType.nullable();
+ }
// 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)) {
« no previous file with comments | « pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart ('k') | pkg/compiler/lib/src/inferrer/type_graph_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698