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

Side by Side Diff: lib/compiler/implementation/typechecker.dart

Issue 10829379: Add erroneous elements for function types and use them to allow unresolvable constructors to be han… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class TypeCheckerTask extends CompilerTask { 5 class TypeCheckerTask extends CompilerTask {
6 TypeCheckerTask(Compiler compiler) : super(compiler); 6 TypeCheckerTask(Compiler compiler) : super(compiler);
7 String get name() => "Type checker"; 7 String get name() => "Type checker";
8 8
9 static final bool LOG_FAILURES = false; 9 static final bool LOG_FAILURES = false;
10 10
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 Type visitFunctionDeclaration(FunctionDeclaration node) { 328 Type visitFunctionDeclaration(FunctionDeclaration node) {
329 analyze(node.function); 329 analyze(node.function);
330 return StatementType.NOT_RETURNING; 330 return StatementType.NOT_RETURNING;
331 } 331 }
332 332
333 Type visitFunctionExpression(FunctionExpression node) { 333 Type visitFunctionExpression(FunctionExpression node) {
334 Type type; 334 Type type;
335 Type returnType; 335 Type returnType;
336 Type previousType; 336 Type previousType;
337 final FunctionElement element = elements[node]; 337 final FunctionElement element = elements[node];
338 if (Element.isInvalid(element)) return types.dynamicType;
338 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR || 339 if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR ||
339 element.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { 340 element.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY) {
340 type = types.dynamicType; 341 type = types.dynamicType;
341 returnType = types.voidType; 342 returnType = types.voidType;
342 } else { 343 } else {
343 FunctionType functionType = computeType(element); 344 FunctionType functionType = computeType(element);
344 returnType = functionType.returnType; 345 returnType = functionType.returnType;
345 type = functionType; 346 type = functionType;
346 } 347 }
347 Type previous = expectedReturnType; 348 Type previous = expectedReturnType;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 641 }
641 return StatementType.RETURNING; 642 return StatementType.RETURNING;
642 } 643 }
643 644
644 Type visitThrow(Throw node) { 645 Type visitThrow(Throw node) {
645 if (node.expression !== null) analyze(node.expression); 646 if (node.expression !== null) analyze(node.expression);
646 return StatementType.RETURNING; 647 return StatementType.RETURNING;
647 } 648 }
648 649
649 Type computeType(Element element) { 650 Type computeType(Element element) {
650 if (element === null) return types.dynamicType; 651 if (Element.isInvalid(element)) return types.dynamicType;
651 Type result = element.computeType(compiler); 652 Type result = element.computeType(compiler);
652 return (result !== null) ? result : types.dynamicType; 653 return (result !== null) ? result : types.dynamicType;
653 } 654 }
654 655
655 Type visitTypeAnnotation(TypeAnnotation node) { 656 Type visitTypeAnnotation(TypeAnnotation node) {
656 return elements.getType(node); 657 return elements.getType(node);
657 } 658 }
658 659
659 visitTypeVariable(TypeVariable node) { 660 visitTypeVariable(TypeVariable node) {
660 return types.dynamicType; 661 return types.dynamicType;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } 782 }
782 783
783 visitCatchBlock(CatchBlock node) { 784 visitCatchBlock(CatchBlock node) {
784 return unhandledStatement(); 785 return unhandledStatement();
785 } 786 }
786 787
787 visitTypedef(Typedef node) { 788 visitTypedef(Typedef node) {
788 return unhandledStatement(); 789 return unhandledStatement();
789 } 790 }
790 } 791 }
OLDNEW
« lib/compiler/implementation/ssa/builder.dart ('K') | « lib/compiler/implementation/ssa/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698