Support property accessor in inline checks

This commit is contained in:
Mikhael Bogdanov
2016-06-21 11:12:13 +03:00
parent 2cc177255f
commit d524a34fc7
6 changed files with 47 additions and 9 deletions
@@ -50,12 +50,12 @@ import static org.jetbrains.kotlin.resolve.inline.InlineUtil.allowsNonLocalRetur
import static org.jetbrains.kotlin.resolve.inline.InlineUtil.checkNonLocalReturnUsage;
class InlineChecker implements SimpleCallChecker {
private final SimpleFunctionDescriptor descriptor;
private final FunctionDescriptor descriptor;
private final Set<CallableDescriptor> inlinableParameters = new LinkedHashSet<CallableDescriptor>();
private final boolean isEffectivelyPublicApiFunction;
private final boolean isEffectivelyPrivateApiFunction;
public InlineChecker(@NotNull SimpleFunctionDescriptor descriptor) {
public InlineChecker(@NotNull FunctionDescriptor descriptor) {
assert InlineUtil.isInline(descriptor) : "This extension should be created only for inline functions: " + descriptor;
this.descriptor = descriptor;
this.isEffectivelyPublicApiFunction = DescriptorUtilsKt.isEffectivelyPublicApi(descriptor);
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.resolve.calls.checkers
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.inline.InlineUtil
@@ -33,7 +33,7 @@ class InlineCheckerWrapper : SimpleCallChecker {
while (parentDescriptor != null) {
if (InlineUtil.isInline(parentDescriptor)) {
val checker = getChecker(parentDescriptor as SimpleFunctionDescriptor)
val checker = getChecker(parentDescriptor as FunctionDescriptor)
checker.check(resolvedCall, context)
}
@@ -41,7 +41,7 @@ class InlineCheckerWrapper : SimpleCallChecker {
}
}
private fun getChecker(descriptor: SimpleFunctionDescriptor): SimpleCallChecker {
private fun getChecker(descriptor: FunctionDescriptor): SimpleCallChecker {
val map = checkersCache?.get() ?: hashMapOf()
checkersCache = checkersCache ?: WeakReference(map)
return map.getOrPut(descriptor) { InlineChecker(descriptor) }
@@ -40,7 +40,7 @@ public class InlineUtil {
}
public static boolean isInline(@Nullable DeclarationDescriptor descriptor) {
return descriptor instanceof SimpleFunctionDescriptor && getInlineStrategy(descriptor).isInline();
return descriptor instanceof FunctionDescriptor && getInlineStrategy((FunctionDescriptor) descriptor).isInline();
}
public static boolean isInlineOrContainingInline(@Nullable DeclarationDescriptor descriptor) {
@@ -50,9 +50,8 @@ public class InlineUtil {
}
@NotNull
public static InlineStrategy getInlineStrategy(@NotNull DeclarationDescriptor descriptor) {
if (descriptor instanceof FunctionDescriptor &&
((FunctionDescriptor) descriptor).isInline()) {
private static InlineStrategy getInlineStrategy(@NotNull FunctionDescriptor descriptor) {
if (descriptor.isInline()) {
return InlineStrategy.AS_FUNCTION;
}