| 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 library dart2js.resolution.signatures; | 5 library dart2js.resolution.signatures; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart'; | 8 import '../common/resolution.dart'; |
| 9 import '../elements/resolution_types.dart'; | 9 import '../elements/resolution_types.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } else { | 393 } else { |
| 394 AsyncMarker asyncMarker = AsyncMarker.SYNC; | 394 AsyncMarker asyncMarker = AsyncMarker.SYNC; |
| 395 if (isFunctionExpression) { | 395 if (isFunctionExpression) { |
| 396 // Use async marker to determine the return type of function | 396 // Use async marker to determine the return type of function |
| 397 // expressions. | 397 // expressions. |
| 398 FunctionElement function = element; | 398 FunctionElement function = element; |
| 399 asyncMarker = function.asyncMarker; | 399 asyncMarker = function.asyncMarker; |
| 400 } | 400 } |
| 401 switch (asyncMarker) { | 401 switch (asyncMarker) { |
| 402 case AsyncMarker.SYNC: | 402 case AsyncMarker.SYNC: |
| 403 returnType = visitor.resolveReturnType(returnNode); | 403 returnType = visitor.resolveTypeAnnotation(returnNode); |
| 404 break; | 404 break; |
| 405 case AsyncMarker.SYNC_STAR: | 405 case AsyncMarker.SYNC_STAR: |
| 406 ResolutionInterfaceType iterableType = | 406 ResolutionInterfaceType iterableType = |
| 407 resolution.commonElements.iterableType(); | 407 resolution.commonElements.iterableType(); |
| 408 returnType = iterableType; | 408 returnType = iterableType; |
| 409 break; | 409 break; |
| 410 case AsyncMarker.ASYNC: | 410 case AsyncMarker.ASYNC: |
| 411 ResolutionInterfaceType futureType = | 411 ResolutionInterfaceType futureType = |
| 412 resolution.commonElements.futureType(); | 412 resolution.commonElements.futureType(); |
| 413 returnType = futureType; | 413 returnType = futureType; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 requiredParameters: parameters, | 476 requiredParameters: parameters, |
| 477 optionalParameters: visitor.optionalParameters, | 477 optionalParameters: visitor.optionalParameters, |
| 478 requiredParameterCount: requiredParameterCount, | 478 requiredParameterCount: requiredParameterCount, |
| 479 optionalParameterCount: visitor.optionalParameterCount, | 479 optionalParameterCount: visitor.optionalParameterCount, |
| 480 optionalParametersAreNamed: visitor.optionalParametersAreNamed, | 480 optionalParametersAreNamed: visitor.optionalParametersAreNamed, |
| 481 orderedOptionalParameters: orderedOptionalParameters, | 481 orderedOptionalParameters: orderedOptionalParameters, |
| 482 type: type); | 482 type: type); |
| 483 } | 483 } |
| 484 | 484 |
| 485 ResolutionDartType resolveTypeAnnotation(TypeAnnotation annotation) { | 485 ResolutionDartType resolveTypeAnnotation(TypeAnnotation annotation) { |
| 486 ResolutionDartType type = resolveReturnType(annotation); | |
| 487 if (type.isVoid) { | |
| 488 reporter.reportErrorMessage(annotation, MessageKind.VOID_NOT_ALLOWED); | |
| 489 } | |
| 490 return type; | |
| 491 } | |
| 492 | |
| 493 ResolutionDartType resolveReturnType(TypeAnnotation annotation) { | |
| 494 if (annotation == null) return const ResolutionDynamicType(); | 486 if (annotation == null) return const ResolutionDynamicType(); |
| 495 ResolutionDartType result = resolver.resolveTypeAnnotation(annotation); | 487 ResolutionDartType result = resolver.resolveTypeAnnotation(annotation); |
| 496 if (result == null) { | 488 if (result == null) { |
| 497 return const ResolutionDynamicType(); | 489 return const ResolutionDynamicType(); |
| 498 } | 490 } |
| 499 return result; | 491 return result; |
| 500 } | 492 } |
| 501 } | 493 } |
| 502 | 494 |
| 503 /// Used during `SignatureResolver.analyze` to provide access to the type | 495 /// Used during `SignatureResolver.analyze` to provide access to the type |
| 504 /// variables of the function signature itself when its signature is analyzed. | 496 /// variables of the function signature itself when its signature is analyzed. |
| 505 class FunctionSignatureBuildingScope extends TypeVariablesScope { | 497 class FunctionSignatureBuildingScope extends TypeVariablesScope { |
| 506 @override | 498 @override |
| 507 final List<ResolutionDartType> typeVariables; | 499 final List<ResolutionDartType> typeVariables; |
| 508 | 500 |
| 509 FunctionSignatureBuildingScope(Scope parent, this.typeVariables) | 501 FunctionSignatureBuildingScope(Scope parent, this.typeVariables) |
| 510 : super(parent); | 502 : super(parent); |
| 511 | 503 |
| 512 String toString() => 'FunctionSignatureBuildingScope($typeVariables)'; | 504 String toString() => 'FunctionSignatureBuildingScope($typeVariables)'; |
| 513 } | 505 } |
| OLD | NEW |