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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 18029018: Check that non-abstract classes implement all methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 years 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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Setlet<Node> get superUses; 9 Setlet<Node> get superUses;
10 10
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 for (Element constructor in constConstructors) { 909 for (Element constructor in constConstructors) {
910 compiler.reportInfo(constructor, 910 compiler.reportInfo(constructor,
911 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR); 911 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR);
912 } 912 }
913 } 913 }
914 for (Element field in nonFinalInstanceFields) { 914 for (Element field in nonFinalInstanceFields) {
915 compiler.reportInfo(field, 915 compiler.reportInfo(field,
916 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD); 916 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD);
917 } 917 }
918 } 918 }
919
920 if (!cls.isAbstract) {
921 for (DartType supertype in cls.allSupertypes) {
922 // This must have been reported elsewhere.
923 if (!supertype.element.isClass()) continue;
924 ClassElement superclass = supertype.element;
925 superclass.forEachMember((ClassElement holder, Element member) {
926 if (member.isAbstract) {
927 Element mine = cls.lookupMember(member.name);
928 if (mine == null || mine.isAbstract) {
929 compiler.reportWarningCode(
930 cls, MessageKind.UNIMPLEMENTED_METHOD,
931 {'class_name': cls.name, 'member_name': member.name});
932 compiler.reportHint(member, MessageKind.THIS_IS_THE_METHOD, {});
933 }
934 }
935 });
936 }
937 }
919 } 938 }
920 939
921 void checkAbstractField(Element member) { 940 void checkAbstractField(Element member) {
922 // Only check for getters. The test can only fail if there is both a setter 941 // Only check for getters. The test can only fail if there is both a setter
923 // and a getter with the same name, and we only need to check each abstract 942 // and a getter with the same name, and we only need to check each abstract
924 // field once, so we just ignore setters. 943 // field once, so we just ignore setters.
925 if (!member.isGetter()) return; 944 if (!member.isGetter()) return;
926 945
927 // Find the associated abstract field. 946 // Find the associated abstract field.
928 ClassElement classElement = member.getEnclosingClass(); 947 ClassElement classElement = member.getEnclosingClass();
(...skipping 3819 matching lines...) Expand 10 before | Expand all | Expand 10 after
4748 return finishConstructorReference(visit(expression), 4767 return finishConstructorReference(visit(expression),
4749 expression, expression); 4768 expression, expression);
4750 } 4769 }
4751 } 4770 }
4752 4771
4753 /// Looks up [name] in [scope] and unwraps the result. 4772 /// Looks up [name] in [scope] and unwraps the result.
4754 Element lookupInScope(Compiler compiler, Node node, 4773 Element lookupInScope(Compiler compiler, Node node,
4755 Scope scope, String name) { 4774 Scope scope, String name) {
4756 return Elements.unwrap(scope.lookup(name), compiler, node); 4775 return Elements.unwrap(scope.lookup(name), compiler, node);
4757 } 4776 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698