Bug 251814 - [1.5][compiler] Dup Enum#valueOf(...) should keep the synthetic one
Summary: [1.5][compiler] Dup Enum#valueOf(...) should keep the synthetic one
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-23 04:01 EDT by Philipe Mulet CLA
Modified: 2009-05-07 03:32 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch with testcases (7.55 KB, patch)
2008-10-23 12:04 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.