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 4125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4136 final List<TypeParameter> typeParameters; | 4136 final List<TypeParameter> typeParameters; |
4137 final int requiredParameterCount; | 4137 final int requiredParameterCount; |
4138 final List<DartType> positionalParameters; | 4138 final List<DartType> positionalParameters; |
4139 final List<NamedType> namedParameters; // Must be sorted. | 4139 final List<NamedType> namedParameters; // Must be sorted. |
4140 | 4140 |
4141 /// The optional names of [positionalParameters], not `null`, but might be | 4141 /// The optional names of [positionalParameters], not `null`, but might be |
4142 /// empty if information is not available. | 4142 /// empty if information is not available. |
4143 @informative | 4143 @informative |
4144 final List<String> positionalParameterNames; | 4144 final List<String> positionalParameterNames; |
4145 | 4145 |
| 4146 /// The [Typedef] this function type is created for. |
| 4147 Reference typedefReference; |
| 4148 |
4146 final DartType returnType; | 4149 final DartType returnType; |
4147 int _hashCode; | 4150 int _hashCode; |
4148 | 4151 |
4149 FunctionType(List<DartType> positionalParameters, this.returnType, | 4152 FunctionType(List<DartType> positionalParameters, this.returnType, |
4150 {this.namedParameters: const <NamedType>[], | 4153 {this.namedParameters: const <NamedType>[], |
4151 this.typeParameters: const <TypeParameter>[], | 4154 this.typeParameters: const <TypeParameter>[], |
4152 int requiredParameterCount, | 4155 int requiredParameterCount, |
4153 this.positionalParameterNames: const <String>[]}) | 4156 this.positionalParameterNames: const <String>[], |
| 4157 this.typedefReference}) |
4154 : this.positionalParameters = positionalParameters, | 4158 : this.positionalParameters = positionalParameters, |
4155 this.requiredParameterCount = | 4159 this.requiredParameterCount = |
4156 requiredParameterCount ?? positionalParameters.length; | 4160 requiredParameterCount ?? positionalParameters.length; |
4157 | 4161 |
| 4162 /// The [Typedef] this function type is created for. |
| 4163 Typedef get typedef => typedefReference?.asTypedef; |
| 4164 |
4158 accept(DartTypeVisitor v) => v.visitFunctionType(this); | 4165 accept(DartTypeVisitor v) => v.visitFunctionType(this); |
4159 | 4166 |
4160 visitChildren(Visitor v) { | 4167 visitChildren(Visitor v) { |
4161 visitList(typeParameters, v); | 4168 visitList(typeParameters, v); |
4162 visitList(positionalParameters, v); | 4169 visitList(positionalParameters, v); |
4163 visitList(namedParameters, v); | 4170 visitList(namedParameters, v); |
4164 returnType.accept(v); | 4171 returnType.accept(v); |
4165 } | 4172 } |
4166 | 4173 |
4167 bool operator ==(Object other) { | 4174 bool operator ==(Object other) { |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4733 if (typedef_.canonicalName == null) { | 4740 if (typedef_.canonicalName == null) { |
4734 throw '$typedef_ has no canonical name'; | 4741 throw '$typedef_ has no canonical name'; |
4735 } | 4742 } |
4736 return typedef_.canonicalName; | 4743 return typedef_.canonicalName; |
4737 } | 4744 } |
4738 | 4745 |
4739 /// Annotation describing information which is not part of Dart semantics; in | 4746 /// Annotation describing information which is not part of Dart semantics; in |
4740 /// other words, if this information (or any information it refers to) changes, | 4747 /// other words, if this information (or any information it refers to) changes, |
4741 /// static analysis and runtime behavior of the library are unaffected. | 4748 /// static analysis and runtime behavior of the library are unaffected. |
4742 const informative = null; | 4749 const informative = null; |
OLD | NEW |