Bug 251814

Summary: [1.5][compiler] Dup Enum#valueOf(...) should keep the synthetic one
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_audel
Version: 3.5   
Target Milestone: 3.5 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch with testcases none

Description Philipe Mulet CLA 2008-10-23 04:01:33 EDT
Head as of 10/22/08

In presence of dup enum special method, the compiler should internally keep the synthetic binding for valueOf since this is the implicit one mentionned in problem report. 

In the case below, the binding kept is "int valueOf(...)" (and it is persisted in problemType). It is different from "X valueOf(...)" implicitly added.

public enum X {
        ;
        static int valueOf(String arg0) { return 0; }//9
}
public class Other {
    void foo() {
    	int i = X.valueOf("");
    }
}
Comment 1 Philipe Mulet CLA 2008-10-23 04:05:01 EDT
e.g.
public enum X {
        ;
        private int valueOf(String arg0) { return 0; }//11
        void foo() {
        	int i = valueOf("");
        }
}

I'd expect 2 errors: 1 for dup #valueOf(...) definition, one for type mismatch since #valueOf(...) in synthetic form is returning an X.
Comment 2 Philipe Mulet CLA 2008-10-23 04:07:53 EDT
Added EnumTest#test166-167 (reflecting current behavior)
Comment 3 Kent Johnson CLA 2008-10-23 12:04:21 EDT
Created attachment 115952 [details]
Proposed patch with testcases

Philippe - please take a look
Comment 4 Philipe Mulet CLA 2008-10-23 12:49:53 EDT
I like the new behavior in the tests, this is what I was hoping for initially.
Looks good to me.
Comment 5 Kent Johnson CLA 2008-10-23 13:24:05 EDT
Philippe - when 3 duplicates exist, we only complain about the first one once
because of :

if (methodDecl == null) {
  methodDecl = method.sourceMethod();


Fix and tests released for 3.5M3
Comment 6 David Audel CLA 2008-10-28 10:14:53 EDT
Verified for 3.5M3 using I20081026-2000 build.