IDELightClassContexts#isDummyResolveApplicable: add missing check
Missing check caused exact resolve being applied to every class that had 'equals' overridden
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
public final class A {
|
||||
private final int y;
|
||||
|
||||
public boolean equals(@org.jetbrains.annotations.Nullable java.lang.Object other) { /* compiled code */ }
|
||||
|
||||
public int hashCode() { /* compiled code */ }
|
||||
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public java.lang.String toString() { /* compiled code */ }
|
||||
|
||||
public final int component1() { /* compiled code */ }
|
||||
|
||||
public final int getY() { /* compiled code */ }
|
||||
|
||||
public A(int y) { /* compiled code */ }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// p.A
|
||||
package p
|
||||
|
||||
class A(val y: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return super.equals(other)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
|
||||
fun component1() = y
|
||||
}
|
||||
@@ -114,6 +114,12 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NonDataClassWithComponentFunctions.kt")
|
||||
public void testNonDataClassWithComponentFunctions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/NonDataClassWithComponentFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PublishedApi.kt")
|
||||
public void testPublishedApi() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/PublishedApi.kt");
|
||||
|
||||
+7
-4
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.idea.project.IdeaEnvironment
|
||||
import org.jetbrains.kotlin.idea.project.ResolveElementCache
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -137,9 +138,11 @@ object IDELightClassContexts {
|
||||
|
||||
private fun isDummyResolveApplicable(classOrObject: KtClassOrObject): Boolean {
|
||||
val hasDelegatedMembers = classOrObject.superTypeListEntries.any { it is KtDelegatedSuperTypeEntry }
|
||||
val dataClassWithGeneratedMembersOverridden = classOrObject.declarations.filterIsInstance<KtFunction>().any {
|
||||
isGeneratedForDataClass(it.nameAsSafeName)
|
||||
}
|
||||
val dataClassWithGeneratedMembersOverridden =
|
||||
classOrObject.hasModifier(KtTokens.DATA_KEYWORD) &&
|
||||
classOrObject.declarations.filterIsInstance<KtFunction>().any {
|
||||
isGeneratedForDataClass(it.nameAsSafeName)
|
||||
}
|
||||
return !hasDelegatedMembers && !dataClassWithGeneratedMembersOverridden
|
||||
&& classOrObject.declarations.filterIsInstance<KtClassOrObject>().all { isDummyResolveApplicable(it) }
|
||||
}
|
||||
@@ -291,7 +294,7 @@ object IDELightClassContexts {
|
||||
moduleDescriptor.getPackage(annotationFqName.parent()).memberScope
|
||||
.getContributedClassifier(annotationFqName.shortName(), NoLookupLocation.FROM_IDE)?.let { return it as? ClassDescriptor }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
+6
@@ -114,6 +114,12 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NonDataClassWithComponentFunctions.kt")
|
||||
public void testNonDataClassWithComponentFunctions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/NonDataClassWithComponentFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PublishedApi.kt")
|
||||
public void testPublishedApi() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/PublishedApi.kt");
|
||||
|
||||
@@ -114,6 +114,12 @@ public class IdeLightClassTestGenerated extends AbstractIdeLightClassTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NonDataClassWithComponentFunctions.kt")
|
||||
public void testNonDataClassWithComponentFunctions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/NonDataClassWithComponentFunctions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PublishedApi.kt")
|
||||
public void testPublishedApi() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/PublishedApi.kt");
|
||||
|
||||
Reference in New Issue
Block a user