[jvm] Fix RefMethodImpl hasBody check for Kotlin accessors

#KTIJ-34354 Fixed

GitOrigin-RevId: 926aab275ad24453f34287cccfe6d9621bf57aee
This commit is contained in:
Bart van Helvert
2025-05-28 16:36:47 +02:00
committed by intellij-monorepo-bot
parent d4110a129f
commit d942ea174c
4 changed files with 22 additions and 8 deletions

View File

@@ -32,6 +32,7 @@ public sealed class RefMethodImpl extends RefJavaElementImpl implements RefMetho
private static final int IS_ONLY_CALLS_SUPER_MASK = 0b100000_00000000_00000000; // 22nd bit
private static final int IS_RETURN_VALUE_USED_MASK = 0b1000000_00000000_00000000; // 23rd bit
private static final int IS_RECORD_ACCESSOR_MASK = 0b10000000_00000000_00000000; // 24th bit
private static final int HAS_BODY_MASK = 0b1_00000000_00000000_00000000; // 25th bit
private static final int IS_CALLED_ON_SUBCLASS_MASK = 0b1000_00000000_00000000_00000000; // 28th bit
@@ -229,13 +230,7 @@ public sealed class RefMethodImpl extends RefJavaElementImpl implements RefMetho
@Override
public boolean hasBody() {
if (!isAbstract()) {
RefClass ownerClass = getOwnerClass();
if (ownerClass == null || !ownerClass.isInterface()) {
return true;
}
}
return !isBodyEmpty();
return checkFlag(HAS_BODY_MASK);
}
private void initializeSuperMethods(PsiMethod method) {
@@ -300,7 +295,14 @@ public sealed class RefMethodImpl extends RefJavaElementImpl implements RefMetho
checkForSuperCall(method);
setOnlyCallsSuper(refUtil.isMethodOnlyCallsSuper(method));
setBodyEmpty(isOnlyCallsSuper() || !isExternalOverride() && isEmptyExpression(method.getUastBody()));
boolean isBodyEmpty = isOnlyCallsSuper() || !isExternalOverride() && isEmptyExpression(method.getUastBody());
setBodyEmpty(isBodyEmpty);
if (!isAbstract() && (ownerClass == null || !ownerClass.isInterface())) {
setHasBody(method.getUastBody() != null);
} else {
setHasBody(!isBodyEmpty);
}
refUtil.addTypeReference(method, method.getReturnType(), getRefManager(), this);
}
@@ -617,6 +619,10 @@ public sealed class RefMethodImpl extends RefJavaElementImpl implements RefMetho
setFlag(bodyEmpty, IS_BODY_EMPTY_MASK);
}
public void setHasBody(boolean hasBody) {
setFlag(hasBody, HAS_BODY_MASK);
}
private void setOnlyCallsSuper(boolean onlyCallsSuper) {
setFlag(onlyCallsSuper, IS_ONLY_CALLS_SUPER_MASK);
}