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

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

Issue 2941093002: Only attempt to do type inference on fields that lack a declared type. (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.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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 void addNamedMixinApplication( 182 void addNamedMixinApplication(
183 List<MetadataBuilder> metadata, 183 List<MetadataBuilder> metadata,
184 String name, 184 String name,
185 List<TypeVariableBuilder> typeVariables, 185 List<TypeVariableBuilder> typeVariables,
186 int modifiers, 186 int modifiers,
187 T mixinApplication, 187 T mixinApplication,
188 List<T> interfaces, 188 List<T> interfaces,
189 int charOffset); 189 int charOffset);
190 190
191 void addField(List<MetadataBuilder> metadata, int modifiers, T type, 191 void addField(
192 String name, int charOffset, Token initializer); 192 List<MetadataBuilder> metadata,
193 int modifiers,
194 T type,
195 String name,
196 int charOffset,
197 Token initializerTokenForInference,
198 bool hasInitializer);
193 199
194 void addFields(List<MetadataBuilder> metadata, int modifiers, T type, 200 void addFields(List<MetadataBuilder> metadata, int modifiers, T type,
195 List<Object> fieldsInfo) { 201 List<Object> fieldsInfo) {
196 for (int i = 0; i < fieldsInfo.length; i += 4) { 202 for (int i = 0; i < fieldsInfo.length; i += 4) {
197 String name = fieldsInfo[i]; 203 String name = fieldsInfo[i];
198 int charOffset = fieldsInfo[i + 1]; 204 int charOffset = fieldsInfo[i + 1];
199 Token initializer = fieldsInfo[i + 2]; 205 bool hasInitializer = fieldsInfo[i + 2] != null;
200 if (initializer != null) { 206 Token initializerTokenForInference =
207 type == null ? fieldsInfo[i + 2] : null;
208 if (initializerTokenForInference != null) {
201 Token beforeLast = fieldsInfo[i + 3]; 209 Token beforeLast = fieldsInfo[i + 3];
202 beforeLast.setNext(new Token.eof(beforeLast.next.offset)); 210 beforeLast.setNext(new Token.eof(beforeLast.next.offset));
203 } 211 }
204 addField(metadata, modifiers, type, name, charOffset, initializer); 212 addField(metadata, modifiers, type, name, charOffset,
213 initializerTokenForInference, hasInitializer);
205 } 214 }
206 } 215 }
207 216
208 void addProcedure( 217 void addProcedure(
209 List<MetadataBuilder> metadata, 218 List<MetadataBuilder> metadata,
210 int modifiers, 219 int modifiers,
211 T returnType, 220 T returnType,
212 String name, 221 String name,
213 List<TypeVariableBuilder> typeVariables, 222 List<TypeVariableBuilder> typeVariables,
214 List<FormalParameterBuilder> formals, 223 List<FormalParameterBuilder> formals,
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 /// synthesize type variables on the factory matching the class'. 599 /// synthesize type variables on the factory matching the class'.
591 void addFactoryDeclaration( 600 void addFactoryDeclaration(
592 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { 601 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) {
593 factoryDeclarations[procedure] = factoryDeclaration; 602 factoryDeclarations[procedure] = factoryDeclaration;
594 } 603 }
595 604
596 Scope toScope(Scope parent) { 605 Scope toScope(Scope parent) {
597 return new Scope(members, setters, parent, isModifiable: false); 606 return new Scope(members, setters, parent, isModifiable: false);
598 } 607 }
599 } 608 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698