Extract JetProperty#hasDelegateExpressionOrInitializer() and use it where appropriate
This commit is contained in:
@@ -248,8 +248,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldInitializeProperty(@NotNull JetProperty property) {
|
private boolean shouldInitializeProperty(@NotNull JetProperty property) {
|
||||||
JetExpression initializer = property.getDelegateExpressionOrInitializer();
|
if (!property.hasDelegateExpressionOrInitializer()) return false;
|
||||||
if (initializer == null) return false;
|
|
||||||
|
|
||||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
|
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
|
||||||
assert propertyDescriptor != null;
|
assert propertyDescriptor != null;
|
||||||
|
|||||||
@@ -166,6 +166,10 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
|||||||
return PsiTreeUtil.getNextSiblingOfType(findChildByType(EQ), JetExpression.class);
|
return PsiTreeUtil.getNextSiblingOfType(findChildByType(EQ), JetExpression.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasDelegateExpressionOrInitializer() {
|
||||||
|
return getDelegateExpressionOrInitializer() != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getDelegateExpressionOrInitializer() {
|
public JetExpression getDelegateExpressionOrInitializer() {
|
||||||
JetExpression expression = getDelegateExpression();
|
JetExpression expression = getDelegateExpression();
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ public class DeclarationsChecker {
|
|||||||
(setter != null && setter.hasBody());
|
(setter != null && setter.hasBody());
|
||||||
|
|
||||||
if (propertyDescriptor.getModality() == Modality.ABSTRACT) {
|
if (propertyDescriptor.getModality() == Modality.ABSTRACT) {
|
||||||
if (property.getDelegateExpressionOrInitializer() == null && property.getTypeRef() == null) {
|
if (!property.hasDelegateExpressionOrInitializer() && property.getTypeRef() == null) {
|
||||||
trace.report(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(property));
|
trace.report(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(property));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -959,7 +959,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
/*package*/
|
/*package*/
|
||||||
static boolean hasBody(JetProperty property) {
|
static boolean hasBody(JetProperty property) {
|
||||||
boolean hasBody = property.getDelegateExpressionOrInitializer() != null;
|
boolean hasBody = property.hasDelegateExpressionOrInitializer();
|
||||||
if (!hasBody) {
|
if (!hasBody) {
|
||||||
JetPropertyAccessor getter = property.getGetter();
|
JetPropertyAccessor getter = property.getGetter();
|
||||||
if (getter != null && getter.hasBody()) {
|
if (getter != null && getter.hasBody()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user