Skip to content

Commit db6b009

Browse files
vsukharevSpace Team
authored andcommitted
[stdlib] Use moved throw helpers from kotlin.internal package
^KT-79334
1 parent bd1ee14 commit db6b009

File tree

6 files changed

+12
-51
lines changed

6 files changed

+12
-51
lines changed

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/PreSerializationSymbols.kt

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.ir.types.classOrNull
2626
import org.jetbrains.kotlin.ir.types.impl.IrDynamicTypeImpl
2727
import org.jetbrains.kotlin.ir.util.*
2828
import org.jetbrains.kotlin.name.*
29-
import org.jetbrains.kotlin.name.StandardClassIds.BASE_KOTLIN_PACKAGE
3029
import org.jetbrains.kotlin.types.Variance
3130
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
3231

@@ -150,6 +149,10 @@ interface PreSerializationKlibSymbols : PreSerializationSymbols {
150149
override val genericSharedVariableBox: SharedVariableBoxClassInfo = findSharedVariableBoxClass(null)
151150
override val syntheticConstructorMarker: IrClassSymbol =
152151
ClassId(StandardNames.KOTLIN_INTERNAL_FQ_NAME, Name.identifier("SyntheticConstructorMarker")).classSymbol()
152+
override val throwUninitializedPropertyAccessException: IrSimpleFunctionSymbol =
153+
THROW_UNINITIALIZED_PROPERTY_ACCESS_NAME.internalCallableId.functionSymbol()
154+
override val throwUnsupportedOperationException: IrSimpleFunctionSymbol =
155+
THROW_UNSUPPORTED_OPERATION_NAME.internalCallableId.functionSymbol()
153156
}
154157

155158
companion object {
@@ -158,6 +161,10 @@ interface PreSerializationKlibSymbols : PreSerializationSymbols {
158161
const val GET_COROUTINE_CONTEXT_NAME = "getCoroutineContext"
159162
const val COROUTINE_CONTEXT_NAME = "coroutineContext"
160163
const val DEFAULT_CONSTRUCTOR_MARKET_NAME = "DefaultConstructorMarker"
164+
165+
private val kotlinInternalPackageFqn = FqName.fromSegments(listOf("kotlin", "internal"))
166+
private val String.internalCallableId: CallableId
167+
get() = CallableId(kotlinInternalPackageFqn, Name.identifier(this))
161168
}
162169
}
163170

