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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart

Issue 2943273002: Implement type inference of getters/setters based on inheritance. (Closed)
Patch Set: 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.kernel_field_builder; 5 library fasta.kernel_field_builder;
6 6
7 import 'package:front_end/src/fasta/kernel/body_builder.dart' show BodyBuilder; 7 import 'package:front_end/src/fasta/kernel/body_builder.dart' show BodyBuilder;
8 8
9 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 9 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
10 show KernelField; 10 show KernelField;
(...skipping 13 matching lines...) Expand all
24 24
25 import 'package:kernel/ast.dart' 25 import 'package:kernel/ast.dart'
26 show DartType, Expression, Field, Name, NullLiteral; 26 show DartType, Expression, Field, Name, NullLiteral;
27 27
28 import '../errors.dart' show internalError; 28 import '../errors.dart' show internalError;
29 29
30 import 'kernel_builder.dart' 30 import 'kernel_builder.dart'
31 show Builder, FieldBuilder, KernelTypeBuilder, MetadataBuilder; 31 show Builder, FieldBuilder, KernelTypeBuilder, MetadataBuilder;
32 32
33 class KernelFieldBuilder extends FieldBuilder<Expression> { 33 class KernelFieldBuilder extends FieldBuilder<Expression> {
34 final Field field; 34 final KernelField field;
35 final List<MetadataBuilder> metadata; 35 final List<MetadataBuilder> metadata;
36 final KernelTypeBuilder type; 36 final KernelTypeBuilder type;
37 final Token initializerTokenForInference; 37 final Token initializerTokenForInference;
38 final bool hasInitializer; 38 final bool hasInitializer;
39 39
40 KernelFieldBuilder( 40 KernelFieldBuilder(
41 this.metadata, 41 this.metadata,
42 this.type, 42 this.type,
43 String name, 43 String name,
44 int modifiers, 44 int modifiers,
(...skipping 21 matching lines...) Expand all
66 field.type = type.build(library); 66 field.type = type.build(library);
67 } 67 }
68 bool isInstanceMember = !isStatic && !isTopLevel; 68 bool isInstanceMember = !isStatic && !isTopLevel;
69 field 69 field
70 ..isFinal = isFinal 70 ..isFinal = isFinal
71 ..isConst = isConst 71 ..isConst = isConst
72 ..hasImplicitGetter = isInstanceMember 72 ..hasImplicitGetter = isInstanceMember
73 ..hasImplicitSetter = isInstanceMember && !isConst && !isFinal 73 ..hasImplicitSetter = isInstanceMember && !isConst && !isFinal
74 ..isStatic = !isInstanceMember; 74 ..isStatic = !isInstanceMember;
75 if (isEligibleForInference) { 75 if (isEligibleForInference) {
76 library.loader.typeInferenceEngine.recordField(field); 76 library.loader.typeInferenceEngine.recordMember(field);
77 } 77 }
78 return field; 78 return field;
79 } 79 }
80 80
81 Field get target => field; 81 Field get target => field;
82 82
83 @override 83 @override
84 void prepareInitializerInference( 84 void prepareInitializerInference(
85 SourceLibraryBuilder library, ClassBuilder currentClass) { 85 SourceLibraryBuilder library, ClassBuilder currentClass) {
86 if (isEligibleForInference) { 86 if (isEligibleForInference) {
(...skipping 22 matching lines...) Expand all
109 Expression expression = bodyBuilder.popForValue(); 109 Expression expression = bodyBuilder.popForValue();
110 bodyBuilder.checkEmpty(token.charOffset); 110 bodyBuilder.checkEmpty(token.charOffset);
111 initializer = expression; 111 initializer = expression;
112 } 112 }
113 } 113 }
114 } 114 }
115 115
116 @override 116 @override
117 DartType get builtType => field.type; 117 DartType get builtType => field.type;
118 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698