| 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 library kernel.transformations.mixin_full_resolution; | 4 library kernel.transformations.mixin_full_resolution; |
| 5 | 5 |
| 6 import '../ast.dart'; | 6 import '../ast.dart'; |
| 7 import '../class_hierarchy.dart'; | 7 import '../class_hierarchy.dart'; |
| 8 import '../clone.dart'; | 8 import '../clone.dart'; |
| 9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
| 10 import '../type_algebra.dart'; | 10 import '../type_algebra.dart'; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 324 |
| 325 // Do we give named that we don't take? | 325 // Do we give named that we don't take? |
| 326 Set<String> givenNamed = arguments.named.map((v) => v.name).toSet(); | 326 Set<String> givenNamed = arguments.named.map((v) => v.name).toSet(); |
| 327 Set<String> takenNamed = | 327 Set<String> takenNamed = |
| 328 targetFunction.namedParameters.map((v) => v.name).toSet(); | 328 targetFunction.namedParameters.map((v) => v.name).toSet(); |
| 329 givenNamed.removeAll(takenNamed); | 329 givenNamed.removeAll(takenNamed); |
| 330 return givenNamed.isEmpty; | 330 return givenNamed.isEmpty; |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 class SuperInitializerResolutionTransformer extends Transformer { | 334 class SuperInitializerResolutionTransformer extends InitializerVisitor { |
| 335 final Class lookupClass; | 335 final Class lookupClass; |
| 336 | 336 |
| 337 SuperInitializerResolutionTransformer(this.lookupClass); | 337 SuperInitializerResolutionTransformer(this.lookupClass); |
| 338 | 338 |
| 339 transformInitializers(List<Initializer> initializers) { | 339 transformInitializers(List<Initializer> initializers) { |
| 340 for (var initializer in initializers) { | 340 for (var initializer in initializers) { |
| 341 initializer.accept(this); | 341 initializer.accept(this); |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 visitSuperInitializer(SuperInitializer node) { | 345 visitSuperInitializer(SuperInitializer node) { |
| 346 Constructor constructor = node.target; | 346 Constructor constructor = node.target; |
| 347 if (constructor.enclosingClass != lookupClass) { | 347 if (constructor.enclosingClass != lookupClass) { |
| 348 // If [node] refers to a constructor target which is not directly the | 348 // If [node] refers to a constructor target which is not directly the |
| 349 // superclass but some indirect base class then this is because classes in | 349 // superclass but some indirect base class then this is because classes in |
| 350 // the middle are mixin applications. These mixin applications will have | 350 // the middle are mixin applications. These mixin applications will have |
| 351 // received a forwarding constructor which we are required to use instead. | 351 // received a forwarding constructor which we are required to use instead. |
| 352 for (var replacement in lookupClass.constructors) { | 352 for (var replacement in lookupClass.constructors) { |
| 353 if (constructor.name == replacement.name) { | 353 if (constructor.name == replacement.name) { |
| 354 node.target = replacement; | 354 node.target = replacement; |
| 355 return; | 355 return null; |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 | 358 |
| 359 throw new Exception( | 359 throw new Exception( |
| 360 'Could not find a generative constructor named "${constructor.name}" ' | 360 'Could not find a generative constructor named "${constructor.name}" ' |
| 361 'in lookup class "${lookupClass.name}"!'); | 361 'in lookup class "${lookupClass.name}"!'); |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 } | 364 } |
| OLD | NEW |