| 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:js_runtime/shared/embedded_names.dart'; | 5 import 'package:js_runtime/shared/embedded_names.dart'; |
| 6 import 'package:kernel/ast.dart' as ir; | 6 import 'package:kernel/ast.dart' as ir; |
| 7 | 7 |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 @override | 740 @override |
| 741 DartType visitTypeParameterType(ir.TypeParameterType node) { | 741 DartType visitTypeParameterType(ir.TypeParameterType node) { |
| 742 if (node.parameter.parent is ir.Class) { | 742 if (node.parameter.parent is ir.Class) { |
| 743 ir.Class cls = node.parameter.parent; | 743 ir.Class cls = node.parameter.parent; |
| 744 int index = cls.typeParameters.indexOf(node.parameter); | 744 int index = cls.typeParameters.indexOf(node.parameter); |
| 745 ClassElement classElement = astAdapter.getElement(cls); | 745 ClassElement classElement = astAdapter.getElement(cls); |
| 746 return classElement.typeVariables[index]; | 746 return classElement.typeVariables[index]; |
| 747 } else if (node.parameter.parent is ir.FunctionNode) { | 747 } else if (node.parameter.parent is ir.FunctionNode) { |
| 748 ir.FunctionNode func = node.parameter.parent; | 748 ir.FunctionNode func = node.parameter.parent; |
| 749 int index = func.typeParameters.indexOf(node.parameter); | 749 int index = func.typeParameters.indexOf(node.parameter); |
| 750 ConstructorElement constructorElement = astAdapter.getElement(func); | 750 Element element = astAdapter.getElement(func); |
| 751 ClassElement classElement = constructorElement.enclosingClass; | 751 if (element.isConstructor) { |
| 752 return classElement.typeVariables[index]; | 752 ClassElement classElement = element.enclosingClass; |
| 753 return classElement.typeVariables[index]; |
| 754 } else { |
| 755 GenericElement genericElement = element; |
| 756 return genericElement.typeVariables[index]; |
| 757 } |
| 753 } | 758 } |
| 754 throw new UnsupportedError('Unsupported type parameter type node $node.'); | 759 throw new UnsupportedError('Unsupported type parameter type node $node.'); |
| 755 } | 760 } |
| 756 | 761 |
| 757 @override | 762 @override |
| 758 DartType visitFunctionType(ir.FunctionType node) { | 763 DartType visitFunctionType(ir.FunctionType node) { |
| 759 return new FunctionType.synthesized( | 764 return new FunctionType.synthesized( |
| 760 visitType(node.returnType), | 765 visitType(node.returnType), |
| 761 visitTypes(node.positionalParameters | 766 visitTypes(node.positionalParameters |
| 762 .take(node.requiredParameterCount) | 767 .take(node.requiredParameterCount) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 astAdapter.reporter.internalError( | 859 astAdapter.reporter.internalError( |
| 855 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); | 860 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); |
| 856 return null; | 861 return null; |
| 857 } | 862 } |
| 858 | 863 |
| 859 @override | 864 @override |
| 860 ConstantExpression visitStringLiteral(ir.StringLiteral node) { | 865 ConstantExpression visitStringLiteral(ir.StringLiteral node) { |
| 861 return new StringConstantExpression(node.value); | 866 return new StringConstantExpression(node.value); |
| 862 } | 867 } |
| 863 } | 868 } |
| OLD | NEW |