Fix incremental compilation for calls to inner classes from supertypes

The problem became actual after 8c2baf0704
This commit is contained in:
Denis Zharkov
2020-06-30 18:17:17 +03:00
committed by Ilya Muradyan
parent 6b81cc8b77
commit 3ce980fd88
16 changed files with 81 additions and 1 deletions

View File

@@ -310,6 +310,11 @@ public class IncrementalJsCompilerRunnerTestGenerated extends AbstractIncrementa
runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/");
}
@TestMetadata("innerClassesFromSupertypes")
public void testInnerClassesFromSupertypes() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/");
}
@TestMetadata("internalClassChanged")
public void testInternalClassChanged() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/");

View File

@@ -310,6 +310,11 @@ public class IncrementalJsCompilerRunnerWithMetadataOnlyTestGenerated extends Ab
runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/");
}
@TestMetadata("innerClassesFromSupertypes")
public void testInnerClassesFromSupertypes() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/");
}
@TestMetadata("internalClassChanged")
public void testInternalClassChanged() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/");

View File

@@ -312,6 +312,11 @@ public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrem
runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/");
}
@TestMetadata("innerClassesFromSupertypes")
public void testInnerClassesFromSupertypes() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/");
}
@TestMetadata("internalClassChanged")
public void testInternalClassChanged() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/");

View File

@@ -310,6 +310,11 @@ public class IncrementalJsKlibCompilerWithScopeExpansionRunnerTestGenerated exte
runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/");
}
@TestMetadata("innerClassesFromSupertypes")
public void testInnerClassesFromSupertypes() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/");
}
@TestMetadata("internalClassChanged")
public void testInternalClassChanged() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/");

View File

@@ -311,6 +311,11 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/");
}
@TestMetadata("innerClassesFromSupertypes")
public void testInnerClassesFromSupertypes() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/");
}
@TestMetadata("internalClassChanged")
public void testInternalClassChanged() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/");

View File

@@ -311,6 +311,11 @@ public class IrIncrementalJvmCompilerRunnerTestGenerated extends AbstractIrIncre
runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/");
}
@TestMetadata("innerClassesFromSupertypes")
public void testInnerClassesFromSupertypes() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/");
}
@TestMetadata("internalClassChanged")
public void testInternalClassChanged() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/");

View File

@@ -126,6 +126,7 @@ class MetadataPackageFragment(
override fun hasClass(name: Name): Boolean = hasTopLevelClass(name)
override fun definitelyDoesNotContainName(name: Name) = false
override fun getClassifierNames(): Set<Name>? = null
override fun getNonDeclaredClassifierNames(): Set<Name>? = null
})
return ChainedMemberScope.create("Metadata scope", scopes)

View File

@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.types.SimpleType
import org.jetbrains.kotlin.types.TypeConstructor
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
import org.jetbrains.kotlin.types.refinement.TypeRefinement
import org.jetbrains.kotlin.utils.addToStdlib.flatMapToNullable
import java.util.*
class DeserializedClassDescriptor(
@@ -307,6 +308,12 @@ class DeserializedClassDescriptor(
}
}
override fun getNonDeclaredClassifierNames(): Set<Name>? {
return classDescriptor.typeConstructor.supertypes.flatMapToNullable(LinkedHashSet()) {
it.memberScope.getClassifierNames()
}
}
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
recordLookup(name, location)
classDescriptor.enumEntries?.findEnumEntry(name)?.let { return it }

View File

@@ -81,9 +81,15 @@ abstract class DeserializedMemberScope protected constructor(
internal val classNames by c.storageManager.createLazyValue { classNames().toSet() }
private val classifierNamesLazy = c.storageManager.createNullableLazyValue {
val nonDeclaredNames = getNonDeclaredClassifierNames() ?: return@createNullableLazyValue null
this.classNames + typeAliasNames + nonDeclaredNames
}
override fun getFunctionNames() = functionNamesLazy
override fun getVariableNames() = variableNamesLazy
override fun getClassifierNames(): Set<Name>? = classNames + typeAliasNames
override fun getClassifierNames(): Set<Name>? = classifierNamesLazy()
override fun definitelyDoesNotContainName(name: Name): Boolean {
return name !in functionNamesLazy && name !in variableNamesLazy && name !in classNames && name !in typeAliasNames
@@ -256,6 +262,7 @@ abstract class DeserializedMemberScope protected constructor(
protected abstract fun getNonDeclaredFunctionNames(): Set<Name>
protected abstract fun getNonDeclaredVariableNames(): Set<Name>
protected abstract fun getNonDeclaredClassifierNames(): Set<Name>?
protected abstract fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)

View File

@@ -69,6 +69,7 @@ open class DeserializedPackageMemberScope(
override fun getNonDeclaredFunctionNames(): Set<Name> = emptySet()
override fun getNonDeclaredVariableNames(): Set<Name> = emptySet()
override fun getNonDeclaredClassifierNames(): Set<Name>? = emptySet()
override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
// Do nothing

View File

@@ -979,6 +979,11 @@ public class IncrementalJvmJpsTestGenerated extends AbstractIncrementalJvmJpsTes
runTest("jps-plugin/testData/incremental/pureKotlin/inlineUsedWhereDeclared/");
}
@TestMetadata("innerClassesFromSupertypes")
public void testInnerClassesFromSupertypes() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/");
}
@TestMetadata("internalClassChanged")
public void testInternalClassChanged() throws Exception {
runTest("jps-plugin/testData/incremental/pureKotlin/internalClassChanged/");

View File

@@ -0,0 +1,7 @@
package test
abstract class A {
inner class Inner(val x: String)
}
abstract class B : A()

View File

@@ -0,0 +1,6 @@
// TODO add var
package test
class C : B() {
val i = Inner("")
}

View File

@@ -0,0 +1,11 @@
================ Step #1 =================
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/test/C.class
End of files
Compiling files:
src/b.kt
End of files
Exit code: OK
------------------------------------------

View File

@@ -0,0 +1,5 @@
package test
fun main() {
C().i.x
}