From 50b0dae7867eff06b51b730297d32298e950d5ea Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 30 Nov 2021 10:55:55 +0300 Subject: [PATCH] KT-47939 fixes after review --- ...SamInterfaceConstructorReferenceChecker.kt | 2 - .../backend/generators/AdapterGenerator.kt | 16 ++++-- .../fir/declarations/deprecationUtils.kt | 2 +- ...nterfaceConstructorReferenceCallChecker.kt | 3 -- .../ReflectionReferencesGenerator.kt | 18 ++++--- .../ir/declarations/IrDeclarationOrigin.kt | 2 - .../funInterfaceConstructor.kt | 2 +- ...funInterfaceConstructorReferences_after.kt | 2 +- ...unInterfaceConstructorReferences_before.kt | 4 +- ...unInterfaceConstructorReference.fir.ir.txt | 49 +++++++++++-------- ...unInterfaceConstructorReference.fir.kt.txt | 28 ++++++++--- .../funInterfaceConstructorReference.ir.txt | 49 +++++++++++-------- .../funInterfaceConstructorReference.kt.txt | 28 ++++++++--- .../kotlin/config/LanguageVersionSettings.kt | 1 - 14 files changed, 126 insertions(+), 80 deletions(-) diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirJavaSamInterfaceConstructorReferenceChecker.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirJavaSamInterfaceConstructorReferenceChecker.kt index 6455a89b5fb..6ce386257e4 100644 --- a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirJavaSamInterfaceConstructorReferenceChecker.kt +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirJavaSamInterfaceConstructorReferenceChecker.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.analysis.jvm.checkers.expression -import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext @@ -23,7 +22,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol object FirJavaSamInterfaceConstructorReferenceChecker : FirQualifiedAccessExpressionChecker() { override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) { if (expression !is FirCallableReferenceAccess) return - if (!context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitJavaSamInterfaceConstructorReference)) return val reference = expression.calleeReference as? FirResolvedNamedReference ?: return val referredSymbol = reference.resolvedSymbol diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index 771d29e273c..64e374a6367 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -577,12 +577,18 @@ internal class AdapterGenerator( IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE ) irAdapterFunction.valueParameters = listOf(irFunctionParameter) - irAdapterFunction.body = irFactory.createExpressionBody( + irAdapterFunction.body = irFactory.createBlockBody( startOffset, endOffset, - IrTypeOperatorCallImpl( - startOffset, endOffset, - irSamType, IrTypeOperator.SAM_CONVERSION, irSamType, - IrGetValueImpl(startOffset, endOffset, irFunctionParameter.symbol) + listOf( + IrReturnImpl( + startOffset, endOffset, components.irBuiltIns.nothingType, + irAdapterFunction.symbol, + IrTypeOperatorCallImpl( + startOffset, endOffset, + irSamType, IrTypeOperator.SAM_CONVERSION, irSamType, + IrGetValueImpl(startOffset, endOffset, irFunctionParameter.symbol) + ) + ) ) ) symbolTable.leaveScope(irAdapterFunction) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt index 2bcf12b2b2f..bbb6f47cca1 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt @@ -45,7 +45,7 @@ fun FirBasedSymbol<*>.getDeprecation(callSite: FirElement?): DeprecationInfo? { fun FirAnnotationContainer.getDeprecationInfos(currentVersion: ApiVersion): DeprecationsPerUseSite { val deprecationByUseSite = mutableMapOf() - val fromJava = this.safeAs()?.isJavaOrEnhancement == true + val fromJava = this is FirDeclaration && this.isJavaOrEnhancement annotations.extractDeprecationInfoPerUseSite(currentVersion, fromJava).toMap(deprecationByUseSite) if (this is FirProperty) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/SamInterfaceConstructorReferenceCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/SamInterfaceConstructorReferenceCallChecker.kt index 1bb6243f097..b15a921b9c7 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/SamInterfaceConstructorReferenceCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/SamInterfaceConstructorReferenceCallChecker.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.resolve.jvm.checkers import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall @@ -16,8 +15,6 @@ import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor object SamInterfaceConstructorReferenceCallChecker : CallChecker { override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { - if (!context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitJavaSamInterfaceConstructorReference)) return - val resultingDescriptor = resolvedCall.resultingDescriptor if (resultingDescriptor !is SamConstructorDescriptor || !resolvedCall.call.isCallableReference()) return diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt index e9e6c186bf9..2f56a0d2c86 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt @@ -172,19 +172,25 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St isExpect = false, isFakeOverride = false ).also { irAdapterFun -> context.symbolTable.withScope(irAdapterFun) { - // TODO irAdapterFun.metadata = ...? + irAdapterFun.metadata = null irAdapterFun.dispatchReceiverParameter = null irAdapterFun.extensionReceiverParameter = null val irFnParameter = createAdapterParameter(startOffset, endOffset, functionParameter.name, 0, functionParameter.type) irAdapterFun.valueParameters = listOf(irFnParameter) irAdapterFun.body = - context.irFactory.createExpressionBody( + context.irFactory.createBlockBody( startOffset, endOffset, - IrTypeOperatorCallImpl( - startOffset, endOffset, - irSamType, IrTypeOperator.SAM_CONVERSION, irSamType, - IrGetValueImpl(startOffset, endOffset, irFnParameter.symbol) + listOf( + IrReturnImpl( + startOffset, endOffset, context.irBuiltIns.nothingType, + irAdapterFun.symbol, + IrTypeOperatorCallImpl( + startOffset, endOffset, + irSamType, IrTypeOperator.SAM_CONVERSION, irSamType, + IrGetValueImpl(startOffset, endOffset, irFnParameter.symbol) + ) + ) ) ) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt index b0695103923..c736f2f7515 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt @@ -16,8 +16,6 @@ package org.jetbrains.kotlin.ir.declarations -import org.jetbrains.kotlin.ir.expressions.IrStatementOriginImpl - interface IrDeclarationOrigin { object DEFINED : IrDeclarationOriginImpl("DEFINED") object FAKE_OVERRIDE : IrDeclarationOriginImpl("FAKE_OVERRIDE") diff --git a/compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructor.kt b/compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructor.kt index cbc956972cf..f889ecad410 100644 --- a/compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructor.kt +++ b/compiler/testData/codegen/box/callableReference/funInterfaceConstructor/funInterfaceConstructor.kt @@ -1,5 +1,5 @@ // !LANGUAGE: +AllowKotlinFunInterfaceConstructorReference -// IGNORE_BACKEND: JVM, JS +// IGNORE_BACKEND: JVM // ^ feature supported in IR-based backends only fun interface KSupplier { diff --git a/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_after.kt b/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_after.kt index 067f2dddae7..2a2e2068e96 100644 --- a/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_after.kt +++ b/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_after.kt @@ -1,5 +1,5 @@ // FIR_IDENTICAL -// !LANGUAGE: +AllowKotlinFunInterfaceConstructorReference +ProhibitJavaSamInterfaceConstructorReference +// !LANGUAGE: +AllowKotlinFunInterfaceConstructorReference fun interface Foo { fun run() diff --git a/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_before.kt b/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_before.kt index 53ba1ae6c78..4ded15752f2 100644 --- a/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_before.kt +++ b/compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_before.kt @@ -1,5 +1,5 @@ // FIR_IDENTICAL -// !LANGUAGE: -AllowKotlinFunInterfaceConstructorReference -ProhibitJavaSamInterfaceConstructorReference +// !LANGUAGE: -AllowKotlinFunInterfaceConstructorReference fun interface Foo { fun run() @@ -7,4 +7,4 @@ fun interface Foo { val x = ::Foo val y = Foo { } -val z = ::Runnable \ No newline at end of file +val z = ::Runnable diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt index 18270ebfdb1..3c0314d3c60 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt @@ -62,9 +62,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KRunnable VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1a visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1, .KRunnable> BLOCK_BODY @@ -72,9 +73,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KRunnable VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<.KRunnable> BLOCK_BODY @@ -82,9 +84,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KRunnable VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -92,9 +95,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSupplier visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KSupplier VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' + TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier + GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -102,9 +106,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSupplier visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KSupplier VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' + TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier + GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -112,9 +117,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KConsumer visibility:local modality:FINAL <> (function:kotlin.Function1) returnType:.KConsumer VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function1 - EXPRESSION_BODY - TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1 declared in .test3.KConsumer' type=kotlin.Function1 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3' + TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer + GET_VAR 'function: kotlin.Function1 declared in .test3.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -122,7 +128,8 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KConsumer visibility:local modality:FINAL <> (function:kotlin.Function1) returnType:.KConsumer VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function1 - EXPRESSION_BODY - TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1 declared in .test3a.KConsumer' type=kotlin.Function1 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3a' + TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer + GET_VAR 'function: kotlin.Function1 declared in .test3a.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3a' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt index f6d72ccffa8..f1dcde7bcf4 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt @@ -18,7 +18,9 @@ fun interface KConsumer { fun test1(): KFunction1, KRunnable> { return { // BLOCK - local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable { + return function /*-> KRunnable */ + } ::KRunnable } @@ -26,7 +28,9 @@ fun test1(): KFunction1, KRunnable> { fun test1a(): KFunction1, KRunnable> { return { // BLOCK - local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable { + return function /*-> KRunnable */ + } ::KRunnable } @@ -34,7 +38,9 @@ fun test1a(): KFunction1, KRunnable> { fun test1b(): KFunction { return { // BLOCK - local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable { + return function /*-> KRunnable */ + } ::KRunnable } @@ -42,7 +48,9 @@ fun test1b(): KFunction { fun test2(): Function1, KSupplier> { return { // BLOCK - local fun KSupplier(function: Function0): KSupplier function /*-> KSupplier */ + local fun KSupplier(function: Function0): KSupplier { + return function /*-> KSupplier */ + } ::KSupplier } @@ -50,7 +58,9 @@ fun test2(): Function1, KSupplier> { fun test2a(): Function1, KSupplier> { return { // BLOCK - local fun KSupplier(function: Function0): KSupplier function /*-> KSupplier */ + local fun KSupplier(function: Function0): KSupplier { + return function /*-> KSupplier */ + } ::KSupplier } @@ -58,7 +68,9 @@ fun test2a(): Function1, KSupplier> { fun test3(): Function1, KConsumer> { return { // BLOCK - local fun KConsumer(function: Function1): KConsumer function /*-> KConsumer */ + local fun KConsumer(function: Function1): KConsumer { + return function /*-> KConsumer */ + } ::KConsumer } @@ -66,7 +78,9 @@ fun test3(): Function1, KConsumer> { fun test3a(): Function1, KConsumer> { return { // BLOCK - local fun KConsumer(function: Function1): KConsumer function /*-> KConsumer */ + local fun KConsumer(function: Function1): KConsumer { + return function /*-> KConsumer */ + } ::KConsumer } diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt index 7469def4e87..676f2df7d48 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt @@ -62,9 +62,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KRunnable VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1a visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> BLOCK_BODY @@ -72,9 +73,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KRunnable VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<.KRunnable> BLOCK_BODY @@ -82,9 +84,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KRunnable visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KRunnable VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -92,9 +95,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSupplier visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KSupplier VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' + TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier + GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test2a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> BLOCK_BODY @@ -102,9 +106,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSupplier visibility:local modality:FINAL <> (function:kotlin.Function0) returnType:.KSupplier VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0 - EXPRESSION_BODY - TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' + TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier + GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -112,9 +117,10 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KConsumer visibility:local modality:FINAL <> (function:kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>) returnType:.KConsumer VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> - EXPRESSION_BODY - TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3' + TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer + GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= FUN name:test3a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> BLOCK_BODY @@ -122,7 +128,8 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KConsumer visibility:local modality:FINAL <> (function:kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>) returnType:.KConsumer VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> - EXPRESSION_BODY - TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3a.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3a' + TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer + GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3a.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt index 4736efbba56..da23c407847 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt @@ -18,7 +18,9 @@ fun interface KConsumer { typealias KCS = KConsumer fun test1(): KFunction1<@ParameterName(name = "function") Function0, KRunnable> { return { // BLOCK - local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable { + return function /*-> KRunnable */ + } ::KRunnable } @@ -26,7 +28,9 @@ fun test1(): KFunction1<@ParameterName(name = "function") Function0, KRunn fun test1a(): KFunction1<@ParameterName(name = "function") Function0, KRunnable> { return { // BLOCK - local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable { + return function /*-> KRunnable */ + } ::KRunnable } @@ -34,7 +38,9 @@ fun test1a(): KFunction1<@ParameterName(name = "function") Function0, KRun fun test1b(): KFunction { return { // BLOCK - local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable { + return function /*-> KRunnable */ + } ::KRunnable } @@ -42,7 +48,9 @@ fun test1b(): KFunction { fun test2(): Function1, KSupplier> { return { // BLOCK - local fun KSupplier(function: Function0): KSupplier function /*-> KSupplier */ + local fun KSupplier(function: Function0): KSupplier { + return function /*-> KSupplier */ + } ::KSupplier } @@ -50,7 +58,9 @@ fun test2(): Function1, KSupplier> { fun test2a(): Function1, KSupplier> { return { // BLOCK - local fun KSupplier(function: Function0): KSupplier function /*-> KSupplier */ + local fun KSupplier(function: Function0): KSupplier { + return function /*-> KSupplier */ + } ::KSupplier } @@ -58,7 +68,9 @@ fun test2a(): Function1, KSupplier> { fun test3(): Function1, KConsumer> { return { // BLOCK - local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer function /*-> KConsumer */ + local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer { + return function /*-> KConsumer */ + } ::KConsumer } @@ -66,7 +78,9 @@ fun test3(): Function1, KConsumer> { fun test3a(): Function1, KConsumer> { return { // BLOCK - local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer function /*-> KConsumer */ + local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer { + return function /*-> KConsumer */ + } ::KConsumer } diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index dd5a8153823..61dcb14b3d7 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -365,7 +365,6 @@ enum class LanguageVersion(val major: Int, val minor: Int) : DescriptionAware, L KOTLIN_1_6(1, 6), KOTLIN_1_7(1, 7), KOTLIN_1_8(1, 8), - KOTLIN_1_9(1, 9), ; override val isStable: Boolean