Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333803 - [move member type] Move Type to New File creates compile error with parametrized outer type
Summary: [move member type] Move Type to New File creates compile error with parametri...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-08 14:22 EST by Markus Keller CLA
Modified: 2011-01-18 03:17 EST (History)
1 user (show)

See Also:


Attachments
fix & test (6.07 KB, patch)
2011-01-18 03:16 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-01-08 14:22:21 EST
HEAD

The 'Move Type to New File' refactoring creates a compile error when the member type contains an array access expression:

public class Outer {
	private final Object[] fSet= new Object[1];
	
	class Inner { //Move Type to New File
		void foo() {
			System.out.println(fSet[0]); // broken
//			System.out.println(fSet);    // OK
		}
	}
}
Comment 1 Markus Keller CLA 2011-01-08 14:23:21 EST
Raksha, please have a look.
Comment 2 Raksha Vasisht CLA 2011-01-17 14:17:57 EST
(In reply to comment #1)
> Raksha, please have a look.

I'm not able to reproduce the compile error with  I20110114-1330. After refactoring I see the following Outer and Inner classes without any compile errors during or after refactoring:

Inner.java 
--------------
class Inner { //Move Type to New File
        /**
		 * 
		 */
		private final Outer outer;

		/**
		 * @param outer
		 */
		Inner(Outer outer) {
			this.outer = outer;
		}

		void foo() {
            System.out.println(this.outer.fSet[0]); // broken
//            System.out.println(fSet);    // OK
        }
    }

Outer.java
---------------
public class Outer {
    final Object[] fSet= new Object[1];
}

Am I missing something?
Comment 3 Markus Keller CLA 2011-01-18 03:16:28 EST
Created attachment 186975 [details]
fix & test

Sorry, I reduced this out of a much more complicated example, and I must have gotten something wrong. The problem is not an array access, but a parameterized outer type. The refactoring does not force me to specify a field for the enclosing instance.

package pack;

public class Outer<E> {
    private final Object fSet= new Object();

    class Inner { //Move Type to New File
        void foo() {
            System.out.println(fSet); // fSet needs outer field
        }
    }
}
Comment 4 Markus Keller CLA 2011-01-18 03:17:37 EST
Fixed in HEAD.