use of com.google.devtools.j2objc.ast.CompilationUnit in project j2objc by google.
the class InnerClassExtractorTest method testMultipleThisReferences.
public void testMultipleThisReferences() throws IOException {
String source = "class A { private int x = 0; " + " interface Foo { void doSomething(); } " + " class Inner { private int x = 1; " + " public void blah() { " + " new Foo() { public void doSomething() { " + " Inner.this.x = 2; A.this.x = 3; }}; }}}";
CompilationUnit unit = translateType("A", source);
List<AbstractTypeDeclaration> types = unit.getTypes();
assertEquals(4, types.size());
String translation = translateSourceFile(source, "A", "A.m");
// Anonymous class constructor in Inner.blah()
assertTranslation(translation, "create_A_Inner_1_initWithA_Inner_(self)");
// A.Inner.x referred to in anonymous Foo
assertTranslation(translation, "this$0_->x_ = 2");
// A.x referred to in anonymous Foo
assertTranslation(translation, "this$0_->this$0_->x_ = 3");
// A.Inner init in anonymous Foo's constructor
assertTranslation(translation, "JreStrongAssign(&self->this$0_, outer$)");
}
Aggregations