Index: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart |
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart |
index f4894c98dd1f26be9a6b34238f04e61207924f7c..45b41b39184a5099257fec64f481f06c1f3488ae 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart |
@@ -455,12 +455,13 @@ class KernelFunctionExpression extends FunctionExpression |
inferrer.closureContext.inferredReturnType, isExpressionFunction); |
if (!isExpressionFunction && |
returnContext != null && |
- !inferrer.typeSchemaEnvironment |
- .isSubtypeOf(inferredReturnType, returnContext)) { |
+ (!inferrer.typeSchemaEnvironment |
+ .isSubtypeOf(inferredReturnType, returnContext) || |
+ returnContext is VoidType)) { |
// For block-bodied functions, if the inferred return type isn't a |
- // subtype of the context, we use the context. TODO(paulberry): this is |
- // inherited from analyzer; it's not part of the spec. See also |
- // dartbug.com/29606. |
+ // subtype of the context (or the context is void), we use the context. |
+ // TODO(paulberry): this is inherited from analyzer; it's not part of |
+ // the spec. See also dartbug.com/29606. |
inferredReturnType = greatestClosure(inferrer.coreTypes, returnContext); |
} |