Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333803

Summary: [move member type] Move Type to New File creates compile error with parametrized outer type
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: raksha.vasisht
Version: 3.7   
Target Milestone: 3.7 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
fix & test none

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.