[light classes] methods: fix PluginException: Incorrect CachedValue use
^KTIJ-6085 Fixed
This commit is contained in:
+10
-9
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -146,21 +146,22 @@ internal class UltraLightMembersCreator(
|
|||||||
|
|
||||||
internal class KtUltraLightAnnotationMethod(
|
internal class KtUltraLightAnnotationMethod(
|
||||||
private val psiMethod: KtLightMethod,
|
private val psiMethod: KtLightMethod,
|
||||||
expression: KtExpression
|
private val expression: KtExpression
|
||||||
) : KtLightMethod by psiMethod,
|
) : KtLightMethod by psiMethod, PsiAnnotationMethod {
|
||||||
PsiAnnotationMethod {
|
|
||||||
|
|
||||||
private val value by lazyPub {
|
private val value by lazyPub {
|
||||||
convertToLightAnnotationMemberValue(psiMethod, expression)
|
convertToLightAnnotationMemberValue(psiMethod, expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = psiMethod == (other as? KtUltraLightAnnotationMethod)?.psiMethod
|
override fun equals(other: Any?): Boolean = other === this ||
|
||||||
|
other is KtUltraLightAnnotationMethod &&
|
||||||
|
other.psiMethod == psiMethod &&
|
||||||
|
other.expression == expression
|
||||||
|
|
||||||
override fun hashCode(): Int = psiMethod.hashCode()
|
override fun hashCode(): Int = psiMethod.hashCode() * 31 + expression.hashCode()
|
||||||
|
|
||||||
override fun toString(): String = psiMethod.toString()
|
override fun toString(): String = "KtUltraLightAnnotationMethod(method=$psiMethod, expression=$expression"
|
||||||
|
|
||||||
override fun getDefaultValue(): PsiAnnotationMemberValue? = value
|
override fun getDefaultValue(): PsiAnnotationMemberValue = value
|
||||||
|
|
||||||
override fun getSourceElement(): PsiElement? = psiMethod.sourceElement
|
override fun getSourceElement(): PsiElement? = psiMethod.sourceElement
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-11
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -134,17 +134,15 @@ internal abstract class KtUltraLightMethod(
|
|||||||
override fun getSignature(substitutor: PsiSubstitutor): MethodSignature =
|
override fun getSignature(substitutor: PsiSubstitutor): MethodSignature =
|
||||||
MethodSignatureBackedByPsiMethod.create(this, substitutor)
|
MethodSignatureBackedByPsiMethod.create(this, substitutor)
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean = other === this ||
|
||||||
if (this === other) return true
|
other is KtUltraLightMethod &&
|
||||||
if (other !is KtUltraLightMethod) return false
|
other.methodIndex == methodIndex &&
|
||||||
if (methodIndex != other.methodIndex) return false
|
other.delegate == delegate &&
|
||||||
if (this.javaClass != other.javaClass) return false
|
super.equals(other)
|
||||||
if (containingClass != other.containingClass) return false
|
|
||||||
if (kotlinOrigin === null || other.kotlinOrigin === null) return false
|
|
||||||
return kotlinOrigin == other.kotlinOrigin
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int = name.hashCode()
|
override fun hashCode(): Int = super.hashCode()
|
||||||
|
.times(31).plus(delegate.hashCode())
|
||||||
|
.times(31).plus(methodIndex.hashCode())
|
||||||
|
|
||||||
override fun isDeprecated(): Boolean = _deprecated
|
override fun isDeprecated(): Boolean = _deprecated
|
||||||
}
|
}
|
||||||
@@ -197,6 +195,13 @@ internal class KtUltraLightMethodForSourceDeclaration(
|
|||||||
override fun getThrowsList(): PsiReferenceList = _throwsList
|
override fun getThrowsList(): PsiReferenceList = _throwsList
|
||||||
|
|
||||||
override val checkNeedToErasureParametersTypes: Boolean by lazyPub { computeCheckNeedToErasureParametersTypes(methodDescriptor) }
|
override val checkNeedToErasureParametersTypes: Boolean by lazyPub { computeCheckNeedToErasureParametersTypes(methodDescriptor) }
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean =
|
||||||
|
other is KtUltraLightMethodForSourceDeclaration &&
|
||||||
|
other.forceToSkipNullabilityAnnotation == forceToSkipNullabilityAnnotation &&
|
||||||
|
super.equals(other)
|
||||||
|
|
||||||
|
override fun hashCode(): Int = super.hashCode() * 31 + forceToSkipNullabilityAnnotation.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class KtUltraLightMethodForDescriptor(
|
internal class KtUltraLightMethodForDescriptor(
|
||||||
|
|||||||
+16
-25
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.asJava.elements
|
package org.jetbrains.kotlin.asJava.elements
|
||||||
@@ -158,19 +147,21 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
get() = (dummyDelegate ?: clsDelegate).memberIndex
|
get() = (dummyDelegate ?: clsDelegate).memberIndex
|
||||||
|
|
||||||
/* comparing origin and member index should be enough to determine equality:
|
/* comparing origin and member index should be enough to determine equality:
|
||||||
for compiled elements origin contains delegate
|
for compiled elements origin contains delegate
|
||||||
for source elements index is unique to each member
|
for source elements index is unique to each member
|
||||||
*/
|
*/
|
||||||
override fun equals(other: Any?): Boolean =
|
override fun equals(other: Any?): Boolean = other === this ||
|
||||||
this === other ||
|
other is KtLightMethodImpl &&
|
||||||
(other is KtLightMethodImpl &&
|
other.javaClass == javaClass &&
|
||||||
this.name == other.name &&
|
other.containingClass == containingClass &&
|
||||||
this.containingClass == other.containingClass &&
|
other.lightMemberOrigin == lightMemberOrigin &&
|
||||||
this.lightMemberOrigin == other.lightMemberOrigin &&
|
other.dummyDelegate == dummyDelegate &&
|
||||||
this.memberIndex == other.memberIndex)
|
other.memberIndex == memberIndex
|
||||||
|
|
||||||
override fun hashCode(): Int = ((name.hashCode() * 31 + (lightMemberOrigin?.hashCode()
|
override fun hashCode(): Int = name.hashCode()
|
||||||
?: 0)) * 31 + containingClass.hashCode()) * 31 + (memberIndex?.hashCode() ?: 0)
|
.times(31).plus(lightMemberOrigin.hashCode())
|
||||||
|
.times(31).plus(containingClass.hashCode())
|
||||||
|
.times(31).plus(memberIndex.hashCode())
|
||||||
|
|
||||||
override fun getDefaultValue() = (clsDelegate as? PsiAnnotationMethod)?.defaultValue
|
override fun getDefaultValue() = (clsDelegate as? PsiAnnotationMethod)?.defaultValue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user