Skip to content

Commit 204eb63

Browse files
ivandev0Space Team
authored andcommitted
[Inline] Apply a patch to ignore broken preprocessed funs in klib
This commit can be reverted after the bootstrap update. #KT-81070 Fixed #KT-81470
1 parent 4fe4c6a commit 204eb63

File tree

52 files changed

+70
-35
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+70
-35
lines changed

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/IrValidationPhase.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class IrValidationAfterInliningAllFunctionsOnTheFirstStagePhase<Context : Loweri
106106
) : IrValidationPhase<Context>(context) {
107107
override val defaultValidationConfig: IrValidatorConfig
108108
get() = IrValidatorConfig()
109-
.withInlineFunctionCallsiteCheck(checkInlineFunctionCallSites)
109+
// Enable after KT-81470 fix
110+
// .withInlineFunctionCallsiteCheck(checkInlineFunctionCallSites)
110111
}
111112

112113
open class IrValidationAfterLoweringPhase<Context : LoweringContext>(context: Context) : IrValidationPhase<Context>(context) {

compiler/ir/ir.inline/src/org/jetbrains/kotlin/ir/inline/FunctionInlining.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ class FunctionInlining(
5656
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: IrDeclaration): IrExpression {
5757
expression.transformChildren(this, data)
5858

59-
val actualCallee = inlineFunctionResolver.getFunctionDeclarationToInline(expression) ?: return expression
60-
if (expression is IrCall && PreSerializationSymbols.isTypeOfIntrinsic(actualCallee.symbol)) {
59+
if (expression is IrCall && PreSerializationSymbols.isTypeOfIntrinsic(expression.symbol)) {
6160
return expression
6261
}
62+
val actualCallee = inlineFunctionResolver.getFunctionDeclarationToInline(expression) ?: return expression
6363
if (actualCallee.body == null) {
6464
return expression
6565
}

compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/NonLinkingIrInlineFunctionDeserializer.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ class NonLinkingIrInlineFunctionDeserializer(
154154
deserializedFunctionCache.getOrPut(signature) {
155155
val idSigIndex = reversedSignatureIndex[signature] ?: return@getOrPut null
156156
val functionProto = fileReader.declaration(idSigIndex)
157+
158+
// Drop after KT-81470 fix
159+
val (s, _) = symbolDeserializer.deserializeSymbolToDeclareInCurrentFile(functionProto.irFunction.base.base.symbol)
160+
if (s.signature !is IdSignature.CompositeSignature) return@getOrPut null
161+
157162
val function = declarationDeserializer.deserializeDeclaration(functionProto) as IrSimpleFunction
158163

159164
val fileEntryProto = fileReader.fileEntry(functionProto.irFunction.preparedInlineFunctionFileEntryId)!!

compiler/testData/codegen/box/delegatedProperty/lazyDelegateInObject.fir.inlined.ir

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -323,38 +323,19 @@ FILE fqName:<root> fileName:/lazyDelegateInObject.kt
323323
correspondingProperty: PROPERTY name:original visibility:public modality:FINAL [delegated,val]
324324
BLOCK_BODY
325325
RETURN type=kotlin.Nothing from='public final fun <get-original> (): kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>'
326-
BLOCK type=kotlin.Any? origin=INLINE_ARGS_CONTAINER
327-
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Lazy<kotlin.Any?> [val]
328-
TYPE_OP type=kotlin.Lazy<kotlin.Any?> origin=IMPLICIT_CAST typeOperand=kotlin.Lazy<kotlin.Any?>
329-
GET_FIELD 'FIELD PROPERTY_DELEGATE name:original$delegate type:kotlin.Lazy<kotlin.Any?> visibility:private [final] declared in <root>.lazyDelegateInObject.<no name provided>' type=kotlin.Lazy<kotlin.Any?> origin=null
330-
receiver: GET_VAR '<this>: <root>.lazyDelegateInObject.<no name provided> declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=<root>.lazyDelegateInObject.<no name provided> origin=IMPLICIT_ARGUMENT
331-
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Any? [val]
332-
TYPE_OP type=kotlin.Any? origin=IMPLICIT_CAST typeOperand=kotlin.Any?
333-
GET_VAR '<this>: <root>.lazyDelegateInObject.<no name provided> declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=<root>.lazyDelegateInObject.<no name provided> origin=null
334-
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.reflect.KProperty<*> [val]
335-
TYPE_OP type=kotlin.reflect.KProperty<*> origin=IMPLICIT_CAST typeOperand=kotlin.reflect.KProperty<*>
336-
RICH_PROPERTY_REFERENCE type=kotlin.reflect.KProperty1<*, kotlin.Any?> origin=PROPERTY_REFERENCE_FOR_DELEGATE reflectionTarget='public final original: kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>'
337-
getter: FUN LOCAL_FUNCTION_FOR_LAMBDA name:<get-original> visibility:local modality:FINAL returnType:kotlin.Any?
338-
VALUE_PARAMETER kind:Regular name:p0 index:0 type:kotlin.Any?
339-
BLOCK_BODY
340-
RETURN type=kotlin.Nothing from='local final fun <get-original> (p0: kotlin.Any?): kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>'
341-
CALL 'public final fun <get-original> (): kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>' type=kotlin.Any? origin=null
342-
ARG <this>: TYPE_OP type=<root>.lazyDelegateInObject.<no name provided> origin=IMPLICIT_CAST typeOperand=<root>.lazyDelegateInObject.<no name provided>
343-
GET_VAR 'p0: kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>.<get-original>' type=kotlin.Any? origin=null
344-
RETURNABLE_BLOCK type=kotlin.Any? origin=null
345-
INLINED_BLOCK type=kotlin.Any? origin=null
346-
inlinedFunctionSymbol: public final fun getValue <T> (<this>: kotlin.Lazy<T of kotlin.getValue>, thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue declared in kotlin
347-
inlinedFunctionFileEntry: FILE_ENTRY path:src/kotlin/util/Lazy.kt
348-
VAR IR_TEMPORARY_VARIABLE_FOR_INLINED_PARAMETER name:this type:kotlin.Lazy<kotlin.Any?> [val]
349-
GET_VAR 'val tmp_0: kotlin.Lazy<kotlin.Any?> declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=kotlin.Lazy<kotlin.Any?> origin=null
350-
VAR IR_TEMPORARY_VARIABLE_FOR_INLINED_PARAMETER name:thisRef type:kotlin.Any? [val]
351-
GET_VAR 'val tmp_1: kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=kotlin.Any? origin=null
352-
VAR IR_TEMPORARY_VARIABLE_FOR_INLINED_PARAMETER name:property type:kotlin.reflect.KProperty<*> [val]
353-
GET_VAR 'val tmp_2: kotlin.reflect.KProperty<*> declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=kotlin.reflect.KProperty<*> origin=null
354-
RETURN type=kotlin.Nothing from='{IrReturnableBlockImpl}'
355-
TYPE_OP type=kotlin.Any? origin=IMPLICIT_CAST typeOperand=kotlin.Any?
356-
CALL 'UNBOUND IrSimpleFunctionSymbolImpl' type=kotlin.Any? origin=GET_PROPERTY
357-
ARG 1: GET_VAR 'val this: kotlin.Lazy<kotlin.Any?> declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=kotlin.Lazy<kotlin.Any?> origin=null
326+
CALL 'public final fun getValue <T> (<this>: kotlin.Lazy<T of kotlin.getValue>, thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue declared in kotlin' type=kotlin.Any? origin=null
327+
TYPE_ARG T: kotlin.Any?
328+
ARG <this>: GET_FIELD 'FIELD PROPERTY_DELEGATE name:original$delegate type:kotlin.Lazy<kotlin.Any?> visibility:private [final] declared in <root>.lazyDelegateInObject.<no name provided>' type=kotlin.Lazy<kotlin.Any?> origin=null
329+
receiver: GET_VAR '<this>: <root>.lazyDelegateInObject.<no name provided> declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=<root>.lazyDelegateInObject.<no name provided> origin=IMPLICIT_ARGUMENT
330+
ARG thisRef: GET_VAR '<this>: <root>.lazyDelegateInObject.<no name provided> declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>' type=<root>.lazyDelegateInObject.<no name provided> origin=null
331+
ARG property: RICH_PROPERTY_REFERENCE type=kotlin.reflect.KProperty1<*, kotlin.Any?> origin=PROPERTY_REFERENCE_FOR_DELEGATE reflectionTarget='public final original: kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>'
332+
getter: FUN LOCAL_FUNCTION_FOR_LAMBDA name:<get-original> visibility:local modality:FINAL returnType:kotlin.Any?
333+
VALUE_PARAMETER kind:Regular name:p0 index:0 type:kotlin.Any?
334+
BLOCK_BODY
335+
RETURN type=kotlin.Nothing from='local final fun <get-original> (p0: kotlin.Any?): kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>'
336+
CALL 'public final fun <get-original> (): kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>' type=kotlin.Any? origin=null
337+
ARG <this>: TYPE_OP type=<root>.lazyDelegateInObject.<no name provided> origin=IMPLICIT_CAST typeOperand=<root>.lazyDelegateInObject.<no name provided>
338+
GET_VAR 'p0: kotlin.Any? declared in <root>.lazyDelegateInObject.<no name provided>.<get-original>.<get-original>' type=kotlin.Any? origin=null
358339
CONSTRUCTOR visibility:public returnType:<root>.lazyDelegateInObject.<no name provided> [primary]
359340
BLOCK_BODY
360341
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'

compiler/testData/klib/syntheticAccessors/privateMember/crossFilePrivateLeak/leakingCompanionPrivateVarThroughInlineFun.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// IGNORE_KLIB_SYNTHETIC_ACCESSORS_CHECKS: JS_IR, WASM
12
// FILE: A.kt
23
class A {
34
companion object{

compiler/testData/klib/syntheticAccessors/privateMember/crossFilePrivateLeak/leakingCompanionPrivateVarThroughInlineVar.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// IGNORE_KLIB_SYNTHETIC_ACCESSORS_CHECKS: JS_IR, WASM
12
// FILE: A.kt
23
class A {
34
companion object{

compiler/testData/klib/syntheticAccessors/privateMember/crossFilePrivateLeak/leakingPrivateExtensionMember.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// IGNORE_KLIB_SYNTHETIC_ACCESSORS_CHECKS: JS_IR, WASM
12
// FILE: A.kt
23
class A {
34
internal inline fun internalInlineMethodA() = 21.privateExtensionMethod()

compiler/testData/klib/syntheticAccessors/privateMember/crossFilePrivateLeak/leakingPrivateExtensionVarThroughInlineFun.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// IGNORE_KLIB_SYNTHETIC_ACCESSORS_CHECKS: JS_IR, WASM
12
// FILE: A.kt
23
class A {
34
internal inline fun customSetVar(value: Int) {

compiler/testData/klib/syntheticAccessors/privateMember/crossFilePrivateLeak/leakingPrivateExtensionVarThroughPrivateInlineVarChain.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// IGNORE_KLIB_SYNTHETIC_ACCESSORS_CHECKS: JS_IR, WASM
12
// FILE: A.kt
23
class A {
34
internal inline var inlineVar: Int

compiler/testData/klib/syntheticAccessors/privateMember/crossFilePrivateLeak/leakingPrivateSetterThroughInlineFun.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// IGNORE_KLIB_SYNTHETIC_ACCESSORS_CHECKS: JS_IR, WASM
12
// JVM_ABI_K1_K2_DIFF
23
// FILE: A.kt
34
class A {

0 commit comments

Comments
 (0)