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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 2667343005: Infer Null for return type of functions with empty returns. (Closed)
Patch Set: Address comments, fix 28630, ddc expectations Created 3 years, 10 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/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 5d90f3c03d3c59932fa4978a73d9d30a7cf213f9..8b6fbf711ef55de721391a5ed9a0d6d059222b0f 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -4208,9 +4208,6 @@ class InferenceContext {
if (_returnStack.isNotEmpty && _inferredReturn.isNotEmpty) {
DartType context = _returnStack.removeLast() ?? DynamicTypeImpl.instance;
DartType inferred = _inferredReturn.removeLast();
- if (inferred.isBottom || inferred.isDartCoreNull) {
- return;
- }
if (_typeSystem.isSubtypeOf(inferred, context)) {
setType(node, inferred);
@@ -4225,7 +4222,7 @@ class InferenceContext {
*/
void pushReturnContext(BlockFunctionBody node) {
_returnStack.add(getContext(node));
- _inferredReturn.add(BottomTypeImpl.instance);
+ _inferredReturn.add(_typeProvider.nullType);
}
/**
@@ -9067,6 +9064,11 @@ abstract class TypeProvider {
InterfaceType get futureNullType;
/**
+ * Return the type representing 'FutureOr<Null>'.
+ */
+ InterfaceType get futureOrNullType;
+
+ /**
* Return the type representing the built-in type 'FutureOr'.
*/
InterfaceType get futureOrType;
@@ -9260,6 +9262,11 @@ class TypeProviderImpl extends TypeProviderBase {
InterfaceType _futureNullType;
/**
+ * The type representing 'FutureOr<Null>'.
+ */
+ InterfaceType _futureOrNullType;
+
+ /**
* The type representing the built-in type 'FutureOr'.
*/
InterfaceType _futureOrType;
@@ -9395,6 +9402,9 @@ class TypeProviderImpl extends TypeProviderBase {
InterfaceType get futureNullType => _futureNullType;
@override
+ InterfaceType get futureOrNullType => _futureOrNullType;
+
+ @override
InterfaceType get futureOrType => _futureOrType;
@override
@@ -9499,6 +9509,7 @@ class TypeProviderImpl extends TypeProviderBase {
_undefinedType = UndefinedTypeImpl.instance;
_futureDynamicType = _futureType.instantiate(<DartType>[_dynamicType]);
_futureNullType = _futureType.instantiate(<DartType>[_nullType]);
+ _futureOrNullType = _futureOrType.instantiate(<DartType>[_nullType]);
Paul Berry 2017/02/07 18:13:03 This line needs to be after line 9517, or a null r
_iterableDynamicType = _iterableType.instantiate(<DartType>[_dynamicType]);
_streamDynamicType = _streamType.instantiate(<DartType>[_dynamicType]);
// FutureOr<T> is still fairly new, so if we're analyzing an SDK that

Powered by Google App Engine
This is Rietveld 408576698