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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java

Issue 223033002: Fix for 16134- class members modify the set of members that are inherited from superclasses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
index bd287d0fbf04b4f16ea30e5bef8f1a10244f0f71..355e8b43e3a2a3d52021579d1ae1a99e6f7ec61f 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/InheritanceManager.java
@@ -868,19 +868,37 @@ public class InheritanceManager {
} else {
if (subtypesOfAllOtherTypesIndexes.isEmpty()) {
//
+ // Determine if the current class has a method or accessor with the member name, if it
+ // does then then this class does not "inherit" from any of the supertypes.
+ // See issue 16134.
+ //
+ boolean classHasMember = false;
+ if (allMethods) {
+ classHasMember = classElt.getMethod(key) != null;
+ } else {
+ PropertyAccessorElement[] accessors = classElt.getAccessors();
+ for (int i = 0; i < accessors.length; i++) {
+ if (accessors[i].getName().equals(key)) {
+ classHasMember = true;
+ }
+ }
+ }
+ //
// Example: class A inherited only 2 method named 'm'. One has the function type
// '() -> int' and one has the function type '() -> String'. Since neither is a subtype
// of the other, we create a warning, and have this class inherit nothing.
//
- String firstTwoFuntionTypesStr = executableElementTypes[0].toString() + ", "
- + executableElementTypes[1].toString();
- reportError(
- classElt,
- classElt.getNameOffset(),
- classElt.getDisplayName().length(),
- StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE,
- key,
- firstTwoFuntionTypesStr);
+ if (!classHasMember) {
+ String firstTwoFuntionTypesStr = executableElementTypes[0].toString() + ", "
+ + executableElementTypes[1].toString();
+ reportError(
+ classElt,
+ classElt.getNameOffset(),
+ classElt.getDisplayName().length(),
+ StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE,
+ key,
+ firstTwoFuntionTypesStr);
+ }
} else {
//
// Example: class A inherits 2 methods named 'm'. One has the function type
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698