Code clean

This commit is contained in:
Mikhael Bogdanov
2016-06-23 15:38:21 +03:00
parent 853c4d4453
commit 93a770fcc8
7 changed files with 27 additions and 34 deletions
@@ -17,10 +17,7 @@
package org.jetbrains.kotlin.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.psi.KtCallableDeclaration;
import org.jetbrains.kotlin.psi.KtNamedFunction;
import org.jetbrains.kotlin.psi.KtProperty;
@@ -29,8 +29,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
object InlineAnalyzerExtension : AnalyzerExtensions.AnalyzerExtension {
override fun process(descriptor: CallableMemberDescriptor, functionOrProperty: KtCallableDeclaration, trace: BindingTrace) {
assert(InlineUtil.isInline(descriptor)) { "This method should be invoked on inline function: " + descriptor }
checkModalityAndOverrides(descriptor, functionOrProperty, trace)
notSupportedInInlineCheck(descriptor, functionOrProperty, trace)
@@ -49,7 +47,7 @@ object InlineAnalyzerExtension : AnalyzerExtensions.AnalyzerExtension {
"Property descriptor $descriptor should have corresponded KtProperty, but has $functionOrProperty"
}
val hasBackingField = java.lang.Boolean.TRUE.equals(trace.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor as PropertyDescriptor))
val hasBackingField = trace.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor as PropertyDescriptor) == true
if (hasBackingField || (functionOrProperty as KtProperty).delegateExpression != null) {
trace.report(Errors.INLINE_PROPERTY_WITH_BACKING_FIELD.on(functionOrProperty))
}
@@ -39,21 +39,17 @@ public class InlineUtil {
FunctionTypesKt.isFunctionType(valueParameterOrReceiver.getOriginal().getType());
}
public static boolean isInlineFunctionOrProperty(@Nullable DeclarationDescriptor descriptor) {
return isInline(descriptor) || isInlineProperty(descriptor);
}
public static boolean isInline(@Nullable DeclarationDescriptor descriptor) {
return descriptor instanceof FunctionDescriptor && getInlineStrategy((FunctionDescriptor) descriptor).isInline();
}
public static boolean hasInlineAccessors(@Nullable PropertyDescriptor propertyDescriptor) {
public static boolean hasInlineAccessors(@NotNull PropertyDescriptor propertyDescriptor) {
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
return getter != null && getter.isInline() || setter != null && setter.isInline();
}
public static boolean isInlineProperty(@Nullable DeclarationDescriptor descriptor) {
public static boolean isPropertyWithAllAccessorsAreInline(@NotNull DeclarationDescriptor descriptor) {
if (!(descriptor instanceof PropertyDescriptor)) return false;
PropertyGetterDescriptor getter = ((PropertyDescriptor) descriptor).getGetter();