From 28ad4989562f2c2186075673427d6f1d7d7f0023 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Tue, 3 Jul 2018 16:06:41 +0300 Subject: [PATCH] Use AnonymousFunctionDescriptor for suspend callable references Also use it for local suspend functions, which allows us to remove hack with dropSuspend. Regenerate tests. --- .../kotlin/codegen/ExpressionCodegen.java | 2 +- .../FunctionReferenceGenerationStrategy.java | 12 ++-- .../binding/CodegenAnnotatingVisitor.java | 30 +++------ .../codegen/coroutines/CoroutineCodegen.kt | 33 ++++++---- .../coroutines/coroutineCodegenUtil.kt | 6 +- .../codegen/state/KotlinTypeMapper.java | 9 +-- .../impl/AnonymousFunctionDescriptor.java | 51 ++++++++++++---- .../DoubleColonExpressionResolver.kt | 2 +- .../callableReference/bound/emptyLHS.kt | 2 +- .../genericCallableReferenceArguments.kt | 2 +- ...ericCallableReferencesWithNullableTypes.kt | 2 +- .../function/getArityViaFunctionImpl.kt | 2 +- .../function/local/equalsHashCode.kt | 2 +- .../callableReference/outsideSuspend.kt | 7 ++- .../ir/IrBlackBoxCodegenTestGenerated.java | 46 ++++++++------ .../IrBlackBoxInlineCodegenTestGenerated.java | 10 +-- ...otlinAgainstInlineKotlinTestGenerated.java | 10 +-- .../DiagnosticsTestWithStdLibGenerated.java | 10 +-- ...ticsTestWithStdLibUsingJavacGenerated.java | 10 +-- .../codegen/BlackBoxCodegenTestGenerated.java | 46 ++++++++------ .../BlackBoxInlineCodegenTestGenerated.java | 10 +-- ...otlinAgainstInlineKotlinTestGenerated.java | 10 +-- .../LightAnalysisModeTestGenerated.java | 46 ++++++++------ .../descriptors/LazyJavaClassMemberScope.kt | 6 +- .../functions/FunctionClassDescriptor.kt | 4 +- .../descriptors/FunctionDescriptor.java | 18 +----- .../impl/FunctionDescriptorImpl.java | 22 +------ .../kotlin/resolve/DescriptorUtils.kt | 22 +++---- .../ErrorSimpleFunctionDescriptorImpl.java | 21 +------ .../IrJsCodegenBoxTestGenerated.java | 37 ++++++----- .../semantics/JsCodegenBoxTestGenerated.java | 61 +++++++------------ 31 files changed, 259 insertions(+), 292 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index c66636ec448..27c9126d96a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -1124,7 +1124,7 @@ public class ExpressionCodegen extends KtVisitor impleme if (!isCrossinlineLambda) { v.aconst(null); } - } else if (superClass != null && superClass.equals(state.getJvmRuntimeTypes().getFunctionReference())) { + } else if (DescriptorUtilsKt.isCallableReferenceToSuspend(classDescriptor, state.getJvmRuntimeTypes().getFunctionReference())) { // Constructor of callable reference to suspend function does not accept continuation: // do nothing. } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java index 8bf41be50e3..39c287fabda 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java @@ -11,7 +11,6 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.backend.common.CodegenUtil; import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt; import org.jetbrains.kotlin.codegen.state.GenerationState; -import org.jetbrains.kotlin.config.LanguageFeature; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; @@ -31,8 +30,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.addFakeContinuationMarker; - /* * Notice the difference between two function descriptors in this class. * - [referencedFunction] is the function declaration which is referenced by the "::" expression. This is a real function present in code. @@ -69,14 +66,13 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat ) { super(state); this.resolvedCall = resolvedCall; - CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor(); - if (resultingDescriptor instanceof FunctionDescriptor && ((FunctionDescriptor) resultingDescriptor).isSuspend()) { - this.referencedFunction = - CoroutineCodegenUtilKt.getOrCreateJvmSuspendFunctionView((FunctionDescriptor) resultingDescriptor, state); + FunctionDescriptor referencedFunction = (FunctionDescriptor) resolvedCall.getResultingDescriptor(); + if (referencedFunction.isSuspend()) { + this.referencedFunction = CoroutineCodegenUtilKt.getOrCreateJvmSuspendFunctionView(referencedFunction, state); this.functionDescriptor = CoroutineCodegenUtilKt.getOrCreateJvmSuspendFunctionView(functionDescriptor, state); } else { - this.referencedFunction = (FunctionDescriptor) resultingDescriptor; + this.referencedFunction = referencedFunction; this.functionDescriptor = functionDescriptor; } this.receiverType = receiverType; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java index 0e4e6e72b02..131f631fee4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java @@ -334,19 +334,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { nameStack.push(name); if (CoroutineUtilKt.isSuspendLambda(functionDescriptor)) { - SimpleFunctionDescriptor jvmSuspendFunctionView = - CoroutineCodegenUtilKt.getOrCreateJvmSuspendFunctionView( - (SimpleFunctionDescriptor) functionDescriptor, - languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines) - ); - - bindingTrace.record( - CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, - functionDescriptor, - jvmSuspendFunctionView - ); - closure.setSuspend(true); - closure.setSuspendLambda(); + createAndRecordSuspendFunctionView(closure, (SimpleFunctionDescriptor) functionDescriptor, true); } functionsStack.push(functionDescriptor); @@ -406,8 +394,8 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { if (callableDescriptor instanceof SimpleFunctionDescriptor) { SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) callableDescriptor; - if (functionDescriptor.isSuspend()){ - createAndRecordSuspendFunctionView(closure, functionDescriptor, /* isSuspendLambda */ false, /* isDropSuspend */ false); + if (functionDescriptor.isSuspend()) { + createAndRecordSuspendFunctionView(closure, functionDescriptor, false); } } @@ -421,15 +409,13 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { private SimpleFunctionDescriptor createAndRecordSuspendFunctionView( MutableClosure closure, SimpleFunctionDescriptor functionDescriptor, - boolean isSuspendLambda, - boolean isDropSuspend + boolean isSuspendLambda ) { SimpleFunctionDescriptor jvmSuspendFunctionView = CoroutineCodegenUtilKt.getOrCreateJvmSuspendFunctionView( functionDescriptor, languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines), - this.bindingContext, - isDropSuspend + this.bindingContext ); bindingTrace.record( @@ -581,8 +567,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { MutableClosure closure = recordClosure(classDescriptor, name); SimpleFunctionDescriptor jvmSuspendFunctionView = - createAndRecordSuspendFunctionView(closure, (SimpleFunctionDescriptor) functionDescriptor, - /* isSuspendLambda*/ false, /* isDropSuspend */ false); + createAndRecordSuspendFunctionView(closure, (SimpleFunctionDescriptor) functionDescriptor, false); // This is a very subtle place (hack). // When generating bytecode of some suspend function, we replace the original descriptor @@ -626,8 +611,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { nameStack.push(name); if (functionDescriptor instanceof SimpleFunctionDescriptor && functionDescriptor.isSuspend()) { - createAndRecordSuspendFunctionView(closure, (SimpleFunctionDescriptor) functionDescriptor, - /* isSuspendLambda */ true, /* isDropSuspend */ true); + createAndRecordSuspendFunctionView(closure, (SimpleFunctionDescriptor) functionDescriptor,true); } functionsStack.push(functionDescriptor); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt index f8bcb4a20df..b7444fc6839 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt @@ -139,19 +139,26 @@ class CoroutineCodegenForLambda private constructor( private lateinit var constructorToUseFromInvoke: Method - private val createCoroutineDescriptor = - funDescriptor.createCustomCopy { - setName(Name.identifier(SUSPEND_FUNCTION_CREATE_METHOD_NAME)) - setReturnType( - funDescriptor.module.getContinuationOfTypeOrAny( - builtIns.unitType, - state.languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines) - ) - ) - // 'create' method should not inherit initial descriptor for suspend function from original descriptor - putUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION, null) - setVisibility(Visibilities.PUBLIC) - } + private val createCoroutineDescriptor = SimpleFunctionDescriptorImpl.create( + funDescriptor.containingDeclaration, + Annotations.EMPTY, + Name.identifier(SUSPEND_FUNCTION_CREATE_METHOD_NAME), + funDescriptor.kind, + funDescriptor.source + ).also { + it.initialize( + funDescriptor.extensionReceiverParameter?.type, + funDescriptor.dispatchReceiverParameter, + funDescriptor.typeParameters, + funDescriptor.valueParameters, + funDescriptor.module.getContinuationOfTypeOrAny( + builtIns.unitType, + state.languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines) + ), + funDescriptor.modality, + Visibilities.PUBLIC + ) + } override fun generateClosureBody() { for (parameter in allFunctionParameters()) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt index a352b55e625..85c7f836b62 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt @@ -214,8 +214,7 @@ fun getOrCreateJvmSuspendFunctionView(function: D, stat fun getOrCreateJvmSuspendFunctionView( function: D, isReleaseCoroutines: Boolean, - bindingContext: BindingContext? = null, - dropSuspend: Boolean = false + bindingContext: BindingContext? = null ): D { assert(function.isSuspend) { "Suspended function is expected, but $function was found" @@ -245,9 +244,6 @@ fun getOrCreateJvmSuspendFunctionView( setPreserveSourceElement() setReturnType(function.builtIns.nullableAnyType) setValueParameters(it.valueParameters + continuationParameter) - if (dropSuspend) { - setIsSuspend(false) - } putUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION, it) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index 646a4e23163..f1bf946a1cd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -1016,7 +1016,7 @@ public class KotlinTypeMapper { return OperatorNameConventions.INVOKE.asString(); } - else if (isLocalFunction(descriptor) || isFunctionExpression(descriptor) || isSuspendFunctionReference(descriptor)) { + else if (isLocalFunction(descriptor) || isFunctionExpression(descriptor)) { return OperatorNameConventions.INVOKE.asString(); } else { @@ -1024,13 +1024,6 @@ public class KotlinTypeMapper { } } - private static boolean isSuspendFunctionReference(FunctionDescriptor descriptor) { - return descriptor instanceof SimpleFunctionDescriptor && - descriptor.getName().isSpecial() && - CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(descriptor) != null && - CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(descriptor).isSuspend(); - } - @NotNull private static OwnerKind getKindForDefaultImplCall(@NotNull FunctionDescriptor baseMethodDescriptor) { DeclarationDescriptor containingDeclaration = baseMethodDescriptor.getContainingDeclaration(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/AnonymousFunctionDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/AnonymousFunctionDescriptor.java index faa7fa896c2..0f76f9c623f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/AnonymousFunctionDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/AnonymousFunctionDescriptor.java @@ -1,25 +1,18 @@ /* - * Copyright 2010-2015 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-2018 JetBrains s.r.o. 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.descriptors.impl; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; +import org.jetbrains.kotlin.descriptors.FunctionDescriptor; +import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; import org.jetbrains.kotlin.descriptors.SourceElement; import org.jetbrains.kotlin.descriptors.annotations.Annotations; +import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.name.SpecialNames; public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl { @@ -36,6 +29,38 @@ public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl { this.isSuspend = isSuspend; } + private AnonymousFunctionDescriptor( + @NotNull DeclarationDescriptor declarationDescriptor, + @Nullable SimpleFunctionDescriptor original, + @NotNull Annotations annotations, + @NotNull Name name, + @NotNull Kind kind, + @NotNull SourceElement source + ) { + super(declarationDescriptor, original, annotations, name, kind, source); + this.isSuspend = false; + } + + @NotNull + @Override + protected FunctionDescriptorImpl createSubstitutedCopy( + @NotNull DeclarationDescriptor newOwner, + @Nullable FunctionDescriptor original, + @NotNull Kind kind, + @Nullable Name newName, + @NotNull Annotations annotations, + @NotNull SourceElement source + ) { + return new AnonymousFunctionDescriptor( + newOwner, + (SimpleFunctionDescriptor) original, + annotations, + newName != null ? newName : getName(), + kind, + source + ); + } + @Override public boolean isSuspend() { return isSuspend; 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 f10ff713f14..b4a6628d8dd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt @@ -632,7 +632,7 @@ class DoubleColonExpressionResolver( val descriptor = if (resolutionResults?.isSingleResult == true) resolutionResults.resultingDescriptor else null if (descriptor is PropertyDescriptor && descriptor.isBuiltInCoroutineContext(languageVersionSettings)) { - context.trace.report(UNSUPPORTED.on(expression.callableReference, "Callable references to suspend property")) + context.trace.report(UNSUPPORTED.on(expression.callableReference, "Callable reference to suspend property")) } val expressionResult = lhsResult as? DoubleColonLHS.Expression ?: return diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt index 6902f3894cd..25cd6e2dde4 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS, JS_IR // COMMON_COROUTINES_TEST // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt index 49da78b8008..20cf5e490e8 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS, NATIVE, JS_IR // WITH_REFLECT // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt index da7a77ec033..3b5f8a70d4a 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS, JS_IR, NATIVE // WITH_REFLECT // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/getArityViaFunctionImpl.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/getArityViaFunctionImpl.kt index f69252db570..8f7c3cc9667 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/getArityViaFunctionImpl.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/getArityViaFunctionImpl.kt @@ -1,5 +1,5 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS, NATIVE, JS_IR // IGNORE_LIGHT_ANALYSIS // LANGUAGE_VERSION: 1.2 diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt index aee553282aa..5689f5b3405 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS, NATIVE, JS_IR // COMMON_COROUTINES_TEST fun box(): String { diff --git a/compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt b/compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt index 7b2dd8959d0..b2002783f61 100644 --- a/compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt +++ b/compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt @@ -1,6 +1,11 @@ // !LANGUAGE: +Coroutines // SKIP_TXT +// !CHECK_TYPE + +import kotlin.reflect.KSuspendFunction0 suspend fun foo() {} -val ref = ::foo +fun test() { + ::foo checkType { _() } +} diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 01a48023d66..24e6ab8ceb8 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -6290,20 +6290,22 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } @TestMetadata("longArgs.kt") public void testLongArgs_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines.experimental"); } @TestMetadata("longArgs.kt") public void testLongArgs_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines"); } @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound") @@ -6314,20 +6316,22 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines.experimental"); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines"); } } @@ -6339,32 +6343,32 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + public void testAllFilesPresentInFunction() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines"); } @TestMetadata("getArityViaFunctionImpl.kt") @@ -6380,20 +6384,22 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + public void testAllFilesPresentInLocal() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines.experimental"); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines"); } } } diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 662fac29950..73f81e0c895 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -3367,6 +3367,10 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } @@ -3378,14 +3382,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli @TestMetadata("simple.kt") public void testSimple_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines.experimental"); } @TestMetadata("simple.kt") public void testSimple_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines"); } @TestMetadata("suspendOfOrdinary.kt") diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index b76acfb3aaa..4a5e699adad 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3367,6 +3367,10 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } @@ -3378,14 +3382,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC @TestMetadata("simple.kt") public void testSimple_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines.experimental"); } @TestMetadata("simple.kt") public void testSimple_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines"); } @TestMetadata("suspendOfOrdinary.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 9c534b173ac..4a15c5abf5c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1586,20 +1586,22 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.ANY, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } @TestMetadata("property.kt") public void testProperty_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines.experimental"); } @TestMetadata("property.kt") public void testProperty_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines"); } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index f482b8f5472..b1a6871e68e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -1586,20 +1586,22 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.ANY, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } @TestMetadata("property.kt") public void testProperty_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines.experimental"); } @TestMetadata("property.kt") public void testProperty_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines"); } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index bfa83d4cc77..7b79872b5a2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -6290,20 +6290,22 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("longArgs.kt") public void testLongArgs_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines.experimental"); } @TestMetadata("longArgs.kt") public void testLongArgs_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines"); } @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound") @@ -6314,20 +6316,22 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines.experimental"); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines"); } } @@ -6339,32 +6343,32 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInFunction() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines"); } @TestMetadata("getArityViaFunctionImpl.kt") @@ -6380,20 +6384,22 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInLocal() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines.experimental"); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines"); } } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 36129e06a60..60bb133d4cc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -3367,6 +3367,10 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.ANY, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } @@ -3378,14 +3382,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo @TestMetadata("simple.kt") public void testSimple_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines.experimental"); } @TestMetadata("simple.kt") public void testSimple_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines"); } @TestMetadata("suspendOfOrdinary.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index e68f4eb7c9e..9a989d9c5ac 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3367,6 +3367,10 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.ANY, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } @@ -3378,14 +3382,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi @TestMetadata("simple.kt") public void testSimple_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines.experimental"); } @TestMetadata("simple.kt") public void testSimple_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/callableReference/simple.kt", "kotlin.coroutines"); } @TestMetadata("suspendOfOrdinary.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 23d26c8fd5d..2f3b49ce2f2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -6290,20 +6290,22 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("longArgs.kt") public void testLongArgs_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines.experimental"); } @TestMetadata("longArgs.kt") public void testLongArgs_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines"); } @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound") @@ -6314,20 +6316,22 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines.experimental"); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines"); } } @@ -6339,32 +6343,32 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInFunction() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines"); } @TestMetadata("getArityViaFunctionImpl.kt") @@ -6380,20 +6384,22 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInLocal() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines.experimental"); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines"); } } } diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 68f5f35158e..07386974c74 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor +import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation @@ -174,11 +175,12 @@ class LazyJavaClassMemberScope( ) } ?: return null - return newCopyBuilder() - .setIsSuspend(true) + val functionDescriptor = newCopyBuilder() .setValueParameters(valueParameters.dropLast(1)) .setReturnType(continuationParameter.type.arguments[0].type) .build() + (functionDescriptor as SimpleFunctionDescriptorImpl?)?.isSuspend = true + return functionDescriptor } private fun SimpleFunctionDescriptor.createRenamedCopy(builtinName: Name): SimpleFunctionDescriptor = diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index 0477522f549..e3720d45f77 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -127,14 +127,12 @@ class FunctionClassDescriptor( add(containingDeclaration, Name.identifier(functionKind.classNamePrefix)) } + // For K{Suspend}Function{n}, add corresponding numbered {Suspend}Function{n} class, e.g. {Suspend}Function2 for K{Suspend}Function2 val numberedSupertypeKind = when (functionKind) { Kind.KFunction -> Kind.Function Kind.KSuspendFunction -> Kind.SuspendFunction else -> null } - - - // For K{Suspend}Function{n}, add corresponding numbered {Suspend}Function{n} class, e.g. {Suspend}Function2 for {Suspend}KFunction2 if (numberedSupertypeKind != null) { val packageView = containingDeclaration.containingDeclaration.getPackage(BUILT_INS_PACKAGE_FQ_NAME) val kotlinPackageFragment = packageView.fragments.filterIsInstance().first() diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/FunctionDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/FunctionDescriptor.java index 4c2b8cbff19..9561aa22234 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/FunctionDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/FunctionDescriptor.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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-2018 JetBrains s.r.o. 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.descriptors; @@ -144,9 +133,6 @@ public interface FunctionDescriptor extends CallableMemberDescriptor { @NotNull CopyBuilder setDropOriginalInContainingParts(); - @NotNull - CopyBuilder setIsSuspend(boolean isSuspend); - @NotNull CopyBuilder setHiddenToOvercomeSignatureClash(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java index 5f0a439d4c0..f9382f422c3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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-2018 JetBrains s.r.o. 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.descriptors.impl; @@ -507,13 +496,6 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo return this; } - @Override - @NotNull - public CopyConfiguration setIsSuspend(boolean isSuspend) { - this.isSuspend = isSuspend; - return this; - } - @Override @NotNull public CopyConfiguration setHiddenToOvercomeSignatureClash() { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt index 57031350060..316bdbc2472 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt @@ -1,22 +1,12 @@ /* - * 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-2018 JetBrains s.r.o. 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.descriptorUtil -import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.builtins.* +import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.ClassKind.* import org.jetbrains.kotlin.descriptors.annotations.Annotated @@ -159,6 +149,10 @@ fun ClassDescriptor.getSuperInterfaces(): List = else null } +fun ClassDescriptor.isCallableReferenceToSuspend(functionReference: ClassDescriptor) = + getSuperClassNotAny() == functionReference && + getSuperInterfaces().singleOrNull()?.getFunctionalClassKind() == FunctionClassDescriptor.Kind.SuspendFunction + val ClassDescriptor.secondaryConstructors: List get() = constructors.filterNot { it.isPrimary } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorSimpleFunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorSimpleFunctionDescriptorImpl.java index 2af3aa23a9e..2004c5e75eb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorSimpleFunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/error/ErrorSimpleFunctionDescriptorImpl.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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-2018 JetBrains s.r.o. 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.types.error; @@ -168,12 +157,6 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI return this; } - @NotNull - @Override - public CopyBuilder setIsSuspend(boolean isSuspend) { - return this; - } - @NotNull @Override public CopyBuilder setHiddenToOvercomeSignatureClash() { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index ea0711e272e..524d907d481 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -5495,20 +5495,17 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); } @TestMetadata("longArgs.kt") public void testLongArgs_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - try { - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); - } - catch (Throwable ignore) { - return; - } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines.experimental"); } @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound") @@ -5519,14 +5516,17 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR, testDataFilePath); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines.experimental"); } } @@ -5538,20 +5538,22 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR, testDataFilePath); + } + public void testAllFilesPresentInFunction() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines.experimental"); } @TestMetadata("getArityViaFunctionImpl.kt") @@ -5567,14 +5569,17 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR, testDataFilePath); + } + public void testAllFilesPresentInLocal() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines.experimental"); } } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 575c82e8270..b366910a16b 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -5495,20 +5495,17 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS, testDataFilePath); + } + public void testAllFilesPresentInCallableReference() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); } @TestMetadata("longArgs.kt") public void testLongArgs_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); - try { - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); - } - catch (Throwable ignore) { - return; - } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt", "kotlin.coroutines.experimental"); } @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound") @@ -5519,20 +5516,17 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS, testDataFilePath); + } + public void testAllFilesPresentInBound() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); } @TestMetadata("emptyLHS.kt") public void testEmptyLHS_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt"); - try { - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); - } - catch (Throwable ignore) { - return; - } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt", "kotlin.coroutines.experimental"); } } @@ -5544,32 +5538,22 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS, testDataFilePath); + } + public void testAllFilesPresentInFunction() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); } @TestMetadata("genericCallableReferenceArguments.kt") public void testGenericCallableReferenceArguments_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt"); - try { - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); - } - catch (Throwable ignore) { - return; - } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferenceArguments.kt", "kotlin.coroutines.experimental"); } @TestMetadata("genericCallableReferencesWithNullableTypes.kt") public void testGenericCallableReferencesWithNullableTypes_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt"); - try { - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); - } - catch (Throwable ignore) { - return; - } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/genericCallableReferencesWithNullableTypes.kt", "kotlin.coroutines.experimental"); } @TestMetadata("getArityViaFunctionImpl.kt") @@ -5585,20 +5569,17 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS, testDataFilePath); + } + public void testAllFilesPresentInLocal() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); } @TestMetadata("equalsHashCode.kt") public void testEqualsHashCode_1_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt"); - try { - doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental"); - } - catch (Throwable ignore) { - return; - } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt", "kotlin.coroutines.experimental"); } } }