| 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 | |
| 297 if (name == null || type.mixins.length != 1) { | 293 if (name == null || type.mixins.length != 1) { |
| 298 TypeBuilder last = type.mixins.last; | 294 TypeBuilder last = type.mixins.last; |
| 299 | 295 |
| 300 /// Compute a signature of the type arguments used by the supertype and | 296 /// Compute a signature of the type arguments used by the supertype and |
| 301 /// mixins. These types are free variables. At this point we can't | 297 /// mixins. These types are free variables. At this point we can't |
| 302 /// trust that the number of type arguments match the type parameters, | 298 /// trust that the number of type arguments match the type parameters, |
| 303 /// so we also need to be able to detect missing type arguments. To do | 299 /// so we also need to be able to detect missing type arguments. To do |
| 304 /// so, we separate each list of type arguments by `^` and type | 300 /// so, we separate each list of type arguments by `^` and type |
| 305 /// arguments by `&`. For example, the mixin `C<S> with M<T, U>` would | 301 /// arguments by `&`. For example, the mixin `C<S> with M<T, U>` would |
| 306 /// look like this: | 302 /// look like this: |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 -1); | 412 -1); |
| 417 } | 413 } |
| 418 KernelNamedTypeBuilder mixin = type.mixins[i]; | 414 KernelNamedTypeBuilder mixin = type.mixins[i]; |
| 419 for (var type in mixin.arguments ?? const []) { | 415 for (var type in mixin.arguments ?? const []) { |
| 420 type.bind(variables[type.name]); | 416 type.bind(variables[type.name]); |
| 421 } | 417 } |
| 422 checkArguments(supertype); | 418 checkArguments(supertype); |
| 423 checkArguments(mixin); | 419 checkArguments(mixin); |
| 424 supertype = applyMixin(supertype, mixin, signature, | 420 supertype = applyMixin(supertype, mixin, signature, |
| 425 isSyntheticMixinImplementation: true, | 421 isSyntheticMixinImplementation: true, |
| 426 typeVariables: new List<TypeVariableBuilder>.from(variables.values), | 422 typeVariables: |
| 427 charOffset: charOffset); | 423 new List<TypeVariableBuilder>.from(variables.values)); |
| 428 } | 424 } |
| 429 KernelNamedTypeBuilder mixin = type.mixins.last; | 425 KernelNamedTypeBuilder mixin = type.mixins.last; |
| 430 | 426 |
| 431 Set<String> supertypeArguments = new Set<String>(); | 427 Set<String> supertypeArguments = new Set<String>(); |
| 432 for (var part in currentSignatureParts) { | 428 for (var part in currentSignatureParts) { |
| 433 supertypeArguments.addAll(part); | 429 supertypeArguments.addAll(part); |
| 434 } | 430 } |
| 435 String signature = name == null ? computeSignature() : ""; | 431 String signature = name == null ? computeSignature() : ""; |
| 436 var variables; | 432 var variables; |
| 437 if (name == null) { | 433 if (name == null) { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 mixinApplicationClasses.putIfAbsent(name, () => builder); | 947 mixinApplicationClasses.putIfAbsent(name, () => builder); |
| 952 if (existing != builder) { | 948 if (existing != builder) { |
| 953 part.scope.local.remove(name); | 949 part.scope.local.remove(name); |
| 954 } | 950 } |
| 955 }); | 951 }); |
| 956 super.includePart(part); | 952 super.includePart(part); |
| 957 nativeMethods.addAll(part.nativeMethods); | 953 nativeMethods.addAll(part.nativeMethods); |
| 958 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 954 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
| 959 } | 955 } |
| 960 } | 956 } |
| OLD | NEW |