Bug 83376 - [1.5] compiler should error on ambiguous method invocation due to duplicate static imports
Summary: [1.5] compiler should error on ambiguous method invocation due to duplicate s...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-21 04:38 EST by Markus Keller CLA
Modified: 2005-02-16 06:52 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-01-21 04:38:50 EST
[1.5] The compiler should error on ambiguous method invocation due to duplicate
static imports.

The example below compiles without error. Eclipse just binds m() to the first
static import that provides a matching method declaration. Javac errors at the
invocation of m().

--- p/A.java: --------------------------------
package p;

import static x.X.m;
import static p.A.m;

public class A {
    public static void main(String[] args) {
        new B().use();
    }

    public static void m() {
        System.out.println("A.m()");
    }

    public static void m(int arg) {
        System.out.println("A.m(" + arg + ")");
    }
}

class B {
    void use() {
        m(); // javac: reference to m is ambiguous,
               //    both method m() in x.X and method m() in p.A match
        m(1);
    }
}

--- c/X.java: --------------------------------
package x;

public class X {
    public static void m() {
        System.out.println("X.m()");
    }
}
Comment 1 Kent Johnson CLA 2005-02-01 14:41:26 EST
Added StaticImport test024
Comment 2 David Audel CLA 2005-02-16 06:52:28 EST
Verified in I20050215-2300