Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321185 - [1.5][compiler] Enclosing instance used despite wrong type arguments
Summary: [1.5][compiler] Enclosing instance used despite wrong type arguments
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-29 01:37 EDT by Matt McCutchen CLA
Modified: 2020-02-18 13:32 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt McCutchen CLA 2010-07-29 01:37:59 EDT
Build Identifier: I20100608-0911

class OuterClassClash {
    static class Outer<T> {
        final T field;
        Outer(T val) {
            field = val;
        }

        class Inner {
            T get() {
                return field;
            }
        }
    }

    static class SubOuter extends Outer<Integer> {
        SubOuter(Integer val) {
            super(val);
        }

        class SubInner extends Outer<String>.Inner {
            /* Expected: "No enclosing instance of type Outer<String> is
             * accessible to invoke the super constructor..."
             * Actual: The Outer<Integer> enclosing instance is used, breaking
             * type safety. */
            SubInner() {}
        }
    }

    public static void main(String[] args) {
        Outer<String>.Inner obj = new SubOuter(42).new SubInner();
        String str = obj.get(); // ClassCastException
    }
}

The same bug exists in javac:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6886402

I ran across that bug entry and decided to test Eclipse.

Reproducible: Always

Steps to Reproduce:
1. Compile and run the given code.
Comment 1 Ayushman Jain CLA 2010-07-29 02:35:53 EDT
Srikanth, please follow up. Thanks!
Comment 2 Eclipse Genie CLA 2020-02-18 13:32:01 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.