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_library_builder; | 5 library fasta.kernel_library_builder; |
6 | 6 |
7 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; | 7 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; |
8 import 'package:front_end/src/fasta/combinator.dart' as fasta; | 8 import 'package:front_end/src/fasta/combinator.dart' as fasta; |
9 import 'package:front_end/src/fasta/export.dart'; | 9 import 'package:front_end/src/fasta/export.dart'; |
10 import 'package:front_end/src/fasta/import.dart'; | 10 import 'package:front_end/src/fasta/import.dart'; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 List<KernelTypeBuilder> interfaces, | 283 List<KernelTypeBuilder> interfaces, |
284 int charOffset: -1}) { | 284 int charOffset: -1}) { |
285 if (type is KernelMixinApplicationBuilder) { | 285 if (type is KernelMixinApplicationBuilder) { |
286 subclassName ??= name; | 286 subclassName ??= name; |
287 List<List<String>> signatureParts = <List<String>>[]; | 287 List<List<String>> signatureParts = <List<String>>[]; |
288 Map<String, String> unresolved = <String, String>{}; | 288 Map<String, String> unresolved = <String, String>{}; |
289 Map<String, String> unresolvedReversed = <String, String>{}; | 289 Map<String, String> unresolvedReversed = <String, String>{}; |
290 int unresolvedCount = 0; | 290 int unresolvedCount = 0; |
291 Map<String, TypeBuilder> freeTypes = <String, TypeBuilder>{}; | 291 Map<String, TypeBuilder> freeTypes = <String, TypeBuilder>{}; |
292 | 292 |
| 293 // TODO(30316): Use correct locations of mixin applications |
| 294 // (e.g. identifiers for mixed-in classes). |
| 295 if (charOffset == -1) charOffset = type.charOffset; |
| 296 |
293 if (name == null || type.mixins.length != 1) { | 297 if (name == null || type.mixins.length != 1) { |
294 TypeBuilder last = type.mixins.last; | 298 TypeBuilder last = type.mixins.last; |
295 | 299 |
296 /// Compute a signature of the type arguments used by the supertype and | 300 /// Compute a signature of the type arguments used by the supertype and |
297 /// mixins. These types are free variables. At this point we can't | 301 /// mixins. These types are free variables. At this point we can't |
298 /// trust that the number of type arguments match the type parameters, | 302 /// trust that the number of type arguments match the type parameters, |
299 /// so we also need to be able to detect missing type arguments. To do | 303 /// so we also need to be able to detect missing type arguments. To do |
300 /// so, we separate each list of type arguments by `^` and type | 304 /// so, we separate each list of type arguments by `^` and type |
301 /// arguments by `&`. For example, the mixin `C<S> with M<T, U>` would | 305 /// arguments by `&`. For example, the mixin `C<S> with M<T, U>` would |
302 /// look like this: | 306 /// look like this: |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 -1); | 416 -1); |
413 } | 417 } |
414 KernelNamedTypeBuilder mixin = type.mixins[i]; | 418 KernelNamedTypeBuilder mixin = type.mixins[i]; |
415 for (var type in mixin.arguments ?? const []) { | 419 for (var type in mixin.arguments ?? const []) { |
416 type.bind(variables[type.name]); | 420 type.bind(variables[type.name]); |
417 } | 421 } |
418 checkArguments(supertype); | 422 checkArguments(supertype); |
419 checkArguments(mixin); | 423 checkArguments(mixin); |
420 supertype = applyMixin(supertype, mixin, signature, | 424 supertype = applyMixin(supertype, mixin, signature, |
421 isSyntheticMixinImplementation: true, | 425 isSyntheticMixinImplementation: true, |
422 typeVariables: | 426 typeVariables: new List<TypeVariableBuilder>.from(variables.values), |
423 new List<TypeVariableBuilder>.from(variables.values)); | 427 charOffset: charOffset); |
424 } | 428 } |
425 KernelNamedTypeBuilder mixin = type.mixins.last; | 429 KernelNamedTypeBuilder mixin = type.mixins.last; |
426 | 430 |
427 Set<String> supertypeArguments = new Set<String>(); | 431 Set<String> supertypeArguments = new Set<String>(); |
428 for (var part in currentSignatureParts) { | 432 for (var part in currentSignatureParts) { |
429 supertypeArguments.addAll(part); | 433 supertypeArguments.addAll(part); |
430 } | 434 } |
431 String signature = name == null ? computeSignature() : ""; | 435 String signature = name == null ? computeSignature() : ""; |
432 var variables; | 436 var variables; |
433 if (name == null) { | 437 if (name == null) { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 mixinApplicationClasses.putIfAbsent(name, () => builder); | 951 mixinApplicationClasses.putIfAbsent(name, () => builder); |
948 if (existing != builder) { | 952 if (existing != builder) { |
949 part.scope.local.remove(name); | 953 part.scope.local.remove(name); |
950 } | 954 } |
951 }); | 955 }); |
952 super.includePart(part); | 956 super.includePart(part); |
953 nativeMethods.addAll(part.nativeMethods); | 957 nativeMethods.addAll(part.nativeMethods); |
954 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 958 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
955 } | 959 } |
956 } | 960 } |
OLD | NEW |