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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2907643003: Correctly infer the return context while compiling a factory constructor. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index a5efbc240083ed52a1021824b5fba8b950824e25..919d44433af6e99a08e02d7953e7e3bfbda49917 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -468,13 +468,25 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
debugEvent("Initializers");
}
+ DartType _computeReturnTypeContext(MemberBuilder member) {
+ if (member is KernelProcedureBuilder) {
+ if (member.target.kind == ProcedureKind.Factory) {
+ return computeFactoryConstructorReturnType(member.target);
+ }
+ return member.target.function.returnType;
+ } else {
+ assert(member is KernelConstructorBuilder);
+ return null;
+ }
+ }
+
@override
void finishFunction(
FormalParameters formals, AsyncMarker asyncModifier, Statement body) {
debugEvent("finishFunction");
typePromoter.finished();
_typeInferrer.inferFunctionBody(
- member.target.function.returnType, asyncModifier, body);
+ _computeReturnTypeContext(member), asyncModifier, body);
KernelFunctionBuilder builder = member;
builder.body = body;
if (formals?.optional != null) {
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698