mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Fix incremental compilation for calls to inner classes from supertypes
The problem became actual after 8c2baf0704
This commit is contained in:
committed by
Ilya Muradyan
parent
6b81cc8b77
commit
3ce980fd88
@@ -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/");
|
||||
|
||||
@@ -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/");
|
||||
|
||||
@@ -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/");
|
||||
|
||||
@@ -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/");
|
||||
|
||||
@@ -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/");
|
||||
|
||||
@@ -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/");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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/");
|
||||
|
||||
7
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/a.kt
vendored
Normal file
7
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/a.kt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
abstract class A {
|
||||
inner class Inner(val x: String)
|
||||
}
|
||||
abstract class B : A()
|
||||
|
||||
6
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/b.kt
vendored
Normal file
6
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/b.kt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// TODO add var
|
||||
package test
|
||||
|
||||
class C : B() {
|
||||
val i = Inner("")
|
||||
}
|
||||
0
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/b.kt.touch
vendored
Normal file
0
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/b.kt.touch
vendored
Normal file
11
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/build.log
vendored
Normal file
11
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/build.log
vendored
Normal 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
|
||||
------------------------------------------
|
||||
5
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/usage.kt
vendored
Normal file
5
jps-plugin/testData/incremental/pureKotlin/innerClassesFromSupertypes/usage.kt
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
fun main() {
|
||||
C().i.x
|
||||
}
|
||||
Reference in New Issue
Block a user