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

Unified Diff: frog/leg/typechecker.dart

Issue 9327001: Implement super initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: frog/leg/typechecker.dart
diff --git a/frog/leg/typechecker.dart b/frog/leg/typechecker.dart
index b66e541e2b36d6a8ca05d3bd76bd3168cb0c0d0d..fd92d05796f90c4632b9d7ffbdb2693ad146e6c1 100644
--- a/frog/leg/typechecker.dart
+++ b/frog/leg/typechecker.dart
@@ -238,9 +238,19 @@ class TypeCheckerVisitor implements Visitor<Type> {
}
Type visitFunctionExpression(FunctionExpression node) {
+ Type type;
+ Type returnType;
+ Type previousType;
final FunctionElement element = elements[node];
- FunctionType functionType = computeType(element);
- Type returnType = functionType.returnType;
+ if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR ||
+ element.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY) {
+ type = types.dynamicType;
+ returnType = types.voidType;
+ } else {
+ FunctionType functionType = computeType(element);
+ returnType = functionType.returnType;
+ type = functionType;
+ }
Type previous = expectedReturnType;
expectedReturnType = returnType;
if (element.isMember()) currentClass = element.enclosingElement;
@@ -256,7 +266,7 @@ class TypeCheckerVisitor implements Visitor<Type> {
reportTypeWarning(node.name, kind);
}
expectedReturnType = previous;
- return functionType;
+ return type;
}
Type visitIdentifier(Identifier node) {
@@ -341,7 +351,7 @@ class TypeCheckerVisitor implements Visitor<Type> {
if (node.receiver !== null) fail(node, 'cannot handle fields');
Element element = elements[node];
if (element === null) fail(node.selector, 'unresolved property');
- return element.computeType(compiler);
+ return computeType(element);
} else if (node.isFunctionObjectInvocation) {
fail(node.receiver, 'function object invocation unimplemented');
@@ -366,7 +376,7 @@ class TypeCheckerVisitor implements Visitor<Type> {
} else {
Element element = elements[node];
if (element.kind === ElementKind.FUNCTION) {
- funType = element.computeType(compiler);
+ funType = computeType(element);
} else if (element.kind === ElementKind.FOREIGN) {
return types.dynamicType;
} else {
@@ -497,7 +507,8 @@ class TypeCheckerVisitor implements Visitor<Type> {
Type computeType(Element element) {
if (element === null) return types.dynamicType;
- return element.computeType(compiler);
+ Type result = element.computeType(compiler);
+ return (result !== null) ? result : types.dynamicType;
}
Type visitTypeAnnotation(TypeAnnotation node) {

Powered by Google App Engine
This is Rietveld 408576698