OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of resolution; | 5 part of resolution; |
6 | 6 |
7 /** | 7 /** |
8 * [SignatureResolver] resolves function signatures. | 8 * [SignatureResolver] resolves function signatures. |
9 */ | 9 */ |
10 class SignatureResolver extends MappingVisitor<ParameterElementX> { | 10 class SignatureResolver extends MappingVisitor<ParameterElementX> { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Inline function typed initializing formal or | 111 // Inline function typed initializing formal or |
112 // parameter with default value, like `C(int this.f(String s))` or | 112 // parameter with default value, like `C(int this.f(String s))` or |
113 // `void m([int f(String s) = null])`. | 113 // `void m([int f(String s) = null])`. |
114 computeFunctionType(link.head.asSend().selector.asFunctionExpression()); | 114 computeFunctionType(link.head.asSend().selector.asFunctionExpression()); |
115 } else { | 115 } else { |
116 assert(invariant(currentDefinitions, | 116 assert(invariant(currentDefinitions, |
117 link.head.asIdentifier() != null || link.head.asSend() != null)); | 117 link.head.asIdentifier() != null || link.head.asSend() != null)); |
118 if (fieldElement != null) { | 118 if (fieldElement != null) { |
119 element.typeCache = fieldElement.computeType(compiler); | 119 element.typeCache = fieldElement.computeType(compiler); |
120 } else { | 120 } else { |
121 element.typeCache = compiler.types.dynamicType; | 121 element.typeCache = const DynamicType(); |
122 } | 122 } |
123 } | 123 } |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 Element visitIdentifier(Identifier node) { | 127 Element visitIdentifier(Identifier node) { |
128 return createParameter(node, null); | 128 return createParameter(node, null); |
129 } | 129 } |
130 | 130 |
131 Identifier getParameterName(Send node) { | 131 Identifier getParameterName(Send node) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 DartType resolveTypeAnnotation(TypeAnnotation annotation) { | 337 DartType resolveTypeAnnotation(TypeAnnotation annotation) { |
338 DartType type = resolveReturnType(annotation); | 338 DartType type = resolveReturnType(annotation); |
339 if (type.isVoid) { | 339 if (type.isVoid) { |
340 compiler.reportError(annotation, MessageKind.VOID_NOT_ALLOWED); | 340 compiler.reportError(annotation, MessageKind.VOID_NOT_ALLOWED); |
341 } | 341 } |
342 return type; | 342 return type; |
343 } | 343 } |
344 | 344 |
345 DartType resolveReturnType(TypeAnnotation annotation) { | 345 DartType resolveReturnType(TypeAnnotation annotation) { |
346 if (annotation == null) return compiler.types.dynamicType; | 346 if (annotation == null) return const DynamicType(); |
347 DartType result = resolver.resolveTypeAnnotation(annotation); | 347 DartType result = resolver.resolveTypeAnnotation(annotation); |
348 if (result == null) { | 348 if (result == null) { |
349 return compiler.types.dynamicType; | 349 return const DynamicType(); |
350 } | 350 } |
351 return result; | 351 return result; |
352 } | 352 } |
353 } | 353 } |
OLD | NEW |