Fix search of correspondent call expression by element (KT-11234)
getStrictParentOfType() looks for nearest parent of given type
In complex expressions like:
SamConversion.doAction({
inlineCall {
{
// here <--
}()
}
})
doAction was found twice, while inlineCall was skipped.
See code:
// call(param, { <it> })
lambdaExpression?.typedParent<KtValueArgument>()?.typedParent<KtValueArgumentList>()?.typedParent<KtCallExpression>() ?:
// call { <it> }
lambdaExpression?.typedParent<KtLambdaArgument>()?.typedParent<KtCallExpression>()
#KT-11234 Fixed
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at stopInInlineUnderOtherCall.kt:11
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stopInInlineUnderOtherCall.StopInInlineUnderOtherCallKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
stopInInlineUnderOtherCall.kt:11
|
||||
stopInInlineUnderOtherCall.kt:12
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at stopInInlineUnderSamConversion.kt:12
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stopInInlineUnderSamConversion.StopInInlineUnderSamConversionKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
stopInInlineUnderSamConversion.kt:12
|
||||
stopInInlineUnderSamConversion.kt:13
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -0,0 +1,11 @@
|
||||
package forTests;
|
||||
|
||||
public class SamConversion {
|
||||
public interface Runnable {
|
||||
public abstract void run();
|
||||
}
|
||||
|
||||
public static void doAction(Runnable runnable) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package stopInInlineUnderOtherCall
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a = 1
|
||||
|
||||
nonInline(
|
||||
{
|
||||
inlineCall {
|
||||
{
|
||||
//Breakpoint!
|
||||
foo(a)
|
||||
}()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun foo(a: Any) {}
|
||||
|
||||
fun nonInline(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
|
||||
inline fun inlineCall(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package stopInInlineUnderSamConversion
|
||||
|
||||
import forTests.SamConversion
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a = 1
|
||||
|
||||
SamConversion.doAction({
|
||||
inlineCall {
|
||||
{
|
||||
//Breakpoint!
|
||||
foo(a)
|
||||
}()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun foo(a: Any) {}
|
||||
|
||||
inline fun inlineCall(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
Reference in New Issue
Block a user