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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/source_library_builder.dart

Issue 2917853002: Compute correct return type for factory methods. (Closed)
Patch Set: Include changes from CL 2916533003. Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.source_library_builder; 5 library fasta.source_library_builder;
6 6
7 import 'package:front_end/src/scanner/token.dart' show Token; 7 import 'package:front_end/src/scanner/token.dart' show Token;
8 8
9 import 'package:kernel/ast.dart' show ProcedureKind; 9 import 'package:kernel/ast.dart' show ProcedureKind;
10 10
(...skipping 12 matching lines...) Expand all
23 import '../builder/builder.dart' 23 import '../builder/builder.dart'
24 show 24 show
25 Builder, 25 Builder,
26 ClassBuilder, 26 ClassBuilder,
27 ConstructorReferenceBuilder, 27 ConstructorReferenceBuilder,
28 FormalParameterBuilder, 28 FormalParameterBuilder,
29 FunctionTypeBuilder, 29 FunctionTypeBuilder,
30 LibraryBuilder, 30 LibraryBuilder,
31 MemberBuilder, 31 MemberBuilder,
32 MetadataBuilder, 32 MetadataBuilder,
33 NamedTypeBuilder,
33 PrefixBuilder, 34 PrefixBuilder,
34 ProcedureBuilder, 35 ProcedureBuilder,
35 Scope, 36 Scope,
36 TypeBuilder, 37 TypeBuilder,
37 TypeDeclarationBuilder, 38 TypeDeclarationBuilder,
38 TypeVariableBuilder, 39 TypeVariableBuilder,
39 Unhandled; 40 Unhandled;
40 41
41 abstract class SourceLibraryBuilder<T extends TypeBuilder, R> 42 abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
42 extends LibraryBuilder<T, R> { 43 extends LibraryBuilder<T, R> {
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 factoryDeclarations.forEach((_, DeclarationBuilder<T> declaration) { 534 factoryDeclarations.forEach((_, DeclarationBuilder<T> declaration) {
534 parent.types.addAll(declaration.types); 535 parent.types.addAll(declaration.types);
535 }); 536 });
536 parent.types.addAll(types); 537 parent.types.addAll(types);
537 } else { 538 } else {
538 factoryDeclarations.forEach( 539 factoryDeclarations.forEach(
539 (ProcedureBuilder procedure, DeclarationBuilder<T> declaration) { 540 (ProcedureBuilder procedure, DeclarationBuilder<T> declaration) {
540 assert(procedure.typeVariables.isEmpty); 541 assert(procedure.typeVariables.isEmpty);
541 procedure.typeVariables 542 procedure.typeVariables
542 .addAll(library.copyTypeVariables(typeVariables)); 543 .addAll(library.copyTypeVariables(typeVariables));
544 DeclarationBuilder<T> savedDeclaration = library.currentDeclaration;
545 library.currentDeclaration = declaration;
546 for (TypeVariableBuilder tv in procedure.typeVariables) {
547 NamedTypeBuilder<T, dynamic> t = procedure.returnType;
548 t.arguments
549 .add(library.addNamedType(tv.name, null, procedure.charOffset));
550 }
551 library.currentDeclaration = savedDeclaration;
543 declaration.resolveTypes(procedure.typeVariables, library); 552 declaration.resolveTypes(procedure.typeVariables, library);
544 }); 553 });
545 Map<String, TypeVariableBuilder> map = <String, TypeVariableBuilder>{}; 554 Map<String, TypeVariableBuilder> map = <String, TypeVariableBuilder>{};
546 for (TypeVariableBuilder builder in typeVariables) { 555 for (TypeVariableBuilder builder in typeVariables) {
547 map[builder.name] = builder; 556 map[builder.name] = builder;
548 } 557 }
549 for (T type in types) { 558 for (T type in types) {
550 String name = type.name; 559 String name = type.name;
551 TypeVariableBuilder builder; 560 TypeVariableBuilder builder;
552 if (name != null) { 561 if (name != null) {
(...skipping 16 matching lines...) Expand all
569 /// synthesize type variables on the factory matching the class'. 578 /// synthesize type variables on the factory matching the class'.
570 void addFactoryDeclaration( 579 void addFactoryDeclaration(
571 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { 580 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) {
572 factoryDeclarations[procedure] = factoryDeclaration; 581 factoryDeclarations[procedure] = factoryDeclaration;
573 } 582 }
574 583
575 Scope toScope(Scope parent) { 584 Scope toScope(Scope parent) {
576 return new Scope(members, setters, parent, isModifiable: false); 585 return new Scope(members, setters, parent, isModifiable: false);
577 } 586 }
578 } 587 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart ('k') | pkg/front_end/test/fasta/compile.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698