[LL API] Support code fragment compilation

This commit is contained in:
Yan Zhulanow
2023-06-20 01:46:50 +09:00
committed by Space Team
parent 9446118d7f
commit e1db3c88cf
126 changed files with 2439 additions and 14 deletions
@@ -138,7 +138,7 @@ internal class KtFe10CompilerFacility(
}
val outputFiles = state.factory.asList().map(::KtCompiledFileForOutputFile)
return KtCompilationResult.Success(outputFiles)
return KtCompilationResult.Success(outputFiles, capturedValues = emptyList())
} finally {
state.destroy()
}
@@ -24,6 +24,7 @@ dependencies {
implementation(project(":compiler:cli-base"))
implementation(project(":compiler:backend"))
implementation(project(":compiler:backend.jvm.entrypoint"))
implementation(project(":compiler:backend.jvm.lower"))
implementation(project(":compiler:ir.backend.common"))
implementation(project(":compiler:ir.serialization.jvm"))
api(intellijCore())
@@ -6,18 +6,22 @@
package org.jetbrains.kotlin.analysis.api.fir.components
import com.intellij.openapi.progress.ProgressManager
import org.jetbrains.kotlin.analysis.api.components.KtCompilationResult
import org.jetbrains.kotlin.analysis.api.compile.CodeFragmentCapturedValue
import org.jetbrains.kotlin.analysis.api.components.KtCompilerFacility
import org.jetbrains.kotlin.analysis.api.components.KtCompilationResult
import org.jetbrains.kotlin.analysis.api.components.KtCompilerTarget
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
import org.jetbrains.kotlin.analysis.api.impl.base.util.KtCompiledFileForOutputFile
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSession
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.collectDiagnosticsForFile
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.targets.LLFirWholeFileResolveTarget
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.targets.resolve
import org.jetbrains.kotlin.analysis.low.level.api.fir.compile.CodeFragmentCapturedValueAnalyzer
import org.jetbrains.kotlin.analysis.low.level.api.fir.compile.CompilationPeerCollector
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.jvm.*
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
@@ -33,19 +37,35 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticMarker
import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.fir.backend.Fir2IrCommonMemberStorage
import org.jetbrains.kotlin.fir.backend.Fir2IrConfiguration
import org.jetbrains.kotlin.fir.backend.Fir2IrConverter
import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.backend.jvm.*
import org.jetbrains.kotlin.fir.declarations.FirCodeFragment
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.pipeline.applyIrGenerationExtensions
import org.jetbrains.kotlin.fir.pipeline.signatureComposerForJvmFir2Ir
import org.jetbrains.kotlin.fir.references.FirReference
import org.jetbrains.kotlin.fir.references.FirThisReference
import org.jetbrains.kotlin.fir.references.toResolvedSymbol
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.PsiIrFileEntry
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmIrMangler
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.util.StubGeneratorExtensions
import org.jetbrains.kotlin.load.kotlin.toSourceElement
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi2ir.generators.fragments.EvaluatorFragmentInfo
import org.jetbrains.kotlin.resolve.source.PsiSourceFile
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
import org.jetbrains.kotlin.utils.addToStdlib.runIf
internal class KtFirCompilerFacility(
override val analysisSession: KtFirAnalysisSession
@@ -75,14 +95,31 @@ internal class KtFirCompilerFacility(
return KtCompilationResult.Failure(frontendErrors)
}
val codeFragmentMappings = runIf(file is KtCodeFragment) {
computeCodeFragmentMappings(file, mainFirFile, firResolveSession, configuration)
}
val compilationPeerData = CompilationPeerCollector.process(mainFirFile)
val filesToCompile = compilationPeerData.files
val filesToCompile = buildList {
val dependencyFiles = buildSet {
addAll(compilationPeerData.files)
addAll(codeFragmentMappings?.capturedFiles.orEmpty())
// The main file needs to be the last so caches for the context declarations are populated in FIR-to-IR.
remove(file)
}
addAll(dependencyFiles)
add(file)
}
val firFilesToCompile = filesToCompile.map(::getFullyResolvedFirFile)
val generateClassFilter = SingleFileGenerateClassFilter(file, compilationPeerData.inlinedClasses)
val fir2IrExtensions = JvmFir2IrExtensions(effectiveConfiguration, JvmIrDeserializerImpl(), JvmIrMangler)
val jvmGeneratorExtensions = JvmFir2IrExtensions(effectiveConfiguration, JvmIrDeserializerImpl(), JvmIrMangler)
val fir2IrExtensions = CompilerFacilityFir2IrExtensions(jvmGeneratorExtensions, codeFragmentMappings?.injectedValueProvider)
val diagnosticsReporter = DiagnosticReporterFactory.createPendingReporter()
val fir2IrConfiguration = Fir2IrConfiguration(
@@ -111,8 +148,11 @@ internal class KtFirCompilerFacility(
ProgressManager.checkCanceled()
val irGeneratorExtensions = IrGenerationExtension.getInstances(project)
fir2IrResult.components.applyIrGenerationExtensions(fir2IrResult.irModuleFragment, irGeneratorExtensions)
val bindingContext = NoScopeRecordCliBindingTrace().bindingContext
val codegenFactory = createJvmIrCodegenFactory(effectiveConfiguration)
val codegenFactory = createJvmIrCodegenFactory(effectiveConfiguration, file is KtCodeFragment, fir2IrResult.irModuleFragment)
val generationState = GenerationState.Builder(
project,
@@ -136,7 +176,7 @@ internal class KtFirCompilerFacility(
fir2IrResult.irModuleFragment,
fir2IrResult.components.symbolTable,
fir2IrResult.components.irProviders,
JvmFir2IrExtensions(effectiveConfiguration, JvmIrDeserializerImpl(), JvmIrMangler),
CompilerFacilityJvmGeneratorExtensions(jvmGeneratorExtensions),
FirJvmBackendExtension(fir2IrResult.components, null),
fir2IrResult.pluginContext
)
@@ -152,7 +192,8 @@ internal class KtFirCompilerFacility(
}
val outputFiles = generationState.factory.asList().map(::KtCompiledFileForOutputFile)
return KtCompilationResult.Success(outputFiles)
val capturedValues = codeFragmentMappings?.capturedValues ?: emptyList()
return KtCompilationResult.Success(outputFiles, capturedValues)
} finally {
generationState.destroy()
}
@@ -182,6 +223,74 @@ internal class KtFirCompilerFacility(
}
}
private class CodeFragmentMappings(
val capturedValues: List<CodeFragmentCapturedValue>,
val capturedFiles: List<KtFile>,
val injectedValueProvider: InjectedSymbolProvider
)
private fun computeCodeFragmentMappings(
mainKtFile: KtFile,
mainFirFile: FirFile,
resolveSession: LLFirResolveSession,
configuration: CompilerConfiguration,
): CodeFragmentMappings {
val codeFragment = mainFirFile.declarations.single() as FirCodeFragment
val capturedData = CodeFragmentCapturedValueAnalyzer.analyze(resolveSession, codeFragment)
val capturedSymbols = capturedData.symbols
val capturedValues = capturedSymbols.map { it.value }
val injectedSymbols = capturedSymbols.map { InjectedValue(it.symbol, it.typeRef, it.value.isMutated) }
codeFragment.conversionData = CodeFragmentConversionData(
classId = ClassId(FqName.ROOT, Name.identifier(configuration[CODE_FRAGMENT_CLASS_NAME] ?: "CodeFragment")),
methodName = Name.identifier(configuration[CODE_FRAGMENT_METHOD_NAME] ?: "run"),
injectedSymbols
)
val injectedSymbolMapping = injectedSymbols.associateBy { it.symbol }
val injectedValueProvider = InjectedSymbolProvider(mainKtFile, injectedSymbolMapping)
return CodeFragmentMappings(capturedValues, capturedData.files, injectedValueProvider)
}
private class InjectedSymbolProvider(
private val mainKtFile: KtFile,
private val injectedSymbolMapping: Map<FirBasedSymbol<*>, InjectedValue>
) : (FirReference, Fir2IrConversionScope) -> InjectedValue? {
override fun invoke(calleeReference: FirReference, conversionScope: Fir2IrConversionScope): InjectedValue? {
val irFile = conversionScope.containingFileIfAny()
val psiFile = (irFile?.fileEntry as? PsiIrFileEntry)?.psiFile
if (psiFile != mainKtFile) {
return null
}
val symbol = when (calleeReference) {
is FirThisReference -> calleeReference.boundSymbol
else -> calleeReference.toResolvedSymbol<FirBasedSymbol<*>>()
}
return injectedSymbolMapping[symbol]
}
}
private class CompilerFacilityJvmGeneratorExtensions(
private val delegate: JvmGeneratorExtensions
) : StubGeneratorExtensions(), JvmGeneratorExtensions by delegate {
override val rawTypeAnnotationConstructor: IrConstructor?
get() = delegate.rawTypeAnnotationConstructor
}
private class CompilerFacilityFir2IrExtensions(
delegate: Fir2IrExtensions,
private val injectedValueProvider: InjectedSymbolProvider?
) : Fir2IrExtensions by delegate {
override fun findInjectedValue(calleeReference: FirReference, conversionScope: Fir2IrConversionScope): InjectedValue? {
return injectedValueProvider?.invoke(calleeReference, conversionScope)
}
}
private class SingleFileGenerateClassFilter(
private val file: KtFile,
private val inlinedClasses: Set<KtClassOrObject>
@@ -208,7 +317,11 @@ internal class KtFirCompilerFacility(
override fun shouldGenerateCodeFragment(script: KtCodeFragment) = false
}
private fun createJvmIrCodegenFactory(configuration: CompilerConfiguration): JvmIrCodegenFactory {
private fun createJvmIrCodegenFactory(
configuration: CompilerConfiguration,
isCodeFragment: Boolean,
irModuleFragment: IrModuleFragment,
): JvmIrCodegenFactory {
val jvmGeneratorExtensions = object : JvmGeneratorExtensionsImpl(configuration) {
override fun getContainerSource(descriptor: DeclarationDescriptor): DeserializedContainerSource? {
// Stubbed top-level function IR symbols (from other source files in the module) require a parent facade class to be
@@ -235,10 +348,21 @@ internal class KtFirCompilerFacility(
shouldReferenceUndiscoveredExpectSymbols = false, // TODO it was true
)
val phaseConfig = PhaseConfig(if (isCodeFragment) jvmFragmentLoweringPhases else jvmLoweringPhases)
@OptIn(ObsoleteDescriptorBasedAPI::class)
val evaluatorFragmentInfoForPsi2Ir = runIf<EvaluatorFragmentInfo?>(isCodeFragment) {
val irFile = irModuleFragment.files.single { (it.fileEntry as? PsiIrFileEntry)?.psiFile is KtCodeFragment }
val irClass = irFile.declarations.single { it is IrClass && it.metadata is FirMetadataSource.CodeFragment } as IrClass
val irFunction = irClass.declarations.single { it is IrFunction && it !is IrConstructor } as IrFunction
EvaluatorFragmentInfo(irClass.descriptor, irFunction.descriptor, emptyList())
}
return JvmIrCodegenFactory(
configuration,
PhaseConfig(jvmPhases),
phaseConfig,
jvmGeneratorExtensions = jvmGeneratorExtensions,
evaluatorFragmentInfoForPsi2Ir = evaluatorFragmentInfoForPsi2Ir,
ideCodegenSettings = ideCodegenSettings,
)
}
@@ -43,4 +43,4 @@ fun FirBasedSymbol<*>.findPsi(): PsiElement? =
*/
fun FirDeclaration.findReferencePsi(): PsiElement? {
return psi ?: FirSyntheticFunctionInterfaceSourceProvider.findPsi(this)
}
}
@@ -0,0 +1,218 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.analysis.api.fir.test.cases.generated.cases.components.compilerFacility;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.analysis.api.fir.test.configurators.AnalysisApiFirTestConfiguratorFactory;
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfiguratorFactoryData;
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator;
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.TestModuleKind;
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.FrontendKind;
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisSessionMode;
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiMode;
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.compilerFacility.AbstractCompilerFacilityTest;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.analysis.api.GenerateAnalysisApiTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("analysis/analysis-api/testData/components/compilerFacility/compilation")
@TestDataPath("$PROJECT_ROOT")
public class FirIdeNormalAnalysisSourceModuleCompilerFacilityTestGenerated extends AbstractCompilerFacilityTest {
@NotNull
@Override
public AnalysisApiTestConfigurator getConfigurator() {
return AnalysisApiFirTestConfiguratorFactory.INSTANCE.createConfigurator(
new AnalysisApiTestConfiguratorFactoryData(
FrontendKind.Fir,
TestModuleKind.Source,
AnalysisSessionMode.Normal,
AnalysisApiMode.Ide
)
);
}
@Test
public void testAllFilesPresentInCompilation() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compilerFacility/compilation"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("classKinds.kt")
public void testClassKinds() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/classKinds.kt");
}
@Test
@TestMetadata("imports.kt")
public void testImports() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/imports.kt");
}
@Test
@TestMetadata("multipleFiles.kt")
public void testMultipleFiles() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/multipleFiles.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/simple.kt");
}
@Nested
@TestMetadata("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments")
@TestDataPath("$PROJECT_ROOT")
public class CodeFragments {
@Test
public void testAllFilesPresentInCodeFragments() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("customName.kt")
public void testCustomName() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/customName.kt");
}
@Test
@TestMetadata("imports.kt")
public void testImports() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/imports.kt");
}
@Test
@TestMetadata("inlineFunctionUsage.kt")
public void testInlineFunctionUsage() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/inlineFunctionUsage.kt");
}
@Test
@TestMetadata("inlineFunctionUsageSource.kt")
public void testInlineFunctionUsageSource() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/inlineFunctionUsageSource.kt");
}
@Test
@TestMetadata("local.kt")
public void testLocal() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/local.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/simple.kt");
}
@Nested
@TestMetadata("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing")
@TestDataPath("$PROJECT_ROOT")
public class Capturing {
@Test
public void testAllFilesPresentInCapturing() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("contextReceiver.kt")
public void testContextReceiver() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/contextReceiver.kt");
}
@Test
@TestMetadata("contextReceiverExplicit.kt")
public void testContextReceiverExplicit() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/contextReceiverExplicit.kt");
}
@Test
@TestMetadata("extensionReceiver.kt")
public void testExtensionReceiver() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiver.kt");
}
@Test
@TestMetadata("extensionReceiverExplicit.kt")
public void testExtensionReceiverExplicit() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverExplicit.kt");
}
@Test
@TestMetadata("extensionReceiverLabeled.kt")
public void testExtensionReceiverLabeled() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverLabeled.kt");
}
@Test
@TestMetadata("initializer.kt")
public void testInitializer() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/initializer.kt");
}
@Test
@TestMetadata("local.kt")
public void testLocal() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/local.kt");
}
@Test
@TestMetadata("localFunction.kt")
public void testLocalFunction() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/localFunction.kt");
}
@Test
@TestMetadata("localMutated.kt")
public void testLocalMutated() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/localMutated.kt");
}
@Test
@TestMetadata("nestedOuterClass.kt")
public void testNestedOuterClass() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/nestedOuterClass.kt");
}
@Test
@TestMetadata("objectFunction.kt")
public void testObjectFunction() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/objectFunction.kt");
}
@Test
@TestMetadata("outerClass.kt")
public void testOuterClass() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/outerClass.kt");
}
@Test
@TestMetadata("outerClassMutated.kt")
public void testOuterClassMutated() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/outerClassMutated.kt");
}
@Test
@TestMetadata("outerClassMutatedPrivate.kt")
public void testOuterClassMutatedPrivate() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/outerClassMutatedPrivate.kt");
}
@Test
@TestMetadata("valueParameter.kt")
public void testValueParameter() throws Exception {
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/valueParameter.kt");
}
}
}
}
@@ -0,0 +1,208 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.compilerFacility
import com.intellij.openapi.extensions.LoadingOrder
import org.jetbrains.kotlin.analysis.api.analyze
import org.jetbrains.kotlin.analysis.api.components.KtCompilationResult
import org.jetbrains.kotlin.analysis.api.components.KtCompiledFile
import org.jetbrains.kotlin.analysis.api.components.KtCompilerFacility
import org.jetbrains.kotlin.analysis.api.components.KtCompilerTarget
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnosticWithPsi
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.codegen.BytecodeListingTextCollectingVisitor
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.util.DumpIrTreeOptions
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.psi.KtCodeFragment
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.ClassNode
import java.io.File
import kotlin.test.assertFalse
abstract class AbstractCompilerFacilityTest : AbstractAnalysisApiBasedSingleModuleTest() {
private companion object {
private val ALLOWED_ERRORS = listOf(
FirErrors.INVISIBLE_REFERENCE,
FirErrors.INVISIBLE_SETTER,
FirErrors.DEPRECATION_ERROR,
FirErrors.DIVISION_BY_ZERO,
FirErrors.OPT_IN_USAGE_ERROR,
FirErrors.OPT_IN_OVERRIDE_ERROR,
FirErrors.UNSAFE_CALL,
FirErrors.UNSAFE_IMPLICIT_INVOKE_CALL,
FirErrors.UNSAFE_INFIX_CALL,
FirErrors.UNSAFE_OPERATOR_CALL,
FirErrors.ITERATOR_ON_NULLABLE,
FirErrors.UNEXPECTED_SAFE_CALL,
FirErrors.DSL_SCOPE_VIOLATION,
).map { it.name }
}
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
val ktFile = ktFiles.singleOrNull() ?: ktFiles.first { it.name == "main.kt" }
val irCollector = CollectingIrGenerationExtension()
val project = ktFile.project
project.extensionArea.getExtensionPoint(IrGenerationExtension.extensionPointName)
.registerExtension(irCollector, LoadingOrder.LAST, project)
val ktCodeFragment = createCodeFragment(ktFile, module, testServices)
if (ktCodeFragment != null) {
for (importNameString in module.directives[Directives.CODE_FRAGMENT_IMPORT]) {
ktCodeFragment.addImport("import $importNameString")
}
}
val compilerConfiguration = CompilerConfiguration().apply {
put(CommonConfigurationKeys.MODULE_NAME, module.name)
put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, module.languageVersionSettings)
put(JVMConfigurationKeys.IR, true)
module.directives[Directives.CODE_FRAGMENT_CLASS_NAME].singleOrNull()
?.let { put(KtCompilerFacility.CODE_FRAGMENT_CLASS_NAME, it) }
module.directives[Directives.CODE_FRAGMENT_METHOD_NAME].singleOrNull()
?.let { put(KtCompilerFacility.CODE_FRAGMENT_METHOD_NAME, it) }
}
val ktTargetFile = ktCodeFragment ?: ktFile
analyze(ktTargetFile) {
val target = KtCompilerTarget.Jvm(ClassBuilderFactories.TEST)
val allowedErrorFilter: (KtDiagnostic) -> Boolean = { it.factoryName in ALLOWED_ERRORS }
val actualText = when (val result = compile(ktTargetFile, compilerConfiguration, target, allowedErrorFilter)) {
is KtCompilationResult.Failure -> result.errors.joinToString("\n") { dumpDiagnostic(it) }
is KtCompilationResult.Success -> dumpClassFiles(result.output)
}
testServices.assertions.assertEqualsToTestDataFileSibling(actualText)
}
testServices.assertions.assertEqualsToTestDataFileSibling(irCollector.result, extension = ".ir.txt")
}
override fun configureTest(builder: TestConfigurationBuilder) {
super.configureTest(builder)
with(builder) {
useDirectives(Directives)
useConfigurators()
defaultDirectives {
+ConfigurationDirectives.WITH_STDLIB
+JvmEnvironmentConfigurationDirectives.FULL_JDK
}
}
}
private fun dumpDiagnostic(diagnostic: KtDiagnostic): String {
val textRanges = when (diagnostic) {
is KtDiagnosticWithPsi<*> -> {
diagnostic.textRanges.singleOrNull()?.toString()
?: diagnostic.textRanges.joinToString(prefix = "[", postfix = "]")
}
else -> null
}
return buildString {
if (textRanges != null) {
append(textRanges)
append(" ")
}
append(diagnostic.factoryName)
append(" ")
append(diagnostic.defaultMessage)
}
}
private fun dumpClassFiles(outputFiles: List<KtCompiledFile>): String {
val classes = outputFiles
.filter { it.path.endsWith(".class", ignoreCase = true) }
.also { check(it.isNotEmpty()) }
.sortedBy { it.path }
.map { outputFile ->
val classReader = ClassReader(outputFile.content)
ClassNode(Opcodes.API_VERSION).also { classReader.accept(it, ClassReader.SKIP_CODE) }
}
val allClasses = classes.associateBy { Type.getObjectType(it.name) }
return classes.joinToString("\n\n") { node ->
val visitor = BytecodeListingTextCollectingVisitor(
BytecodeListingTextCollectingVisitor.Filter.EMPTY,
allClasses,
withSignatures = false,
withAnnotations = false,
sortDeclarations = true
)
node.accept(visitor)
visitor.text
}
}
object Directives : SimpleDirectivesContainer() {
val CODE_FRAGMENT_IMPORT by stringDirective("Import directive for a code fragment")
val CODE_FRAGMENT_CLASS_NAME by stringDirective("Short name of a code fragment class")
val CODE_FRAGMENT_METHOD_NAME by stringDirective("Name of a code fragment facade method")
}
}
internal fun createCodeFragment(ktFile: KtFile, module: TestModule, testServices: TestServices): KtCodeFragment? {
val ioFile = module.files.single { it.name == ktFile.name }.originalFile
val ioFragmentFile = File(ioFile.parent, "${ioFile.nameWithoutExtension}.fragment.${ioFile.extension}")
if (!ioFragmentFile.exists()) {
return null
}
val contextElement = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtDeclaration>(ktFile)
val fragmentText = ioFragmentFile.readText()
val isBlockFragment = fragmentText.any { it == '\n' }
val project = ktFile.project
val factory = KtPsiFactory(project, markGenerated = false)
return when {
isBlockFragment -> factory.createBlockCodeFragment(fragmentText, contextElement)
else -> factory.createExpressionCodeFragment(fragmentText, contextElement)
}
}
private class CollectingIrGenerationExtension : IrGenerationExtension {
lateinit var result: String
private set
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) {
assertFalse { ::result.isInitialized }
val dumpOptions = DumpIrTreeOptions(normalizeNames = true, stableOrder = true)
result = moduleFragment.dump(dumpOptions)
}
}
@@ -0,0 +1,104 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.analysis.api.compile
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
public sealed class CodeFragmentCapturedValue(
public val name: String,
public val isMutated: Boolean,
public val isCrossingInlineBounds: Boolean,
) {
public open val displayText: String
get() = name
override fun toString(): String {
return javaClass.simpleName + "[name: " + name + "; isMutated: " + isMutated + "; displayText: " + displayText + "]"
}
/** Represents a local variable or a parameter. */
public class Local(
name: Name,
isMutated: Boolean,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue(name.asString(), isMutated, isCrossingInlineBounds)
/** Represents a delegated local variable (`val local by...`). */
public class LocalDelegate(
name: Name,
isMutated: Boolean,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue(name.asString(), isMutated, isCrossingInlineBounds) {
override val displayText: String
get() = "$name\$delegate"
}
/** Represents a backing field (a `field` variable inside a property accessor). */
public class BackingField(
name: Name,
isMutated: Boolean,
isCrossingInlineBounds: Boolean
) : CodeFragmentCapturedValue(name.asString(), isMutated, isCrossingInlineBounds) {
override val displayText: String
get() = "field"
}
/** Represents a captured outer class. */
public class ContainingClass(
private val classId: ClassId,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue("<this>", isMutated = false, isCrossingInlineBounds) {
override val displayText: String
get() {
val simpleName = classId.shortClassName
return if (simpleName.isSpecial) "this" else "this@" + simpleName.asString()
}
}
/** Represents a captured super class (`super.foo()`). */
public class SuperClass(
private val classId: ClassId,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue("<super>", isMutated = false, isCrossingInlineBounds) {
override val displayText: String
get() = "super@" + classId.shortClassName.asString()
}
public class ExtensionReceiver(
labelName: String,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue(labelName, isMutated = false, isCrossingInlineBounds) {
override val displayText: String
get() = "this@$name"
}
public class ContextReceiver(
public val index: Int,
labelName: Name,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue(labelName.asString(), isMutated = false, isCrossingInlineBounds) {
override val displayText: String
get() = "this@$name"
}
/** Represents a captured named local function. */
public class LocalFunction(
name: Name,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue(name.asString(), isMutated = false, isCrossingInlineBounds)
/** Represents an externally provided value. */
public class ForeignValue(
name: Name,
isCrossingInlineBounds: Boolean,
) : CodeFragmentCapturedValue(name.asString(), isMutated = false, isCrossingInlineBounds)
/** Represents a `coroutineContext` call. */
public class CoroutineContext(
isCrossingInlineBounds: Boolean
) : CodeFragmentCapturedValue("coroutineContext", isMutated = false, isCrossingInlineBounds)
}
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.analysis.api.components
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.analysis.api.compile.CodeFragmentCapturedValue
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
import org.jetbrains.kotlin.codegen.ClassBuilderFactory
import org.jetbrains.kotlin.config.CompilerConfiguration
@@ -26,8 +27,12 @@ public sealed class KtCompilationResult {
* Successful compilation result.
*
* @property output Output files produced by the compiler. For the JVM target, these are class files and '.kotlin_module'.
* @property capturedValues Context values captured by a [KtCodeFragment]. Empty for an ordinary [KtFile].
*/
public class Success(public val output: List<KtCompiledFile>) : KtCompilationResult()
public class Success(
public val output: List<KtCompiledFile>,
public val capturedValues: List<CodeFragmentCapturedValue>
) : KtCompilationResult()
/**
* Failed compilation result.
@@ -69,6 +74,16 @@ public sealed class KtCompilerTarget {
}
public abstract class KtCompilerFacility : KtAnalysisSessionComponent() {
public companion object {
/** Simple class name for the code fragment facade class. */
public val CODE_FRAGMENT_CLASS_NAME: CompilerConfigurationKey<String> =
CompilerConfigurationKey<String>("code fragment class name")
/** Entry point method name for the code fragment. */
public val CODE_FRAGMENT_METHOD_NAME: CompilerConfigurationKey<String> =
CompilerConfigurationKey<String>("code fragment method name")
}
public abstract fun compile(
file: KtFile,
configuration: CompilerConfiguration,
@@ -0,0 +1,303 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/classKinds.kt
CLASS ANNOTATION_CLASS name:Anno modality:OPEN visibility:public superTypes:[kotlin.Annotation]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Anno
CONSTRUCTOR visibility:public <> () returnType:<root>.Anno [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Anno modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Generic modality:FINAL visibility:public superTypes:[<root>.Ordinary; <root>.Intf]
annotations:
Anno
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Generic<T of <root>.Generic>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
CONSTRUCTOR visibility:public <> () returnType:<root>.Generic<T of <root>.Generic> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Ordinary'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Generic modality:FINAL visibility:public superTypes:[<root>.Ordinary; <root>.Intf]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Ordinary
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Ordinary
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.Ordinary
public open fun toString (): kotlin.String [fake_override] declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:run visibility:public modality:OPEN <> ($this:<root>.Generic<T of <root>.Generic>) returnType:kotlin.Unit
overridden:
public abstract fun run (): kotlin.Unit declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:<root>.Generic<T of <root>.Generic>
BLOCK_BODY
CLASS CLASS name:Operation modality:SEALED visibility:public superTypes:[kotlin.Any]
sealedSubclasses:
CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[<root>.Operation]
CLASS CLASS name:Subtract modality:FINAL visibility:public superTypes:[<root>.Operation]
CLASS CLASS name:Negate modality:FINAL visibility:public superTypes:[<root>.Operation]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Operation
CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[<root>.Operation]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Operation.Add
PROPERTY name:firstValue visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:firstValue type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
GET_VAR 'firstValue: kotlin.Int declared in <root>.Operation.Add.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-firstValue> visibility:public modality:FINAL <> ($this:<root>.Operation.Add) returnType:kotlin.Int
correspondingProperty: PROPERTY name:firstValue visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Operation.Add
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-firstValue> (): kotlin.Int declared in <root>.Operation.Add'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:firstValue type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.Operation.Add declared in <root>.Operation.Add.<get-firstValue>' type=<root>.Operation.Add origin=null
PROPERTY name:secondValue visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:secondValue type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
GET_VAR 'secondValue: kotlin.Int declared in <root>.Operation.Add.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-secondValue> visibility:public modality:FINAL <> ($this:<root>.Operation.Add) returnType:kotlin.Int
correspondingProperty: PROPERTY name:secondValue visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Operation.Add
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-secondValue> (): kotlin.Int declared in <root>.Operation.Add'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:secondValue type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.Operation.Add declared in <root>.Operation.Add.<get-secondValue>' type=<root>.Operation.Add origin=null
CONSTRUCTOR visibility:public <> (firstValue:kotlin.Int, secondValue:kotlin.Int) returnType:<root>.Operation.Add [primary]
VALUE_PARAMETER name:firstValue index:0 type:kotlin.Int
VALUE_PARAMETER name:secondValue index:1 type:kotlin.Int
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'protected constructor <init> () [primary] declared in <root>.Operation'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[<root>.Operation]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Negate modality:FINAL visibility:public superTypes:[<root>.Operation]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Operation.Negate
PROPERTY name:value visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
GET_VAR 'value: kotlin.Int declared in <root>.Operation.Negate.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> ($this:<root>.Operation.Negate) returnType:kotlin.Int
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Operation.Negate
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-value> (): kotlin.Int declared in <root>.Operation.Negate'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.Operation.Negate declared in <root>.Operation.Negate.<get-value>' type=<root>.Operation.Negate origin=null
CONSTRUCTOR visibility:public <> (value:kotlin.Int) returnType:<root>.Operation.Negate [primary]
VALUE_PARAMETER name:value index:0 type:kotlin.Int
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'protected constructor <init> () [primary] declared in <root>.Operation'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Negate modality:FINAL visibility:public superTypes:[<root>.Operation]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Subtract modality:FINAL visibility:public superTypes:[<root>.Operation]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Operation.Subtract
PROPERTY name:minuend visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:minuend type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
GET_VAR 'minuend: kotlin.Int declared in <root>.Operation.Subtract.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-minuend> visibility:public modality:FINAL <> ($this:<root>.Operation.Subtract) returnType:kotlin.Int
correspondingProperty: PROPERTY name:minuend visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Operation.Subtract
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-minuend> (): kotlin.Int declared in <root>.Operation.Subtract'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:minuend type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.Operation.Subtract declared in <root>.Operation.Subtract.<get-minuend>' type=<root>.Operation.Subtract origin=null
PROPERTY name:subtrahend visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:subtrahend type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
GET_VAR 'subtrahend: kotlin.Int declared in <root>.Operation.Subtract.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-subtrahend> visibility:public modality:FINAL <> ($this:<root>.Operation.Subtract) returnType:kotlin.Int
correspondingProperty: PROPERTY name:subtrahend visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Operation.Subtract
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-subtrahend> (): kotlin.Int declared in <root>.Operation.Subtract'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:subtrahend type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.Operation.Subtract declared in <root>.Operation.Subtract.<get-subtrahend>' type=<root>.Operation.Subtract origin=null
CONSTRUCTOR visibility:public <> (minuend:kotlin.Int, subtrahend:kotlin.Int) returnType:<root>.Operation.Subtract [primary]
VALUE_PARAMETER name:minuend index:0 type:kotlin.Int
VALUE_PARAMETER name:subtrahend index:1 type:kotlin.Int
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'protected constructor <init> () [primary] declared in <root>.Operation'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Subtract modality:FINAL visibility:public superTypes:[<root>.Operation]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.Operation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CONSTRUCTOR visibility:protected <> () returnType:<root>.Operation [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Operation modality:SEALED visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Ordinary modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Ordinary
CONSTRUCTOR visibility:public <> () returnType:<root>.Ordinary [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Ordinary modality:ABSTRACT visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS ENUM_CLASS name:Direction modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.Direction>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Direction
CONSTRUCTOR visibility:private <> () returnType:<root>.Direction [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
<E>: <root>.Direction
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Direction modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.Direction>]'
ENUM_ENTRY name:EAST
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Direction'
ENUM_ENTRY name:NORTH
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Direction'
ENUM_ENTRY name:SOUTH
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Direction'
ENUM_ENTRY name:WEST
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Direction'
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.Direction
VALUE_PARAMETER name:value index:0 type:kotlin.String
SYNTHETIC_BODY kind=ENUM_VALUEOF
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.Direction>
SYNTHETIC_BODY kind=ENUM_VALUES
FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.Any [fake_override]
overridden:
protected final fun clone (): kotlin.Any declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>, other:<root>.Direction) returnType:kotlin.Int [fake_override,operator]
overridden:
public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
VALUE_PARAMETER name:other index:0 type:<root>.Direction
FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.Unit [fake_override]
overridden:
protected/*protected and package*/ final fun finalize (): kotlin.Unit declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:@[FlexibleNullability] java.lang.Class<@[FlexibleNullability] <root>.Direction?>? [fake_override]
overridden:
public final fun getDeclaringClass (): @[FlexibleNullability] java.lang.Class<@[FlexibleNullability] E of kotlin.Enum?>? declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.Int [fake_override]
overridden:
public final fun hashCode (): kotlin.Int declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
PROPERTY ENUM_CLASS_SPECIAL_MEMBER name:entries visibility:public modality:FINAL [val]
FUN ENUM_CLASS_SPECIAL_MEMBER name:<get-entries> visibility:public modality:FINAL <> () returnType:kotlin.enums.EnumEntries<<root>.Direction>
correspondingProperty: PROPERTY ENUM_CLASS_SPECIAL_MEMBER name:entries visibility:public modality:FINAL [val]
SYNTHETIC_BODY kind=ENUM_ENTRIES
PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
annotations:
IntrinsicConstEvaluation
overridden:
public final name: kotlin.String [val]
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.String [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val]
overridden:
public final fun <get-name> (): kotlin.String declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
overridden:
public final ordinal: kotlin.Int [val]
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<E of kotlin.Enum>) returnType:kotlin.Int [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val]
overridden:
public final fun <get-ordinal> (): kotlin.Int declared in kotlin.Enum
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<E of kotlin.Enum>
CLASS INTERFACE name:Intf modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Intf
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.Intf) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Intf
@@ -0,0 +1,22 @@
interface Intf {
fun run()
}
abstract class Ordinary
annotation class Anno
@Anno
class Generic<T> : Ordinary(), Intf {
override fun run() {}
}
enum class Direction {
NORTH, SOUTH, WEST, EAST
}
sealed class Operation {
class Add(val firstValue: Int, val secondValue: Int) : Operation()
class Subtract(val minuend: Int, val subtrahend: Int) : Operation()
class Negate(val value: Int) : Operation()
}
@@ -0,0 +1,72 @@
public annotation class Anno {
// source: 'classKinds.kt'
}
public final enum class Direction {
// source: 'classKinds.kt'
private synthetic final static field $ENTRIES: kotlin.enums.EnumEntries
private synthetic final static field $VALUES: Direction[]
public final enum static field EAST: Direction
public final enum static field NORTH: Direction
public final enum static field SOUTH: Direction
public final enum static field WEST: Direction
private synthetic final static method $values(): Direction[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method getEntries(): kotlin.enums.EnumEntries
public static method valueOf(p0: java.lang.String): Direction
public static method values(): Direction[]
}
public final class Generic {
// source: 'classKinds.kt'
public method <init>(): void
public method run(): void
}
public interface Intf {
// source: 'classKinds.kt'
public abstract method run(): void
}
public final class Operation$Add {
// source: 'classKinds.kt'
private final field firstValue: int
private final field secondValue: int
public method <init>(p0: int, p1: int): void
public final method getFirstValue(): int
public final method getSecondValue(): int
public final inner class Operation$Add
}
public final class Operation$Negate {
// source: 'classKinds.kt'
private final field value: int
public method <init>(p0: int): void
public final method getValue(): int
public final inner class Operation$Negate
}
public final class Operation$Subtract {
// source: 'classKinds.kt'
private final field minuend: int
private final field subtrahend: int
public method <init>(p0: int, p1: int): void
public final method getMinuend(): int
public final method getSubtrahend(): int
public final inner class Operation$Subtract
}
public abstract class Operation {
// source: 'classKinds.kt'
private method <init>(): void
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
public final inner class Operation$Add
public final inner class Operation$Negate
public final inner class Operation$Subtract
}
public abstract class Ordinary {
// source: 'classKinds.kt'
public method <init>(): void
}
@@ -0,0 +1,4 @@
ContextReceiver[name: Foo; isMutated: false; displayText: this@Foo]
context(R|Foo|)
fun call(): R|kotlin/Unit|
R|Foo|
@@ -0,0 +1,13 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Foo) returnType:kotlin.String
VALUE_PARAMETER name:p0 index:0 type:<root>.Foo
EXPRESSION_BODY
BLOCK type=kotlin.String origin=null
CALL 'public final fun <get-foo> (): kotlin.String declared in <root>.Foo' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR 'p0: <root>.Foo declared in <root>.CodeFragment.run' type=<root>.Foo origin=null
@@ -0,0 +1,12 @@
fun test() {
call(Foo())
}
context(Foo)
fun call() {
<caret>val x = 0
}
class Foo {
val foo: String = "foo"
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Foo): java.lang.String
}
@@ -0,0 +1,4 @@
ContextReceiver[name: Foo; isMutated: false; displayText: this@Foo]
context(R|Foo|)
fun call(): R|kotlin/Unit|
R|Foo|
@@ -0,0 +1,13 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Foo) returnType:kotlin.String
VALUE_PARAMETER name:p0 index:0 type:<root>.Foo
EXPRESSION_BODY
BLOCK type=kotlin.String origin=null
CALL 'public final fun <get-foo> (): kotlin.String declared in <root>.Foo' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR 'p0: <root>.Foo declared in <root>.CodeFragment.run' type=<root>.Foo origin=null
@@ -0,0 +1,12 @@
fun test() {
call(Foo())
}
context(Foo)
fun call() {
<caret>val x = 0
}
class Foo {
val foo: String = "foo"
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Foo): java.lang.String
}
@@ -0,0 +1,6 @@
ExtensionReceiver[name: with; isMutated: false; displayText: this@with]
with@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE>
R|kotlin/String|
ExtensionReceiver[name: with; isMutated: false; displayText: this@with]
with@fun R|Foo|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE>
R|Foo|
@@ -0,0 +1,18 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.String, p1:<root>.Foo) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:kotlin.String
VALUE_PARAMETER name:p1 index:1 type:<root>.Foo
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
$this: CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'p0: kotlin.String declared in <root>.CodeFragment.run' type=kotlin.String origin=null
other: CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: CALL 'public final fun <get-foo> (): kotlin.String declared in <root>.Foo' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR 'p1: <root>.Foo declared in <root>.CodeFragment.run' type=<root>.Foo origin=null
@@ -0,0 +1,11 @@
fun test() {
with("Hello, world!") {
with(Foo()) {
<caret>val x = 0
}
}
}
class Foo {
val foo: String = "foo"
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: java.lang.String, p1: Foo): int
}
@@ -0,0 +1,3 @@
ExtensionReceiver[name: with; isMutated: false; displayText: this@with]
with@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE>
R|kotlin/String|
@@ -0,0 +1,13 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.String) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:kotlin.String
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'p0: kotlin.String declared in <root>.CodeFragment.run' type=kotlin.String origin=null
@@ -0,0 +1,5 @@
fun test() {
with("Hello, world!") {
<caret>val x = 0
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: java.lang.String): int
}
@@ -0,0 +1,3 @@
ExtensionReceiver[name: str; isMutated: false; displayText: this@str]
str@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE>
R|kotlin/String|
@@ -0,0 +1,13 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.String) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:kotlin.String
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'p0: kotlin.String declared in <root>.CodeFragment.run' type=kotlin.String origin=null
@@ -0,0 +1,5 @@
fun test() {
with("Hello, world!") str@{
<caret>val x = 0
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: java.lang.String): int
}
@@ -0,0 +1,6 @@
Local[name: a; isMutated: false; displayText: a]
a: R|kotlin/Int|
R|kotlin/Int|
Local[name: b; isMutated: false; displayText: b]
b: R|kotlin/String|
R|kotlin/String|
@@ -0,0 +1,16 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Int, p1:kotlin.String) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
VALUE_PARAMETER name:p1 index:1 type:kotlin.String
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
$this: GET_VAR 'p0: kotlin.Int declared in <root>.CodeFragment.run' type=kotlin.Int origin=null
other: CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'p1: kotlin.String declared in <root>.CodeFragment.run' type=kotlin.String origin=null
@@ -0,0 +1,5 @@
class Foo(a: Int, b: String) {
init {
<caret>val x = 0
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: int, p1: java.lang.String): int
}
@@ -0,0 +1,3 @@
Local[name: x; isMutated: false; displayText: x]
lval x: R|kotlin/Int|
R|kotlin/Int|
@@ -0,0 +1,12 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
GET_VAR 'p0: kotlin.Int declared in <root>.CodeFragment.run' type=kotlin.Int origin=null
@@ -0,0 +1,4 @@
fun test() {
val x = 0
<caret>val y = 0
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: int): int
}
@@ -0,0 +1,9 @@
LocalFunction[name: call; isMutated: false; displayText: call]
fun call(a: R|kotlin/Int|, b: R|kotlin/String|): R|kotlin/Unit|
R|(kotlin/Int, kotlin/String) -> kotlin/Unit|
Local[name: x; isMutated: false; displayText: x]
lval x: R|kotlin/Int|
R|kotlin/Int|
Local[name: y; isMutated: false; displayText: y]
lval y: R|kotlin/String|
R|kotlin/String|
@@ -0,0 +1,31 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/localFunction.kt
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
FUN LOCAL_FUNCTION name:call visibility:local modality:FINAL <> (a:kotlin.Int, b:kotlin.String) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Int
VALUE_PARAMETER name:b index:1 type:kotlin.String
BLOCK_BODY
CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null
message: CALL 'public final fun repeat (n: kotlin.Int): kotlin.String declared in kotlin.text' type=kotlin.String origin=null
$receiver: GET_VAR 'b: kotlin.String declared in <root>.test.call' type=kotlin.String origin=null
n: GET_VAR 'a: kotlin.Int declared in <root>.test.call' type=kotlin.Int origin=null
VAR name:x type:kotlin.Int [val]
CONST Int type=kotlin.Int value=2
VAR name:y type:kotlin.String [val]
CONST String type=kotlin.String value="foo"
VAR name:z type:kotlin.Unit [val]
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit>, p1:kotlin.Int, p2:kotlin.String) returnType:kotlin.Unit
VALUE_PARAMETER name:p0 index:0 type:kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit>
VALUE_PARAMETER name:p1 index:1 type:kotlin.Int
VALUE_PARAMETER name:p2 index:2 type:kotlin.String
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
GET_VAR 'p0: kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit> declared in <root>.CodeFragment.run' type=kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit> origin=null
@@ -0,0 +1,9 @@
fun test() {
fun call(a: Int, b: String) {
println(b.repeat(a))
}
val x = 2
val y = "foo"
<caret>val z = Unit
}
@@ -0,0 +1,7 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: kotlin.jvm.functions.Function2, p1: int, p2: java.lang.String): void
}
public final class LocalFunctionKt
@@ -0,0 +1,3 @@
Local[name: x; isMutated: true; displayText: x]
lvar x: R|kotlin/Int|
R|kotlin/Int|
@@ -0,0 +1,13 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:generated_for_debugger_fun visibility:public modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER SHARED_VARIABLE_IN_EVALUATOR_FRAGMENT name:p0 index:0 type:kotlin.Int [assignable]
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
SET_VAR 'p0: kotlin.Int [assignable] declared in <root>.CodeFragment.generated_for_debugger_fun' type=kotlin.Unit origin=null
CONST Int type=kotlin.Int value=1
@@ -0,0 +1,7 @@
fun test() {
var x = 0
<caret>val y = 0
}
// FragmentSharedVariablesLowering depends on a specific function name
// CODE_FRAGMENT_METHOD_NAME: generated_for_debugger_fun
@@ -0,0 +1,6 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method generated_for_debugger_fun(p0: kotlin.jvm.internal.Ref$IntRef): void
public final inner class kotlin/jvm/internal/Ref$IntRef
}
@@ -0,0 +1,6 @@
ContainingClass[name: <this>; isMutated: false; displayText: this@Foo]
class Foo : R|kotlin/Any|
R|Foo|
ContainingClass[name: <this>; isMutated: false; displayText: this@Bar]
class Bar : R|kotlin/Any|
R|Foo.Bar|
@@ -0,0 +1 @@
callFoo(this@Foo) + callString(a) + callString(b)
@@ -0,0 +1,22 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Foo, p1:<root>.Foo.Bar) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:<root>.Foo
VALUE_PARAMETER name:p1 index:1 type:<root>.Foo.Bar
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
$this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
$this: CALL 'public final fun callFoo (foo: <root>.Foo): kotlin.Int declared in <root>.NestedOuterClassKt' type=kotlin.Int origin=null
foo: GET_VAR 'p0: <root>.Foo declared in <root>.CodeFragment.run' type=<root>.Foo origin=null
other: CALL 'public final fun callString (string: kotlin.String): kotlin.Int declared in <root>.NestedOuterClassKt' type=kotlin.Int origin=null
string: CALL 'private final fun <get-a> (): kotlin.String declared in <root>.Foo' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR 'p0: <root>.Foo declared in <root>.CodeFragment.run' type=<root>.Foo origin=null
other: CALL 'public final fun callString (string: kotlin.String): kotlin.Int declared in <root>.NestedOuterClassKt' type=kotlin.Int origin=null
string: CALL 'private final fun <get-b> (): kotlin.String declared in <root>.Foo.Bar' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR 'p1: <root>.Foo.Bar declared in <root>.CodeFragment.run' type=<root>.Foo.Bar origin=null
@@ -0,0 +1,19 @@
class Foo {
private val a: String = "foo"
inner class Bar {
private val b: String = "bar"
fun test() {
<caret>val x = 0
}
}
}
fun callFoo(foo: Foo): Int {
return 0
}
fun callString(string: String): Int {
return 1
}
@@ -0,0 +1,6 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Foo, p1: Foo$Bar): int
public final inner class Foo$Bar
}
@@ -0,0 +1,12 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> () returnType:kotlin.Unit
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
CALL 'public final fun call (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.Foo
@@ -0,0 +1,7 @@
object Foo {
fun test() {
<caret>val x = 0
}
fun call() {}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(): void
}
@@ -0,0 +1,3 @@
ContainingClass[name: <this>; isMutated: false; displayText: this@Test]
class Test : R|kotlin/Any|
R|Test|
@@ -0,0 +1,14 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Test) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:<root>.Test
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: CALL 'public final fun <get-a> (): kotlin.String declared in <root>.Test' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR 'p0: <root>.Test declared in <root>.CodeFragment.run' type=<root>.Test origin=null
@@ -0,0 +1,7 @@
class Test {
val a: String = "foo"
fun test() {
<caret>val x = 0
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Test): int
}
@@ -0,0 +1,3 @@
ContainingClass[name: <this>; isMutated: false; displayText: this@Test]
class Test : R|kotlin/Any|
R|Test|
@@ -0,0 +1,14 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Test) returnType:kotlin.Unit
VALUE_PARAMETER name:p0 index:0 type:<root>.Test
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
CALL 'public final fun <set-a> (value: kotlin.String): kotlin.Unit declared in <root>.Test' type=kotlin.Unit origin=EQ
$this: GET_VAR 'p0: <root>.Test declared in <root>.CodeFragment.run' type=<root>.Test origin=null
value: CONST String type=kotlin.String value="bar"
@@ -0,0 +1,7 @@
class Test {
var a: String = "foo"
fun test() {
<caret>val x = 0
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Test): void
}
@@ -0,0 +1,3 @@
ContainingClass[name: <this>; isMutated: false; displayText: this@Test]
class Test : R|kotlin/Any|
R|Test|
@@ -0,0 +1,14 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Test) returnType:kotlin.Unit
VALUE_PARAMETER name:p0 index:0 type:<root>.Test
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
CALL 'private final fun <set-a> (value: kotlin.String): kotlin.Unit declared in <root>.Test' type=kotlin.Unit origin=EQ
$this: GET_VAR 'p0: <root>.Test declared in <root>.CodeFragment.run' type=<root>.Test origin=null
value: CONST String type=kotlin.String value="bar"
@@ -0,0 +1,7 @@
class Test {
private var a: String = "foo"
fun test() {
<caret>val x = 0
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Test): void
}
@@ -0,0 +1,3 @@
Local[name: foo; isMutated: false; displayText: foo]
foo: R|Foo?|
R|Foo?|
@@ -0,0 +1,24 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Foo?) returnType:kotlin.Unit?
VALUE_PARAMETER name:p0 index:0 type:<root>.Foo?
EXPRESSION_BODY
BLOCK type=kotlin.Unit? origin=null
BLOCK type=kotlin.Unit? origin=SAFE_CALL
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.Foo? [val]
GET_VAR 'p0: <root>.Foo? declared in <root>.CodeFragment.run' type=<root>.Foo? origin=null
WHEN type=kotlin.Unit? origin=null
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_0: <root>.Foo? [val] declared in <root>.CodeFragment.run' type=<root>.Foo? origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Null type=kotlin.Nothing? value=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public final fun call (): kotlin.Unit declared in <root>.Foo' type=kotlin.Unit origin=null
$this: GET_VAR 'val tmp_0: <root>.Foo? [val] declared in <root>.CodeFragment.run' type=<root>.Foo? origin=null
@@ -0,0 +1,7 @@
fun test(foo: Foo?) {
<caret>val x = 0
}
class Foo {
fun call() {}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Foo): kotlin.Unit
}
@@ -0,0 +1,11 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:MyCodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyCodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.MyCodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:invoke visibility:public modality:FINAL <> () returnType:kotlin.String
EXPRESSION_BODY
BLOCK type=kotlin.String origin=null
CONST String type=kotlin.String value="foo"
@@ -0,0 +1,6 @@
fun test() {
<caret>val x = 0
}
// CODE_FRAGMENT_CLASS_NAME: MyCodeFragment
// CODE_FRAGMENT_METHOD_NAME: invoke
@@ -0,0 +1,5 @@
public final class MyCodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method invoke(): java.lang.String
}
@@ -0,0 +1 @@
TreeSet(File("foo").readLines())
@@ -0,0 +1,15 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> () returnType:java.util.TreeSet<@[FlexibleNullability] kotlin.String?>
EXPRESSION_BODY
BLOCK type=java.util.TreeSet<@[FlexibleNullability] kotlin.String?> origin=null
CONSTRUCTOR_CALL 'public constructor <init> (p0: @[FlexibleNullability] @[FlexibleMutability] kotlin.collections.MutableCollection<out @[FlexibleNullability] E of java.util.TreeSet?>?) declared in java.util.TreeSet' type=java.util.TreeSet<@[FlexibleNullability] kotlin.String?> origin=null
<class: E>: @[FlexibleNullability] kotlin.String?
p0: CALL 'public final fun readLines (charset: java.nio.charset.Charset): kotlin.collections.List<kotlin.String> declared in kotlin.io' type=kotlin.collections.List<kotlin.String> origin=null
$receiver: CONSTRUCTOR_CALL 'public constructor <init> (p0: @[FlexibleNullability] kotlin.String?) declared in java.io.File' type=java.io.File origin=null
p0: CONST String type=kotlin.String value="foo"
@@ -0,0 +1,7 @@
import java.util.TreeSet
fun test() {
<caret>val x = 0
}
// CODE_FRAGMENT_IMPORT: java.io.File
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(): java.util.TreeSet
}
@@ -0,0 +1,4 @@
listOf(1, 2, 3, 4, 5)
.filter { (it % 2) == 0 }
.map { it * 2 }
.forEach { System.out.println(it) }
@@ -0,0 +1,50 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> () returnType:kotlin.Unit
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
CALL 'public final fun forEach <T> (action: kotlin.Function1<T of kotlin.collections.forEach, kotlin.Unit>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
<T>: kotlin.Int
$receiver: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.map, R of kotlin.collections.map>): kotlin.collections.List<R of kotlin.collections.map> [inline] declared in kotlin.collections' type=kotlin.collections.List<kotlin.Int> origin=null
<T>: kotlin.Int
<R>: kotlin.Int
$receiver: CALL 'public final fun filter <T> (predicate: kotlin.Function1<T of kotlin.collections.filter, kotlin.Boolean>): kotlin.collections.List<T of kotlin.collections.filter> [inline] declared in kotlin.collections' type=kotlin.collections.List<kotlin.Int> origin=null
<T>: kotlin.Int
$receiver: CALL 'public final fun listOf <T> (vararg elements: T of kotlin.collections.listOf): kotlin.collections.List<T of kotlin.collections.listOf> declared in kotlin.collections' type=kotlin.collections.List<kotlin.Int> origin=null
<T>: kotlin.Int
elements: VARARG type=kotlin.Array<out kotlin.Int> varargElementType=kotlin.Int
CONST Int type=kotlin.Int value=1
CONST Int type=kotlin.Int value=2
CONST Int type=kotlin.Int value=3
CONST Int type=kotlin.Int value=4
CONST Int type=kotlin.Int value=5
predicate: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Boolean> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Boolean
VALUE_PARAMETER name:it index:0 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.Int): kotlin.Boolean declared in <root>.CodeFragment.run'
CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: CALL 'public final fun rem (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PERC
$this: GET_VAR 'it: kotlin.Int declared in <root>.CodeFragment.run.<anonymous>' type=kotlin.Int origin=null
other: CONST Int type=kotlin.Int value=2
arg1: CONST Int type=kotlin.Int value=0
transform: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int
VALUE_PARAMETER name:it index:0 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.Int): kotlin.Int declared in <root>.CodeFragment.run'
CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL
$this: GET_VAR 'it: kotlin.Int declared in <root>.CodeFragment.run.<anonymous>' type=kotlin.Int origin=null
other: CONST Int type=kotlin.Int value=2
action: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER name:it index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.Int): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:@[FlexibleNullability] java.io.PrintStream? visibility:public [final,static]' type=@[FlexibleNullability] java.io.PrintStream? origin=GET_PROPERTY
p0: GET_VAR 'it: kotlin.Int declared in <root>.CodeFragment.run.<anonymous>' type=kotlin.Int origin=null
@@ -0,0 +1,3 @@
fun test() {
<caret>val x = 0
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(): void
}
@@ -0,0 +1,32 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/inlineFunctionUsageSource.kt
FUN name:call visibility:public modality:FINAL <> (block:kotlin.Function1<kotlin.Int, kotlin.Int>) returnType:kotlin.Unit [inline]
VALUE_PARAMETER name:block index:0 type:kotlin.Function1<kotlin.Int, kotlin.Int>
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.Int): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:@[FlexibleNullability] java.io.PrintStream? visibility:public [final,static]' type=@[FlexibleNullability] java.io.PrintStream? origin=GET_PROPERTY
p0: CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 [operator] declared in kotlin.Function1' type=kotlin.Int origin=INVOKE
$this: GET_VAR 'block: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.call' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=VARIABLE_AS_FUNCTION
p1: CONST Int type=kotlin.Int value=5
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:x type:kotlin.Int [val]
CONST Int type=kotlin.Int value=0
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> () returnType:kotlin.Unit
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
CALL 'public final fun call (block: kotlin.Function1<kotlin.Int, kotlin.Int>): kotlin.Unit [inline] declared in <root>' type=kotlin.Unit origin=null
block: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int
VALUE_PARAMETER name:it index:0 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.Int): kotlin.Int declared in <root>.CodeFragment.run'
CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL
$this: GET_VAR 'it: kotlin.Int declared in <root>.CodeFragment.run.<anonymous>' type=kotlin.Int origin=null
other: CONST Int type=kotlin.Int value=2

Some files were not shown because too many files have changed in this diff Show More