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

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

Issue 2667343005: Infer Null for return type of functions with empty returns. (Closed)
Patch Set: Avoid merge conflict Created 3 years, 11 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 61f6a106b1835ee569844af2117f9db7b3e197b1..44176db0f51d6f7493cfc48512b289a8c9976b3d 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);
}
/**
@@ -9030,6 +9027,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;
@@ -9223,6 +9225,11 @@ class TypeProviderImpl extends TypeProviderBase {
InterfaceType _futureNullType;
/**
+ * The type representing 'FutureOr<Null>'.
+ */
+ InterfaceType _futureOrNullType;
+
+ /**
* The type representing the built-in type 'FutureOr'.
*/
InterfaceType _futureOrType;
@@ -9358,6 +9365,9 @@ class TypeProviderImpl extends TypeProviderBase {
InterfaceType get futureNullType => _futureNullType;
@override
+ InterfaceType get futureOrNullType => _futureOrNullType;
+
+ @override
InterfaceType get futureOrType => _futureOrType;
@override
@@ -9462,6 +9472,7 @@ class TypeProviderImpl extends TypeProviderBase {
_undefinedType = UndefinedTypeImpl.instance;
_futureDynamicType = _futureType.instantiate(<DartType>[_dynamicType]);
_futureNullType = _futureType.instantiate(<DartType>[_nullType]);
+ _futureOrNullType = _futureOrType.instantiate(<DartType>[_nullType]);
_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