Do additional resolve for inline properties for backend (KT-27460)
There's an additional resolve for inline declarations to make backend happy with the passed binding context object. Unlike functions, properties were not processed. #KT-27460 Fixed
This commit is contained in:
@@ -24,6 +24,7 @@ import com.sun.jdi.Location
|
|||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileTypeFactory
|
import org.jetbrains.kotlin.idea.KotlinFileTypeFactory
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||||
@@ -169,7 +170,7 @@ object DebuggerUtils {
|
|||||||
fullResolveContext: BindingContext? = null
|
fullResolveContext: BindingContext? = null
|
||||||
): BindingContext {
|
): BindingContext {
|
||||||
val project = element.project
|
val project = element.project
|
||||||
val inlineFunctions = HashSet<KtNamedFunction>()
|
val declarationsWithBody = HashSet<KtDeclarationWithBody>()
|
||||||
|
|
||||||
val innerContexts = ArrayList<BindingContext>()
|
val innerContexts = ArrayList<BindingContext>()
|
||||||
innerContexts.addIfNotNull(fullResolveContext)
|
innerContexts.addIfNotNull(fullResolveContext)
|
||||||
@@ -216,19 +217,32 @@ object DebuggerUtils {
|
|||||||
val descriptor = resolvedCall.resultingDescriptor
|
val descriptor = resolvedCall.resultingDescriptor
|
||||||
if (descriptor is DeserializedSimpleFunctionDescriptor) return
|
if (descriptor is DeserializedSimpleFunctionDescriptor) return
|
||||||
|
|
||||||
if (InlineUtil.isInline(descriptor) && (analyzeInlineFunctions || hasReifiedTypeParameters(descriptor))) {
|
isAdditionalResolveNeededForDescriptor(descriptor)
|
||||||
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor)
|
|
||||||
if (declaration != null && declaration is KtNamedFunction && !analyzedElements.contains(declaration)) {
|
if (descriptor is PropertyDescriptor) {
|
||||||
inlineFunctions.add(declaration)
|
for (accessor in descriptor.accessors) {
|
||||||
|
isAdditionalResolveNeededForDescriptor(accessor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isAdditionalResolveNeededForDescriptor(descriptor: CallableDescriptor) {
|
||||||
|
if (!(InlineUtil.isInline(descriptor) && (analyzeInlineFunctions || hasReifiedTypeParameters(descriptor)))) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor)
|
||||||
|
if (declaration != null && declaration is KtDeclarationWithBody && !analyzedElements.contains(declaration)) {
|
||||||
|
declarationsWithBody.add(declaration)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
analyzedElements.add(element)
|
analyzedElements.add(element)
|
||||||
|
|
||||||
if (!inlineFunctions.isEmpty() && deep < 10) {
|
if (!declarationsWithBody.isEmpty() && deep < 10) {
|
||||||
for (inlineFunction in inlineFunctions) {
|
for (inlineFunction in declarationsWithBody) {
|
||||||
val body = inlineFunction.bodyExpression
|
val body = inlineFunction.bodyExpression
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
innerContexts.add(
|
innerContexts.add(
|
||||||
@@ -243,7 +257,7 @@ object DebuggerUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
analyzedElements.addAll(inlineFunctions)
|
analyzedElements.addAll(declarationsWithBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompositeBindingContext.create(innerContexts)
|
return CompositeBindingContext.create(innerContexts)
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package inlineProperty
|
||||||
|
|
||||||
|
val x = "".foo
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package inlineProperty
|
||||||
|
|
||||||
|
inline val String.foo: Boolean
|
||||||
|
get() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
+5
@@ -59,6 +59,11 @@ public class BytecodeToolWindowTestGenerated extends AbstractBytecodeToolWindowT
|
|||||||
runTest("idea/testData/internal/toolWindow/inlineFunctionReifiedParam/");
|
runTest("idea/testData/internal/toolWindow/inlineFunctionReifiedParam/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineProperty")
|
||||||
|
public void testInlineProperty() throws Exception {
|
||||||
|
runTest("idea/testData/internal/toolWindow/inlineProperty/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("iteratorFun")
|
@TestMetadata("iteratorFun")
|
||||||
public void testIteratorFun() throws Exception {
|
public void testIteratorFun() throws Exception {
|
||||||
runTest("idea/testData/internal/toolWindow/iteratorFun/");
|
runTest("idea/testData/internal/toolWindow/iteratorFun/");
|
||||||
|
|||||||
Reference in New Issue
Block a user