| OLD | NEW |
| 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:kernel/ast.dart' show | 7 import 'package:kernel/ast.dart' show |
| 8 Arguments, | 8 Arguments, |
| 9 AsyncMarker, | 9 AsyncMarker, |
| 10 Constructor, | 10 Constructor, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 VoidType, | 33 VoidType, |
| 34 setParents; | 34 setParents; |
| 35 | 35 |
| 36 import 'package:kernel/type_algebra.dart' show | 36 import 'package:kernel/type_algebra.dart' show |
| 37 containsTypeVariable, | 37 containsTypeVariable, |
| 38 substitute; | 38 substitute; |
| 39 | 39 |
| 40 import '../errors.dart' show | 40 import '../errors.dart' show |
| 41 internalError; | 41 internalError; |
| 42 | 42 |
| 43 import '../messages.dart' show |
| 44 warning; |
| 45 |
| 43 import '../loader.dart' show | 46 import '../loader.dart' show |
| 44 Loader; | 47 Loader; |
| 45 | 48 |
| 46 import '../util/relativize.dart' show | 49 import '../util/relativize.dart' show |
| 47 relativizeUri; | 50 relativizeUri; |
| 48 | 51 |
| 49 import 'kernel_builder.dart' show | 52 import 'kernel_builder.dart' show |
| 50 Builder, | 53 Builder, |
| 51 ClassBuilder, | 54 ClassBuilder, |
| 52 ConstructorReferenceBuilder, | 55 ConstructorReferenceBuilder, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 List<TypeParameter> typeParameters = parent.target.typeParameters; | 125 List<TypeParameter> typeParameters = parent.target.typeParameters; |
| 123 if (typeParameters.isNotEmpty) { | 126 if (typeParameters.isNotEmpty) { |
| 124 Map<TypeParameter, DartType> substitution; | 127 Map<TypeParameter, DartType> substitution; |
| 125 DartType removeTypeVariables(DartType type) { | 128 DartType removeTypeVariables(DartType type) { |
| 126 if (substitution == null) { | 129 if (substitution == null) { |
| 127 substitution = <TypeParameter, DartType>{}; | 130 substitution = <TypeParameter, DartType>{}; |
| 128 for (TypeParameter parameter in typeParameters) { | 131 for (TypeParameter parameter in typeParameters) { |
| 129 substitution[parameter] = const DynamicType(); | 132 substitution[parameter] = const DynamicType(); |
| 130 } | 133 } |
| 131 } | 134 } |
| 132 print("Can only use type variables in instance methods."); | 135 warning(fileUri, charOffset, |
| 136 "Can only use type variables in instance methods."); |
| 133 return substitute(type, substitution); | 137 return substitute(type, substitution); |
| 134 } | 138 } |
| 135 Set<TypeParameter> set = typeParameters.toSet(); | 139 Set<TypeParameter> set = typeParameters.toSet(); |
| 136 for (VariableDeclaration parameter in result.positionalParameters) { | 140 for (VariableDeclaration parameter in result.positionalParameters) { |
| 137 if (containsTypeVariable(parameter.type, set)) { | 141 if (containsTypeVariable(parameter.type, set)) { |
| 138 parameter.type = removeTypeVariables(parameter.type); | 142 parameter.type = removeTypeVariables(parameter.type); |
| 139 } | 143 } |
| 140 } | 144 } |
| 141 for (VariableDeclaration parameter in result.namedParameters) { | 145 for (VariableDeclaration parameter in result.namedParameters) { |
| 142 if (containsTypeVariable(parameter.type, set)) { | 146 if (containsTypeVariable(parameter.type, set)) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 331 } |
| 328 } | 332 } |
| 329 initializers.add(initializer..parent = constructor); | 333 initializers.add(initializer..parent = constructor); |
| 330 initializers.add(superInitializer); | 334 initializers.add(superInitializer); |
| 331 return; | 335 return; |
| 332 } | 336 } |
| 333 initializers.add(initializer); | 337 initializers.add(initializer); |
| 334 initializer.parent = constructor; | 338 initializer.parent = constructor; |
| 335 } | 339 } |
| 336 } | 340 } |
| OLD | NEW |