Minor, refactor: Move hasBody() to KtProperty
This commit is contained in:
@@ -298,4 +298,17 @@ public class KtProperty extends KtTypeParameterListOwnerStub<KotlinPropertyStub>
|
||||
// Suppress Java check for out-of-block
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBody() {
|
||||
if (hasDelegateExpressionOrInitializer()) return true;
|
||||
KtPropertyAccessor getter = getGetter();
|
||||
if (getter != null && getter.hasBody()) {
|
||||
return true;
|
||||
}
|
||||
KtPropertyAccessor setter = getSetter();
|
||||
if (setter != null && setter.hasBody()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,4 +526,10 @@ fun KtCallExpression.getOrCreateValueArgumentList(): KtValueArgumentList {
|
||||
valueArgumentList?.let { return it }
|
||||
return addAfter(KtPsiFactory(this).createCallArguments("()"),
|
||||
typeArgumentList ?: calleeExpression) as KtValueArgumentList
|
||||
}
|
||||
}
|
||||
|
||||
fun KtDeclaration.hasBody() = when (this) {
|
||||
is KtFunction -> hasBody()
|
||||
is KtProperty -> hasBody()
|
||||
else -> false
|
||||
}
|
||||
|
||||
@@ -788,10 +788,9 @@ public class DescriptorResolver {
|
||||
KtModifierList modifierList = property.getModifierList();
|
||||
boolean isVar = property.isVar();
|
||||
|
||||
boolean hasBody = hasBody(property);
|
||||
Visibility visibility = resolveVisibilityFromModifiers(property, getDefaultVisibility(property, containingDeclaration));
|
||||
Modality modality = containingDeclaration instanceof ClassDescriptor
|
||||
? resolveMemberModalityFromModifiers(property, getDefaultModality(containingDeclaration, visibility, hasBody),
|
||||
? resolveMemberModalityFromModifiers(property, getDefaultModality(containingDeclaration, visibility, property.hasBody()),
|
||||
trace.getBindingContext(), containingDeclaration)
|
||||
: Modality.FINAL;
|
||||
|
||||
@@ -896,22 +895,6 @@ public class DescriptorResolver {
|
||||
return propertyDescriptor;
|
||||
}
|
||||
|
||||
public static boolean hasBody(KtProperty property) {
|
||||
boolean hasBody = property.hasDelegateExpressionOrInitializer();
|
||||
if (!hasBody) {
|
||||
KtPropertyAccessor getter = property.getGetter();
|
||||
if (getter != null && getter.hasBody()) {
|
||||
hasBody = true;
|
||||
}
|
||||
KtPropertyAccessor setter = property.getSetter();
|
||||
if (!hasBody && setter != null && setter.hasBody()) {
|
||||
hasBody = true;
|
||||
}
|
||||
}
|
||||
return hasBody;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
/*package*/ static KotlinType transformAnonymousTypeIfNeeded(
|
||||
@NotNull DeclarationDescriptorWithVisibility descriptor,
|
||||
|
||||
Reference in New Issue
Block a user