| 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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 | 1532 |
| 1533 static NamedType _getNamedTypeOfVariable(VariableDeclaration node) { | 1533 static NamedType _getNamedTypeOfVariable(VariableDeclaration node) { |
| 1534 return new NamedType(node.name, node.type); | 1534 return new NamedType(node.name, node.type); |
| 1535 } | 1535 } |
| 1536 | 1536 |
| 1537 FunctionType get functionType { | 1537 FunctionType get functionType { |
| 1538 TreeNode parent = this.parent; | 1538 TreeNode parent = this.parent; |
| 1539 List<NamedType> named = | 1539 List<NamedType> named = |
| 1540 namedParameters.map(_getNamedTypeOfVariable).toList(growable: false); | 1540 namedParameters.map(_getNamedTypeOfVariable).toList(growable: false); |
| 1541 named.sort(); | 1541 named.sort(); |
| 1542 // We need create a copy of the list of type parameters, otherwise |
| 1543 // transformations like erasure don't work. |
| 1544 var typeParametersCopy = new List<TypeParameter>.from(parent is Constructor |
| 1545 ? parent.enclosingClass.typeParameters |
| 1546 : typeParameters); |
| 1542 return new FunctionType( | 1547 return new FunctionType( |
| 1543 positionalParameters.map(_getTypeOfVariable).toList(growable: false), | 1548 positionalParameters.map(_getTypeOfVariable).toList(growable: false), |
| 1544 returnType, | 1549 returnType, |
| 1545 namedParameters: named, | 1550 namedParameters: named, |
| 1546 typeParameters: parent is Constructor | 1551 typeParameters: typeParametersCopy, |
| 1547 ? parent.enclosingClass.typeParameters | |
| 1548 : typeParameters, | |
| 1549 requiredParameterCount: requiredParameterCount); | 1552 requiredParameterCount: requiredParameterCount); |
| 1550 } | 1553 } |
| 1551 | 1554 |
| 1552 accept(TreeVisitor v) => v.visitFunctionNode(this); | 1555 accept(TreeVisitor v) => v.visitFunctionNode(this); |
| 1553 | 1556 |
| 1554 visitChildren(Visitor v) { | 1557 visitChildren(Visitor v) { |
| 1555 visitList(typeParameters, v); | 1558 visitList(typeParameters, v); |
| 1556 visitList(positionalParameters, v); | 1559 visitList(positionalParameters, v); |
| 1557 visitList(namedParameters, v); | 1560 visitList(namedParameters, v); |
| 1558 returnType?.accept(v); | 1561 returnType?.accept(v); |
| (...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4746 if (typedef_.canonicalName == null) { | 4749 if (typedef_.canonicalName == null) { |
| 4747 throw '$typedef_ has no canonical name'; | 4750 throw '$typedef_ has no canonical name'; |
| 4748 } | 4751 } |
| 4749 return typedef_.canonicalName; | 4752 return typedef_.canonicalName; |
| 4750 } | 4753 } |
| 4751 | 4754 |
| 4752 /// Annotation describing information which is not part of Dart semantics; in | 4755 /// Annotation describing information which is not part of Dart semantics; in |
| 4753 /// other words, if this information (or any information it refers to) changes, | 4756 /// other words, if this information (or any information it refers to) changes, |
| 4754 /// static analysis and runtime behavior of the library are unaffected. | 4757 /// static analysis and runtime behavior of the library are unaffected. |
| 4755 const informative = null; | 4758 const informative = null; |
| OLD | NEW |