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

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

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

Powered by Google App Engine
This is Rietveld 408576698