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

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

Issue 2965393002: Use FastaMessage instead of String. Part 1. (Closed)
Patch Set: Add type variable to Code. Created 3 years, 5 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_procedure_builder; 5 library fasta.kernel_procedure_builder;
6 6
7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
8 show KernelProcedure; 8 show KernelProcedure;
9 9
10 import 'package:front_end/src/fasta/source/source_library_builder.dart' 10 import 'package:front_end/src/fasta/source/source_library_builder.dart'
(...skipping 28 matching lines...) Expand all
39 TypeParameter, 39 TypeParameter,
40 VariableDeclaration, 40 VariableDeclaration,
41 VariableGet, 41 VariableGet,
42 VoidType, 42 VoidType,
43 setParents; 43 setParents;
44 44
45 import 'package:kernel/type_algebra.dart' show containsTypeVariable, substitute; 45 import 'package:kernel/type_algebra.dart' show containsTypeVariable, substitute;
46 46
47 import '../deprecated_problems.dart' show deprecated_internalProblem; 47 import '../deprecated_problems.dart' show deprecated_internalProblem;
48 48
49 import '../messages.dart' show deprecated_warning; 49 import '../messages.dart' show messageNonInstanceTypeVariableUse, warning;
50 50
51 import '../loader.dart' show Loader; 51 import '../loader.dart' show Loader;
52 52
53 import 'kernel_builder.dart' 53 import 'kernel_builder.dart'
54 show 54 show
55 Builder, 55 Builder,
56 ClassBuilder, 56 ClassBuilder,
57 ConstructorReferenceBuilder, 57 ConstructorReferenceBuilder,
58 FormalParameterBuilder, 58 FormalParameterBuilder,
59 KernelFormalParameterBuilder, 59 KernelFormalParameterBuilder,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 List<TypeParameter> typeParameters = parent.target.typeParameters; 144 List<TypeParameter> typeParameters = parent.target.typeParameters;
145 if (typeParameters.isNotEmpty) { 145 if (typeParameters.isNotEmpty) {
146 Map<TypeParameter, DartType> substitution; 146 Map<TypeParameter, DartType> substitution;
147 DartType removeTypeVariables(DartType type) { 147 DartType removeTypeVariables(DartType type) {
148 if (substitution == null) { 148 if (substitution == null) {
149 substitution = <TypeParameter, DartType>{}; 149 substitution = <TypeParameter, DartType>{};
150 for (TypeParameter parameter in typeParameters) { 150 for (TypeParameter parameter in typeParameters) {
151 substitution[parameter] = const DynamicType(); 151 substitution[parameter] = const DynamicType();
152 } 152 }
153 } 153 }
154 deprecated_warning(fileUri, charOffset, 154 warning(messageNonInstanceTypeVariableUse, charOffset, fileUri);
155 "Can only use type variables in instance methods.");
156 return substitute(type, substitution); 155 return substitute(type, substitution);
157 } 156 }
158 157
159 Set<TypeParameter> set = typeParameters.toSet(); 158 Set<TypeParameter> set = typeParameters.toSet();
160 for (VariableDeclaration parameter in result.positionalParameters) { 159 for (VariableDeclaration parameter in result.positionalParameters) {
161 if (containsTypeVariable(parameter.type, set)) { 160 if (containsTypeVariable(parameter.type, set)) {
162 parameter.type = removeTypeVariables(parameter.type); 161 parameter.type = removeTypeVariables(parameter.type);
163 } 162 }
164 } 163 }
165 for (VariableDeclaration parameter in result.namedParameters) { 164 for (VariableDeclaration parameter in result.namedParameters) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 410 }
412 } 411 }
413 initializers.add(initializer..parent = constructor); 412 initializers.add(initializer..parent = constructor);
414 initializers.add(superInitializer); 413 initializers.add(superInitializer);
415 return; 414 return;
416 } 415 }
417 initializers.add(initializer); 416 initializers.add(initializer);
418 initializer.parent = constructor; 417 initializer.parent = constructor;
419 } 418 }
420 } 419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698