Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 146981 Details for
Bug 289247
[1.5][compiler]Detecting duplicate methods should not consider return type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch for code changes
patch.txt (text/plain), 8.92 KB, created by
Kent Johnson
on 2009-09-11 14:28:50 EDT
(
hide
)
Description:
Proposed patch for code changes
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2009-09-11 14:28:50 EDT
Size:
8.92 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.173 >diff -u -r1.173 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 14 May 2009 14:50:31 -0000 1.173 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 11 Sep 2009 18:31:03 -0000 >@@ -1099,7 +1099,6 @@ > > // find & report collision cases > boolean complyTo15 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5; >- boolean complyTo17 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7; > for (int i = 0, length = this.methods.length; i < length; i++) { > MethodBinding method = resolvedMethods[i]; > if (method == null) >@@ -1113,64 +1112,8 @@ > if (!CharOperation.equals(selector, method2.selector)) > break nextSibling; // methods with same selector are contiguous > >- if (complyTo15 && method.returnType != null && method2.returnType != null) { >- // 8.4.2, for collision to be detected between m1 and m2: >- // signature(m1) == signature(m2) i.e. same arity, same type parameter count, can be substituted >- // signature(m1) == erasure(signature(m2)) or erasure(signature(m1)) == signature(m2) >- TypeBinding[] params1 = method.parameters; >- TypeBinding[] params2 = method2.parameters; >- int pLength = params1.length; >- if (pLength != params2.length) >- continue nextSibling; >- >- TypeVariableBinding[] vars = method.typeVariables; >- TypeVariableBinding[] vars2 = method2.typeVariables; >- boolean equalTypeVars = vars == vars2; >- MethodBinding subMethod = method2; >- if (!equalTypeVars) { >- MethodBinding temp = method.computeSubstitutedMethod(method2, this.scope.environment()); >- if (temp != null) { >- equalTypeVars = true; >- subMethod = temp; >- } >- } >- boolean equalParams = method.areParametersEqual(subMethod); >- if (equalParams && equalTypeVars) { >- // duplicates regardless of return types >- } else if ((complyTo17 || method.returnType.erasure() == subMethod.returnType.erasure()) >- && (equalParams || method.areParameterErasuresEqual(method2))) { >- // with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 >- // we now ignore return types when detecting duplicates, just as we did before 1.5 >- // name clash for sure if not duplicates, report as duplicates >- // FYI for now we will only make this change when compliance is set to 1.7 or higher >- } else if (!equalTypeVars && vars != Binding.NO_TYPE_VARIABLES && vars2 != Binding.NO_TYPE_VARIABLES) { >- // type variables are different so we can distinguish between methods >- continue nextSibling; >- } else if (pLength > 0) { >- // check to see if the erasure of either method is equal to the other >- int index = pLength; >- for (; --index >= 0;) { >- if (params1[index] != params2[index].erasure()) >- break; >- if (params1[index] == params2[index]) { >- TypeBinding type = params1[index].leafComponentType(); >- if (type instanceof SourceTypeBinding && type.typeVariables() != Binding.NO_TYPE_VARIABLES) { >- index = pLength; // handle comparing identical source types like X<T>... its erasure is itself BUT we need to answer false >- break; >- } >- } >- } >- if (index >= 0 && index < pLength) { >- for (index = pLength; --index >= 0;) >- if (params1[index].erasure() != params2[index]) >- break; >- } >- if (index >= 0) >- continue nextSibling; >- } >- } else if (!method.areParametersEqual(method2)) { // prior to 1.5, parameter identity meant a collision case >- continue nextSibling; >- } >+ if (complyTo15 ? !method.areParameterErasuresEqual(method2) : !method.areParametersEqual(method2)) >+ continue nextSibling; // otherwise duplicates / name clash > boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES)); > // report duplicate > boolean removeMethod2 = true; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v >retrieving revision 1.101 >diff -u -r1.101 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 31 Jul 2009 17:32:45 -0000 1.101 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 11 Sep 2009 18:31:03 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.jdt.internal.compiler.lookup; > > import org.eclipse.jdt.internal.compiler.ast.TypeParameter; >-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; > import org.eclipse.jdt.internal.compiler.util.SimpleSet; > >@@ -549,13 +548,6 @@ > boolean detectInheritedNameClash(MethodBinding inherited, MethodBinding otherInherited) { > if (!inherited.areParameterErasuresEqual(otherInherited)) > return false; >- if (this.environment.globalOptions.sourceLevel < ClassFileConstants.JDK1_7) { >- // with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 >- // we now ignore return types when detecting name clashes >- // FYI for now we will only make this change when compliance is set to 1.7 or higher >- if (inherited.returnType.erasure() != otherInherited.returnType.erasure()) >- return false; >- } > // skip it if otherInherited is defined by a subtype of inherited's declaringClass > if (inherited.declaringClass.erasure() != otherInherited.declaringClass.erasure()) > if (inherited.declaringClass.findSuperTypeOriginatingFrom(otherInherited.declaringClass) != null) >@@ -568,13 +560,6 @@ > MethodBinding original = inherited.original(); // can be the same as inherited > if (!current.areParameterErasuresEqual(original)) > return false; >- if (this.environment.globalOptions.sourceLevel < ClassFileConstants.JDK1_7) { >- // with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 >- // we now ignore return types when detecting name clashes >- // FYI for now we will only make this change when compliance is set to 1.7 or higher >- if (current.returnType.erasure() != original.returnType.erasure()) >- return false; >- } > > problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original); > return true; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java,v >retrieving revision 1.119 >diff -u -r1.119 MethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 16 Jun 2009 17:26:23 -0000 1.119 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 11 Sep 2009 18:31:03 -0000 >@@ -161,13 +161,22 @@ > arguments[i] = env.convertToRawType(var.upperBound(), false /*do not force conversion of enclosing types*/); > } else { > // use an intersection type to retain full bound information if more than 1 bound >- TypeBinding rawSuperclass = env.convertToRawType(var.superclass(), false); > TypeBinding[] itsSuperinterfaces = var.superInterfaces(); > int superLength = itsSuperinterfaces.length; >- TypeBinding[] rawSuperinterfaces = new TypeBinding[superLength]; >- for (int s = 0; s < superLength; s++) >- rawSuperinterfaces[s] = env.convertToRawType(itsSuperinterfaces[s], false); >- arguments[i] = env.createWildcard(null, 0, rawSuperclass, rawSuperinterfaces, org.eclipse.jdt.internal.compiler.ast.Wildcard.EXTENDS); >+ TypeBinding rawFirstBound = null; >+ TypeBinding[] rawOtherBounds = null; >+ if (var.boundsCount() == superLength) { >+ rawFirstBound = env.convertToRawType(itsSuperinterfaces[0], false); >+ rawOtherBounds = new TypeBinding[superLength - 1]; >+ for (int s = 1; s < superLength; s++) >+ rawOtherBounds[s - 1] = env.convertToRawType(itsSuperinterfaces[s], false); >+ } else { >+ rawFirstBound = env.convertToRawType(var.superclass(), false); >+ rawOtherBounds = new TypeBinding[superLength]; >+ for (int s = 0; s < superLength; s++) >+ rawOtherBounds[s] = env.convertToRawType(itsSuperinterfaces[s], false); >+ } >+ arguments[i] = env.createWildcard(null, 0, rawFirstBound, rawOtherBounds, org.eclipse.jdt.internal.compiler.ast.Wildcard.EXTENDS); > } > } > return env.createParameterizedGenericMethod(this, arguments);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 289247
: 146981 |
146982