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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart'; | 8 import '../common/names.dart'; |
9 import '../compiler.dart'; | 9 import '../compiler.dart'; |
10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 handleNew(node, node.target, isConst: node.isConst); | 269 handleNew(node, node.target, isConst: node.isConst); |
270 } | 270 } |
271 | 271 |
272 void handleNew(ir.InvocationExpression node, ir.Member target, | 272 void handleNew(ir.InvocationExpression node, ir.Member target, |
273 {bool isConst: false}) { | 273 {bool isConst: false}) { |
274 _visitArguments(node.arguments); | 274 _visitArguments(node.arguments); |
275 ConstructorEntity constructor = elementAdapter.getConstructor(target); | 275 ConstructorEntity constructor = elementAdapter.getConstructor(target); |
276 if (commonElements.isSymbolConstructor(constructor)) { | 276 if (commonElements.isSymbolConstructor(constructor)) { |
277 impactBuilder.registerFeature(Feature.SYMBOL_CONSTRUCTOR); | 277 impactBuilder.registerFeature(Feature.SYMBOL_CONSTRUCTOR); |
278 } | 278 } |
| 279 |
| 280 if (target.isExternal && |
| 281 constructor.isFromEnvironmentConstructor && |
| 282 !isConst) { |
| 283 impactBuilder.registerFeature(Feature.THROW_UNSUPPORTED_ERROR); |
| 284 return; |
| 285 } |
| 286 |
279 InterfaceType type = elementAdapter.createInterfaceType( | 287 InterfaceType type = elementAdapter.createInterfaceType( |
280 target.enclosingClass, node.arguments.types); | 288 target.enclosingClass, node.arguments.types); |
281 CallStructure callStructure = | 289 CallStructure callStructure = |
282 elementAdapter.getCallStructure(node.arguments); | 290 elementAdapter.getCallStructure(node.arguments); |
283 impactBuilder.registerStaticUse(isConst | 291 impactBuilder.registerStaticUse(isConst |
284 ? new StaticUse.constConstructorInvoke(constructor, callStructure, type) | 292 ? new StaticUse.constConstructorInvoke(constructor, callStructure, type) |
285 : new StaticUse.typedConstructorInvoke( | 293 : new StaticUse.typedConstructorInvoke( |
286 constructor, callStructure, type)); | 294 constructor, callStructure, type)); |
287 if (type.typeArguments.any((DartType type) => !type.isDynamic)) { | 295 if (type.typeArguments.any((DartType type) => !type.isDynamic)) { |
288 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); | 296 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 ConstructorEntity target = elementAdapter.getConstructor(node.target); | 612 ConstructorEntity target = elementAdapter.getConstructor(node.target); |
605 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( | 613 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( |
606 target, elementAdapter.getCallStructure(node.arguments))); | 614 target, elementAdapter.getCallStructure(node.arguments))); |
607 } | 615 } |
608 | 616 |
609 // TODO(johnniwinther): Make this throw and visit child nodes explicitly | 617 // TODO(johnniwinther): Make this throw and visit child nodes explicitly |
610 // instead to ensure that we don't visit unwanted parts of the ir. | 618 // instead to ensure that we don't visit unwanted parts of the ir. |
611 @override | 619 @override |
612 void defaultNode(ir.Node node) => node.visitChildren(this); | 620 void defaultNode(ir.Node node) => node.visitChildren(this); |
613 } | 621 } |
OLD | NEW |