Bug 85062 - [compiler] Implicit static method invocation should target the receiver type not the declaring class
Summary: [compiler] Implicit static method invocation should target the receiver type ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-11 16:51 EST by Olivier Thomann CLA
Modified: 2005-03-31 09:17 EST (History)
1 user (show)

See Also:


Attachments
Apply on HEAD (3.51 KB, patch)
2005-02-11 16:52 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2005-02-11 16:51:12 EST
In this example,

class A { 
    static int foo() { 
        return 10;
    }
    
	static int bar() { 
        return 11;
    }    
}

public class X extends A {
    public static void main(String argv[]) {
        int i = A.foo();
        int j = bar();
        System.out.println(i + " - " + j);
    }
}

The method invocation A.foo() should have the declaring class A, but the method
invocation bar() should have the declaring class X. Not A.
Comment 1 Olivier Thomann CLA 2005-02-11 16:52:27 EST
Created attachment 17877 [details]
Apply on HEAD

This patch fixes the declaring class by using the actualReceiverType if the
receiver is an implicit this.
Comment 2 Olivier Thomann CLA 2005-02-11 16:57:28 EST
I am not sure that the test if (receiver.isImplicitThis()) { is required,
because the actualReceiverType is fine in both cases.
Comment 3 Philipe Mulet CLA 2005-02-19 12:16:02 EST
Consider static receiver type from 1.4 compliance on, also had to tweak lookup
using static imports to properly set the actualReceiverType.

Updated Compliance_1* tests to match new behavior.
We now match 1.4.2 (and no longer 1.4.1).
Fixed
Comment 4 David Audel CLA 2005-03-31 09:17:46 EST
Verified in I20050330-0500