Lazy light classes: can't use laziness for classes with supertypes delegates
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
public final class B implements p.I {
|
||||
private final p.I f;
|
||||
|
||||
public B(@org.jetbrains.annotations.NotNull p.I f) { /* compiled code */ }
|
||||
|
||||
public void f() { /* compiled code */ }
|
||||
|
||||
public void g() { /* compiled code */ }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// p.B
|
||||
package p
|
||||
|
||||
class B(private val f: I) : I by f {
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun g()
|
||||
|
||||
fun f()
|
||||
}
|
||||
|
||||
// LAZINESS:NoLaziness
|
||||
@@ -42,6 +42,12 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/Delegation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedEnumEntry.kt")
|
||||
public void testDeprecatedEnumEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DeprecatedEnumEntry.kt");
|
||||
|
||||
+3
-1
@@ -69,10 +69,12 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
|
||||
)
|
||||
}
|
||||
else {
|
||||
val hasDelegatedMembers = classOrObject.superTypeListEntries.any { it is KtDelegatedSuperTypeEntry }
|
||||
val dummyContextProvider = { IDELightClassContexts.lightContextForClassOrObject(classOrObject) }
|
||||
LazyLightClassDataHolder.ForClass(
|
||||
builder,
|
||||
exactContextProvider = { IDELightClassContexts.contextForNonLocalClassOrObject(classOrObject) },
|
||||
dummyContextProvider = { IDELightClassContexts.lightContextForClassOrObject(classOrObject) }
|
||||
dummyContextProvider = if (!hasDelegatedMembers) dummyContextProvider else null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +199,9 @@ object LightClassLazinessChecker {
|
||||
// still running code above to catch possible exceptions
|
||||
if (lazinessMode == Mode.NoConsistency) return
|
||||
|
||||
assertEquals(lightClass.clsDelegate.methods.names(), lightClass.methods.names())
|
||||
assertEquals(lightClass.clsDelegate.fields.names(), lightClass.fields.names())
|
||||
|
||||
// check collected data against delegates which should contain correct data
|
||||
for ((field, lightFieldInfo) in fieldsToInfo) {
|
||||
val delegate = (field as KtLightField).clsDelegate
|
||||
@@ -210,6 +213,8 @@ object LightClassLazinessChecker {
|
||||
}
|
||||
}
|
||||
|
||||
private fun Array<out PsiMember>.names() = mapTo(LinkedHashSet()) { it.name }
|
||||
|
||||
private data class FieldInfo(
|
||||
val name: String,
|
||||
val modifiers: List<String>
|
||||
|
||||
+6
@@ -42,6 +42,12 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/Delegation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedEnumEntry.kt")
|
||||
public void testDeprecatedEnumEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DeprecatedEnumEntry.kt");
|
||||
|
||||
@@ -42,6 +42,12 @@ public class IdeLightClassTestGenerated extends AbstractIdeLightClassTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/Delegation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedEnumEntry.kt")
|
||||
public void testDeprecatedEnumEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DeprecatedEnumEntry.kt");
|
||||
|
||||
Reference in New Issue
Block a user