diff --git a/.idea/artifacts/KotlinPlugin.xml b/.idea/artifacts/KotlinPlugin.xml
index 7d68ec67b24..857c5128ff4 100644
--- a/.idea/artifacts/KotlinPlugin.xml
+++ b/.idea/artifacts/KotlinPlugin.xml
@@ -1,103 +1,109 @@
-
- $PROJECT_DIR$/out/artifacts/Kotlin
-
-
- file://$PROJECT_DIR$/idea-runner/runner.xml
- copy-runtime-for-idea-plugin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ $PROJECT_DIR$/out/artifacts/Kotlin
+
+
+ file://$PROJECT_DIR$/idea-runner/runner.xml
+ copy-runtime-for-idea-plugin
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index ee900a4aa0d..c081eff7dd3 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -85,6 +85,8 @@
+
+
diff --git a/build.xml b/build.xml
index 5e2fb1807c9..e7495038cb4 100644
--- a/build.xml
+++ b/build.xml
@@ -865,6 +865,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1273,11 +1296,11 @@
depends="builtins,stdlib,kotlin-test,core,reflection,pack-runtime,pack-runtime-sources,script-runtime,mock-runtime-for-test"/>
()
useImpl()
useImpl()
- useInstance(SamConversionResolverImpl)
+ useImpl()
+ useImpl()
useImpl()
useInstance(InternalFlexibleTypeTransformer)
diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt
index 53984136c21..c4402f2caae 100644
--- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt
+++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt
@@ -25,9 +25,10 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
+import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.SimpleType
-object SamConversionResolverImpl : SamConversionResolver {
+class SamConversionResolverImpl(val storageManager: StorageManager, val samWithReceiverResolver: SamWithReceiverResolver): SamConversionResolver {
override fun resolveSamConstructor(constructorOwner: DeclarationDescriptor, classifier: () -> ClassifierDescriptor?): SamConstructorDescriptor? {
val classifierDescriptor = classifier()
if (classifierDescriptor !is LazyJavaClassDescriptor || classifierDescriptor.functionTypeForSamInterface == null) return null
@@ -44,8 +45,13 @@ object SamConversionResolverImpl : SamConversionResolver {
}
}
+ private val functionTypesForSamInterfaces = storageManager.createCacheWithNullableValues()
+
override fun resolveFunctionTypeIfSamInterface(classDescriptor: JavaClassDescriptor): SimpleType? {
- val abstractMethod = SingleAbstractMethodUtils.getSingleAbstractMethodOrNull(classDescriptor) ?: return null
- return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod)
+ return functionTypesForSamInterfaces.computeIfAbsent(classDescriptor) {
+ val abstractMethod = SingleAbstractMethodUtils.getSingleAbstractMethodOrNull(classDescriptor) ?: return@computeIfAbsent null
+ val shouldConvertFirstParameterToDescriptor = samWithReceiverResolver.shouldConvertFirstSamParameterToReceiver(abstractMethod)
+ SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod, shouldConvertFirstParameterToDescriptor)
+ }
}
}
diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamWithReceiverResolver.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamWithReceiverResolver.kt
new file mode 100644
index 00000000000..c80f00d2fac
--- /dev/null
+++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamWithReceiverResolver.kt
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package org.jetbrains.kotlin.load.java.sam
+
+import org.jetbrains.kotlin.descriptors.FunctionDescriptor
+
+class SamWithReceiverResolver {
+ private val extensions = mutableListOf()
+
+ fun registerExtension(extension: Extension) {
+ extensions += extension
+ }
+
+ fun shouldConvertFirstSamParameterToReceiver(function: FunctionDescriptor): Boolean {
+ return extensions.any { it.shouldConvertFirstSamParameterToReceiver(function) }
+ }
+
+ interface Extension {
+ fun shouldConvertFirstSamParameterToReceiver(function: FunctionDescriptor): Boolean
+ }
+}
\ No newline at end of file
diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java
index 115c2ea42b1..0d71509e2aa 100644
--- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java
+++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.load.java.sam;
+import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*;
@@ -23,19 +24,19 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl;
+import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension;
import org.jetbrains.kotlin.load.java.descriptors.*;
+import org.jetbrains.kotlin.load.java.sources.JavaSourceElement;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.name.SpecialNames;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.calls.util.FunctionTypeResolveUtilsKt;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
+import org.jetbrains.kotlin.resolve.source.PsiSourceElement;
import org.jetbrains.kotlin.types.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static org.jetbrains.kotlin.types.Variance.IN_VARIANCE;
@@ -97,18 +98,33 @@ public class SingleAbstractMethodUtils {
}
@NotNull
- public static SimpleType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
+ public static SimpleType getFunctionTypeForAbstractMethod(
+ @NotNull FunctionDescriptor function,
+ boolean shouldConvertFirstParameterToDescriptor
+ ) {
KotlinType returnType = function.getReturnType();
assert returnType != null : "function is not initialized: " + function;
List valueParameters = function.getValueParameters();
List parameterTypes = new ArrayList(valueParameters.size());
List parameterNames = new ArrayList(valueParameters.size());
- for (ValueParameterDescriptor parameter : valueParameters) {
+
+ int startIndex = 0;
+ KotlinType receiverType = null;
+
+ if (shouldConvertFirstParameterToDescriptor && !function.getValueParameters().isEmpty()) {
+ receiverType = valueParameters.get(0).getType();
+ startIndex = 1;
+ }
+
+ for (int i = startIndex; i < valueParameters.size(); ++i) {
+ ValueParameterDescriptor parameter = valueParameters.get(i);
parameterTypes.add(parameter.getType());
parameterNames.add(function.hasSynthesizedParameterNames() ? SpecialNames.NO_NAME_PROVIDED : parameter.getName());
}
+
return FunctionTypeResolveUtilsKt.createFunctionType(
- DescriptorUtilsKt.getBuiltIns(function), Annotations.Companion.getEMPTY(), null, parameterTypes, parameterNames, returnType
+ DescriptorUtilsKt.getBuiltIns(function), Annotations.Companion.getEMPTY(),
+ receiverType, parameterTypes, parameterNames, returnType
);
}
diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt
index 0a1611826d9..a5006897e6f 100644
--- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt
+++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.context.ModuleContext
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
+import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.frontend.java.di.createContainerForLazyResolveWithJava
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.load.java.lazy.ModuleClassResolverImpl
@@ -91,6 +92,9 @@ object JvmAnalyzerFacade : AnalyzerFacade() {
useBuiltInsProvider = false, // TODO: load built-ins from module dependencies in IDE
useLazyResolve = true
)
+
+ StorageComponentContainerContributor.getInstances(project).forEach { it.onContainerComposed(container, moduleInfo) }
+
val resolveSession = container.get()
val javaDescriptorResolver = container.get()
diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.kt
index e05246eda16..4184a5a2ce1 100644
--- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.kt
+++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.kt
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
import org.jetbrains.kotlin.descriptors.impl.ModuleDependenciesImpl
+import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.frontend.java.di.createContainerForTopDownAnalyzerForJvm
import org.jetbrains.kotlin.frontend.java.di.initJvmBuiltInsForTopDownAnalysis
import org.jetbrains.kotlin.frontend.java.di.initialize
@@ -80,6 +81,8 @@ object TopDownAnalyzerFacadeForJVM {
project, files, trace, configuration, packagePartProvider, declarationProviderFactory, sourceModuleSearchScope
)
+ StorageComponentContainerContributor.getInstances(project).forEach { it.onContainerComposed(container, null) }
+
val module = container.get()
val moduleContext = container.get()
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/extensions/AnnotationBasedExtension.kt b/compiler/frontend/src/org/jetbrains/kotlin/extensions/AnnotationBasedExtension.kt
index f600affd8b2..bdcf687ffcc 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/extensions/AnnotationBasedExtension.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/extensions/AnnotationBasedExtension.kt
@@ -24,9 +24,9 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.types.TypeUtils
interface AnnotationBasedExtension {
- fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner): List
+ fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner?): List
- fun DeclarationDescriptor.hasSpecialAnnotation(modifierListOwner: KtModifierListOwner): Boolean {
+ fun DeclarationDescriptor.hasSpecialAnnotation(modifierListOwner: KtModifierListOwner?): Boolean {
if (annotations.any { it.isASpecialAnnotation(modifierListOwner) }) return true
if (this is ClassDescriptor) {
@@ -40,7 +40,7 @@ interface AnnotationBasedExtension {
}
private fun AnnotationDescriptor.isASpecialAnnotation(
- modifierListOwner: KtModifierListOwner,
+ modifierListOwner: KtModifierListOwner?,
allowMetaAnnotations: Boolean = true
): Boolean {
val annotationType = type.constructor.declarationDescriptor ?: return false
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/extensions/DeclarationAttributeAltererExtension.kt b/compiler/frontend/src/org/jetbrains/kotlin/extensions/DeclarationAttributeAltererExtension.kt
index 3e20bca1026..2bc3f00f720 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/extensions/DeclarationAttributeAltererExtension.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/extensions/DeclarationAttributeAltererExtension.kt
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.extensions
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.resolve.BindingContext
@@ -37,4 +38,6 @@ interface DeclarationAttributeAltererExtension {
currentModality: Modality,
bindingContext: BindingContext
): Modality? = null
+
+ fun shouldConvertFirstSAMParameterToReceiver(function: FunctionDescriptor) : Boolean = false
}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/extensions/StorageComponentContainerContributor.kt b/compiler/frontend/src/org/jetbrains/kotlin/extensions/StorageComponentContainerContributor.kt
index a5104e50abc..7065ba5c9e9 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/extensions/StorageComponentContainerContributor.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/extensions/StorageComponentContainerContributor.kt
@@ -16,6 +16,8 @@
package org.jetbrains.kotlin.extensions
+import org.jetbrains.kotlin.analyzer.ModuleInfo
+import org.jetbrains.kotlin.container.ComponentProvider
import org.jetbrains.kotlin.container.StorageComponentContainer
import org.jetbrains.kotlin.resolve.TargetPlatform
@@ -24,5 +26,7 @@ interface StorageComponentContainerContributor {
"org.jetbrains.kotlin.storageComponentContainerContributor", StorageComponentContainerContributor::class.java
)
- fun addDeclarations(container: StorageComponentContainer, platform: TargetPlatform)
+ fun addDeclarations(container: StorageComponentContainer, platform: TargetPlatform) {}
+
+ fun onContainerComposed(container: ComponentProvider, moduleInfo: ModuleInfo?) {}
}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/script/KotlinScriptDefinition.kt b/compiler/frontend/src/org/jetbrains/kotlin/script/KotlinScriptDefinition.kt
index 708e0f129db..d60e2c42eea 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/script/KotlinScriptDefinition.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/script/KotlinScriptDefinition.kt
@@ -34,6 +34,9 @@ open class KotlinScriptDefinition(val template: KClass) {
// TODO: consider creating separate type (subtype? for kotlin scripts)
open val fileType: LanguageFileType = KotlinFileType.INSTANCE
+ open val annotationsForSamWithReceivers: List
+ get() = emptyList()
+
open fun isScript(file: TF): Boolean =
getFileName(file).endsWith(KotlinParserDefinition.STD_SCRIPT_EXT)
diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.java b/compiler/tests-common/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.java
similarity index 97%
rename from compiler/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.java
rename to compiler/tests-common/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.java
index 40b5883d118..ab6b45abb58 100644
--- a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.java
+++ b/compiler/tests-common/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
+import junit.framework.TestCase;
import kotlin.TuplesKt;
import kotlin.collections.CollectionsKt;
import kotlin.collections.MapsKt;
@@ -189,7 +190,7 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
}
else {
File lazyLogFile = getLazyLogFile(testDataFile);
- assertFalse("No lazy log expected, but found: " + lazyLogFile.getAbsolutePath(), lazyLogFile.exists());
+ TestCase.assertFalse("No lazy log expected, but found: " + lazyLogFile.getAbsolutePath(), lazyLogFile.exists());
}
Throwable exceptionFromDescriptorValidation = null;
@@ -225,7 +226,7 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
KotlinTestUtils.assertEqualsToFile(testDataFile, actualText.toString());
- assertTrue("Diagnostics mismatch. See the output above", ok);
+ TestCase.assertTrue("Diagnostics mismatch. See the output above", ok);
// now we throw a previously found error, if any
if (exceptionFromDescriptorValidation != null) {
@@ -440,7 +441,7 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
return InTextDirectivesUtils.isDirectiveDefined(file.expectedText, "// SKIP_TXT");
}
})) {
- assertFalse(".txt file should not exist if SKIP_TXT directive is used: " + expectedFile, expectedFile.exists());
+ TestCase.assertFalse(".txt file should not exist if SKIP_TXT directive is used: " + expectedFile, expectedFile.exists());
return;
}
@@ -452,7 +453,7 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
for (Iterator module = CollectionsKt.sorted(modules.keySet()).iterator(); module.hasNext(); ) {
ModuleDescriptorImpl moduleDescriptor = modules.get(module.next());
PackageViewDescriptor aPackage = moduleDescriptor.getPackage(FqName.ROOT);
- assertFalse(aPackage.isEmpty());
+ TestCase.assertFalse(aPackage.isEmpty());
if (isMultiModuleTest) {
rootPackageText.append(String.format("// -- Module: %s --\n", moduleDescriptor.getName()));
@@ -587,8 +588,8 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
DiagnosticUtils.LineAndColumn lineAndColumn =
DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange());
- assertTrue("Resolved call for '" + element.getText() + "'" + lineAndColumn + " is not completed",
- ((MutableResolvedCall>) resolvedCall).isCompleted());
+ TestCase.assertTrue("Resolved call for '" + element.getText() + "'" + lineAndColumn + " is not completed",
+ ((MutableResolvedCall>) resolvedCall).isCompleted());
}
checkResolvedCallsInDiagnostics(bindingContext);
@@ -633,8 +634,8 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
DiagnosticUtils.LineAndColumn lineAndColumn =
DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange());
- assertTrue("Resolved calls stored in " + diagnostic.getFactory().getName() + "\n" +
- "for '" + element.getText() + "'" + lineAndColumn + " are not completed",
- allCallsAreCompleted);
+ TestCase.assertTrue("Resolved calls stored in " + diagnostic.getFactory().getName() + "\n" +
+ "for '" + element.getText() + "'" + lineAndColumn + " are not completed",
+ allCallsAreCompleted);
}
}
diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java b/compiler/tests-common/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java
similarity index 100%
rename from compiler/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java
rename to compiler/tests-common/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java
diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt b/compiler/tests-common/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt
similarity index 100%
rename from compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt
rename to compiler/tests-common/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt
diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/LoggingStorageManager.kt b/compiler/tests-common/org/jetbrains/kotlin/checkers/LoggingStorageManager.kt
similarity index 100%
rename from compiler/tests/org/jetbrains/kotlin/checkers/LoggingStorageManager.kt
rename to compiler/tests-common/org/jetbrains/kotlin/checkers/LoggingStorageManager.kt
diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt
index 753bc9857d9..4abd1d29fa4 100644
--- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt
+++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt
@@ -53,7 +53,7 @@ import org.jetbrains.kotlin.utils.toReadOnlyList
import java.util.*
class LazyJavaClassDescriptor(
- outerContext: LazyJavaResolverContext,
+ val outerContext: LazyJavaResolverContext,
containingDeclaration: DeclarationDescriptor,
private val jClass: JavaClass,
private val additionalSupertypeClassDescriptor: ClassDescriptor? = null
@@ -123,10 +123,6 @@ class LazyJavaClassDescriptor(
override val annotations by c.storageManager.createLazyValue { c.resolveAnnotations(jClass) }
- private val functionTypeForSamInterface = c.storageManager.createNullableLazyValue {
- c.components.samConversionResolver.resolveFunctionTypeIfSamInterface(this)
- }
-
private val declaredParameters = c.storageManager.createLazyValue {
jClass.typeParameters.map {
p ->
@@ -137,7 +133,7 @@ class LazyJavaClassDescriptor(
override fun getDeclaredTypeParameters() = declaredParameters()
- override fun getFunctionTypeForSamInterface(): SimpleType? = functionTypeForSamInterface()
+ override fun getFunctionTypeForSamInterface(): SimpleType? = c.components.samConversionResolver.resolveFunctionTypeIfSamInterface(this)
override fun toString() = "Lazy Java class ${this.fqNameUnsafe}"
diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
index a6f51fff74b..dbb547e2b69 100755
--- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
+++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
@@ -163,6 +163,7 @@ import org.jetbrains.kotlin.shortenRefs.AbstractShortenRefsTest
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.types.AbstractTypeBindingTest
import org.jetbrains.kotlin.idea.refactoring.AbstractNameSuggestionProviderTest
+import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverTest
import java.io.File
import java.lang.IllegalArgumentException
import java.util.*
@@ -1172,6 +1173,12 @@ fun main(args: Array) {
}
}
+ testGroup("plugins/plugins-tests/tests", "plugins/sam-with-receiver/sam-with-receiver-cli/testData") {
+ testClass {
+ model("diagnostics")
+ }
+ }
+
testGroup("plugins/android-extensions/android-extensions-idea/tests", "plugins/android-extensions/android-extensions-idea/testData") {
testClass() {
model("android/completion", recursive = false, extension = null)
diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt
index e96f561b610..6efbe1e7d06 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt
@@ -76,15 +76,16 @@ class KotlinCacheServiceImpl(val project: Project) : KotlinCacheService {
}
- private val facadesForScriptDependencies: SLRUCache =
- object : SLRUCache(2, 3) {
- override fun createValue(key: KotlinScriptExternalDependencies?): ProjectResolutionFacade {
- return createFacadeForScriptDependencies(ScriptDependenciesModuleInfo(project, key))
+ private val facadesForScriptDependencies: SLRUCache =
+ object : SLRUCache(2, 3) {
+ override fun createValue(scriptModuleInfo: ScriptModuleInfo?): ProjectResolutionFacade {
+ val dependencies = scriptModuleInfo?.externalDependencies
+ return createFacadeForScriptDependencies(ScriptDependenciesModuleInfo(project, dependencies, scriptModuleInfo))
}
}
- private fun getFacadeForScriptDependencies(dependencies: KotlinScriptExternalDependencies?) = synchronized(facadesForScriptDependencies) {
- facadesForScriptDependencies.get(dependencies)
+ private fun getFacadeForScriptDependencies(scriptModuleInfo: ScriptModuleInfo) = synchronized(facadesForScriptDependencies) {
+ facadesForScriptDependencies.get(scriptModuleInfo)
}
private fun createFacadeForScriptDependencies(
@@ -230,7 +231,7 @@ class KotlinCacheServiceImpl(val project: Project) : KotlinCacheService {
createFacadeForScriptDependencies(syntheticFileModule, files)
}
syntheticFileModule is ScriptModuleInfo -> {
- val facadeForScriptDependencies = getFacadeForScriptDependencies(syntheticFileModule.externalDependencies)
+ val facadeForScriptDependencies = getFacadeForScriptDependencies(syntheticFileModule)
val globalContext = facadeForScriptDependencies.globalContext.contextWithNewLockAndCompositeExceptionTracker()
ProjectResolutionFacade(
"facadeForSynthetic in ScriptModuleInfo",
diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ScriptModuleInfos.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ScriptModuleInfos.kt
index f31c503d0c2..25a64f136e9 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ScriptModuleInfos.kt
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ScriptModuleInfos.kt
@@ -55,7 +55,7 @@ data class ScriptModuleInfo(val project: Project, val scriptFile: VirtualFile,
override fun dependencies(): List {
return listOf(
this,
- ScriptDependenciesModuleInfo(project, externalDependencies)
+ ScriptDependenciesModuleInfo(project, externalDependencies, this)
) + sdkDependencies(externalDependencies, project)
}
}
@@ -73,7 +73,11 @@ fun findJdk(dependencies: KotlinScriptExternalDependencies?, project: Project):
allJdks.firstOrNull()
}
-class ScriptDependenciesModuleInfo(val project: Project, val dependencies: KotlinScriptExternalDependencies?): IdeaModuleInfo {
+class ScriptDependenciesModuleInfo(
+ val project: Project,
+ val dependencies: KotlinScriptExternalDependencies?,
+ val scriptModuleInfo: ScriptModuleInfo?
+): IdeaModuleInfo {
override fun dependencies() = (listOf(this) + sdkDependencies(dependencies, project))
override val name = Name.special("