Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: pkg/compiler/lib/src/resolution/signatures.dart

Issue 895583006: Update yield warnings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix example Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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<FormalElementX> { 10 class SignatureResolver extends MappingVisitor<FormalElementX> {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 /** 256 /**
257 * Resolves formal parameters and return type of a [FunctionExpression] 257 * Resolves formal parameters and return type of a [FunctionExpression]
258 * to a [FunctionSignature]. 258 * to a [FunctionSignature].
259 * 259 *
260 * If [createRealParameters] is `true`, the parameters will be 260 * If [createRealParameters] is `true`, the parameters will be
261 * real parameters implementing the [ParameterElement] interface. Otherwise, 261 * real parameters implementing the [ParameterElement] interface. Otherwise,
262 * the parameters will only implement [FormalElement]. 262 * the parameters will only implement [FormalElement].
263 */ 263 */
264 static FunctionSignature analyze(Compiler compiler, 264 static FunctionSignature analyze(
265 NodeList formalParameters, 265 Compiler compiler,
266 Node returnNode, 266 NodeList formalParameters,
267 FunctionTypedElement element, 267 Node returnNode,
268 ResolutionRegistry registry, 268 FunctionTypedElement element,
269 {MessageKind defaultValuesError, 269 ResolutionRegistry registry,
270 bool createRealParameters: false}) { 270 {MessageKind defaultValuesError,
271 bool createRealParameters: false,
272 AsyncMarker asyncMarker: AsyncMarker.SYNC}) {
273
271 SignatureResolver visitor = new SignatureResolver(compiler, element, 274 SignatureResolver visitor = new SignatureResolver(compiler, element,
272 registry, defaultValuesError: defaultValuesError, 275 registry, defaultValuesError: defaultValuesError,
273 createRealParameters: createRealParameters); 276 createRealParameters: createRealParameters);
274 Link<Element> parameters = const Link<Element>(); 277 Link<Element> parameters = const Link<Element>();
275 int requiredParameterCount = 0; 278 int requiredParameterCount = 0;
276 if (formalParameters == null) { 279 if (formalParameters == null) {
277 if (!element.isGetter) { 280 if (!element.isGetter) {
278 if (element.isErroneous) { 281 if (element.isErroneous) {
279 // If the element is erroneous, an error should already have been 282 // If the element is erroneous, an error should already have been
280 // reported. In the case of parse errors, it is possible that there 283 // reported. In the case of parse errors, it is possible that there
(...skipping 20 matching lines...) Expand all
301 } 304 }
302 DartType returnType; 305 DartType returnType;
303 if (element.isFactoryConstructor) { 306 if (element.isFactoryConstructor) {
304 returnType = element.enclosingClass.thisType; 307 returnType = element.enclosingClass.thisType;
305 // Because there is no type annotation for the return type of 308 // Because there is no type annotation for the return type of
306 // this element, we explicitly add one. 309 // this element, we explicitly add one.
307 if (compiler.enableTypeAssertions) { 310 if (compiler.enableTypeAssertions) {
308 registry.registerIsCheck(returnType); 311 registry.registerIsCheck(returnType);
309 } 312 }
310 } else { 313 } else {
311 returnType = visitor.resolveReturnType(returnNode); 314 switch (asyncMarker) {
315 case AsyncMarker.SYNC:
316 returnType = visitor.resolveReturnType(returnNode);
317 break;
318 case AsyncMarker.SYNC_STAR:
319 returnType = compiler.coreTypes.iterableType();
320 break;
321 case AsyncMarker.ASYNC:
322 returnType = compiler.coreTypes.futureType();
323 break;
324 case AsyncMarker.ASYNC_STAR:
325 returnType = compiler.coreTypes.streamType();
326 break;
327 }
312 } 328 }
313 329
314 if (element.isSetter && (requiredParameterCount != 1 || 330 if (element.isSetter && (requiredParameterCount != 1 ||
315 visitor.optionalParameterCount != 0)) { 331 visitor.optionalParameterCount != 0)) {
316 // If there are no formal parameters, we already reported an error above. 332 // If there are no formal parameters, we already reported an error above.
317 if (formalParameters != null) { 333 if (formalParameters != null) {
318 compiler.reportError(formalParameters, 334 compiler.reportError(formalParameters,
319 MessageKind.ILLEGAL_SETTER_FORMALS); 335 MessageKind.ILLEGAL_SETTER_FORMALS);
320 } 336 }
321 } 337 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 396
381 DartType resolveReturnType(TypeAnnotation annotation) { 397 DartType resolveReturnType(TypeAnnotation annotation) {
382 if (annotation == null) return const DynamicType(); 398 if (annotation == null) return const DynamicType();
383 DartType result = resolver.resolveTypeAnnotation(annotation); 399 DartType result = resolver.resolveTypeAnnotation(annotation);
384 if (result == null) { 400 if (result == null) {
385 return const DynamicType(); 401 return const DynamicType();
386 } 402 }
387 return result; 403 return result;
388 } 404 }
389 } 405 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698