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

Side by Side Diff: pkg/compiler/lib/src/typechecker.dart

Issue 1155633002: Fix 56 hints in pkg/compiler (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: rebase Created 5 years, 7 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) 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 part of dart2js; 5 part of dart2js;
6 6
7 class TypeCheckerTask extends CompilerTask { 7 class TypeCheckerTask extends CompilerTask {
8 TypeCheckerTask(Compiler compiler) : super(compiler); 8 TypeCheckerTask(Compiler compiler) : super(compiler);
9 String get name => "Type checker"; 9 String get name => "Type checker";
10 10
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 587 }
588 588
589 DartType visitFunctionDeclaration(FunctionDeclaration node) { 589 DartType visitFunctionDeclaration(FunctionDeclaration node) {
590 analyze(node.function); 590 analyze(node.function);
591 return const StatementType(); 591 return const StatementType();
592 } 592 }
593 593
594 DartType visitFunctionExpression(FunctionExpression node) { 594 DartType visitFunctionExpression(FunctionExpression node) {
595 DartType type; 595 DartType type;
596 DartType returnType; 596 DartType returnType;
597 DartType previousType;
598 final FunctionElement element = elements.getFunctionDefinition(node); 597 final FunctionElement element = elements.getFunctionDefinition(node);
599 assert(invariant(node, element != null, 598 assert(invariant(node, element != null,
600 message: 'FunctionExpression with no element')); 599 message: 'FunctionExpression with no element'));
601 if (Elements.isUnresolved(element)) return const DynamicType(); 600 if (Elements.isUnresolved(element)) return const DynamicType();
602 if (element.isGenerativeConstructor) { 601 if (element.isGenerativeConstructor) {
603 type = const DynamicType(); 602 type = const DynamicType();
604 returnType = const VoidType(); 603 returnType = const VoidType();
605 604
606 element.functionSignature.forEachParameter((ParameterElement parameter) { 605 element.functionSignature.forEachParameter((ParameterElement parameter) {
607 if (parameter.isInitializingFormal) { 606 if (parameter.isInitializingFormal) {
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 assert(invariant(node, element != null, 986 assert(invariant(node, element != null,
988 message: 'Prefixed node has no element.')); 987 message: 'Prefixed node has no element.'));
989 return computeResolvedAccess(node, name, element, memberKind); 988 return computeResolvedAccess(node, name, element, memberKind);
990 } 989 }
991 } 990 }
992 // e.foo() for some expression e. 991 // e.foo() for some expression e.
993 DartType receiverType = analyze(node.receiver); 992 DartType receiverType = analyze(node.receiver);
994 if (receiverType.treatAsDynamic || receiverType.isVoid) { 993 if (receiverType.treatAsDynamic || receiverType.isVoid) {
995 return const DynamicAccess(); 994 return const DynamicAccess();
996 } 995 }
997 TypeKind receiverKind = receiverType.kind;
998 return lookupMember(node, receiverType, name, memberKind, 996 return lookupMember(node, receiverType, name, memberKind,
999 elements[node.receiver], 997 elements[node.receiver],
1000 lookupClassMember: lookupClassMember || 998 lookupClassMember: lookupClassMember ||
1001 element != null && element.isStatic); 999 element != null && element.isStatic);
1002 } else { 1000 } else {
1003 return computeResolvedAccess(node, name, element, memberKind); 1001 return computeResolvedAccess(node, name, element, memberKind);
1004 } 1002 }
1005 } 1003 }
1006 1004
1007 /** 1005 /**
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 DartType initializer = analyzeNonVoid(initialization.arguments.head); 1674 DartType initializer = analyzeNonVoid(initialization.arguments.head);
1677 checkAssignable(initialization.assignmentOperator, initializer, type); 1675 checkAssignable(initialization.assignmentOperator, initializer, type);
1678 } 1676 }
1679 } 1677 }
1680 return const StatementType(); 1678 return const StatementType();
1681 } 1679 }
1682 1680
1683 DartType visitWhile(While node) { 1681 DartType visitWhile(While node) {
1684 checkCondition(node.condition); 1682 checkCondition(node.condition);
1685 analyze(node.body); 1683 analyze(node.body);
1686 Expression cond = node.condition.asParenthesizedExpression().expression;
1687 return const StatementType(); 1684 return const StatementType();
1688 } 1685 }
1689 1686
1690 DartType visitParenthesizedExpression(ParenthesizedExpression node) { 1687 DartType visitParenthesizedExpression(ParenthesizedExpression node) {
1691 Expression expression = node.expression; 1688 Expression expression = node.expression;
1692 DartType type = analyze(expression); 1689 DartType type = analyze(expression);
1693 for (TypePromotion typePromotion in getShownTypePromotionsFor(expression)) { 1690 for (TypePromotion typePromotion in getShownTypePromotionsFor(expression)) {
1694 showTypePromotion(node, typePromotion); 1691 showTypePromotion(node, typePromotion);
1695 } 1692 }
1696 return type; 1693 return type;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 1855
1859 visitTypedef(Typedef node) { 1856 visitTypedef(Typedef node) {
1860 // Do not typecheck [Typedef] nodes. 1857 // Do not typecheck [Typedef] nodes.
1861 } 1858 }
1862 1859
1863 visitNode(Node node) { 1860 visitNode(Node node) {
1864 compiler.internalError(node, 1861 compiler.internalError(node,
1865 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 1862 'Unexpected node ${node.getObjectDescription()} in the type checker.');
1866 } 1863 }
1867 } 1864 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart ('k') | pkg/compiler/lib/src/universe/side_effects.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698