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 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
8 /// | 8 /// |
9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 | 1529 |
1530 static NamedType _getNamedTypeOfVariable(VariableDeclaration node) { | 1530 static NamedType _getNamedTypeOfVariable(VariableDeclaration node) { |
1531 return new NamedType(node.name, node.type); | 1531 return new NamedType(node.name, node.type); |
1532 } | 1532 } |
1533 | 1533 |
1534 FunctionType get functionType { | 1534 FunctionType get functionType { |
1535 TreeNode parent = this.parent; | 1535 TreeNode parent = this.parent; |
1536 List<NamedType> named = | 1536 List<NamedType> named = |
1537 namedParameters.map(_getNamedTypeOfVariable).toList(growable: false); | 1537 namedParameters.map(_getNamedTypeOfVariable).toList(growable: false); |
1538 named.sort(); | 1538 named.sort(); |
| 1539 // We need create a copy of the list of type parameters, otherwise |
| 1540 // transformations like erasure don't work. |
| 1541 var typeParametersCopy = new List<TypeParameter>.from(parent is Constructor |
| 1542 ? parent.enclosingClass.typeParameters |
| 1543 : typeParameters); |
1539 return new FunctionType( | 1544 return new FunctionType( |
1540 positionalParameters.map(_getTypeOfVariable).toList(growable: false), | 1545 positionalParameters.map(_getTypeOfVariable).toList(growable: false), |
1541 returnType, | 1546 returnType, |
1542 namedParameters: named, | 1547 namedParameters: named, |
1543 typeParameters: parent is Constructor | 1548 typeParameters: typeParametersCopy, |
1544 ? parent.enclosingClass.typeParameters | |
1545 : typeParameters, | |
1546 requiredParameterCount: requiredParameterCount); | 1549 requiredParameterCount: requiredParameterCount); |
1547 } | 1550 } |
1548 | 1551 |
1549 accept(TreeVisitor v) => v.visitFunctionNode(this); | 1552 accept(TreeVisitor v) => v.visitFunctionNode(this); |
1550 | 1553 |
1551 visitChildren(Visitor v) { | 1554 visitChildren(Visitor v) { |
1552 visitList(typeParameters, v); | 1555 visitList(typeParameters, v); |
1553 visitList(positionalParameters, v); | 1556 visitList(positionalParameters, v); |
1554 visitList(namedParameters, v); | 1557 visitList(namedParameters, v); |
1555 returnType?.accept(v); | 1558 returnType?.accept(v); |
(...skipping 3184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4740 if (typedef_.canonicalName == null) { | 4743 if (typedef_.canonicalName == null) { |
4741 throw '$typedef_ has no canonical name'; | 4744 throw '$typedef_ has no canonical name'; |
4742 } | 4745 } |
4743 return typedef_.canonicalName; | 4746 return typedef_.canonicalName; |
4744 } | 4747 } |
4745 | 4748 |
4746 /// Annotation describing information which is not part of Dart semantics; in | 4749 /// Annotation describing information which is not part of Dart semantics; in |
4747 /// other words, if this information (or any information it refers to) changes, | 4750 /// other words, if this information (or any information it refers to) changes, |
4748 /// static analysis and runtime behavior of the library are unaffected. | 4751 /// static analysis and runtime behavior of the library are unaffected. |
4749 const informative = null; | 4752 const informative = null; |
OLD | NEW |