Skip to content

Commit 34f5c9d

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
[cfe] Implement new async return rules
Closes #41800 Closes #41900 Closes #42134 Closes #42282 Closes #42236 Closes #42169 Change-Id: Ia994bc07fba4e2342fcb59d44fc77608198a328b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152150 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Dmitry Stefantsov <[email protected]>
1 parent 3a4aad6 commit 34f5c9d

34 files changed

+1217
-362
lines changed

pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart

+20
Original file line numberDiff line numberDiff line change
@@ -7541,6 +7541,26 @@ const MessageCode messageReturnWithoutExpression = const MessageCode(
75417541
severity: Severity.warning,
75427542
message: r"""Must explicitly return a value from a non-void function.""");
75437543

7544+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
7545+
const Code<Null> codeReturnWithoutExpressionAsync =
7546+
messageReturnWithoutExpressionAsync;
7547+
7548+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
7549+
const MessageCode messageReturnWithoutExpressionAsync = const MessageCode(
7550+
"ReturnWithoutExpressionAsync",
7551+
message:
7552+
r"""A value must be explicitly returned from a non-void async function.""");
7553+
7554+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
7555+
const Code<Null> codeReturnWithoutExpressionSync =
7556+
messageReturnWithoutExpressionSync;
7557+
7558+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
7559+
const MessageCode messageReturnWithoutExpressionSync = const MessageCode(
7560+
"ReturnWithoutExpressionSync",
7561+
message:
7562+
r"""A value must be explicitly returned from a non-void function.""");
7563+
75447564
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
75457565
const Template<Message Function(Uri uri_)> templateSdkRootNotFound =
75467566
const Template<Message Function(Uri uri_)>(

pkg/compiler/lib/src/ir/static_type_base.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ abstract class StaticTypeBase extends ir.Visitor<ir.DartType> {
100100

101101
@override
102102
ir.DartType visitAwaitExpression(ir.AwaitExpression node) {
103-
return typeEnvironment.unfutureType(visitNode(node.operand));
103+
return typeEnvironment.flatten(visitNode(node.operand));
104104
}
105105

106106
@override

pkg/dev_compiler/lib/src/kernel/compiler.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
31253125
var gen = emitGeneratorFn((_) => []);
31263126
// Return type of an async body is `Future<flatten(T)>`, where T is the
31273127
// declared return type.
3128-
var returnType = _types.unfutureType(function
3128+
var returnType = _types.flatten(function
31293129
.computeThisFunctionType(_currentLibrary.nonNullable)
31303130
.returnType);
31313131
return js.call('#.async(#, #)',

pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class InferenceVisitor
271271
node.operand, typeContext, true,
272272
isVoidAllowed: !inferrer.isNonNullableByDefault);
273273
DartType inferredType =
274-
inferrer.typeSchemaEnvironment.unfutureType(operandResult.inferredType);
274+
inferrer.typeSchemaEnvironment.flatten(operandResult.inferredType);
275275
node.operand = operandResult.expression..parent = node;
276276
return new ExpressionInferenceResult(inferredType, node);
277277
}
@@ -2161,7 +2161,7 @@ class InferenceVisitor
21612161
bool typeContextIsMap = node.keyType is! ImplicitTypeArgument;
21622162
bool typeContextIsIterable = false;
21632163
DartType unfuturedTypeContext =
2164-
inferrer.typeSchemaEnvironment.unfutureType(typeContext);
2164+
inferrer.typeSchemaEnvironment.flatten(typeContext);
21652165
if (!inferrer.isTopLevel && inferenceNeeded) {
21662166
// Ambiguous set/map literal
21672167
if (unfuturedTypeContext is InterfaceType) {

0 commit comments

Comments
 (0)