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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10908238: Only allow 'void' as a return type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
===================================================================
--- lib/compiler/implementation/resolver.dart (revision 12312)
+++ lib/compiler/implementation/resolver.dart (working copy)
@@ -212,6 +212,14 @@
}
DartType resolveTypeAnnotation(Element element, TypeAnnotation annotation) {
+ DartType type = resolveReturnType(element, annotation);
+ if (type == compiler.types.voidType) {
+ error(annotation, MessageKind.VOID_NOT_ALLOWED);
+ }
+ return type;
+ }
+
+ DartType resolveReturnType(Element element, TypeAnnotation annotation) {
if (annotation === null) return compiler.types.dynamicType;
ResolverVisitor visitor = new ResolverVisitor(compiler, element);
DartType result = visitor.resolveTypeAnnotation(annotation);
@@ -2372,6 +2380,8 @@
Element visitIdentifier(Identifier node) {
Element variables = new VariableListElement.node(currentDefinitions,
ElementKind.VARIABLE_LIST, enclosingElement);
+ // Ensure a parameter is not typed 'void'.
+ variables.computeType(compiler);
return new VariableElement(node.source, variables,
ElementKind.PARAMETER, enclosingElement, node: node);
}
@@ -2491,7 +2501,7 @@
requiredParameterCount = parametersBuilder.length;
parameters = parametersBuilder.toLink();
}
- DartType returnType = compiler.resolveTypeAnnotation(element, returnNode);
+ DartType returnType = compiler.resolveReturnType(element, returnNode);
return new FunctionSignature(parameters,
visitor.optionalParameters,
requiredParameterCount,
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698