@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationBase
25
25
import org.jetbrains.kotlin.ir.declarations.IrFile
26
26
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
27
27
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
28
- import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
29
28
import org.jetbrains.kotlin.ir.symbols.IrSymbol
30
29
import org.jetbrains.kotlin.ir.types.IrType
31
30
import org.jetbrains.kotlin.ir.util.IrTreeSymbolsVisitor
@@ -52,23 +51,6 @@ data class IrValidatorConfig(
52
51
val checkOverridePrivateDeclaration : Boolean = true ,
53
52
)
54
53
55
- fun interface InlineFunctionUseSiteChecker {
56
- /* *
57
- * Check if the given use site of the inline function is permitted at the current phase of IR validation.
58
- *
59
- * Example 1: Check use sites after inlining all private functions.
60
- * It is permitted to have only use sites of non-private functions in the whole IR tree. So, for a use site
61
- * of a private inline function we should return `false` if it is met in the IR. For any other use site
62
- * we should return `true` (== permitted).
63
- *
64
- * Example 2: Check use sites after inlining all functions.
65
- * Normally, no use sites of inline functions should remain in the whole IR tree. So, if we met one we shall
66
- * return `false` (== not permitted). However, there are a few exceptions that are temporarily permitted.
67
- * For example, `inline external` intrinsics in Native (KT-66734).
68
- */
69
- fun isPermitted (inlineFunctionUseSite : IrFunctionAccessExpression ): Boolean
70
- }
71
-
72
54
private class IrValidator (
73
55
val validatorConfig : IrValidatorConfig ,
74
56
val irBuiltIns : IrBuiltIns ,
@@ -78,15 +60,15 @@ private class IrValidator(
78
60
throw IllegalStateException (" IR validation must start from files, modules, or declarations" )
79
61
80
62
override fun visitFile (declaration : IrFile ) {
81
- val context = CheckerContext (irBuiltIns, validatorConfig.checkInlineFunctionUseSites, declaration, reportError)
63
+ val context = CheckerContext (irBuiltIns, declaration, reportError)
82
64
val fileValidator = IrFileValidator (validatorConfig, context)
83
65
declaration.acceptVoid(fileValidator)
84
66
}
85
67
86
68
override fun visitModuleFragment (declaration : IrModuleFragment ) = declaration.acceptChildrenVoid(this )
87
69
88
70
override fun visitDeclaration (declaration : IrDeclarationBase ) {
89
- val context = CheckerContext (irBuiltIns, validatorConfig.checkInlineFunctionUseSites, declaration.file, reportError)
71
+ val context = CheckerContext (irBuiltIns, declaration.file, reportError)
90
72
val fileValidator = IrFileValidator (validatorConfig, context)
91
73
declaration.acceptVoid(fileValidator)
92
74
}
@@ -98,7 +80,7 @@ private class IrFileValidator(
98
80
) : IrTreeSymbolsVisitor() {
99
81
private val contextUpdaters: MutableSet <ContextUpdater > = mutableSetOf (ParentChainUpdater )
100
82
private val elementCheckers: MutableList <IrElementChecker <* >> = mutableListOf (
101
- IrNoInlineUseSitesChecker , IrSetValueAssignabilityChecker ,
83
+ IrSetValueAssignabilityChecker ,
102
84
IrFunctionDispatchReceiverChecker , IrFunctionParametersChecker , IrConstructorReceiverChecker ,
103
85
IrTypeOperatorTypeOperandChecker ,
104
86
IrPropertyAccessorsChecker , IrFunctionPropertiesChecker ,
@@ -144,6 +126,9 @@ private class IrFileValidator(
144
126
if (config.checkOverridePrivateDeclaration) {
145
127
elementCheckers.add(IrPrivateDeclarationOverrideChecker )
146
128
}
129
+ config.checkInlineFunctionUseSites?.let {
130
+ elementCheckers.add(IrNoInlineUseSitesChecker (it))
131
+ }
147
132
148
133
for (checker in elementCheckers + symbolCheckers + typeCheckers) {
149
134
contextUpdaters + = checker.requiredContextUpdaters
0 commit comments