Fix invalid signature for UL method
Fixed #KT-32245
This commit is contained in:
+20
-4
@@ -22,12 +22,15 @@ import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFunction
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.KtTypeParameterListOwner
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind
|
||||
import org.jetbrains.kotlin.types.RawType
|
||||
|
||||
internal const val METHOD_INDEX_FOR_GETTER = 1
|
||||
internal const val METHOD_INDEX_FOR_SETTER = 2
|
||||
@@ -69,10 +72,23 @@ internal abstract class KtUltraLightMethod(
|
||||
}
|
||||
|
||||
protected fun computeCheckNeedToErasureParametersTypes(methodDescriptor: FunctionDescriptor?): Boolean {
|
||||
return methodDescriptor
|
||||
?.getSpecialSignatureInfo()
|
||||
?.let { it.valueParametersSignature !== null }
|
||||
?: false
|
||||
|
||||
if (methodDescriptor == null) return false
|
||||
|
||||
val hasSpecialSignatureInfo = methodDescriptor.getSpecialSignatureInfo()
|
||||
?.let { it.valueParametersSignature != null } ?: false
|
||||
if (hasSpecialSignatureInfo) return true
|
||||
|
||||
// Workaround for KT-32245 that checks if this signature could be affected by KT-38406
|
||||
if (!DescriptorUtils.isOverride(methodDescriptor)) return false
|
||||
|
||||
val hasStarProjectionParameterType = methodDescriptor.valueParameters
|
||||
.any { parameter -> parameter.type.arguments.any { it.isStarProjection } }
|
||||
if (!hasStarProjectionParameterType) return false
|
||||
|
||||
return methodDescriptor.overriddenDescriptors
|
||||
.filterIsInstance<JavaMethodDescriptor>()
|
||||
.any { it.valueParameters.any { parameter -> parameter.type is RawType } }
|
||||
}
|
||||
|
||||
abstract override fun buildTypeParameterList(): PsiTypeParameterList
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiMethod
|
||||
// OPTIONS: overrides
|
||||
public interface Foo2 {
|
||||
interface X<T> {}
|
||||
void <caret>baz(X clazz);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class FooImpl2 : Foo2 {
|
||||
override fun baz(clazz: Foo2.X<*>?) = Unit
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
Unclassified usage 2 override fun baz(clazz: Foo2.X<*>?) = Unit
|
||||
@@ -1764,6 +1764,11 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest {
|
||||
runTest("idea/testData/findUsages/java/findJavaMethodUsages/OverridenRawGenericSignatureBase.0.java");
|
||||
}
|
||||
|
||||
@TestMetadata("OverridenRawGenericSignatureBase2.0.java")
|
||||
public void testOverridenRawGenericSignatureBase2() throws Exception {
|
||||
runTest("idea/testData/findUsages/java/findJavaMethodUsages/OverridenRawGenericSignatureBase2.0.java");
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticProperties.0.java")
|
||||
public void testSyntheticProperties() throws Exception {
|
||||
runTest("idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.0.java");
|
||||
|
||||
Reference in New Issue
Block a user