diff --git a/build.gradle.kts b/build.gradle.kts index 88ef1820899..3c0eb8a6deb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -230,6 +230,7 @@ extra["compilerModules"] = arrayOf( ":compiler:frontend", ":compiler:frontend.common", ":compiler:frontend.java", + ":compiler:frontend:cfg", ":compiler:cli-common", ":compiler:ir.tree", ":compiler:ir.tree.impl", diff --git a/compiler/cli/build.gradle.kts b/compiler/cli/build.gradle.kts index 4b625d46d34..cbe53c0babf 100644 --- a/compiler/cli/build.gradle.kts +++ b/compiler/cli/build.gradle.kts @@ -8,6 +8,7 @@ dependencies { compile(project(":compiler:cli-common")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) + compile(project(":compiler:frontend:cfg")) compile(project(":compiler:backend-common")) compile(project(":compiler:backend")) compile(project(":compiler:backend.jvm")) diff --git a/compiler/cli/src/org/jetbrains/kotlin/resolve/CompilerEnvironment.kt b/compiler/cli/src/org/jetbrains/kotlin/resolve/CompilerEnvironment.kt index 43d90bf5368..81d3bd3f454 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/resolve/CompilerEnvironment.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/resolve/CompilerEnvironment.kt @@ -5,10 +5,13 @@ package org.jetbrains.kotlin.resolve +import org.jetbrains.kotlin.cfg.ControlFlowInformationProviderImpl import org.jetbrains.kotlin.container.StorageComponentContainer +import org.jetbrains.kotlin.container.useInstance object CompilerEnvironment : TargetEnvironment("Compiler") { override fun configure(container: StorageComponentContainer) { configureCompilerEnvironment(container) + container.useInstance(ControlFlowInformationProviderImpl.Factory) } } diff --git a/compiler/frontend/cfg/build.gradle.kts b/compiler/frontend/cfg/build.gradle.kts new file mode 100644 index 00000000000..e76386cf74b --- /dev/null +++ b/compiler/frontend/cfg/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + compile(project(":compiler:frontend")) + compileOnly(intellijCoreDep()) { includeJars("intellij-core") } + compileOnly(intellijDep()) { includeJars("guava", rootProject = rootProject) } +} + +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/BlockInfo.java b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/BlockInfo.java similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/BlockInfo.java rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/BlockInfo.java diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/BreakableBlockInfo.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/BreakableBlockInfo.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/BreakableBlockInfo.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/BreakableBlockInfo.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ConstructorConsistencyChecker.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ConstructorConsistencyChecker.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/ConstructorConsistencyChecker.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ConstructorConsistencyChecker.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowBuilder.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowBuilder.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowBuilder.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowBuilder.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowBuilderAdapter.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowBuilderAdapter.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowBuilderAdapter.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowBuilderAdapter.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt similarity index 98% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt index 07e72d2ee93..277f14cde72 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt +++ b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt @@ -63,14 +63,13 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import org.jetbrains.kotlin.types.isFlexible import org.jetbrains.kotlin.util.OperatorNameConventions -class ControlFlowInformationProvider private constructor( +class ControlFlowInformationProviderImpl private constructor( private val subroutine: KtElement, private val trace: BindingTrace, private val pseudocode: Pseudocode, private val languageVersionSettings: LanguageVersionSettings, private val diagnosticSuppressor: PlatformDiagnosticSuppressor -) { - +) : ControlFlowInformationProvider { private val pseudocodeVariablesData by lazy { PseudocodeVariablesData(pseudocode, trace.bindingContext) } @@ -88,14 +87,14 @@ class ControlFlowInformationProvider private constructor( diagnosticSuppressor ) - fun checkForLocalClassOrObjectMode() { + override fun checkForLocalClassOrObjectMode() { // Local classes and objects are analyzed twice: when TopDownAnalyzer processes it and as a part of its container. // Almost all checks can be done when the container is analyzed // except recording initialized variables (this information is needed for DeclarationChecker). recordInitializedVariables() } - fun checkDeclaration() { + override fun checkDeclaration() { recordInitializedVariables() @@ -123,7 +122,7 @@ class ControlFlowInformationProvider private constructor( checkConstructorConsistency() } - fun checkFunction(expectedReturnType: KotlinType?) { + override fun checkFunction(expectedReturnType: KotlinType?) { val unreachableCode = collectUnreachableCode() reportUnreachableCode(unreachableCode) @@ -235,7 +234,7 @@ class ControlFlowInformationProvider private constructor( val functionDescriptor = trace.bindingContext.get(DECLARATION_TO_DESCRIPTOR, element) as? CallableDescriptor val expectedType = functionDescriptor?.returnType - val providerForLocalDeclaration = ControlFlowInformationProvider( + val providerForLocalDeclaration = ControlFlowInformationProviderImpl( element, trace, localDeclarationInstruction.body, languageVersionSettings, diagnosticSuppressor ) @@ -1122,7 +1121,7 @@ class ControlFlowInformationProvider private constructor( KtTryExpression::class.java, KtFunction::class.java, KtAnonymousInitializer::class.java ) is KtTryExpression - private fun CallInstruction.isTailCall(subroutine: KtElement = this@ControlFlowInformationProvider.subroutine): Boolean { + private fun CallInstruction.isTailCall(subroutine: KtElement = this@ControlFlowInformationProviderImpl.subroutine): Boolean { val tailInstructionDetector = TailInstructionDetector(subroutine) return traverseFollowingInstructions( this, @@ -1221,6 +1220,16 @@ class ControlFlowInformationProvider private constructor( map: MutableMap> ) : VariableContext(instruction, map) + object Factory : ControlFlowInformationProvider.Factory { + override fun createControlFlowInformationProvider( + declaration: KtElement, + trace: BindingTrace, + languageVersionSettings: LanguageVersionSettings, + diagnosticSuppressor: PlatformDiagnosticSuppressor + ): ControlFlowInformationProvider = + ControlFlowInformationProviderImpl(declaration, trace, languageVersionSettings, diagnosticSuppressor) + } + companion object { private fun isUsedAsResultOfLambda(usages: List): Boolean { for (usage in usages) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/GenerationTrigger.java b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/GenerationTrigger.java similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/GenerationTrigger.java rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/GenerationTrigger.java diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/Label.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/Label.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/Label.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/Label.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/LoopInfo.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/LoopInfo.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/LoopInfo.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/LoopInfo.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/SubroutineInfo.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/SubroutineInfo.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/SubroutineInfo.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/SubroutineInfo.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/TailInstructionDetector.java b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/TailInstructionDetector.java similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/TailInstructionDetector.java rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/TailInstructionDetector.java diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValueImpl.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValueImpl.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValueImpl.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValueImpl.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeLabel.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/BlockScope.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/BlockScope.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/BlockScope.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/BlockScope.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnNoValueInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnNoValueInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnNoValueInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnNoValueInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnValueInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnValueInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnValueInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ReturnValueInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ThrowExceptionInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ThrowExceptionInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ThrowExceptionInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ThrowExceptionInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/UnconditionalJumpInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/UnconditionalJumpInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/UnconditionalJumpInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/UnconditionalJumpInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/InlinedLocalFunctionDeclarationInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/InlinedLocalFunctionDeclarationInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/InlinedLocalFunctionDeclarationInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/InlinedLocalFunctionDeclarationInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/LocalFunctionDeclarationInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/LocalFunctionDeclarationInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/LocalFunctionDeclarationInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/LocalFunctionDeclarationInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/MarkInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/MarkInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/MarkInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/MarkInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineEnterInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineEnterInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineEnterInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineEnterInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineExitInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineExitInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineExitInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineExitInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineSinkInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineSinkInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineSinkInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/SubroutineSinkInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/VariableDeclarationInstruction.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/VariableDeclarationInstruction.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/VariableDeclarationInstruction.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/special/VariableDeclarationInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariableDataCollector.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariableDataCollector.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariableDataCollector.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariableDataCollector.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariablesData.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariablesData.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariablesData.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/variable/PseudocodeVariablesData.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/variable/VariableControlFlowInfo.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/variable/VariableControlFlowInfo.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/cfg/variable/VariableControlFlowInfo.kt rename to compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/variable/VariableControlFlowInfo.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt new file mode 100644 index 00000000000..69b753c35eb --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2020 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.cfg + +import org.jetbrains.kotlin.config.LanguageVersionSettings +import org.jetbrains.kotlin.psi.KtElement +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.checkers.PlatformDiagnosticSuppressor +import org.jetbrains.kotlin.types.KotlinType + +interface ControlFlowInformationProvider { + fun checkForLocalClassOrObjectMode() + + fun checkDeclaration() + + fun checkFunction(expectedReturnType: KotlinType?) + + interface Factory { + fun createControlFlowInformationProvider( + declaration: KtElement, + trace: BindingTrace, + languageVersionSettings: LanguageVersionSettings, + diagnosticSuppressor: PlatformDiagnosticSuppressor, + ): ControlFlowInformationProvider + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt b/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt index 17ddfc664f4..d724f3b0de9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.frontend.di +import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.isTypeRefinementEnabled import org.jetbrains.kotlin.container.StorageComponentContainer @@ -136,6 +137,7 @@ fun createContainerForBodyResolve( languageVersionSettings: LanguageVersionSettings, moduleStructureOracle: ModuleStructureOracle, sealedProvider: SealedClassInheritorsProvider, + controlFlowInformationProviderFactory: ControlFlowInformationProvider.Factory, ): StorageComponentContainer = createContainer("BodyResolve", analyzerServices) { configureModule(moduleContext, platform, analyzerServices, bindingTrace, languageVersionSettings, sealedProvider) @@ -146,6 +148,7 @@ fun createContainerForBodyResolve( useImpl() useInstance(moduleStructureOracle) + useInstance(controlFlowInformationProviderFactory) } fun createContainerForLazyBodyResolve( @@ -159,6 +162,7 @@ fun createContainerForLazyBodyResolve( moduleStructureOracle: ModuleStructureOracle, mainFunctionDetectorFactory: MainFunctionDetector.Factory, sealedProvider: SealedClassInheritorsProvider, + controlFlowInformationProviderFactory: ControlFlowInformationProvider.Factory, ): StorageComponentContainer = createContainer("LazyBodyResolve", analyzerServices) { configureModule(moduleContext, platform, analyzerServices, bindingTrace, languageVersionSettings, sealedProvider) useInstance(mainFunctionDetectorFactory) @@ -169,6 +173,7 @@ fun createContainerForLazyBodyResolve( useImpl() useImpl() useInstance(moduleStructureOracle) + useInstance(controlFlowInformationProviderFactory) // All containers except common inject ExpectedActualDeclarationChecker, so for common we do that // explicitly. @@ -185,7 +190,8 @@ fun createContainerForLazyLocalClassifierAnalyzer( languageVersionSettings: LanguageVersionSettings, statementFilter: StatementFilter, localClassDescriptorHolder: LocalClassDescriptorHolder, - analyzerServices: PlatformDependentAnalyzerServices + analyzerServices: PlatformDependentAnalyzerServices, + controlFlowInformationProviderFactory: ControlFlowInformationProvider.Factory, ): StorageComponentContainer = createContainer("LocalClassifierAnalyzer", analyzerServices) { configureModule(moduleContext, platform, analyzerServices, bindingTrace, languageVersionSettings) @@ -198,6 +204,7 @@ fun createContainerForLazyLocalClassifierAnalyzer( useInstance(NoTopLevelDescriptorProvider) TargetEnvironment.configureCompilerEnvironment(this) + useInstance(controlFlowInformationProviderFactory) useInstance(FileScopeProvider.ThrowException) useImpl() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java index a396915894e..9652a7cc513 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java @@ -37,17 +37,20 @@ public class ControlFlowAnalyzer { private final KotlinBuiltIns builtIns; private final LanguageVersionSettings languageVersionSettings; private final PlatformDiagnosticSuppressor diagnosticSuppressor; + private final ControlFlowInformationProvider.Factory controlFlowInformationProviderFactory; public ControlFlowAnalyzer( @NotNull BindingTrace trace, @NotNull KotlinBuiltIns builtIns, @NotNull LanguageVersionSettings languageVersionSettings, - @NotNull PlatformDiagnosticSuppressor diagnosticSuppressor + @NotNull PlatformDiagnosticSuppressor diagnosticSuppressor, + @NotNull ControlFlowInformationProvider.Factory controlFlowInformationProviderFactory ) { this.trace = trace; this.builtIns = builtIns; this.languageVersionSettings = languageVersionSettings; this.diagnosticSuppressor = diagnosticSuppressor; + this.controlFlowInformationProviderFactory = controlFlowInformationProviderFactory; } public void process(@NotNull BodiesResolveContext c) { @@ -80,7 +83,9 @@ public class ControlFlowAnalyzer { private void checkSecondaryConstructor(@NotNull KtSecondaryConstructor constructor) { ControlFlowInformationProvider controlFlowInformationProvider = - new ControlFlowInformationProvider(constructor, trace, languageVersionSettings, diagnosticSuppressor); + controlFlowInformationProviderFactory.createControlFlowInformationProvider( + constructor, trace, languageVersionSettings, diagnosticSuppressor + ); controlFlowInformationProvider.checkDeclaration(); controlFlowInformationProvider.checkFunction(builtIns.getUnitType()); } @@ -88,9 +93,10 @@ public class ControlFlowAnalyzer { private void checkDeclarationContainer(@NotNull BodiesResolveContext c, KtDeclarationContainer declarationContainer) { // A pseudocode of class/object initialization corresponds to a class/object // or initialization of properties corresponds to a package declared in a file - ControlFlowInformationProvider controlFlowInformationProvider = new ControlFlowInformationProvider( - (KtElement) declarationContainer, trace, languageVersionSettings, diagnosticSuppressor - ); + ControlFlowInformationProvider controlFlowInformationProvider = + controlFlowInformationProviderFactory.createControlFlowInformationProvider( + (KtElement) declarationContainer, trace, languageVersionSettings, diagnosticSuppressor + ); if (c.getTopDownAnalysisMode().isLocalDeclarations()) { controlFlowInformationProvider.checkForLocalClassOrObjectMode(); return; @@ -113,7 +119,9 @@ public class ControlFlowAnalyzer { @NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KotlinType expectedReturnType ) { ControlFlowInformationProvider controlFlowInformationProvider = - new ControlFlowInformationProvider(function, trace, languageVersionSettings, diagnosticSuppressor); + controlFlowInformationProviderFactory.createControlFlowInformationProvider( + function, trace, languageVersionSettings, diagnosticSuppressor + ); if (c.getTopDownAnalysisMode().isLocalDeclarations()) { controlFlowInformationProvider.checkForLocalClassOrObjectMode(); return; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt index 1588c983802..476aaf7f2af 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.types.expressions import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.context.GlobalContext @@ -71,7 +72,8 @@ class LocalClassifierAnalyzer( private val kotlinTypeChecker: NewKotlinTypeChecker, private val samConversionResolver: SamConversionResolver, private val additionalClassPartsProvider: AdditionalClassPartsProvider, - private val sealedClassInheritorsProvider: SealedClassInheritorsProvider + private val sealedClassInheritorsProvider: SealedClassInheritorsProvider, + private val controlFlowInformationProviderFactory: ControlFlowInformationProvider.Factory, ) { fun processClassOrObject( scope: LexicalWritableScope?, @@ -110,7 +112,8 @@ class LocalClassifierAnalyzer( additionalClassPartsProvider, sealedClassInheritorsProvider ), - analyzerServices + analyzerServices, + controlFlowInformationProviderFactory, ) container.get().analyzeDeclarations( @@ -185,7 +188,8 @@ class LocalClassDescriptorHolder( override val samConversionResolver: SamConversionResolver = this@LocalClassDescriptorHolder.samConversionResolver override val additionalClassPartsProvider: AdditionalClassPartsProvider = this@LocalClassDescriptorHolder.additionalClassPartsProvider - override val sealedClassInheritorsProvider: SealedClassInheritorsProvider = this@LocalClassDescriptorHolder.sealedClassInheritorsProvider + override val sealedClassInheritorsProvider: SealedClassInheritorsProvider = + this@LocalClassDescriptorHolder.sealedClassInheritorsProvider }, containingDeclaration, classOrObject.nameAsSafeName, diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/tests/di/injection.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/tests/di/injection.kt index fe5e700ebe9..3fbd52be2f7 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/tests/di/injection.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/tests/di/injection.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.tests.di import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.cfg.ControlFlowInformationProviderImpl import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.getValue @@ -43,6 +44,7 @@ fun createContainerForTests(project: Project, module: ModuleDescriptor): Contain ) useImpl() useInstance(ModuleStructureOracle.SingleModule) + useInstance(ControlFlowInformationProviderImpl.Factory) }) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/PerFileAnalysisCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/PerFileAnalysisCache.kt index dd57d976184..24e2bad310b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/PerFileAnalysisCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/PerFileAnalysisCache.kt @@ -16,6 +16,7 @@ import com.intellij.openapi.util.ModificationTracker import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.analyzer.AnalysisResult +import org.jetbrains.kotlin.cfg.ControlFlowInformationProviderImpl import org.jetbrains.kotlin.container.ComponentProvider import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.context.GlobalContext @@ -47,7 +48,6 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice import org.jetbrains.kotlin.util.slicedMap.WritableSlice import org.jetbrains.kotlin.utils.checkWithAttachment -import java.util.* import java.util.concurrent.locks.ReentrantLock internal class PerFileAnalysisCache(val file: KtFile, componentProvider: ComponentProvider) { @@ -484,8 +484,9 @@ private object KotlinResolveDataProvider { analyzableElement.languageVersionSettings, IdeaModuleStructureOracle(), IdeMainFunctionDetectorFactory(), - IdeSealedClassInheritorsProvider - ).get() + IdeSealedClassInheritorsProvider, + ControlFlowInformationProviderImpl.Factory, + ).get() lazyTopDownAnalyzer.analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, listOf(analyzableElement)) } finally { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/util/ControlFlowUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/util/ControlFlowUtils.kt index 8ab2efd620a..4de3dd8f8d3 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/util/ControlFlowUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/util/ControlFlowUtils.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.idea.caches.resolve.util -import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider +import org.jetbrains.kotlin.cfg.ControlFlowInformationProviderImpl import org.jetbrains.kotlin.idea.project.languageVersionSettings import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.BindingTrace @@ -16,7 +16,7 @@ fun analyzeControlFlow(resolveSession: ResolveSession, resolveElement: KtElement val controlFlowTrace = DelegatingBindingTrace( trace.bindingContext, "Element control flow resolve", resolveElement, allowSliceRewrite = true ) - ControlFlowInformationProvider( + ControlFlowInformationProviderImpl( resolveElement, controlFlowTrace, resolveElement.languageVersionSettings, resolveSession.platformDiagnosticSuppressor ).checkDeclaration() controlFlowTrace.addOwnDataTo(trace, null, false) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt index 282af7e272d..045509bf04b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaEnvironment.kt @@ -16,8 +16,10 @@ package org.jetbrains.kotlin.idea.project +import org.jetbrains.kotlin.cfg.ControlFlowInformationProviderImpl import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.useImpl +import org.jetbrains.kotlin.container.useInstance import org.jetbrains.kotlin.idea.caches.lightClasses.LazyLightClassDataHolder import org.jetbrains.kotlin.idea.compiler.IdeMainFunctionDetectorFactory import org.jetbrains.kotlin.resolve.TargetEnvironment @@ -30,5 +32,6 @@ object IdeaEnvironment : TargetEnvironment("Idea") { container.useImpl() container.useImpl() container.useImpl() + container.useInstance(ControlFlowInformationProviderImpl.Factory) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index f5800202432..a908c6a7c99 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -15,7 +15,7 @@ import com.intellij.psi.util.CachedValuesManager import com.intellij.util.containers.ContainerUtil import com.intellij.util.containers.SLRUCache import org.jetbrains.annotations.TestOnly -import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider +import org.jetbrains.kotlin.cfg.ControlFlowInformationProviderImpl import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.context.SimpleGlobalContext import org.jetbrains.kotlin.context.withModule @@ -44,7 +44,6 @@ import org.jetbrains.kotlin.resolve.lazy.* import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext -import java.util.* import java.util.concurrent.ConcurrentMap class ResolveElementCache( @@ -647,7 +646,7 @@ class ResolveElementCache( forceResolveAnnotationsInside(property) for (accessor in property.accessors) { - ControlFlowInformationProvider( + ControlFlowInformationProviderImpl( accessor, trace, accessor.languageVersionSettings, resolveSession.platformDiagnosticSuppressor ).checkDeclaration() } @@ -787,7 +786,8 @@ class ResolveElementCache( targetPlatform.findAnalyzerServices(file.project), file.languageVersionSettings, IdeaModuleStructureOracle(), - IdeSealedClassInheritorsProvider + IdeSealedClassInheritorsProvider, + ControlFlowInformationProviderImpl.Factory, ).get() } @@ -845,4 +845,3 @@ class ResolveElementCache( var forceFullAnalysisModeInTests: Boolean = false } } - diff --git a/idea/idea-core/build.gradle.kts b/idea/idea-core/build.gradle.kts index 4705c035796..44f2f32f36b 100644 --- a/idea/idea-core/build.gradle.kts +++ b/idea/idea-core/build.gradle.kts @@ -1,4 +1,3 @@ - plugins { kotlin("jvm") id("jps-compatible") @@ -12,6 +11,7 @@ dependencies { compile(project(":core:descriptors.jvm")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) + compile(project(":compiler:frontend:cfg")) compile(project(":compiler:light-classes")) compile(project(":compiler:util")) compile(project(":idea:ide-common")) diff --git a/prepare/idea-plugin/build.gradle.kts b/prepare/idea-plugin/build.gradle.kts index 2c71957e235..c3e0864b4cc 100644 --- a/prepare/idea-plugin/build.gradle.kts +++ b/prepare/idea-plugin/build.gradle.kts @@ -62,6 +62,7 @@ val projectsToShadow by extra(listOf( ":compiler:frontend", ":compiler:frontend.common", ":compiler:frontend.java", + ":compiler:frontend:cfg", ":idea", ":idea:idea-native", ":idea:idea-core", diff --git a/settings.gradle b/settings.gradle index 0cf60573b00..9299938332c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -90,6 +90,7 @@ include ":benchmarks", ":compiler:frontend", ":compiler:frontend.common", ":compiler:frontend.java", + ":compiler:frontend:cfg", ":kotlin-compiler-runner", ":compiler:cli-common", ":compiler:ir.tree",