Chromium Code Reviews| 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)) { |