Support other kinds of variables for invoke receiver
This commit is contained in:
@@ -298,14 +298,11 @@ abstract class Slicer(
|
||||
val dispatchReceiverPseudoValue = instruction.receiverValues.entries
|
||||
.singleOrNull { it.value == dispatchReceiver }?.key
|
||||
?: return true
|
||||
when (val createdAt = dispatchReceiverPseudoValue.createdAt) {
|
||||
is ReadValueInstruction -> {
|
||||
val accessedDescriptor = createdAt.target.accessedDescriptor
|
||||
if (accessedDescriptor is ValueParameterDescriptor) {
|
||||
val accessedDeclaration = accessedDescriptor.originalSource.getPsi()
|
||||
accessedDeclaration?.passToProcessor(mode.withBehaviour(LambdaReceiverInflowBehaviour))
|
||||
}
|
||||
}
|
||||
val createdAt = dispatchReceiverPseudoValue.createdAt
|
||||
val accessedDescriptor = (createdAt as ReadValueInstruction?)?.target?.accessedDescriptor
|
||||
if (accessedDescriptor is VariableDescriptor) {
|
||||
val accessedDeclaration = accessedDescriptor.originalSource.getPsi()
|
||||
accessedDeclaration?.passToProcessor(mode.withBehaviour(LambdaReceiverInflowBehaviour))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// FLOW: OUT
|
||||
|
||||
fun String.foo(<caret>p: String) {
|
||||
val v = bar(p) { this }
|
||||
}
|
||||
|
||||
fun <T, R> bar(receiver: T, block: T.() -> R): R {
|
||||
val b = block
|
||||
return receiver.b()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
3 fun String.foo(<bold>p: String</bold>) {
|
||||
4 val v = bar(<bold>p</bold>) { this }
|
||||
7 fun <T, R> bar(<bold>receiver: T</bold>, block: T.() -> R): R {
|
||||
9 return <bold>receiver</bold>.b()
|
||||
8 [LAMBDA RECEIVER IN] val <bold>b = block</bold>
|
||||
8 [LAMBDA RECEIVER IN] val b = <bold>block</bold>
|
||||
7 [LAMBDA RECEIVER IN] fun <T, R> bar(receiver: T, <bold>block: T.() -> R</bold>): R {
|
||||
4 [LAMBDA RECEIVER IN] val v = bar(p) <bold>{ this }</bold>
|
||||
4 val v = bar(p) { <bold>this</bold> }
|
||||
4 val v = bar(p) <bold>{ this }</bold>
|
||||
4 [LAMBDA CALLS] val v = bar(p) <bold>{ this }</bold>
|
||||
7 [LAMBDA CALLS] fun <T, R> bar(receiver: T, <bold>block: T.() -> R</bold>): R {
|
||||
8 [LAMBDA CALLS] val b = <bold>block</bold>
|
||||
8 [LAMBDA CALLS] val <bold>b = block</bold>
|
||||
9 return receiver.<bold>b()</bold>
|
||||
7 fun <T, R> <bold>bar(receiver: T, block: T.() -> R): R {</bold>
|
||||
4 val v = <bold>bar(p) { this }</bold>
|
||||
4 val <bold>v = bar(p) { this }</bold>
|
||||
@@ -608,6 +608,11 @@ public class SlicerTreeTestGenerated extends AbstractSlicerTreeTest {
|
||||
runTest("idea/testData/slicer/outflow/invokeExtensionLambda2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokeExtensionLambda3.kt")
|
||||
public void testInvokeExtensionLambda3() throws Exception {
|
||||
runTest("idea/testData/slicer/outflow/invokeExtensionLambda3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokeLambdaSecondParam.kt")
|
||||
public void testInvokeLambdaSecondParam() throws Exception {
|
||||
runTest("idea/testData/slicer/outflow/invokeLambdaSecondParam.kt");
|
||||
|
||||
Reference in New Issue
Block a user