diff --git a/idea/src/org/jetbrains/kotlin/idea/slicer/InflowSlicer.kt b/idea/src/org/jetbrains/kotlin/idea/slicer/InflowSlicer.kt index 1c1a4194290..4aa9d0145d4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/slicer/InflowSlicer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/slicer/InflowSlicer.kt @@ -77,7 +77,7 @@ class InflowSlicer( val getter = (property.unsafeResolveToDescriptor() as VariableDescriptorWithAccessors).getter ?: return val bindingContext = property.analyzeWithContent() val delegateGetterResolvedCall = bindingContext[BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, getter] - delegateGetterResolvedCall?.resultingDescriptor?.originalSource?.getPsi()?.passToProcessor() + delegateGetterResolvedCall?.resultingDescriptor?.toPsi()?.passToProcessor() return } @@ -178,7 +178,7 @@ class InflowSlicer( } val accessedDescriptor = createdAt.target.accessedDescriptor ?: return - val accessedDeclaration = accessedDescriptor.originalSource.getPsi() + val accessedDeclaration = accessedDescriptor.toPsi() when (accessedDescriptor) { is SyntheticFieldDescriptor -> { val property = accessedDeclaration as? KtProperty ?: return @@ -192,7 +192,7 @@ class InflowSlicer( is ReceiverParameterDescriptor -> { //TODO: handle non-extension receivers? val callable = accessedDescriptor.containingDeclaration as? CallableDescriptor ?: return - when (val declaration = callable.originalSource.getPsi()) { + when (val declaration = callable.toPsi()) { is KtFunctionLiteral -> { declaration.passToProcessorAsValue(mode.withBehaviour(LambdaCallsBehaviour(ReceiverSliceProducer))) } @@ -231,8 +231,7 @@ class InflowSlicer( val callableRefExpr = expressionValue.element as? KtCallableReferenceExpression ?: return val bindingContext = expression.analyze(BodyResolveMode.PARTIAL) val referencedDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, callableRefExpr.callableReference] ?: return - val referencedDeclaration = (referencedDescriptor as? DeclarationDescriptorWithSource)?.originalSource?.getPsi() - ?: return + val referencedDeclaration = (referencedDescriptor as? DeclarationDescriptorWithSource)?.toPsi() ?: return when (currentBehaviour) { is LambdaResultInflowBehaviour -> { referencedDeclaration.passToProcessor(mode.dropBehaviour()) @@ -262,7 +261,7 @@ class InflowSlicer( (resolvedCall.dispatchReceiver as? ExpressionReceiver)?.expression ?.passToProcessorAsValue(mode.withBehaviour(LambdaResultInflowBehaviour)) } else { - resultingDescriptor.originalSource.getPsi()?.passToProcessorInCallMode(createdAt.element, withOverriders = true) + resultingDescriptor.toPsi()?.passToProcessorInCallMode(createdAt.element, withOverriders = true) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/slicer/OutflowSlicer.kt b/idea/src/org/jetbrains/kotlin/idea/slicer/OutflowSlicer.kt index 02645e37a08..15a9e1b769c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/slicer/OutflowSlicer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/slicer/OutflowSlicer.kt @@ -9,6 +9,7 @@ import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector.Access import com.intellij.psi.PsiComment import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod +import com.intellij.psi.search.LocalSearchScope import com.intellij.psi.util.parentOfType import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.builtins.isExtensionFunctionType @@ -32,7 +33,6 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.parameterIndex import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.resolve.source.getPsi class OutflowSlicer( element: KtElement, @@ -68,7 +68,7 @@ class OutflowSlicer( declaration.resolveToDescriptorIfAny(BodyResolveMode.FULL) ?.actualsForExpected() ?.forEach { - val actualDeclaration = (it as? DeclarationDescriptorWithSource)?.originalSource?.getPsi() + val actualDeclaration = (it as? DeclarationDescriptorWithSource)?.toPsi() (actualDeclaration as? KtCallableDeclaration)?.receiverTypeReference?.passToProcessor() } } @@ -112,6 +112,8 @@ class OutflowSlicer( } } + var searchScope = analysisScope + if (variable is KtParameter) { if (!canProcessParameter(variable)) return //TODO @@ -122,7 +124,7 @@ class OutflowSlicer( variable.resolveToDescriptorIfAny(BodyResolveMode.FULL) ?.actualsForExpected() ?.forEach { - (it as? DeclarationDescriptorWithSource)?.originalSource?.getPsi()?.passToProcessor() + (it as? DeclarationDescriptorWithSource)?.toPsi()?.passToProcessor() } } @@ -148,10 +150,14 @@ class OutflowSlicer( } true } + + if (callable is KtNamedFunction) { // references to parameters of inline function can be outside analysis scope + searchScope = LocalSearchScope(callable) + } } } - processVariableAccesses(variable, analysisScope, accessKind, ::processVariableAccess) + processVariableAccesses(variable, searchScope, accessKind, ::processVariableAccess) } private fun processFunction(function: KtFunction) { @@ -167,7 +173,7 @@ class OutflowSlicer( when (instruction) { is WriteValueInstruction -> { if (!pseudoValue.processIfReceiverValue(instruction, mode)) { - instruction.target.accessedDescriptor?.originalSource?.getPsi()?.passToProcessor() + instruction.target.accessedDescriptor?.toPsi()?.passToProcessor() } } @@ -178,7 +184,7 @@ class OutflowSlicer( is CallInstruction -> { if (!pseudoValue.processIfReceiverValue(instruction, mode)) { val parameterDescriptor = instruction.arguments[pseudoValue] ?: return@processPseudocodeUsages - val parameter = parameterDescriptor.originalSource.getPsi() + val parameter = parameterDescriptor.toPsi() if (parameter != null) { parameter.passToProcessorInCallMode(instruction.element) } else { @@ -225,7 +231,7 @@ class OutflowSlicer( val targetDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, receiverExpression] if (targetDescriptor is CallableDescriptor) { receiverType = targetDescriptor.returnType - receiver = targetDescriptor.originalSource.getPsi() ?: return + receiver = targetDescriptor.toPsi() ?: return } } if (receiverType == null || !receiverType.isFunctionType) return diff --git a/idea/src/org/jetbrains/kotlin/idea/slicer/ReceiverSliceProducer.kt b/idea/src/org/jetbrains/kotlin/idea/slicer/ReceiverSliceProducer.kt index 4c8c66e4b69..9c6a4d85627 100644 --- a/idea/src/org/jetbrains/kotlin/idea/slicer/ReceiverSliceProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/slicer/ReceiverSliceProducer.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFunctionLiteral import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver -import org.jetbrains.kotlin.resolve.source.getPsi object ReceiverSliceProducer : SliceProducer { override fun produce(usage: UsageInfo, mode: KotlinSliceAnalysisMode, parent: SliceUsage): Collection? { @@ -29,16 +28,15 @@ object ReceiverSliceProducer : SliceProducer { } is ImplicitReceiver -> { - val callableDescriptor = receiver.declarationDescriptor as? CallableDescriptor - ?: return emptyList() - when (val callableDeclaration = callableDescriptor.originalSource.getPsi()) { + val callableDescriptor = receiver.declarationDescriptor as? CallableDescriptor ?: return emptyList() + when (val declaration = Slicer.descriptorToPsi(callableDescriptor, usage.project, parent.scope.toSearchScope())) { is KtFunctionLiteral -> { val newMode = mode.withBehaviour(LambdaCallsBehaviour(ReceiverSliceProducer)) - return listOf(KotlinSliceUsage(callableDeclaration, parent, newMode, forcedExpressionMode = true)) + return listOf(KotlinSliceUsage(declaration, parent, newMode, forcedExpressionMode = true)) } is KtCallableDeclaration -> { - val receiverTypeReference = callableDeclaration.receiverTypeReference ?: return emptyList() + val receiverTypeReference = declaration.receiverTypeReference ?: return emptyList() return listOf(KotlinSliceUsage(receiverTypeReference, parent, mode, false)) } diff --git a/idea/src/org/jetbrains/kotlin/idea/slicer/Slicer.kt b/idea/src/org/jetbrains/kotlin/idea/slicer/Slicer.kt index fb0c61e1211..d8e6b8b5f7a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/slicer/Slicer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/slicer/Slicer.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.slicer +import com.intellij.openapi.project.Project import com.intellij.psi.PsiComment import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod @@ -25,6 +26,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny +import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.core.getDeepestSuperDeclarations import org.jetbrains.kotlin.idea.findUsages.KotlinFunctionFindUsagesOptions import org.jetbrains.kotlin.idea.findUsages.KotlinPropertyFindUsagesOptions @@ -38,9 +40,12 @@ import org.jetbrains.kotlin.idea.util.expectedDescriptor import org.jetbrains.kotlin.idea.util.hasInlineModifier import org.jetbrains.kotlin.idea.util.isExpectDeclaration import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.contains import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType +import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue @@ -119,7 +124,7 @@ abstract class Slicer( resolveToDescriptorIfAny(BodyResolveMode.FULL) ?.actualsForExpected() ?.forEach { - (it as? DeclarationDescriptorWithSource)?.originalSource?.getPsi()?.passToProcessor(mode) + (it as? DeclarationDescriptorWithSource)?.toPsi()?.passToProcessor(mode) } } } @@ -168,7 +173,7 @@ abstract class Slicer( } for (superDescriptor in superDescriptors) { - val declaration = superDescriptor.originalSource.getPsi() ?: continue + val declaration = superDescriptor.toPsi() ?: continue when (declaration) { is KtDeclaration -> { val usageProcessor: (UsageInfo) -> Unit = processor@ { usageInfo -> @@ -226,12 +231,28 @@ abstract class Slicer( DescriptorUtils.getAllOverriddenDeclarations(descriptor) } additionalDescriptors.mapNotNullTo(allDeclarations) { - it.originalSource.getPsi() as? KtCallableDeclaration + it.toPsi() as? KtCallableDeclaration } } - allDeclarations.forEach { it.processAllExactUsages(options, usageProcessor) } + allDeclarations.forEach { + it.processAllExactUsages(options) { usageInfo -> + if (!shouldIgnoreVariableUsage(usageInfo)) { + usageProcessor.invoke(usageInfo) + } + } + } + } + + // ignore parameter usages in function contract + private fun shouldIgnoreVariableUsage(usage: UsageInfo): Boolean { + val element = usage.element ?: return true + return element.parents.any { + it is KtCallExpression && + (it.calleeExpression as? KtSimpleNameExpression)?.getReferencedName() == "contract" && + it.resolveToCall()?.resultingDescriptor?.fqNameOrNull()?.asString() == "kotlin.contracts.contract" + } } protected fun canProcessParameter(parameter: KtParameter) = !parameter.isVarArg @@ -304,21 +325,24 @@ abstract class Slicer( 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)) + accessedDescriptor.toPsi()?.passToProcessor(mode.withBehaviour(LambdaReceiverInflowBehaviour)) } } } } else { if (receiverValue == resolvedCall.extensionReceiver) { - val declaration = descriptor.originalSource.getPsi() - (declaration as? KtCallableDeclaration)?.receiverTypeReference?.passToProcessorInCallMode(instruction.element, mode) + (descriptor.toPsi() as? KtCallableDeclaration)?.receiverTypeReference + ?.passToProcessorInCallMode(instruction.element, mode) } } return true } + protected fun DeclarationDescriptor.toPsi(): PsiElement? { + return descriptorToPsi(this, project, analysisScope) + } + companion object { protected fun KtDeclaration?.callMode(callElement: KtElement, defaultMode: KotlinSliceAnalysisMode): KotlinSliceAnalysisMode { return if (this is KtNamedFunction && hasInlineModifier()) @@ -326,21 +350,25 @@ abstract class Slicer( else defaultMode } + + fun descriptorToPsi(descriptor: DeclarationDescriptor, project: Project, analysisScope: SearchScope): PsiElement? { + val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor) ?: return null + if (analysisScope.contains(declaration)) return declaration.navigationElement + + // we ignore access scope for inline declarations + val isInline = when (declaration) { + is KtNamedFunction -> declaration.hasInlineModifier() + is KtParameter -> declaration.ownerFunction?.hasInlineModifier() == true + else -> false + } + return if (isInline) declaration.navigationElement else null + } } } -val DeclarationDescriptorWithSource.originalSource: SourceElement - get() { - var descriptor = this - while (descriptor.original != descriptor) { - descriptor = descriptor.original - } - return descriptor.source - } - fun CallableDescriptor.isImplicitInvokeFunction(): Boolean { if (this !is FunctionDescriptor) return false if (!isOperator) return false if (name != OperatorNameConventions.INVOKE) return false - return originalSource.getPsi() == null + return source.getPsi() == null } \ No newline at end of file diff --git a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.kt b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.kt index 6bf5511cdcd..6e32d22dd5f 100644 --- a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.kt +++ b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.kt @@ -1,4 +1,5 @@ // FLOW: IN +// RUNTIME_WITH_SOURCES fun foo(f: String.(Int) -> Unit) { f("", 1) diff --git a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.leafGroups.txt b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.leafGroups.txt index 993c5864922..f96e6d5caa9 100644 --- a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.leafGroups.txt +++ b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.leafGroups.txt @@ -1,18 +1,18 @@ -4 f("", 1) -15 val v = it -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -4 f("", 1) +5 f("", 1) +16 val v = it +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +5 f("", 1) -6 "".f(2) -15 val v = it -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -6 "".f(2) +7 "".f(2) +16 val v = it +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +7 "".f(2) -9 f(3) -15 val v = it -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -9 f(3) +10 f(3) +16 val v = it +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +10 f(3) diff --git a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.nullnessGroups.txt b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.nullnessGroups.txt index 616157e55ab..b9d6f1e6c3d 100644 --- a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.nullnessGroups.txt +++ b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.nullnessGroups.txt @@ -1,4 +1,4 @@ [NotNull Values] -15 val v = it -15 val v = it +16 val v = it +16 val v = it diff --git a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.results.txt b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.results.txt index 719293b6c52..bd997196ffe 100644 --- a/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.results.txt +++ b/idea/testData/slicer/inflow/extensionLambdaImplicitParameter.results.txt @@ -1,6 +1,6 @@ -15 val v = it -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -4 f("", 1) -6 "".f(2) -9 f(3) +16 val v = it +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +5 f("", 1) +7 "".f(2) +10 f(3) diff --git a/idea/testData/slicer/inflow/extensionLambdaParameter.kt b/idea/testData/slicer/inflow/extensionLambdaParameter.kt index eeb43147214..75560d7477f 100644 --- a/idea/testData/slicer/inflow/extensionLambdaParameter.kt +++ b/idea/testData/slicer/inflow/extensionLambdaParameter.kt @@ -1,4 +1,5 @@ // FLOW: IN +// RUNTIME_WITH_SOURCES fun foo(f: String.(Int) -> Unit) { f("", 1) @@ -15,7 +16,3 @@ fun test() { val v = i } } - -inline fun with(receiver: T, block: T.() -> R): R { - return receiver.block() -} diff --git a/idea/testData/slicer/inflow/extensionLambdaParameter.leafGroups.txt b/idea/testData/slicer/inflow/extensionLambdaParameter.leafGroups.txt index d0b5c6c215a..cf7889b8c3e 100644 --- a/idea/testData/slicer/inflow/extensionLambdaParameter.leafGroups.txt +++ b/idea/testData/slicer/inflow/extensionLambdaParameter.leafGroups.txt @@ -1,21 +1,21 @@ -4 f("", 1) -15 val v = i -14 foo { i -> -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -4 f("", 1) +5 f("", 1) +16 val v = i +15 foo { i -> +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +5 f("", 1) -6 "".f(2) -15 val v = i -14 foo { i -> -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -6 "".f(2) +7 "".f(2) +16 val v = i +15 foo { i -> +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +7 "".f(2) -9 f(3) -15 val v = i -14 foo { i -> -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -9 f(3) +10 f(3) +16 val v = i +15 foo { i -> +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +10 f(3) diff --git a/idea/testData/slicer/inflow/extensionLambdaParameter.nullnessGroups.txt b/idea/testData/slicer/inflow/extensionLambdaParameter.nullnessGroups.txt index 956e88c9371..2295e82c5c5 100644 --- a/idea/testData/slicer/inflow/extensionLambdaParameter.nullnessGroups.txt +++ b/idea/testData/slicer/inflow/extensionLambdaParameter.nullnessGroups.txt @@ -1,4 +1,4 @@ [NotNull Values] -15 val v = i -15 val v = i +16 val v = i +16 val v = i diff --git a/idea/testData/slicer/inflow/extensionLambdaParameter.results.txt b/idea/testData/slicer/inflow/extensionLambdaParameter.results.txt index 28f7e32deb7..a06b283271d 100644 --- a/idea/testData/slicer/inflow/extensionLambdaParameter.results.txt +++ b/idea/testData/slicer/inflow/extensionLambdaParameter.results.txt @@ -1,7 +1,7 @@ -15 val v = i -14 foo { i -> -14 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> -3 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { -4 f("", 1) -6 "".f(2) -9 f(3) +16 val v = i +15 foo { i -> +15 [LAMBDA CALLS ARGUMENT #0 EXTENSION] foo { i -> +4 [LAMBDA CALLS ARGUMENT #0 EXTENSION] fun foo(f: String.(Int) -> Unit) { +5 f("", 1) +7 "".f(2) +10 f(3) diff --git a/idea/testData/slicer/inflow/extensionLambdaReceiver.kt b/idea/testData/slicer/inflow/extensionLambdaReceiver.kt index f7bfbf625bd..0124a0a0044 100644 --- a/idea/testData/slicer/inflow/extensionLambdaReceiver.kt +++ b/idea/testData/slicer/inflow/extensionLambdaReceiver.kt @@ -1,11 +1,8 @@ // FLOW: IN +// RUNTIME_WITH_SOURCES fun foo() { with("A") { val v = this } } - -inline fun with(receiver: T, block: T.() -> R): R { - return receiver.block() -} diff --git a/idea/testData/slicer/inflow/extensionLambdaReceiver.leafGroups.txt b/idea/testData/slicer/inflow/extensionLambdaReceiver.leafGroups.txt index 047beb80bb0..34b9a6d1a62 100644 --- a/idea/testData/slicer/inflow/extensionLambdaReceiver.leafGroups.txt +++ b/idea/testData/slicer/inflow/extensionLambdaReceiver.leafGroups.txt @@ -1,9 +1,9 @@ -4 with("A") { -5 val v = this -5 val v = this -4 [LAMBDA CALLS RECEIVER] with("A") { -9 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -10 (INLINE CALL with) return receiver.block() -9 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -4 with("A") { +5 with("A") { +6 val v = this +6 val v = this +5 [LAMBDA CALLS RECEIVER] with("A") { +66 (INLINE CALL with) [LAMBDA CALLS RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { +5 with("A") { diff --git a/idea/testData/slicer/inflow/extensionLambdaReceiver.nullnessGroups.txt b/idea/testData/slicer/inflow/extensionLambdaReceiver.nullnessGroups.txt index dd20223c288..a27379352c3 100644 --- a/idea/testData/slicer/inflow/extensionLambdaReceiver.nullnessGroups.txt +++ b/idea/testData/slicer/inflow/extensionLambdaReceiver.nullnessGroups.txt @@ -1,3 +1,4 @@ [NotNull Values] -5 val v = this -5 val v = this +6 val v = this +6 val v = this + diff --git a/idea/testData/slicer/inflow/extensionLambdaReceiver.results.txt b/idea/testData/slicer/inflow/extensionLambdaReceiver.results.txt index 85e289d745c..e1603d8eec8 100644 --- a/idea/testData/slicer/inflow/extensionLambdaReceiver.results.txt +++ b/idea/testData/slicer/inflow/extensionLambdaReceiver.results.txt @@ -1,7 +1,7 @@ -5 val v = this -5 val v = this -4 [LAMBDA CALLS RECEIVER] with("A") { -9 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -10 (INLINE CALL with) return receiver.block() -9 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -4 with("A") { +6 val v = this +6 val v = this +5 [LAMBDA CALLS RECEIVER] with("A") { +66 (INLINE CALL with) [LAMBDA CALLS RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { +5 with("A") { diff --git a/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.kt b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.kt new file mode 100644 index 00000000000..7c08ba911b2 --- /dev/null +++ b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.kt @@ -0,0 +1,12 @@ +// FLOW: IN +// RUNTIME_WITH_SOURCES + +class C + +fun foo() { + val c = C().apply { + extensionFun() + } +} + +fun C.extensionFun() {} diff --git a/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.leafGroups.txt b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.leafGroups.txt new file mode 100644 index 00000000000..82245569686 --- /dev/null +++ b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.leafGroups.txt @@ -0,0 +1,8 @@ +4 class C +12 fun C.extensionFun() {} +7 [LAMBDA CALLS RECEIVER] val c = C().apply { +79 (INLINE CALL apply) [LAMBDA CALLS RECEIVER] public inline fun T.apply(block: T.() -> Unit): T { +79 (INLINE CALL apply) public inline fun T.apply(block: T.() -> Unit): T { +7 val c = C().apply { +4 class C + diff --git a/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.nullnessGroups.txt b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.nullnessGroups.txt new file mode 100644 index 00000000000..fd275aab3fd --- /dev/null +++ b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.nullnessGroups.txt @@ -0,0 +1,8 @@ +[NotNull Values] +7 val c = C().apply { +12 fun C.extensionFun() {} +7 [LAMBDA CALLS RECEIVER] val c = C().apply { +79 (INLINE CALL apply) [LAMBDA CALLS RECEIVER] public inline fun T.apply(block: T.() -> Unit): T { +79 (INLINE CALL apply) public inline fun T.apply(block: T.() -> Unit): T { +7 val c = C().apply { + diff --git a/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.results.txt b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.results.txt new file mode 100644 index 00000000000..c60eb0744a0 --- /dev/null +++ b/idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.results.txt @@ -0,0 +1,6 @@ +12 fun C.extensionFun() {} +7 [LAMBDA CALLS RECEIVER] val c = C().apply { +79 (INLINE CALL apply) [LAMBDA CALLS RECEIVER] public inline fun T.apply(block: T.() -> Unit): T { +79 (INLINE CALL apply) public inline fun T.apply(block: T.() -> Unit): T { +7 val c = C().apply { +4 class C diff --git a/idea/testData/slicer/inflow/inlineFunctionManyCalls.kt b/idea/testData/slicer/inflow/inlineFunctionManyCalls.kt index 2bbf84d8fe1..bc8ada2acb9 100644 --- a/idea/testData/slicer/inflow/inlineFunctionManyCalls.kt +++ b/idea/testData/slicer/inflow/inlineFunctionManyCalls.kt @@ -1,4 +1,5 @@ // FLOW: IN +// RUNTIME_WITH_SOURCES fun Any.extensionFun() { } @@ -46,10 +47,6 @@ inline fun with(receiver: T, block: T.() -> R): R { return result } -inline fun T.let(block: (T) -> R): R { - return block(this) -} - fun withNoInline(receiver: T, block: T.() -> R): R { val result = receiver.block() return result diff --git a/idea/testData/slicer/inflow/inlineFunctionManyCalls.leafGroups.txt b/idea/testData/slicer/inflow/inlineFunctionManyCalls.leafGroups.txt index 6d4617c1d31..6564e404225 100644 --- a/idea/testData/slicer/inflow/inlineFunctionManyCalls.leafGroups.txt +++ b/idea/testData/slicer/inflow/inlineFunctionManyCalls.leafGroups.txt @@ -1,60 +1,60 @@ -35 "D".letNoInline { -3 fun Any.extensionFun() { -36 it.extensionFun() -35 [LAMBDA CALLS ARGUMENT #0] "D".letNoInline { -58 [LAMBDA CALLS ARGUMENT #0] fun T.letNoInline(block: (T) -> R): R { -59 return block(this) -58 fun T.letNoInline(block: (T) -> R): R { -35 "D".letNoInline { +36 "D".letNoInline { +4 fun Any.extensionFun() { +37 it.extensionFun() +36 [LAMBDA CALLS ARGUMENT #0] "D".letNoInline { +55 [LAMBDA CALLS ARGUMENT #0] fun T.letNoInline(block: (T) -> R): R { +56 return block(this) +55 fun T.letNoInline(block: (T) -> R): R { +36 "D".letNoInline { -39 "C".letNoInline { -3 fun Any.extensionFun() { -36 it.extensionFun() -35 [LAMBDA CALLS ARGUMENT #0] "D".letNoInline { -58 [LAMBDA CALLS ARGUMENT #0] fun T.letNoInline(block: (T) -> R): R { -59 return block(this) -58 fun T.letNoInline(block: (T) -> R): R { -39 "C".letNoInline { +40 "C".letNoInline { +4 fun Any.extensionFun() { +37 it.extensionFun() +36 [LAMBDA CALLS ARGUMENT #0] "D".letNoInline { +55 [LAMBDA CALLS ARGUMENT #0] fun T.letNoInline(block: (T) -> R): R { +56 return block(this) +55 fun T.letNoInline(block: (T) -> R): R { +40 "C".letNoInline { -27 "A".let { -3 fun Any.extensionFun() { -28 it.extensionFun() -27 [LAMBDA CALLS ARGUMENT #0] "A".let { -49 (INLINE CALL let) [LAMBDA CALLS ARGUMENT #0] inline fun T.let(block: (T) -> R): R { -50 (INLINE CALL let) return block(this) -49 (INLINE CALL let) inline fun T.let(block: (T) -> R): R { -27 "A".let { +28 "A".let { +4 fun Any.extensionFun() { +29 it.extensionFun() +28 [LAMBDA CALLS ARGUMENT #0] "A".let { +108 (INLINE CALL let) [LAMBDA CALLS ARGUMENT #0] public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +108 (INLINE CALL let) public inline fun T.let(block: (T) -> R): R { +28 "A".let { -19 withNoInline(1) { -3 fun Any.extensionFun() { -19 [LAMBDA CALLS RECEIVER] withNoInline(1) { -53 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { -54 val result = receiver.block() -53 fun withNoInline(receiver: T, block: T.() -> R): R { -19 withNoInline(1) { +20 withNoInline(1) { +4 fun Any.extensionFun() { +20 [LAMBDA CALLS RECEIVER] withNoInline(1) { +50 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { +51 val result = receiver.block() +50 fun withNoInline(receiver: T, block: T.() -> R): R { +20 withNoInline(1) { -7 with(123) { -3 fun Any.extensionFun() { -7 [LAMBDA CALLS RECEIVER] with(123) { -44 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -45 (INLINE CALL with) val result = receiver.block() -44 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -7 with(123) { +8 with(123) { +4 fun Any.extensionFun() { +8 [LAMBDA CALLS RECEIVER] with(123) { +45 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { +46 (INLINE CALL with) val result = receiver.block() +45 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +8 with(123) { -23 withNoInline(2) { -3 fun Any.extensionFun() { -19 [LAMBDA CALLS RECEIVER] withNoInline(1) { -53 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { -54 val result = receiver.block() -53 fun withNoInline(receiver: T, block: T.() -> R): R { -23 withNoInline(2) { +24 withNoInline(2) { +4 fun Any.extensionFun() { +20 [LAMBDA CALLS RECEIVER] withNoInline(1) { +50 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { +51 val result = receiver.block() +50 fun withNoInline(receiver: T, block: T.() -> R): R { +24 withNoInline(2) { -11 with(456) { -3 fun Any.extensionFun() { -12 this.extensionFun() -11 [LAMBDA CALLS RECEIVER] with(456) { -44 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -45 (INLINE CALL with) val result = receiver.block() -44 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -11 with(456) { +12 with(456) { +4 fun Any.extensionFun() { +13 this.extensionFun() +12 [LAMBDA CALLS RECEIVER] with(456) { +45 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { +46 (INLINE CALL with) val result = receiver.block() +45 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +12 with(456) { diff --git a/idea/testData/slicer/inflow/inlineFunctionManyCalls.nullnessGroups.txt b/idea/testData/slicer/inflow/inlineFunctionManyCalls.nullnessGroups.txt index 550ab3e5010..f0ad1987167 100644 --- a/idea/testData/slicer/inflow/inlineFunctionManyCalls.nullnessGroups.txt +++ b/idea/testData/slicer/inflow/inlineFunctionManyCalls.nullnessGroups.txt @@ -1,30 +1,30 @@ [NotNull Values] -7 with(123) { -3 fun Any.extensionFun() { -7 [LAMBDA CALLS RECEIVER] with(123) { -44 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -45 (INLINE CALL with) val result = receiver.block() -44 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -7 with(123) { -12 this.extensionFun() -3 fun Any.extensionFun() { -12 this.extensionFun() -19 withNoInline(1) { -3 fun Any.extensionFun() { -19 [LAMBDA CALLS RECEIVER] withNoInline(1) { -53 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { -54 val result = receiver.block() -53 fun withNoInline(receiver: T, block: T.() -> R): R { -19 withNoInline(1) { -23 withNoInline(2) { -3 fun Any.extensionFun() { -19 [LAMBDA CALLS RECEIVER] withNoInline(1) { -53 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { -54 val result = receiver.block() -53 fun withNoInline(receiver: T, block: T.() -> R): R { -23 withNoInline(2) { -28 it.extensionFun() -3 fun Any.extensionFun() { -28 it.extensionFun() -36 it.extensionFun() +8 with(123) { +4 fun Any.extensionFun() { +8 [LAMBDA CALLS RECEIVER] with(123) { +45 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { +46 (INLINE CALL with) val result = receiver.block() +45 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +8 with(123) { +13 this.extensionFun() +4 fun Any.extensionFun() { +13 this.extensionFun() +20 withNoInline(1) { +4 fun Any.extensionFun() { +20 [LAMBDA CALLS RECEIVER] withNoInline(1) { +50 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { +51 val result = receiver.block() +50 fun withNoInline(receiver: T, block: T.() -> R): R { +20 withNoInline(1) { +24 withNoInline(2) { +4 fun Any.extensionFun() { +20 [LAMBDA CALLS RECEIVER] withNoInline(1) { +50 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { +51 val result = receiver.block() +50 fun withNoInline(receiver: T, block: T.() -> R): R { +24 withNoInline(2) { +37 it.extensionFun() +4 fun Any.extensionFun() { +29 it.extensionFun() +37 it.extensionFun() diff --git a/idea/testData/slicer/inflow/inlineFunctionManyCalls.results.txt b/idea/testData/slicer/inflow/inlineFunctionManyCalls.results.txt index 04afb7118d3..530943222a2 100644 --- a/idea/testData/slicer/inflow/inlineFunctionManyCalls.results.txt +++ b/idea/testData/slicer/inflow/inlineFunctionManyCalls.results.txt @@ -1,31 +1,31 @@ -3 fun Any.extensionFun() { -7 [LAMBDA CALLS RECEIVER] with(123) { -44 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -45 (INLINE CALL with) val result = receiver.block() -44 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -7 with(123) { -12 this.extensionFun() -11 [LAMBDA CALLS RECEIVER] with(456) { -44 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -45 (INLINE CALL with) val result = receiver.block() -44 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -11 with(456) { -19 [LAMBDA CALLS RECEIVER] withNoInline(1) { -53 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { -54 val result = receiver.block() -53 fun withNoInline(receiver: T, block: T.() -> R): R { -19 withNoInline(1) { -23 withNoInline(2) { -28 it.extensionFun() -27 [LAMBDA CALLS ARGUMENT #0] "A".let { -49 (INLINE CALL let) [LAMBDA CALLS ARGUMENT #0] inline fun T.let(block: (T) -> R): R { -50 (INLINE CALL let) return block(this) -49 (INLINE CALL let) inline fun T.let(block: (T) -> R): R { -27 "A".let { -36 it.extensionFun() -35 [LAMBDA CALLS ARGUMENT #0] "D".letNoInline { -58 [LAMBDA CALLS ARGUMENT #0] fun T.letNoInline(block: (T) -> R): R { -59 return block(this) -58 fun T.letNoInline(block: (T) -> R): R { -35 "D".letNoInline { -39 "C".letNoInline { +4 fun Any.extensionFun() { +8 [LAMBDA CALLS RECEIVER] with(123) { +45 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { +46 (INLINE CALL with) val result = receiver.block() +45 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +8 with(123) { +13 this.extensionFun() +12 [LAMBDA CALLS RECEIVER] with(456) { +45 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { +46 (INLINE CALL with) val result = receiver.block() +45 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +12 with(456) { +20 [LAMBDA CALLS RECEIVER] withNoInline(1) { +50 [LAMBDA CALLS RECEIVER] fun withNoInline(receiver: T, block: T.() -> R): R { +51 val result = receiver.block() +50 fun withNoInline(receiver: T, block: T.() -> R): R { +20 withNoInline(1) { +24 withNoInline(2) { +29 it.extensionFun() +28 [LAMBDA CALLS ARGUMENT #0] "A".let { +108 (INLINE CALL let) [LAMBDA CALLS ARGUMENT #0] public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +108 (INLINE CALL let) public inline fun T.let(block: (T) -> R): R { +28 "A".let { +37 it.extensionFun() +36 [LAMBDA CALLS ARGUMENT #0] "D".letNoInline { +55 [LAMBDA CALLS ARGUMENT #0] fun T.letNoInline(block: (T) -> R): R { +56 return block(this) +55 fun T.letNoInline(block: (T) -> R): R { +36 "D".letNoInline { +40 "C".letNoInline { diff --git a/idea/testData/slicer/inflow/onFunctionReceiverType.kt b/idea/testData/slicer/inflow/onFunctionReceiverType.kt index 7735227767d..25bf646b896 100644 --- a/idea/testData/slicer/inflow/onFunctionReceiverType.kt +++ b/idea/testData/slicer/inflow/onFunctionReceiverType.kt @@ -1,5 +1,5 @@ // FLOW: IN -// WITH_RUNTIME +// RUNTIME_WITH_SOURCES @file: JvmName("KotlinUtil") @@ -23,7 +23,3 @@ fun String.foo() { fun main() { "A".foo() } - -inline fun with(receiver: T, block: T.() -> R): R { - return receiver.block() -} diff --git a/idea/testData/slicer/inflow/onFunctionReceiverType.leafGroups.txt b/idea/testData/slicer/inflow/onFunctionReceiverType.leafGroups.txt index 38c6b506da8..250d10e08a9 100644 --- a/idea/testData/slicer/inflow/onFunctionReceiverType.leafGroups.txt +++ b/idea/testData/slicer/inflow/onFunctionReceiverType.leafGroups.txt @@ -18,8 +18,8 @@ 18 with(123) { 8 fun Any.extensionFun() { 18 [LAMBDA CALLS RECEIVER] with(123) { -27 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -28 (INLINE CALL with) return receiver.block() -27 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +66 (INLINE CALL with) [LAMBDA CALLS RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { 18 with(123) { diff --git a/idea/testData/slicer/inflow/onFunctionReceiverType.nullnessGroups.txt b/idea/testData/slicer/inflow/onFunctionReceiverType.nullnessGroups.txt index b1e4390d4a5..d3f670b006a 100644 --- a/idea/testData/slicer/inflow/onFunctionReceiverType.nullnessGroups.txt +++ b/idea/testData/slicer/inflow/onFunctionReceiverType.nullnessGroups.txt @@ -8,9 +8,9 @@ 18 with(123) { 8 fun Any.extensionFun() { 18 [LAMBDA CALLS RECEIVER] with(123) { -27 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -28 (INLINE CALL with) return receiver.block() -27 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +66 (INLINE CALL with) [LAMBDA CALLS RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { 18 with(123) { 24 "A".foo() 8 fun Any.extensionFun() { diff --git a/idea/testData/slicer/inflow/onFunctionReceiverType.results.txt b/idea/testData/slicer/inflow/onFunctionReceiverType.results.txt index f807be99e14..6b1ccc0b80a 100644 --- a/idea/testData/slicer/inflow/onFunctionReceiverType.results.txt +++ b/idea/testData/slicer/inflow/onFunctionReceiverType.results.txt @@ -5,7 +5,7 @@ 12 "".extensionFun() 14 1.extensionFun() 18 [LAMBDA CALLS RECEIVER] with(123) { -27 (INLINE CALL with) [LAMBDA CALLS RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -28 (INLINE CALL with) return receiver.block() -27 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { +66 (INLINE CALL with) [LAMBDA CALLS RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { 18 with(123) { diff --git a/idea/testData/slicer/outflow/letResult.kt b/idea/testData/slicer/outflow/letResult.kt index beb347ab5ea..062d1124700 100644 --- a/idea/testData/slicer/outflow/letResult.kt +++ b/idea/testData/slicer/outflow/letResult.kt @@ -1,4 +1,5 @@ // FLOW: OUT +// RUNTIME_WITH_SOURCES fun foo(p: String) { val v1 = p.let { value -> bar(value) } @@ -15,7 +16,3 @@ fun foo(p: String) { fun bar(s: String) = s fun zoo(s: String) = s - -inline fun T.let(block: (T) -> R): R { - return block(this) -} diff --git a/idea/testData/slicer/outflow/letResult.results.txt b/idea/testData/slicer/outflow/letResult.results.txt index e86e5011aac..a20ab5fe832 100644 --- a/idea/testData/slicer/outflow/letResult.results.txt +++ b/idea/testData/slicer/outflow/letResult.results.txt @@ -1,48 +1,48 @@ -3 fun foo(p: String) { -4 val v1 = p.let { value -> bar(value) } -19 (INLINE CALL let) inline fun T.let(block: (T) -> R): R { -20 (INLINE CALL let) return block(this) -19 (INLINE CALL let) [LAMBDA PARAMETER #0] inline fun T.let(block: (T) -> R): R { -4 [LAMBDA PARAMETER #0] val v1 = p.let { value -> bar(value) } -4 val v1 = p.let { value -> bar(value) } -4 val v1 = p.let { value -> bar(value) } -16 fun bar(s: String) = s -16 fun bar(s: String) = s -16 fun bar(s: String) = s -4 val v1 = p.let { value -> bar(value) } -4 val v1 = p.let { value -> bar(value) } -4 [LAMBDA CALLS] val v1 = p.let { value -> bar(value) } -19 (INLINE CALL let) [LAMBDA CALLS] inline fun T.let(block: (T) -> R): R { -20 (INLINE CALL let) return block(this) -4 val v1 = p.let { value -> bar(value) } -4 val v1 = p.let { value -> bar(value) } -6 val v2 = p.let { it } -19 (INLINE CALL let) inline fun T.let(block: (T) -> R): R { -20 (INLINE CALL let) return block(this) -19 (INLINE CALL let) [LAMBDA PARAMETER #0] inline fun T.let(block: (T) -> R): R { -6 [LAMBDA PARAMETER #0] val v2 = p.let { it } -6 val v2 = p.let { it } -6 val v2 = p.let { it } -6 [LAMBDA CALLS] val v2 = p.let { it } -19 (INLINE CALL let) [LAMBDA CALLS] inline fun T.let(block: (T) -> R): R { -20 (INLINE CALL let) return block(this) -6 val v2 = p.let { it } -6 val v2 = p.let { it } -8 val v3 = p.let { -19 (INLINE CALL let) inline fun T.let(block: (T) -> R): R { -20 (INLINE CALL let) return block(this) -19 (INLINE CALL let) [LAMBDA PARAMETER #0] inline fun T.let(block: (T) -> R): R { -8 [LAMBDA PARAMETER #0] val v3 = p.let { -13 val v4 = p.let(::zoo) -19 (INLINE CALL let) inline fun T.let(block: (T) -> R): R { -20 (INLINE CALL let) return block(this) -19 (INLINE CALL let) [LAMBDA PARAMETER #0] inline fun T.let(block: (T) -> R): R { -13 [LAMBDA PARAMETER #0] val v4 = p.let(::zoo) -17 fun zoo(s: String) = s -17 fun zoo(s: String) = s -17 fun zoo(s: String) = s -13 [LAMBDA CALLS] val v4 = p.let(::zoo) -19 (INLINE CALL let) [LAMBDA CALLS] inline fun T.let(block: (T) -> R): R { -20 (INLINE CALL let) return block(this) -13 val v4 = p.let(::zoo) -13 val v4 = p.let(::zoo) +4 fun foo(p: String) { +5 val v1 = p.let { value -> bar(value) } +108 (INLINE CALL let) public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +108 (INLINE CALL let) [LAMBDA PARAMETER #0] public inline fun T.let(block: (T) -> R): R { +5 [LAMBDA PARAMETER #0] val v1 = p.let { value -> bar(value) } +5 val v1 = p.let { value -> bar(value) } +5 val v1 = p.let { value -> bar(value) } +17 fun bar(s: String) = s +17 fun bar(s: String) = s +17 fun bar(s: String) = s +5 val v1 = p.let { value -> bar(value) } +5 val v1 = p.let { value -> bar(value) } +5 [LAMBDA CALLS] val v1 = p.let { value -> bar(value) } +108 (INLINE CALL let) [LAMBDA CALLS] public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +5 val v1 = p.let { value -> bar(value) } +5 val v1 = p.let { value -> bar(value) } +7 val v2 = p.let { it } +108 (INLINE CALL let) public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +108 (INLINE CALL let) [LAMBDA PARAMETER #0] public inline fun T.let(block: (T) -> R): R { +7 [LAMBDA PARAMETER #0] val v2 = p.let { it } +7 val v2 = p.let { it } +7 val v2 = p.let { it } +7 [LAMBDA CALLS] val v2 = p.let { it } +108 (INLINE CALL let) [LAMBDA CALLS] public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +7 val v2 = p.let { it } +7 val v2 = p.let { it } +9 val v3 = p.let { +108 (INLINE CALL let) public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +108 (INLINE CALL let) [LAMBDA PARAMETER #0] public inline fun T.let(block: (T) -> R): R { +9 [LAMBDA PARAMETER #0] val v3 = p.let { +14 val v4 = p.let(::zoo) +108 (INLINE CALL let) public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +108 (INLINE CALL let) [LAMBDA PARAMETER #0] public inline fun T.let(block: (T) -> R): R { +14 [LAMBDA PARAMETER #0] val v4 = p.let(::zoo) +18 fun zoo(s: String) = s +18 fun zoo(s: String) = s +18 fun zoo(s: String) = s +14 [LAMBDA CALLS] val v4 = p.let(::zoo) +108 (INLINE CALL let) [LAMBDA CALLS] public inline fun T.let(block: (T) -> R): R { +112 (INLINE CALL let) return block(this) +14 val v4 = p.let(::zoo) +14 val v4 = p.let(::zoo) diff --git a/idea/testData/slicer/outflow/withResult.kt b/idea/testData/slicer/outflow/withResult.kt index 7c682e9d61e..43a395517be 100644 --- a/idea/testData/slicer/outflow/withResult.kt +++ b/idea/testData/slicer/outflow/withResult.kt @@ -1,4 +1,5 @@ // FLOW: OUT +// RUNTIME_WITH_SOURCES fun String.foo(p: String) { val v1 = with(p) { this } @@ -12,7 +13,3 @@ fun String.foo(p: String) { fun bar(s: String) = s fun zoo(s: String) = s - -inline fun with(receiver: T, block: T.() -> R): R { - return receiver.block() -} diff --git a/idea/testData/slicer/outflow/withResult.results.txt b/idea/testData/slicer/outflow/withResult.results.txt index 62dcdd0d090..1a2f96cbdd0 100644 --- a/idea/testData/slicer/outflow/withResult.results.txt +++ b/idea/testData/slicer/outflow/withResult.results.txt @@ -1,47 +1,47 @@ -3 fun String.foo(p: String) { -4 val v1 = with(p) { this } -16 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -17 (INLINE CALL with) return receiver.block() -16 (INLINE CALL with) [LAMBDA RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -4 [LAMBDA RECEIVER] val v1 = with(p) { this } -4 val v1 = with(p) { this } -4 val v1 = with(p) { this } -4 [LAMBDA CALLS] val v1 = with(p) { this } -16 (INLINE CALL with) [LAMBDA CALLS] inline fun with(receiver: T, block: T.() -> R): R { -17 (INLINE CALL with) return receiver.block() -4 val v1 = with(p) { this } -4 val v1 = with(p) { this } -6 val v2 = with(p) { bar(this) } -16 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -17 (INLINE CALL with) return receiver.block() -16 (INLINE CALL with) [LAMBDA RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -6 [LAMBDA RECEIVER] val v2 = with(p) { bar(this) } -6 val v2 = with(p) { bar(this) } -13 fun bar(s: String) = s -13 fun bar(s: String) = s -13 fun bar(s: String) = s -6 val v2 = with(p) { bar(this) } -6 val v2 = with(p) { bar(this) } -6 [LAMBDA CALLS] val v2 = with(p) { bar(this) } -16 (INLINE CALL with) [LAMBDA CALLS] inline fun with(receiver: T, block: T.() -> R): R { -17 (INLINE CALL with) return receiver.block() -6 val v2 = with(p) { bar(this) } -6 val v2 = with(p) { bar(this) } -8 val v3 = with(p) { this@foo } -16 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -17 (INLINE CALL with) return receiver.block() -16 (INLINE CALL with) [LAMBDA RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -8 [LAMBDA RECEIVER] val v3 = with(p) { this@foo } -10 val v4 = with(p, ::zoo) -16 (INLINE CALL with) inline fun with(receiver: T, block: T.() -> R): R { -17 (INLINE CALL with) return receiver.block() -16 (INLINE CALL with) [LAMBDA RECEIVER] inline fun with(receiver: T, block: T.() -> R): R { -10 [LAMBDA RECEIVER] val v4 = with(p, ::zoo) -14 fun zoo(s: String) = s -14 fun zoo(s: String) = s -14 fun zoo(s: String) = s -10 [LAMBDA CALLS] val v4 = with(p, ::zoo) -16 (INLINE CALL with) [LAMBDA CALLS] inline fun with(receiver: T, block: T.() -> R): R { -17 (INLINE CALL with) return receiver.block() -10 val v4 = with(p, ::zoo) -10 val v4 = with(p, ::zoo) +4 fun String.foo(p: String) { +5 val v1 = with(p) { this } +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) [LAMBDA RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +5 [LAMBDA RECEIVER] val v1 = with(p) { this } +5 val v1 = with(p) { this } +5 val v1 = with(p) { this } +5 [LAMBDA CALLS] val v1 = with(p) { this } +66 (INLINE CALL with) [LAMBDA CALLS] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +5 val v1 = with(p) { this } +5 val v1 = with(p) { this } +7 val v2 = with(p) { bar(this) } +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) [LAMBDA RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +7 [LAMBDA RECEIVER] val v2 = with(p) { bar(this) } +7 val v2 = with(p) { bar(this) } +14 fun bar(s: String) = s +14 fun bar(s: String) = s +14 fun bar(s: String) = s +7 val v2 = with(p) { bar(this) } +7 val v2 = with(p) { bar(this) } +7 [LAMBDA CALLS] val v2 = with(p) { bar(this) } +66 (INLINE CALL with) [LAMBDA CALLS] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +7 val v2 = with(p) { bar(this) } +7 val v2 = with(p) { bar(this) } +9 val v3 = with(p) { this@foo } +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) [LAMBDA RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +9 [LAMBDA RECEIVER] val v3 = with(p) { this@foo } +11 val v4 = with(p, ::zoo) +66 (INLINE CALL with) public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +66 (INLINE CALL with) [LAMBDA RECEIVER] public inline fun with(receiver: T, block: T.() -> R): R { +11 [LAMBDA RECEIVER] val v4 = with(p, ::zoo) +15 fun zoo(s: String) = s +15 fun zoo(s: String) = s +15 fun zoo(s: String) = s +11 [LAMBDA CALLS] val v4 = with(p, ::zoo) +66 (INLINE CALL with) [LAMBDA CALLS] public inline fun with(receiver: T, block: T.() -> R): R { +70 (INLINE CALL with) return receiver.block() +11 val v4 = with(p, ::zoo) +11 val v4 = with(p, ::zoo) diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java index 8f7503f1766..2242947e309 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java @@ -178,6 +178,11 @@ public class SlicerLeafGroupingTestGenerated extends AbstractSlicerLeafGroupingT runTest("idea/testData/slicer/inflow/ifExpression.kt"); } + @TestMetadata("inlineExtensionImplicitReceiver.kt") + public void testInlineExtensionImplicitReceiver() throws Exception { + runTest("idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.kt"); + } + @TestMetadata("inlineFunctionManyCalls.kt") public void testInlineFunctionManyCalls() throws Exception { runTest("idea/testData/slicer/inflow/inlineFunctionManyCalls.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerNullnessGroupingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerNullnessGroupingTestGenerated.java index 0e5167ae3c6..7473b924b7d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerNullnessGroupingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerNullnessGroupingTestGenerated.java @@ -178,6 +178,11 @@ public class SlicerNullnessGroupingTestGenerated extends AbstractSlicerNullnessG runTest("idea/testData/slicer/inflow/ifExpression.kt"); } + @TestMetadata("inlineExtensionImplicitReceiver.kt") + public void testInlineExtensionImplicitReceiver() throws Exception { + runTest("idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.kt"); + } + @TestMetadata("inlineFunctionManyCalls.kt") public void testInlineFunctionManyCalls() throws Exception { runTest("idea/testData/slicer/inflow/inlineFunctionManyCalls.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java index 73567e58da6..4d8e587fec1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java @@ -190,6 +190,11 @@ public class SlicerTreeTestGenerated extends AbstractSlicerTreeTest { runTest("idea/testData/slicer/inflow/ifExpression.kt"); } + @TestMetadata("inlineExtensionImplicitReceiver.kt") + public void testInlineExtensionImplicitReceiver() throws Exception { + runTest("idea/testData/slicer/inflow/inlineExtensionImplicitReceiver.kt"); + } + @TestMetadata("inlineFunctionManyCalls.kt") public void testInlineFunctionManyCalls() throws Exception { runTest("idea/testData/slicer/inflow/inlineFunctionManyCalls.kt");