Skip to content

Commit

Permalink
bug: no fully qualified name if top package is shadowed by a local va…
Browse files Browse the repository at this point in the history
…riable
  • Loading branch information
monperrus committed Nov 16, 2016
1 parent b4fbe3e commit 9694ff9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package spoon.test.variable;

import org.junit.Test;
import spoon.Launcher;
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.factory.Factory;
import spoon.test.main.MainTest;
import spoon.test.variable.testclasses.Burritos;
import spoon.test.variable.testclasses.Tacos;

import static spoon.testing.utils.ModelUtils.build;
import static spoon.testing.utils.ModelUtils.canBeBuilt;

public class AccessFullyQualifiedFieldTest {
@Test
Expand All @@ -14,4 +19,16 @@ public void testCheckAssignmentContracts() throws Exception {

MainTest.checkAssignmentContracts(factory.Package().getRootPackage());
}
}

@Test
public void testNoFQN() throws Exception {
// contract: no fully qualified name if top package is shadowed by a local variable
Launcher spoon = new Launcher();
spoon.addInputResource("src/test/java/spoon/test/variable/testclasses/Burritos.java");
String output = "target/spooned-" + this.getClass().getSimpleName()+"/";
spoon.setSourceOutputDirectory(output);
spoon.run();
canBeBuilt(output, 7);
}

}
11 changes: 11 additions & 0 deletions src/test/java/spoon/test/variable/testclasses/Burritos.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package spoon.test.variable.testclasses;


import static spoon.Launcher.SPOONED_CLASSES;

public class Burritos {
void foo() {
Object spoon = null;
Object xx = SPOONED_CLASSES; // cannot be written spoon.o, has to be with implicit visibility or static import
}
}

0 comments on commit 9694ff9

Please sign in to comment.