FIR2IR: Postpone binding overrides for lazy classes until sources processed
This commit is contained in:
@@ -52,6 +52,9 @@ class Fir2IrConverter(
|
|||||||
|
|
||||||
private val generatorExtensions = session.extensionService.declarationGenerators
|
private val generatorExtensions = session.extensionService.declarationGenerators
|
||||||
|
|
||||||
|
private var wereSourcesFakeOverridesBound = false
|
||||||
|
private val postponedDeclarationsForFakeOverridesBinding = mutableListOf<IrDeclaration>()
|
||||||
|
|
||||||
fun runSourcesConversion(
|
fun runSourcesConversion(
|
||||||
allFirFiles: List<FirFile>,
|
allFirFiles: List<FirFile>,
|
||||||
irModuleFragment: IrModuleFragmentImpl,
|
irModuleFragment: IrModuleFragmentImpl,
|
||||||
@@ -90,6 +93,11 @@ class Fir2IrConverter(
|
|||||||
for (firFile in allFirFiles) {
|
for (firFile in allFirFiles) {
|
||||||
bindFakeOverridesInFile(firFile)
|
bindFakeOverridesInFile(firFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wereSourcesFakeOverridesBound = true
|
||||||
|
fakeOverrideGenerator.bindOverriddenSymbols(postponedDeclarationsForFakeOverridesBinding)
|
||||||
|
postponedDeclarationsForFakeOverridesBinding.clear()
|
||||||
|
|
||||||
// Do (3) and (4) for local classes encountered during (3)
|
// Do (3) and (4) for local classes encountered during (3)
|
||||||
classifierStorage.processMembersOfClassesCreatedOnTheFly()
|
classifierStorage.processMembersOfClassesCreatedOnTheFly()
|
||||||
|
|
||||||
@@ -120,6 +128,15 @@ class Fir2IrConverter(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun bindFakeOverridesOrPostpone(declarations: List<IrDeclaration>) {
|
||||||
|
// Do not run binding for lazy classes until all sources declarations are processed
|
||||||
|
if (wereSourcesFakeOverridesBound) {
|
||||||
|
fakeOverrideGenerator.bindOverriddenSymbols(declarations)
|
||||||
|
} else {
|
||||||
|
postponedDeclarationsForFakeOverridesBinding += declarations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun processLocalClassAndNestedClassesOnTheFly(regularClass: FirRegularClass, parent: IrDeclarationParent): IrClass {
|
fun processLocalClassAndNestedClassesOnTheFly(regularClass: FirRegularClass, parent: IrDeclarationParent): IrClass {
|
||||||
val irClass = registerClassAndNestedClasses(regularClass, parent)
|
val irClass = registerClassAndNestedClasses(regularClass, parent)
|
||||||
processClassAndNestedClassHeaders(regularClass)
|
processClassAndNestedClassHeaders(regularClass)
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class Fir2IrLazyClass(
|
|||||||
|
|
||||||
fun getFakeOverridesByName(name: Name): Collection<IrDeclaration> = fakeOverridesByName.getOrPut(name) {
|
fun getFakeOverridesByName(name: Name): Collection<IrDeclaration> = fakeOverridesByName.getOrPut(name) {
|
||||||
fakeOverrideGenerator.generateFakeOverridesForName(this@Fir2IrLazyClass, name, fir)
|
fakeOverrideGenerator.generateFakeOverridesForName(this@Fir2IrLazyClass, name, fir)
|
||||||
.also(fakeOverrideGenerator::bindOverriddenSymbols)
|
.also(converter::bindFakeOverridesOrPostpone)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val declarations: MutableList<IrDeclaration> by lazyVar(lock) {
|
override val declarations: MutableList<IrDeclaration> by lazyVar(lock) {
|
||||||
|
|||||||
+5
@@ -617,6 +617,11 @@ public class IncrementalFirJvmCompilerRunnerTestGenerated extends AbstractIncrem
|
|||||||
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("serializedSubClassAndChangedInterfaces")
|
||||||
|
public void testSerializedSubClassAndChangedInterfaces() throws Exception {
|
||||||
|
runTest("jps-plugin/testData/incremental/pureKotlin/serializedSubClassAndChangedInterfaces/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClassDependency")
|
@TestMetadata("simpleClassDependency")
|
||||||
public void testSimpleClassDependency() throws Exception {
|
public void testSimpleClassDependency() throws Exception {
|
||||||
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
||||||
|
|||||||
+5
@@ -616,6 +616,11 @@ public class IncrementalJsCompilerRunnerTestGenerated extends AbstractIncrementa
|
|||||||
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("serializedSubClassAndChangedInterfaces")
|
||||||
|
public void testSerializedSubClassAndChangedInterfaces() throws Exception {
|
||||||
|
runTest("jps-plugin/testData/incremental/pureKotlin/serializedSubClassAndChangedInterfaces/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClassDependency")
|
@TestMetadata("simpleClassDependency")
|
||||||
public void testSimpleClassDependency() throws Exception {
|
public void testSimpleClassDependency() throws Exception {
|
||||||
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
||||||
|
|||||||
+5
@@ -616,6 +616,11 @@ public class IncrementalJsCompilerRunnerWithMetadataOnlyTestGenerated extends Ab
|
|||||||
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("serializedSubClassAndChangedInterfaces")
|
||||||
|
public void testSerializedSubClassAndChangedInterfaces() throws Exception {
|
||||||
|
runTest("jps-plugin/testData/incremental/pureKotlin/serializedSubClassAndChangedInterfaces/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClassDependency")
|
@TestMetadata("simpleClassDependency")
|
||||||
public void testSimpleClassDependency() throws Exception {
|
public void testSimpleClassDependency() throws Exception {
|
||||||
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
||||||
|
|||||||
+5
@@ -591,6 +591,11 @@ public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrem
|
|||||||
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("serializedSubClassAndChangedInterfaces")
|
||||||
|
public void testSerializedSubClassAndChangedInterfaces() throws Exception {
|
||||||
|
runTest("jps-plugin/testData/incremental/pureKotlin/serializedSubClassAndChangedInterfaces/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClassDependency")
|
@TestMetadata("simpleClassDependency")
|
||||||
public void testSimpleClassDependency() throws Exception {
|
public void testSimpleClassDependency() throws Exception {
|
||||||
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
||||||
|
|||||||
+5
@@ -591,6 +591,11 @@ public class IncrementalJsKlibCompilerWithScopeExpansionRunnerTestGenerated exte
|
|||||||
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("serializedSubClassAndChangedInterfaces")
|
||||||
|
public void testSerializedSubClassAndChangedInterfaces() throws Exception {
|
||||||
|
runTest("jps-plugin/testData/incremental/pureKotlin/serializedSubClassAndChangedInterfaces/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClassDependency")
|
@TestMetadata("simpleClassDependency")
|
||||||
public void testSimpleClassDependency() throws Exception {
|
public void testSimpleClassDependency() throws Exception {
|
||||||
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
||||||
|
|||||||
+5
@@ -617,6 +617,11 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
|
|||||||
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("serializedSubClassAndChangedInterfaces")
|
||||||
|
public void testSerializedSubClassAndChangedInterfaces() throws Exception {
|
||||||
|
runTest("jps-plugin/testData/incremental/pureKotlin/serializedSubClassAndChangedInterfaces/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClassDependency")
|
@TestMetadata("simpleClassDependency")
|
||||||
public void testSimpleClassDependency() throws Exception {
|
public void testSimpleClassDependency() throws Exception {
|
||||||
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
||||||
|
|||||||
+5
@@ -617,6 +617,11 @@ public class IncrementalJvmOldBackendCompilerRunnerTestGenerated extends Abstrac
|
|||||||
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/secondaryConstructorInlined/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("serializedSubClassAndChangedInterfaces")
|
||||||
|
public void testSerializedSubClassAndChangedInterfaces() throws Exception {
|
||||||
|
runTest("jps-plugin/testData/incremental/pureKotlin/serializedSubClassAndChangedInterfaces/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClassDependency")
|
@TestMetadata("simpleClassDependency")
|
||||||
public void testSimpleClassDependency() throws Exception {
|
public void testSimpleClassDependency() throws Exception {
|
||||||
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
runTest("jps-plugin/testData/incremental/pureKotlin/simpleClassDependency/");
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class A : I1, I2
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
data class B(val a: A) // generates a call to A::hashCode that is a fake override in A
|
||||||
Vendored
Vendored
+13
@@ -0,0 +1,13 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test/BKt.class
|
||||||
|
out/production/module/test/UsageKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/b.kt
|
||||||
|
src/interfaces.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
interface I1
|
||||||
|
interface I2
|
||||||
Reference in New Issue
Block a user