Skip to content

Commit

Permalink
IDEA-154389 Remove and restore superclass leads to wrong state of Cla…
Browse files Browse the repository at this point in the history
…ssToSubclasses mappings
  • Loading branch information
Eugene Zhuravlev committed Apr 21, 2016
1 parent 8a035e0 commit ba90cfb
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 1 deletion.
@@ -0,0 +1,13 @@
Cleaning output files:
out/production/IntegrateOnSuperclassRemovedAndRestored/A.class
End of files
Cleaning output files:
out/production/IntegrateOnSuperclassRemovedAndRestored/B.class
End of files
Compiling files:
src/B.java
End of files
Compiling files:
src/A.java
src/B.java
End of files
@@ -0,0 +1 @@
class A {}
@@ -0,0 +1 @@
class A {}
@@ -0,0 +1 @@
class A {}
@@ -0,0 +1,3 @@
class B extends A {

}
Expand Up @@ -2164,6 +2164,31 @@ public boolean execute(File fileName, Collection<ClassRepr> classes) {
}
}

// Now that the list of added classes is complete,
// check that super-classes of compiled classes are among newly added ones.
// Even if compiled class did not change, we should register 'added' superclass
// Consider situation for class B extends A:
// 1. file A is removed, make fails with error in file B
// 2. A is added back, B and A are compiled together in the second make session
// 3. Even if B did not change, A is considered as newly added and should be registered again in ClassToSubclasses dependencies
// Without this code such registration will not happen because list of B's parents did not change
final Set<ClassRepr> addedClasses = myDelta.getAddedClasses();
if (!addedClasses.isEmpty()) {
final TIntHashSet addedNames = new TIntHashSet();
for (ClassRepr repr : addedClasses) {
addedNames.add(repr.name);
}
for (FileClasses compiledFile : newClasses) {
for (ClassRepr aClass : compiledFile.myFileClasses) {
for (int parent : aClass.getSupers()) {
if (addedNames.contains(parent)) {
myDelta.registerAddedSuperClass(aClass.name, parent);
}
}
}
}
}

debug("End of Differentiate.");

if (myEasyMode) {
Expand Down
7 changes: 6 additions & 1 deletion jps/jps-builders/testSrc/org/jetbrains/ether/CommonTest.java
Expand Up @@ -149,7 +149,12 @@ public void testMoveClassFromJavaFileToDependentModule() throws Exception {
JpsModuleRootModificationUtil.addDependency(moduleB, moduleA);
doTestBuild(1).assertSuccessful();
}


public void testIntegrateOnSuperclassRemovedAndRestored() throws Exception {
setupInitialProject();

doTestBuild(2);
}
public void testMoveToplevelClassToAnotherFile() throws Exception {
doTest();
}
Expand Down

0 comments on commit ba90cfb

Please sign in to comment.