From e1d75d55819132faecef836cc7901e67980e381c Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 27 Mar 2018 13:32:39 +0300 Subject: [PATCH] Migration fixes for new inference --- .../kotlin/cli/jvm/compiler/TopDownAnalyzerFacadeForJVM.kt | 3 ++- .../src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt | 4 +++- .../src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt | 2 +- .../src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt | 5 +++-- .../types/expressions/DoubleColonExpressionResolver.kt | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/TopDownAnalyzerFacadeForJVM.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/TopDownAnalyzerFacadeForJVM.kt index a8421b4a9e5..70e81c9ff01 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/TopDownAnalyzerFacadeForJVM.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/TopDownAnalyzerFacadeForJVM.kt @@ -70,6 +70,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProvid import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration import org.jetbrains.kotlin.storage.StorageManager import java.util.* +import kotlin.reflect.KFunction1 object TopDownAnalyzerFacadeForJVM { @JvmStatic @@ -161,7 +162,7 @@ object TopDownAnalyzerFacadeForJVM { val configureJavaClassFinder = if (configuration.getBoolean(JVMConfigurationKeys.USE_JAVAC)) StorageComponentContainer::useJavac - else null + else null as KFunction1? val dependencyModule = if (separateModules) { val dependenciesContext = ContextForNewModule( diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt index 752880ad1a5..3edee70e33b 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt @@ -37,7 +37,9 @@ fun createJvmProfile(targetRoot: File, version: Int): Profile = Profile("JVM$ver fun createJsProfile(targetRoot: File): Profile = Profile("JS", JsPlatformEvaluator(), File(targetRoot, "js")) val profileEvaluators: Map Evaluator> = - listOf(6, 7, 8).associateBy({ version -> "JVM$version" }, { version -> { JvmPlatformEvaluator(version) } }) + ("JS" to { JsPlatformEvaluator() }) + listOf(6, 7, 8) + .associateBy({ version -> "JVM$version" }, { version -> { JvmPlatformEvaluator(version) } }) + .plus PlatformEvaluator>(("JS" to { JsPlatformEvaluator() })) fun createProfile(name: String, targetRoot: File): Profile { val (profileName, evaluator) = profileEvaluators.entries.firstOrNull { it.key.equals(name, ignoreCase = true) } ?: throw IllegalArgumentException("Profile with name '$name' is not supported") diff --git a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt index 65d274ffcb1..5acd3da94d6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt @@ -318,7 +318,7 @@ class LazyModuleDependencies( ) : ModuleDependencies { private val dependencies = storageManager.createLazyValue { val moduleDescriptor = resolverForProject.descriptorForModule(module) - buildSequence { + buildSequence { if (firstDependency != null) { yield(resolverForProject.descriptorForModule(firstDependency)) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt index f79a496e0fa..c6a4957c83f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.context.CallPosition import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.inference.isCaptured import org.jetbrains.kotlin.resolve.calls.inference.wrapWithCapturingSubstitution +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructorSubstitution @@ -56,11 +57,11 @@ fun ResolutionContext<*>.reportTypeMismatchDueToTypeProjection( callPosition.resolvedCall, { f: CallableDescriptor -> getEffectiveExpectedType(f.valueParameters[callPosition.valueParameter.index], callPosition.valueArgument, this) }) - is CallPosition.ExtensionReceiverPosition -> Pair( + is CallPosition.ExtensionReceiverPosition -> Pair, (CallableDescriptor) -> KotlinType?>( callPosition.resolvedCall, { f: CallableDescriptor -> f.extensionReceiverParameter?.type }) - is CallPosition.PropertyAssignment -> Pair( + is CallPosition.PropertyAssignment -> Pair, (CallableDescriptor) -> KotlinType?>( callPosition.leftPart.getResolvedCall(trace.bindingContext) ?: return false, { f: CallableDescriptor -> (f as? PropertyDescriptor)?.setter?.valueParameters?.get(0)?.type }) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt index 7e4cdd50249..e22944557f7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt @@ -704,7 +704,7 @@ class DoubleColonExpressionResolver( ?.apply { commitTrace() }?.results } - val resultSequence = buildSequence { + val resultSequence = buildSequence { when (lhs) { is DoubleColonLHS.Type -> { val classifier = lhsType.constructor.declarationDescriptor