From 64766e125c274df61ceb69c647d63a273576e1ba Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 26 Aug 2020 11:08:30 +0300 Subject: [PATCH] Move common inference classes to :compiler:resolution.common --- build.gradle.kts | 1 + compiler/fir/fir2ir/build.gradle.kts | 1 + compiler/resolution.common/build.gradle.kts | 13 +++++++++++++ .../calls/NewCommonSuperTypeCalculator.kt | 15 ++------------- .../PostponedArgumentsAnalyzerContext.kt | 0 .../inference/ConstraintSystemBuilder.kt | 15 ++------------- .../resolve/calls/inference/InferenceUtils.kt | 15 ++------------- .../calls/inference/NewConstraintSystem.kt | 16 ++-------------- ...ctTypeCheckerContextForConstraintSystem.kt | 2 +- .../components/ConstraintIncorporator.kt | 5 ++--- .../components/ConstraintInjector.kt | 15 ++------------- .../ConstraintSystemCompletionContext.kt | 0 .../ConstraintSystemCompletionMode.kt | 0 .../components/ConstraintSystemUtilContext.kt | 0 .../components/ResultTypeResolver.kt | 15 ++------------- .../TrivialConstraintTypeInferenceOracle.kt | 2 +- ...peVariableDependencyInformationProvider.kt | 17 +++-------------- .../TypeVariableDirectionCalculator.kt | 17 +++-------------- .../components/VariableFixationFinder.kt | 15 ++------------- .../model/ConstraintPositionAndErrors.kt | 15 ++------------- .../inference/model/ConstraintStorage.kt | 2 +- .../model/MutableConstraintStorage.kt | 2 +- .../model/NewConstraintSystemImpl.kt | 2 +- .../model/PostponedResolvedAtomMarker.kt | 0 .../results/TypeSpecificityComparator.kt | 19 +++++++++++++++++++ .../calls/tasks/ExplicitReceiverKind.java | 0 .../tower/ResolutionCandidateApplicability.kt | 3 +++ .../kotlin/types/AbstractTypeApproximator.kt | 0 .../types/TypeApproximatorConfiguration.kt | 12 ++++++------ compiler/resolution/build.gradle.kts | 1 + .../resolve/calls/results/FlatSignature.kt | 11 ----------- .../kotlin/resolve/calls/tower/TowerUtils.kt | 6 +----- .../complexBuildGradleKts/build.gradle.kts | 3 ++- prepare/idea-plugin/build.gradle.kts | 1 + settings.gradle | 1 + 35 files changed, 78 insertions(+), 164 deletions(-) create mode 100644 compiler/resolution.common/build.gradle.kts rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt (97%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzerContext.kt (100%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilder.kt (82%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt (75%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/NewConstraintSystem.kt (55%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt (99%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt (98%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt (96%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionContext.kt (100%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionMode.kt (100%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemUtilContext.kt (100%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt (94%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/TrivialConstraintTypeInferenceOracle.kt (98%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDependencyInformationProvider.kt (91%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDirectionCalculator.kt (90%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt (92%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt (87%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintStorage.kt (98%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt (99%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt (99%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/model/PostponedResolvedAtomMarker.kt (100%) create mode 100644 compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/results/TypeSpecificityComparator.kt rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java (100%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/resolve/calls/tower/ResolutionCandidateApplicability.kt (90%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt (100%) rename compiler/{resolution => resolution.common}/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt (84%) diff --git a/build.gradle.kts b/build.gradle.kts index 577518cd8d5..d45da29c817 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -221,6 +221,7 @@ extra["compilerModules"] = arrayOf( ":compiler:config", ":compiler:config.jvm", ":compiler:container", + ":compiler:resolution.common", ":compiler:resolution", ":compiler:serialization", ":compiler:psi", diff --git a/compiler/fir/fir2ir/build.gradle.kts b/compiler/fir/fir2ir/build.gradle.kts index 39f2e535769..7dc2a4730f6 100644 --- a/compiler/fir/fir2ir/build.gradle.kts +++ b/compiler/fir/fir2ir/build.gradle.kts @@ -23,6 +23,7 @@ dependencies { testCompileOnly(project(":kotlin-test:kotlin-test-junit")) testCompile(projectTests(":compiler:tests-common")) testCompile(projectTests(":compiler:fir:analysis-tests")) + testApi(project(":compiler:resolution.common")) testCompileOnly(project(":kotlin-reflect-api")) testRuntime(project(":kotlin-reflect")) diff --git a/compiler/resolution.common/build.gradle.kts b/compiler/resolution.common/build.gradle.kts new file mode 100644 index 00000000000..3fa6889434b --- /dev/null +++ b/compiler/resolution.common/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + api(project(":core:compiler.common")) +} + +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt similarity index 97% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt index 938c00e0f01..08b381d22dc 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzerContext.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzerContext.kt similarity index 100% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzerContext.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzerContext.kt diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilder.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilder.kt similarity index 82% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilder.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilder.kt index eebf0c82a78..9c168f08b88 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilder.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilder.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt similarity index 75% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt index d383b1dfa1b..64a886535b9 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/NewConstraintSystem.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/NewConstraintSystem.kt similarity index 55% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/NewConstraintSystem.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/NewConstraintSystem.kt index 754f669e469..6321f4a85b5 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/NewConstraintSystem.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/NewConstraintSystem.kt @@ -1,24 +1,12 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzerContext import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext -import org.jetbrains.kotlin.resolve.calls.inference.components.PostponedArgumentInputTypesResolver import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt similarity index 99% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt index 93be486e8b3..2dcbce8046d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt similarity index 98% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt index 91479efbf73..020f6e0d88d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.types.model.* import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.SmartSet import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.utils.addToStdlib.safeAs import java.util.* // todo problem: intersection types in constrains: A <: Number, B <: Inv =>? B <: Inv @@ -248,7 +247,7 @@ class ConstraintIncorporator( val kind = if (isSubtype) ConstraintKind.LOWER else ConstraintKind.UPPER - val inputTypePosition = baseConstraint.position.from.safeAs() + val inputTypePosition = baseConstraint.position.from as? OnlyInputTypeConstraintPosition val isNewConstraintUsefulForNullability = isUsefulForNullabilityConstraint && newConstraint.isNullableNothing() val isOtherConstraintUsefulForNullability = otherConstraint.isNullabilityConstraint && otherConstraint.type.isNullableNothing() diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt similarity index 96% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt index 91d884ea54c..20a3674a58d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference.components diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionContext.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionContext.kt similarity index 100% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionContext.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionContext.kt diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionMode.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionMode.kt similarity index 100% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionMode.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemCompletionMode.kt diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemUtilContext.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemUtilContext.kt similarity index 100% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemUtilContext.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintSystemUtilContext.kt diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt similarity index 94% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt index 90cb24ef82f..bd5f8914fb2 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference.components diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TrivialConstraintTypeInferenceOracle.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TrivialConstraintTypeInferenceOracle.kt similarity index 98% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TrivialConstraintTypeInferenceOracle.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TrivialConstraintTypeInferenceOracle.kt index 683a1eea659..7fb0aee3d76 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TrivialConstraintTypeInferenceOracle.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TrivialConstraintTypeInferenceOracle.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDependencyInformationProvider.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDependencyInformationProvider.kt similarity index 91% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDependencyInformationProvider.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDependencyInformationProvider.kt index 2bd6a0b15ba..7b7ae720a79 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDependencyInformationProvider.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDependencyInformationProvider.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference.components @@ -163,4 +152,4 @@ class TypeVariableDependencyInformationProvider( } -} \ No newline at end of file +} diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDirectionCalculator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDirectionCalculator.kt similarity index 90% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDirectionCalculator.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDirectionCalculator.kt index 16b8d3c00aa..0ec39f65fc2 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDirectionCalculator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeVariableDirectionCalculator.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference.components @@ -160,4 +149,4 @@ class TypeVariableDirectionCalculator( ResolveDirection.TO_SUPERTYPE -> ResolveDirection.TO_SUBTYPE ResolveDirection.TO_SUBTYPE -> ResolveDirection.TO_SUPERTYPE } -} \ No newline at end of file +} diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt similarity index 92% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt index 10f275bd194..f0d2f8ff214 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference.components diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt similarity index 87% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt index d18d82ec558..b236008250d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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.resolve.calls.inference.model diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintStorage.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintStorage.kt similarity index 98% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintStorage.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintStorage.kt index cd883f2631f..73580c2d006 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintStorage.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintStorage.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt similarity index 99% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt index 27e47d66ad5..0ce8c01d8fe 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt similarity index 99% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt index 5b52d2b1b68..7e3f0532d59 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/PostponedResolvedAtomMarker.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/model/PostponedResolvedAtomMarker.kt similarity index 100% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/PostponedResolvedAtomMarker.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/model/PostponedResolvedAtomMarker.kt diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/results/TypeSpecificityComparator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/results/TypeSpecificityComparator.kt new file mode 100644 index 00000000000..2b3e2d6ab93 --- /dev/null +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/results/TypeSpecificityComparator.kt @@ -0,0 +1,19 @@ +/* + * 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.resolve.calls.results + +import org.jetbrains.kotlin.container.DefaultImplementation +import org.jetbrains.kotlin.container.PlatformSpecificExtension +import org.jetbrains.kotlin.types.model.KotlinTypeMarker + +@DefaultImplementation(impl = TypeSpecificityComparator.NONE::class) +interface TypeSpecificityComparator : PlatformSpecificExtension { + fun isDefinitelyLessSpecific(specific: KotlinTypeMarker, general: KotlinTypeMarker): Boolean + + object NONE : TypeSpecificityComparator { + override fun isDefinitelyLessSpecific(specific: KotlinTypeMarker, general: KotlinTypeMarker) = false + } +} diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java similarity index 100% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tasks/ExplicitReceiverKind.java diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ResolutionCandidateApplicability.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/ResolutionCandidateApplicability.kt similarity index 90% rename from compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ResolutionCandidateApplicability.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/ResolutionCandidateApplicability.kt index 83c09522161..e52cc07c37a 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ResolutionCandidateApplicability.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/ResolutionCandidateApplicability.kt @@ -20,3 +20,6 @@ enum class ResolutionCandidateApplicability { HIDDEN, // removed from resolve RESOLVED_TO_SAM_WITH_VARARG, // migration warning up to 1.5 (when resolve to function with SAM conversion and array without spread as vararg) } + +val ResolutionCandidateApplicability.isSuccess: Boolean + get() = this <= ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY diff --git a/compiler/resolution/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt similarity index 100% rename from compiler/resolution/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt diff --git a/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt similarity index 84% rename from compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt rename to compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt index da46fdb6bd0..652f778f88c 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt @@ -52,7 +52,7 @@ open class TypeApproximatorConfiguration { } abstract class AbstractCapturedTypesApproximation(val approximatedCapturedStatus: CaptureStatus) : - TypeApproximatorConfiguration.AllFlexibleSameValue() { + AllFlexibleSameValue() { override val allFlexible: Boolean get() = true override val errorType: Boolean get() = true @@ -64,20 +64,20 @@ open class TypeApproximatorConfiguration { override val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean get() = { true } } - object IncorporationConfiguration : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(CaptureStatus.FOR_INCORPORATION) - object SubtypeCapturedTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(CaptureStatus.FOR_SUBTYPING) - object InternalTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(CaptureStatus.FROM_EXPRESSION) { + object IncorporationConfiguration : AbstractCapturedTypesApproximation(CaptureStatus.FOR_INCORPORATION) + object SubtypeCapturedTypesApproximation : AbstractCapturedTypesApproximation(CaptureStatus.FOR_SUBTYPING) + object InternalTypesApproximation : AbstractCapturedTypesApproximation(CaptureStatus.FROM_EXPRESSION) { override val integerLiteralType: Boolean get() = true override val intersectionTypesInContravariantPositions: Boolean get() = true } object FinalApproximationAfterResolutionAndInference : - TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(CaptureStatus.FROM_EXPRESSION) { + AbstractCapturedTypesApproximation(CaptureStatus.FROM_EXPRESSION) { override val integerLiteralType: Boolean get() = true override val intersectionTypesInContravariantPositions: Boolean get() = true } - object IntegerLiteralsTypesApproximation : TypeApproximatorConfiguration.AllFlexibleSameValue() { + object IntegerLiteralsTypesApproximation : AllFlexibleSameValue() { override val integerLiteralType: Boolean get() = true override val allFlexible: Boolean get() = true override val intersection: IntersectionStrategy get() = IntersectionStrategy.ALLOWED diff --git a/compiler/resolution/build.gradle.kts b/compiler/resolution/build.gradle.kts index 9be7664bdbb..6048a611681 100644 --- a/compiler/resolution/build.gradle.kts +++ b/compiler/resolution/build.gradle.kts @@ -6,6 +6,7 @@ plugins { dependencies { compile(project(":compiler:util")) compile(project(":core:descriptors")) + api(project(":compiler:resolution.common")) compileOnly(intellijDep()) { includeJars("trove4j") } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt index 9fe7df4405b..31e5088fe1c 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt @@ -17,8 +17,6 @@ package org.jetbrains.kotlin.resolve.calls.results import org.jetbrains.kotlin.builtins.getValueParameterTypesFromCallableReflectionType -import org.jetbrains.kotlin.container.DefaultImplementation -import org.jetbrains.kotlin.container.PlatformSpecificExtension import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.MemberDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor @@ -33,15 +31,6 @@ interface SpecificityComparisonCallbacks { fun isNonSubtypeNotLessSpecific(specific: KotlinTypeMarker, general: KotlinTypeMarker): Boolean } -@DefaultImplementation(impl = TypeSpecificityComparator.NONE::class) -interface TypeSpecificityComparator : PlatformSpecificExtension { - fun isDefinitelyLessSpecific(specific: KotlinTypeMarker, general: KotlinTypeMarker): Boolean - - object NONE : TypeSpecificityComparator { - override fun isDefinitelyLessSpecific(specific: KotlinTypeMarker, general: KotlinTypeMarker) = false - } -} - class FlatSignature constructor( val origin: T, val typeParameters: Collection, diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt index 4b9bf9d0a14..d79d3ea8605 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.calls.tower import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo private val INAPPLICABLE_STATUSES = setOf( ResolutionCandidateApplicability.INAPPLICABLE, @@ -26,9 +25,6 @@ private val INAPPLICABLE_STATUSES = setOf( ResolutionCandidateApplicability.INAPPLICABLE_WRONG_RECEIVER ) -val ResolutionCandidateApplicability.isSuccess: Boolean - get() = this <= ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY - val CallableDescriptor.isSynthesized: Boolean get() = (this is CallableMemberDescriptor && kind == CallableMemberDescriptor.Kind.SYNTHESIZED) @@ -41,4 +37,4 @@ val ResolutionCandidateApplicability.isInapplicable: Boolean fun C.forceResolution(): C { resultingApplicability return this -} \ No newline at end of file +} diff --git a/idea/testData/gradle/highlighting/complexBuildGradleKts/build.gradle.kts b/idea/testData/gradle/highlighting/complexBuildGradleKts/build.gradle.kts index 558409fe082..2acf65654a5 100644 --- a/idea/testData/gradle/highlighting/complexBuildGradleKts/build.gradle.kts +++ b/idea/testData/gradle/highlighting/complexBuildGradleKts/build.gradle.kts @@ -110,6 +110,7 @@ extra["IntellijCoreDependencies"] = extra["compilerModules"] = arrayOf( ":compiler:util", ":compiler:container", + ":compiler:resolution.common", ":compiler:resolution", ":compiler:serialization", ":compiler:psi", @@ -430,4 +431,4 @@ tasks { create("mainCeck") { dependsOn("test") } -} \ No newline at end of file +} diff --git a/prepare/idea-plugin/build.gradle.kts b/prepare/idea-plugin/build.gradle.kts index f278a69eefb..2e684d6be52 100644 --- a/prepare/idea-plugin/build.gradle.kts +++ b/prepare/idea-plugin/build.gradle.kts @@ -75,6 +75,7 @@ val projectsToShadow by extra(listOf( ":compiler:light-classes", ":compiler:plugin-api", ":kotlin-preloader", + ":compiler:resolution.common", ":compiler:resolution", ":compiler:serialization", ":compiler:util", diff --git a/settings.gradle b/settings.gradle index c2f0324f8b4..d319e3e3e69 100644 --- a/settings.gradle +++ b/settings.gradle @@ -78,6 +78,7 @@ include ":benchmarks", ":kotlin-preloader", ":kotlin-runner", ":compiler:container", + ":compiler:resolution.common", ":compiler:resolution", ":compiler:serialization", ":compiler:psi",