Code clean
This commit is contained in:
@@ -2330,11 +2330,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return lookupCapturedValueInConstructorParameters(descriptor);
|
||||
}
|
||||
|
||||
return lookupInContext(descriptor, StackValue.LOCAL_0, state, false, context, this);
|
||||
return lookupValuaAndLocalVariableMetadata(descriptor, StackValue.LOCAL_0, state, false, context, this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static StackValue lookupInContext(
|
||||
static StackValue lookupValuaAndLocalVariableMetadata(
|
||||
@NotNull DeclarationDescriptor descriptor,
|
||||
@NotNull StackValue prefix,
|
||||
@NotNull GenerationState state,
|
||||
@@ -2353,7 +2353,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
assert metadataValue != null : "Metadata stack value should be non-null for local delegated property";
|
||||
//required for ImplementationBodyCodegen.lookupConstructorExpressionsInClosureIfPresent
|
||||
if (codegen == null) return null;
|
||||
return codegen.delegatedVariableValue(value, metadataValue, (VariableDescriptorWithAccessors) descriptor, state.getBindingContext(),
|
||||
return codegen.delegatedVariableValue(value, metadataValue, (VariableDescriptorWithAccessors) descriptor,
|
||||
state.getTypeMapper());
|
||||
}
|
||||
|
||||
@@ -3780,7 +3780,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
VariableDescriptorWithAccessors variableDescriptor = (VariableDescriptorWithAccessors) descriptor;
|
||||
StackValue metadataValue = getVariableMetadataValue(variableDescriptor);
|
||||
return delegatedVariableValue(varValue, metadataValue, variableDescriptor, bindingContext, typeMapper);
|
||||
return delegatedVariableValue(varValue, metadataValue, variableDescriptor, typeMapper);
|
||||
}
|
||||
|
||||
private void initializeLocalVariable(
|
||||
@@ -4488,7 +4488,6 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
@NotNull StackValue delegateValue,
|
||||
@NotNull StackValue metadataValue,
|
||||
@NotNull VariableDescriptorWithAccessors variableDescriptor,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull KotlinTypeMapper typeMapper
|
||||
) {
|
||||
return StackValue.delegate(typeMapper.mapType(variableDescriptor.getType()), delegateValue, metadataValue, variableDescriptor, this);
|
||||
|
||||
@@ -1256,7 +1256,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
|
||||
private void lookupInContext(@NotNull DeclarationDescriptor toLookup) {
|
||||
ExpressionCodegen.lookupInContext(toLookup, StackValue.LOCAL_0, state, true, context, null);
|
||||
ExpressionCodegen.lookupValuaAndLocalVariableMetadata(toLookup, StackValue.LOCAL_0, state, true, context, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1208,16 +1208,17 @@ public abstract class StackValue {
|
||||
coerceTo(type, v);
|
||||
}
|
||||
else {
|
||||
PropertyGetterDescriptor getter = descriptor.getGetter();
|
||||
assert getter != null : "Getter descriptor should be not null for " + descriptor;
|
||||
if (resolvedCall != null && getter.isInline()) {
|
||||
CallGenerator callGenerator = codegen.getOrCreateCallGenerator(resolvedCall, getter);
|
||||
PropertyGetterDescriptor getterDescriptor = descriptor.getGetter();
|
||||
assert getterDescriptor != null : "Getter descriptor should be not null for " + descriptor;
|
||||
if (resolvedCall != null && getterDescriptor.isInline()) {
|
||||
CallGenerator callGenerator = codegen.getOrCreateCallGenerator(resolvedCall, getterDescriptor);
|
||||
callGenerator.putHiddenParams();
|
||||
callGenerator.genCall(this.getter, resolvedCall, false, codegen);
|
||||
} else {
|
||||
this.getter.genInvokeInstruction(v);
|
||||
callGenerator.genCall(getter, resolvedCall, false, codegen);
|
||||
}
|
||||
coerce(this.getter.getReturnType(), type, v);
|
||||
else {
|
||||
getter.genInvokeInstruction(v);
|
||||
}
|
||||
coerce(getter.getReturnType(), type, v);
|
||||
|
||||
KotlinType returnType = descriptor.getReturnType();
|
||||
if (returnType != null && KotlinBuiltIns.isNothing(returnType)) {
|
||||
@@ -1261,17 +1262,18 @@ public abstract class StackValue {
|
||||
|
||||
@Override
|
||||
public void store(@NotNull StackValue rightSide, @NotNull InstructionAdapter v, boolean skipReceiver) {
|
||||
PropertySetterDescriptor setter = descriptor.getSetter();
|
||||
if (resolvedCall != null && setter != null && setter.isInline()) {
|
||||
assert this.setter != null : "Setter descriptor should be not null for " + descriptor;
|
||||
CallGenerator callGenerator = codegen.getOrCreateCallGenerator(resolvedCall, setter);
|
||||
PropertySetterDescriptor setterDescriptor = descriptor.getSetter();
|
||||
if (resolvedCall != null && setterDescriptor != null && setterDescriptor.isInline()) {
|
||||
assert setter != null : "Setter should be not null for " + descriptor;
|
||||
CallGenerator callGenerator = codegen.getOrCreateCallGenerator(resolvedCall, setterDescriptor);
|
||||
if (!skipReceiver) {
|
||||
putReceiver(v, false);
|
||||
}
|
||||
callGenerator.putHiddenParams();
|
||||
callGenerator.putValueIfNeeded(rightSide.type, rightSide);
|
||||
callGenerator.genCall(this.setter, resolvedCall, false, codegen);
|
||||
} else {
|
||||
callGenerator.genCall(setter, resolvedCall, false, codegen);
|
||||
}
|
||||
else {
|
||||
super.store(rightSide, v, skipReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -233,7 +233,8 @@ class ReifiedTypeParameterAnnotationChecker : SimpleDeclarationChecker {
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
) {
|
||||
if (descriptor is CallableDescriptor && !InlineUtil.isInlineFunctionOrProperty(descriptor)) {
|
||||
if (descriptor is CallableDescriptor &&
|
||||
!(InlineUtil.isInline(descriptor) || InlineUtil.isPropertyWithAllAccessorsAreInline(descriptor))) {
|
||||
checkTypeParameterDescriptorsAreNotReified(descriptor.typeParameters, diagnosticHolder)
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-3
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user