@@ -182,11 +189,6 @@ interface PreSerializationJsSymbols : PreSerializationWebSymbols {
182189
val jsOutlinedFunctionAnnotationSymbol: IrClassSymbol
183190

184191
open class Impl(irBuiltIns: IrBuiltIns) : PreSerializationJsSymbols, PreSerializationWebSymbols.Impl(irBuiltIns) {
185-
override val throwUninitializedPropertyAccessException: IrSimpleFunctionSymbol =
186-
CallableIds.throwUninitializedPropertyAccessException.functionSymbol()
187-
override val throwUnsupportedOperationException: IrSimpleFunctionSymbol =
188-
CallableIds.throwUnsupportedOperationException.functionSymbol()
189-
190192
override val defaultConstructorMarker: IrClassSymbol = ClassIds.defaultConstructorMarker.classSymbol()
191193

192194
override val suspendCoroutineUninterceptedOrReturn: IrSimpleFunctionSymbol =
@@ -200,13 +202,6 @@ interface PreSerializationJsSymbols : PreSerializationWebSymbols {
200202
private const val COROUTINE_SUSPEND_OR_RETURN_JS_NAME = "suspendCoroutineUninterceptedOrReturnJS"
201203

202204
private object CallableIds {
203-
private val String.rootCallableId: CallableId
204-
get() = CallableId(kotlinPackageFqn, Name.identifier(this))
205-
val throwUninitializedPropertyAccessException: CallableId =
206-
PreSerializationKlibSymbols.THROW_UNINITIALIZED_PROPERTY_ACCESS_NAME.rootCallableId
207-
val throwUnsupportedOperationException: CallableId =
208-
PreSerializationKlibSymbols.THROW_UNSUPPORTED_OPERATION_NAME.rootCallableId
209-
210205
private val String.baseJsCallableId: CallableId
211206
get() = CallableId(StandardClassIds.BASE_JS_PACKAGE, Name.identifier(this))
212207
val suspendCoroutineUninterceptedOrReturn: CallableId = COROUTINE_SUSPEND_OR_RETURN_JS_NAME.baseJsCallableId
@@ -226,11 +221,6 @@ interface PreSerializationJsSymbols : PreSerializationWebSymbols {
226221

227222
interface PreSerializationWasmSymbols : PreSerializationWebSymbols {
228223
open class Impl(irBuiltIns: IrBuiltIns) : PreSerializationWasmSymbols, PreSerializationWebSymbols.Impl(irBuiltIns) {
229-
override val throwUninitializedPropertyAccessException: IrSimpleFunctionSymbol =
230-
CallableIds.throwUninitializedPropertyAccessException.functionSymbol()
231-
override val throwUnsupportedOperationException: IrSimpleFunctionSymbol =
232-
CallableIds.throwUnsupportedOperationException.functionSymbol()
233-
234224
override val defaultConstructorMarker: IrClassSymbol = ClassIds.defaultConstructorMarker.classSymbol()
235225

236226
override val suspendCoroutineUninterceptedOrReturn: IrSimpleFunctionSymbol =
@@ -244,10 +234,6 @@ interface PreSerializationWasmSymbols : PreSerializationWebSymbols {
244234
private object CallableIds {
245235
private val String.internalCallableId: CallableId
246236
get() = CallableId(wasmInternalFqName, Name.identifier(this))
247-
val throwUninitializedPropertyAccessException: CallableId =
248-
PreSerializationKlibSymbols.THROW_UNINITIALIZED_PROPERTY_ACCESS_NAME.internalCallableId
249-
val throwUnsupportedOperationException: CallableId =
250-
PreSerializationKlibSymbols.THROW_UNSUPPORTED_OPERATION_NAME.internalCallableId
251237

252238
val suspendCoroutineUninterceptedOrReturn: CallableId = COROUTINE_SUSPEND_OR_RETURN_NAME.internalCallableId
253239
val coroutineGetContext: CallableId = PreSerializationKlibSymbols.GET_COROUTINE_CONTEXT_NAME.internalCallableId
@@ -269,10 +255,6 @@ interface PreSerializationNativeSymbols : PreSerializationKlibSymbols {
269255
open class Impl(irBuiltIns: IrBuiltIns) : PreSerializationNativeSymbols, PreSerializationKlibSymbols.Impl(irBuiltIns) {
270256
override val asserts: Iterable<IrSimpleFunctionSymbol> = CallableIds.asserts.functionSymbols()
271257

272-
override val throwUninitializedPropertyAccessException: IrSimpleFunctionSymbol =
273-
CallableIds.throwUninitializedPropertyAccessException.functionSymbol()
274-
override val throwUnsupportedOperationException: IrSimpleFunctionSymbol =
275-
CallableIds.throwUnsupportedOperationException.functionSymbol()
276258
override val defaultConstructorMarker: IrClassSymbol = ClassIds.defaultConstructorMarker.classSymbol()
277259
override val isAssertionArgumentEvaluationEnabled: IrSimpleFunctionSymbol =
278260
CallableIds.isAssertionArgumentEvaluationEnabled.functionSymbol()
@@ -290,10 +272,6 @@ interface PreSerializationNativeSymbols : PreSerializationKlibSymbols {
290272
// Internal functions
291273
private val String.internalCallableId: CallableId
292274
get() = CallableId(kotlinNativeInternalPackageName, Name.identifier(this))
293-
val throwUninitializedPropertyAccessException: CallableId =
294-
PreSerializationKlibSymbols.THROW_UNINITIALIZED_PROPERTY_ACCESS_NAME.capitalizeAsciiOnly().internalCallableId
295-
val throwUnsupportedOperationException: CallableId =
296-
PreSerializationKlibSymbols.THROW_UNSUPPORTED_OPERATION_NAME.capitalizeAsciiOnly().internalCallableId
297275
val suspendCoroutineUninterceptedOrReturn: CallableId = COROUTINE_SUSPEND_OR_RETURN_NAME.internalCallableId
298276
val getCoroutineContext: CallableId = PreSerializationKlibSymbols.GET_COROUTINE_CONTEXT_NAME.internalCallableId
299277

compiler/testData/codegen/box/delegatedProperty/local/localDelegatedPropertyCall.fir.inlined.ir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ FILE fqName:<root> fileName:/localDelegatedPropertyCall.kt
342342
ARG prop: RICH_PROPERTY_REFERENCE type=kotlin.reflect.KProperty0<kotlin.String> origin=PROPERTY_REFERENCE_FOR_DELEGATE reflectionTarget='val x: kotlin.String by (...)'
343343
getter: FUN LOCAL_FUNCTION_FOR_LAMBDA name:<get-x> visibility:local modality:FINAL returnType:kotlin.Nothing
344344
BLOCK_BODY
345-
CALL 'internal final fun throwUnsupportedOperationException (message: kotlin.String): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=null
345+
CALL 'internal final fun throwUnsupportedOperationException (message: kotlin.String): kotlin.Nothing declared in kotlin.internal' type=kotlin.Nothing origin=null
346346
ARG message: CONST String type=kotlin.String value="Not supported for local property reference."
347347
CALL 'local final fun <get-x> (): kotlin.String declared in <root>.box' type=kotlin.String origin=GET_LOCAL_PROPERTY
348348
CATCH parameter=val e: kotlin.UnsupportedOperationException declared in <root>.box

kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,6 @@ internal fun ThrowNoWhenBranchMatchedException(): Nothing {
7979
throw NoWhenBranchMatchedException()
8080
}
8181

82-
// TODO KT-79334: Drop this fun after bootstrap update, and use `kotlin.internal.throwUninitializedPropertyAccessException` instead
83-
@UsedFromCompilerGeneratedCode
84-
@PublishedApi
85-
internal fun ThrowUninitializedPropertyAccessException(propertyName: String): Nothing {
86-
kotlin.internal.throwUninitializedPropertyAccessException(propertyName)
87-
}
88-
89-
// TODO KT-79334: Drop this fun after bootstrap update, and use `kotlin.internal.throwUnsupportedOperationException` instead
90-
@UsedFromCompilerGeneratedCode
91-
@PublishedApi
92-
internal fun ThrowUnsupportedOperationException(message: String): Nothing {
93-
kotlin.internal.throwUnsupportedOperationException(message)
94-
}
95-
9682
@ExportForCppRuntime
9783
internal fun ThrowIllegalArgumentException() : Nothing {
9884
throw IllegalArgumentException()

libraries/stdlib/common-non-jvm/src/kotlin/internal/ThrowHelpers.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ package kotlin.internal
88
@Suppress("DEPRECATION_ERROR")
99
@PublishedApi
1010
@SinceKotlin("2.3")
11+
@UsedFromCompilerGeneratedCode
1112
internal fun throwUninitializedPropertyAccessException(name: String): Nothing =
1213
throw UninitializedPropertyAccessException("lateinit property $name has not been initialized")
1314

1415
@PublishedApi
1516
@SinceKotlin("2.3")
17+
@UsedFromCompilerGeneratedCode
1618
internal fun throwUnsupportedOperationException(message: String): Nothing =
1719
throw UnsupportedOperationException(message)

libraries/stdlib/js/runtime/reflectRuntime.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package kotlin.js
77

88
import kotlin.internal.UsedFromCompilerGeneratedCode
99
import kotlin.internal.throwIrLinkageError
10+
import kotlin.internal.throwUnsupportedOperationException
1011
import kotlin.reflect.KProperty
1112

1213
@UsedFromCompilerGeneratedCode

libraries/tools/binary-compatibility-validator/klib-public-api/kotlin-stdlib.api

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12825,12 +12825,6 @@ final fun kotlin.native.internal/ThrowNullPointerException(): kotlin/Nothing //
1282512825
// Targets: [native]
1282612826
final fun kotlin.native.internal/ThrowTypeCastException(kotlin/Any, kotlin/String): kotlin/Nothing // kotlin.native.internal/ThrowTypeCastException|ThrowTypeCastException(kotlin.Any;kotlin.String){}[0]
1282712827

12828-
// Targets: [native]
12829-
final fun kotlin.native.internal/ThrowUninitializedPropertyAccessException(kotlin/String): kotlin/Nothing // kotlin.native.internal/ThrowUninitializedPropertyAccessException|ThrowUninitializedPropertyAccessException(kotlin.String){}[0]
12830-
12831-
// Targets: [native]
12832-
final fun kotlin.native.internal/ThrowUnsupportedOperationException(kotlin/String): kotlin/Nothing // kotlin.native.internal/ThrowUnsupportedOperationException|ThrowUnsupportedOperationException(kotlin.String){}[0]
12833-
1283412828
// Targets: [native]
1283512829
final fun kotlin.native.internal/areEqualByValue(kotlin.native.internal/NativePtr, kotlin.native.internal/NativePtr): kotlin/Boolean // kotlin.native.internal/areEqualByValue|areEqualByValue(kotlin.native.internal.NativePtr;kotlin.native.internal.NativePtr){}[0]
1283612830

0 commit comments

Comments
 (0)