KotlinBytecodeToolWindow: analyze inline functions from multi declarations and from iterator call in for
This commit is contained in:
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.codegen.KotlinCodegenFacade;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.codegen.state.Progress;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink;
|
||||
@@ -317,6 +318,30 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
|
||||
if (call == null) return;
|
||||
|
||||
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, call);
|
||||
checkResolveCall(resolvedCall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMultiDeclaration(@NotNull JetMultiDeclaration multiDeclaration) {
|
||||
super.visitMultiDeclaration(multiDeclaration);
|
||||
|
||||
for (JetMultiDeclarationEntry entry : multiDeclaration.getEntries()) {
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall =
|
||||
bindingContext.get(BindingContext.COMPONENT_RESOLVED_CALL, entry);
|
||||
checkResolveCall(resolvedCall);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitForExpression(@NotNull JetForExpression expression) {
|
||||
super.visitForExpression(expression);
|
||||
|
||||
checkResolveCall(bindingContext.get(BindingContext.LOOP_RANGE_ITERATOR_RESOLVED_CALL, expression.getLoopRange()));
|
||||
checkResolveCall(bindingContext.get(BindingContext.LOOP_RANGE_HAS_NEXT_RESOLVED_CALL, expression.getLoopRange()));
|
||||
checkResolveCall(bindingContext.get(BindingContext.LOOP_RANGE_NEXT_RESOLVED_CALL, expression.getLoopRange()));
|
||||
}
|
||||
|
||||
private void checkResolveCall(ResolvedCall<?> resolvedCall) {
|
||||
if (resolvedCall == null) return;
|
||||
|
||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
import inlineFun1.*
|
||||
|
||||
fun test() {
|
||||
val (a, b) = A()
|
||||
println(a)
|
||||
println(b)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package inlineFun1
|
||||
|
||||
class A {
|
||||
inline fun component1() = foo { 1 }
|
||||
inline fun component2() = foo { 2 }
|
||||
|
||||
inline fun foo(f: () -> Int) = f()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package inlineFun1
|
||||
|
||||
class A() {
|
||||
inline fun iterator() : Iterator<Int> = throw UnsupportedOperationException()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
import inlineFun1.*
|
||||
|
||||
fun test() {
|
||||
for (i in A()) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,12 @@ public class BytecodeToolWindowTestGenerated extends AbstractBytecodeToolWindowT
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/internal/toolWindow"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("componentInlineFun")
|
||||
public void testComponentInlineFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/internal/toolWindow/componentInlineFun/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionBodyResolve")
|
||||
public void testInlineFunctionBodyResolve() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/internal/toolWindow/inlineFunctionBodyResolve/");
|
||||
@@ -65,6 +71,12 @@ public class BytecodeToolWindowTestGenerated extends AbstractBytecodeToolWindowT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("iteratorFun")
|
||||
public void testIteratorFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/internal/toolWindow/iteratorFun/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multipleInlineFunctionCalls")
|
||||
public void testMultipleInlineFunctionCalls() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/internal/toolWindow/multipleInlineFunctionCalls/");
|
||||
|
||||
Reference in New Issue
Block a user