Bug 96330 - [1.5][compiler] varargs overloading problem
Summary: [1.5][compiler] varargs overloading problem
Status: RESOLVED DUPLICATE of bug 346039
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 106866 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-05-23 13:42 EDT by Tim Hanson CLA
Modified: 2021-06-17 10:23 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Hanson CLA 2005-05-23 13:42:05 EDT
The following should compile:

class Test implements IClass{

    Test(IClass c, Test t, IType... args) {}
    Test(IClass c, IType... args) {}

    public static void main(String args[]) {
        IClass c = null;
        Test t = null;

        Test t2 = new Test(c, t);
    }

}

interface IType{}
interface IClass extends IType{}


Eclipse incorrectly calls the method constructor invocation as ambiguous. Both
constructors are applicable. So is the first constructor more specific than the
second constructor? According to the rules of JLS3 in the middle of page 448:

The first constructor has n=3 parameters & the second constructor has k=2
parameters. This is the first set of rules for n >= k.

For all j from 1 to k - 1 (1): Tj <: Uj
That gives: IClass <: IClass

Then, For all j from k (2) to n, Tj <: Uk
That gives: Test <: IType
and       : IType <: IType

Note that the element types of the array (vararg) parameters are used
in the comparison, not the array type itself. 

Note also that javac has this same bug.
See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5088429
Comment 1 Olivier Thomann CLA 2005-08-17 13:32:15 EDT
*** Bug 106866 has been marked as a duplicate of this bug. ***
Comment 2 Kent Johnson CLA 2007-06-18 11:56:39 EDT
Waiting to see if the spec is clarified and/or javac's behaviour changes.
Comment 3 Srikanth Sankaran CLA 2011-05-24 20:28:04 EDT
Same as bug 346039

*** This bug has been marked as a duplicate of bug 346039 ***