@ JsName ( "<STR_LIT>" ) <EOL> @ OptIn ( ExperimentalSerializationApi :: class ) <EOL> internal fun < T > Json . encodeDynamic ( serializer : SerializationStrategy < T > , value : T ) : dynamic

{ <EOL> if ( serializer . descriptor . kind is PrimitiveKind || serializer . descriptor . kind is SerialKind . ENUM ) { <EOL> val encoder = DynamicPrimitiveEncoder ( this ) <EOL> encoder . encodeSerializableValue ( serializer , value ) <EOL> return encoder . result <EOL> } <EOL> val encoder = DynamicObjectEncoder ( this , false ) <EOL> encoder . encodeSerializableValue ( serializer , value ) <EOL> return encoder . result <EOL> }

/**
 * Converts Kotlin data structures to plain Javascript objects
 *
 *
 * Limitations:
 * * Map keys must be of primitive or enum type
 * * Enums are serialized as the value of `@SerialName` if present or their name, in that order.
 * * Currently does not support polymorphism
 *
 * Example of usage:
 * ```
 * @Serializable
 * open class DataWrapper(open val s: String, val d: String?)
 *
 * val wrapper = DataWrapper("foo", "bar")
 * val plainJS: dynamic = DynamicObjectSerializer().serialize(DataWrapper.serializer(), wrapper)
 * ```
 */


public operator fun < T : SelfInvocationContext > T . invoke ( block : T . ( ) -> Unit ) : T

= apply ( block )

/**
 * Creates a context with this [SelfInvocationContext] as a receiver and applies to this.
 */


fun put ( key : K , value : D , oldValue : D ? ) : S

{ <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> if ( value == oldValue ) return this as S <EOL> return copy ( map . put ( key , value ) ) <EOL> }

/**
 * This overload exists just for sake of optimizations: in some cases we've just retrieved the old value,
 * so we don't need to scan through the persistent hashmap again
 */


{ <EOL> val modelHub = TFModelHub ( cacheDirectory = File ( "<STR_LIT>" ) ) <EOL> val modelType = TFModels . CV . MobileNet ( ) <EOL> val model = modelHub . loadModel ( modelType ) <EOL> val hdfFile = modelHub . loadWeights ( modelType ) <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = Losses . MAE , metric = Metrics . ACCURACY ) <EOL> it . logSummary ( ) <EOL> } <EOL> val layers = model . layers . toMutableList ( ) <EOL> layers . forEach ( Layer :: freeze ) <EOL> val lastLayer = layers . last ( ) <EOL> for ( outboundLayer in lastLayer . inboundLayers ) <EOL> outboundLayer . outboundLayers . remove ( lastLayer ) <EOL> layers . removeLast ( ) <EOL> var x = Dense ( name = "<STR_LIT>" , kernelInitializer = GlorotUniform ( ) , biasInitializer = GlorotUniform ( ) , outputSize = <NUM_LIT> , activation = Activations . Relu ) ( layers . last ( ) ) <EOL> x = Dense ( name = "<STR_LIT>" , kernelInitializer = GlorotUniform ( ) , biasInitializer = GlorotUniform ( ) , outputSize = NUM_CLASSES , activation = Activations . Linear ) ( x ) <EOL> val model2 = Functional . fromOutput ( x ) <EOL> val dogsCatsImages = dogsCatsSmallDatasetPath ( ) <EOL> val dataset = OnHeapDataset . create ( File ( dogsCatsImages ) , FromFolders ( mapping = mapOf ( "<STR_LIT>" to <NUM_LIT:0> , "<STR_LIT>" to <NUM_LIT:1> ) ) , modelType . createPreprocessing ( model2 ) ) . shuffle ( ) <EOL> val ( train , test ) = dataset . split ( TRAIN_TEST_SPLIT_RATIO ) <EOL> model2 . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = Losses . SOFT_MAX_CROSS_ENTROPY_WITH_LOGITS , metric = Metrics . ACCURACY ) <EOL> it . logSummary ( ) <EOL> it . loadWeightsForFrozenLayers ( hdfFile ) <EOL> val accuracyBeforeTraining = it . evaluate ( dataset = test , batchSize = TEST_BATCH_SIZE ) . metrics [ Metrics . ACCURACY ] <EOL> println ( "<STR_LIT>" ) <EOL> it . fit ( dataset = train , batchSize = TRAINING_BATCH_SIZE , epochs = EPOCHS ) <EOL> val accuracyAfterTraining = it . evaluate ( dataset = test , batchSize = TEST_BATCH_SIZE ) . metrics [ Metrics . ACCURACY ] <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * This example demonstrates the transfer learning concept on MobileNet model:
 * - Model configuration, model weights and labels are obtained from [TFModelHub].
 * - Weights are loaded from .h5 file, configuration is loaded from .json file.
 * - All layers, excluding the last [Dense], are added to the new Neural Network, its weights are frozen.
 * - New Dense layers are added and initialized via defined initializers.
 * - Model is re-trained on [dogsCatsSmallDatasetPath] dataset.
 * - Special preprocessing (used in MobileNet during training on ImageNet dataset) is applied to each image before prediction via [call] stage.
 *
 * We use the preprocessing DSL to describe the dataset generation pipeline.
 * We demonstrate the workflow on the subset of Kaggle Cats vs Dogs binary classification dataset.
 */


= mobilenetWithAdditionalTraining ( )


public suspend fun collect ( collector : FlowCollector < T > )

/**
 * Accepts the given [collector] and [emits][FlowCollector.emit] values into it.
 *
 * This method can be used along with SAM-conversion of [FlowCollector]:
 * ```
 * myFlow.collect { value -> println("Collected $value") }
 * ```
 *
 * ### Method inheritance
 *
 * To ensure the context preservation property, it is not recommended implementing this method directly.
 * Instead, [AbstractFlow] can be used as the base type to properly ensure flow's properties.
 *
 * All default flow implementations ensure context preservation and exception transparency properties on a best-effort basis
 * and throw [IllegalStateException] if a violation was detected.
 */


public abstract suspend fun collectSafely ( collector : FlowCollector < T > )

/**
 * Accepts the given [collector] and [emits][FlowCollector.emit] values into it.
 *
 * A valid implementation of this method has the following constraints:
 * 1) It should not change the coroutine context (e.g. with `withContext(Dispatchers.IO)`) when emitting values.
 * The emission should happen in the context of the [collect] call.
 * Please refer to the top-level [Flow] documentation for more details.
 * 2) It should serialize calls to [emit][FlowCollector.emit] as [FlowCollector] implementations are not
 * thread-safe by default.
 * To automatically serialize emissions [channelFlow] builder can be used instead of [flow]
 *
 * @throws IllegalStateException if any of the invariants are violated.
 */


public fun status ( statusConfig : FirResolvedDeclarationStatusImpl . ( ) -> Unit )

{ <EOL> statusConfigs += statusConfig <EOL> }

/**
 * Allows to configure flags in status of declaration
 * For full list of possible flags refer to [FirDeclarationStatus] class
 * Note that not all flags are meaningful for each declaration
 * E.g. there is no point to mark function as inner
 */


public open fun typeParameter ( name : Name , variance : Variance = Variance . INVARIANT , isReified : Boolean = false , key : GeneratedDeclarationKey = this @ DeclarationBuildingContext . key , config : TypeParameterBuildingContext . ( ) -> Unit = { } )

{ <EOL> typeParameters += TypeParameterData ( name , variance , isReified , TypeParameterBuildingContext ( ) . apply ( config ) . boundProviders , key ) <EOL> }

/**
 * Adds type parameter with specified [name] and [variance] to declaration
 *
 * Upper bounds of type parameters can be configured in [config] lambda
 *
 * If no bounds passed then `kotlin.Any?` bound will be added automatically
 */


public fun bound ( type : ConeKotlinType )

{ <EOL> bound { type } <EOL> }

/**
 * Declares [type] as upper bound of type parameter
 */


public fun bound ( typeProvider : ( List < FirTypeParameterRef > ) -> ConeKotlinType )

{ <EOL> boundProviders += typeProvider <EOL> }

/**
 * Type produced by [typeProvider] will be an upper bound of the type parameter
 *
 * Use this method when bounds of your type parameters depend on each other
 * For example, in this case:
 * ```
 * interface Out<out X>
 *
 * fun <T, R> foo() where T : R, R : Out<T> {}
 * ```
 */


public open fun contextReceiver ( type : ConeKotlinType )

{ <EOL> contextReceiver { type } <EOL> }

/**
 * Adds context receiver with [type] type to declaration
 */


public open fun contextReceiver ( typeProvider : ( List < FirTypeParameterRef > ) -> ConeKotlinType )

{ <EOL> contextReceiverTypeProviders += typeProvider <EOL> }

/**
 * Adds context receiver with type provided by [typeProvider] to declaration
 * Use this overload when context receiver type uses type parameters of constructed declaration
 */


{ <EOL> return "<STR_LIT:test>" <EOL> }

/**
 * JS actual implementation for `getCurrentDate`
 */


{ <EOL> val ( train , test ) = fashionMnist ( ) <EOL> val jsonConfigFile = getJSONConfigFileToyResNet ( ) <EOL> val model = Functional . loadModelConfiguration ( jsonConfigFile ) <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = Losses . SOFT_MAX_CROSS_ENTROPY_WITH_LOGITS , metric = Metrics . ACCURACY ) <EOL> it . logSummary ( ) <EOL> val hdfFile = getWeightsFileToyResNet ( ) <EOL> it . loadWeights ( hdfFile ) <EOL> var accuracy = it . evaluate ( dataset = test , batchSize = <NUM_LIT> ) . metrics [ Metrics . ACCURACY ] <EOL> println ( "<STR_LIT>" ) <EOL> it . freeze ( ) <EOL> it . layers . last ( ) . unfreeze ( ) <EOL> it . fit ( dataset = train , epochs = <NUM_LIT:1> , batchSize = <NUM_LIT> ) <EOL> accuracy = it . evaluate ( dataset = test , batchSize = <NUM_LIT> ) . metrics [ Metrics . ACCURACY ] <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * So, let's update the weights of last layer of the pretrained model from Keras.
 *
 * All layers except last should be frozen.
 *
 * As a result the training will be fast.
 */


@ Test <EOL> fun testUnconfinedDispatcher ( )

= runTest { <EOL> val values = mutableListOf < Int > ( ) <EOL> val stateFlow = MutableStateFlow ( <NUM_LIT:0> ) <EOL> val job = launch ( UnconfinedTestDispatcher ( testScheduler ) ) { <EOL> stateFlow . collect { <EOL> values . add ( it ) <EOL> } <EOL> } <EOL> stateFlow . value = <NUM_LIT:1> <EOL> stateFlow . value = <NUM_LIT:2> <EOL> stateFlow . value = <NUM_LIT:3> <EOL> job . cancel ( ) <EOL> assertEquals ( listOf ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , values ) <EOL> }

/** An example from the [UnconfinedTestDispatcher] documentation. */


@ Test <EOL> fun testEagerlyEnteringChildCoroutines ( )

= runTest ( UnconfinedTestDispatcher ( ) ) { <EOL> var entered = false <EOL> val deferred = CompletableDeferred < Unit > ( ) <EOL> var completed = false <EOL> launch { <EOL> entered = true <EOL> deferred . await ( ) <EOL> completed = true <EOL> } <EOL> assertTrue ( entered ) <EOL> assertFalse ( completed ) <EOL> deferred . complete ( Unit ) <EOL> assertTrue ( completed ) <EOL> }

/** Tests that child coroutines are eagerly entered. */


{ <EOL> val dispatcher1 = StandardTestDispatcher ( ) <EOL> Dispatchers . setMain ( dispatcher1 ) <EOL> try { <EOL> val dispatcher2 = UnconfinedTestDispatcher ( ) <EOL> assertSame ( dispatcher1 . scheduler , dispatcher2 . scheduler ) <EOL> } finally { <EOL> Dispatchers . resetMain ( ) <EOL> } <EOL> }

/** Tests that the [TestCoroutineScheduler] used for [Dispatchers.Main] gets used by default. */


@ kotlin . internal . InlineOnly <EOL> public inline fun String . toRegex ( ) : Regex

= Regex ( this )

/**
 * Converts the string into a regular expression [Regex] with the default options.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun String . toRegex ( option : RegexOption ) : Regex

= Regex ( this , option )

/**
 * Converts the string into a regular expression [Regex] with the specified single [option].
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun String . toRegex ( options : Set < RegexOption > ) : Regex

= Regex ( this , options )

/**
 * Converts the string into a regular expression [Regex] with the specified set of [options].
 */


@ SinceKotlin ( "<STR_LIT:1.9>" ) <EOL> public expect operator fun MatchGroupCollection . get ( name : String ) : MatchGroup ?

/**
 * Returns a named group with the specified [name].
 *
 * @return An instance of [MatchGroup] if the group with the specified [name] was matched or `null` otherwise.
 * @throws IllegalArgumentException if there is no group with the specified [name] defined in the regex pattern.
 * @throws UnsupportedOperationException if this match group collection doesn't support getting match groups by name,
 * for example, when it's not supported by the current platform.
 */


public fun declarationsByAnnotation ( queriedAnnotation : ClassId ) : Set < KtAnnotated >

/**
 * @param queriedAnnotation A qualified name of the annotation in question.
 * @return A set of PSI declarations which have [queriedAnnotation] declared directly on them.
 * Might contain both false positives and false negatives.
 */


public fun annotationsOnDeclaration ( declaration : KtAnnotated ) : Set < ClassId >

/**
 * @param declaration A [org.jetbrains.kotlin.psi.KtDeclaration] or [org.jetbrains.kotlin.psi.KtFile] to resolve annotations on. Other
 * [KtElement]s are not supported.
 * @return A set of annotations declared directly on the [declaration]. Might contain both false positives and false negatives.
 */


public fun createAnnotationResolver ( searchScope : GlobalSearchScope ) : KotlinAnnotationsResolver

/**
 * @param searchScope A scope in which the created [KotlinAnnotationsResolver] will operate. Make sure that this scope contains all
 * the annotations that you might want to resolve.
 */


fun identicalArguments ( a : SimpleTypeMarker , b : SimpleTypeMarker )

= false

/**
 * @return true is a.arguments == b.arguments, or false if not supported
 */


fun CapturedTypeMarker . hasRawSuperType ( ) : Boolean


fun useRefinedBoundsForTypeVariableInFlexiblePosition ( ) : Boolean

/**
 * For case Foo <: (T..T?) return LowerConstraint for new constraint LowerConstraint <: T
 * In K1, in case nullable it was just Foo?, so constraint was Foo? <: T
 * But it's not 100% correct because prevent having not-nullable upper constraint on T while initial (Foo? <: (T..T?)) is not violated
 *
 * In FIR, we try to have a correct one: (Foo & Any..Foo?) <: T
 *
 * The same logic applies for T! <: UpperConstraint, as well
 * In K1, it was reduced to T <: UpperConstraint..UpperConstraint?
 * In FIR, we use UpperConstraint & Any..UpperConstraint?
 *
 * In future once we have only FIR (or FE 1.0 behavior is fixed) this method should be inlined to the use-site
 */


fun KotlinTypeMarker . convertToNonRaw ( ) : KotlinTypeMarker

/**
 * It's only relevant for K2 (and is not expected to be implemented properly in other contexts)
 */


fun SimpleTypeMarker . isSingleClassifierType ( ) : Boolean

/**
 *
 * SingleClassifierType is one of the following types:
 * - classType
 * - type for type parameter
 * - captured type
 *
 * Such types can contains error types in our arguments, but type constructor isn't errorTypeConstructor
 */


fun TypeSubstitutorMarker . safeSubstitute ( type : KotlinTypeMarker ) : KotlinTypeMarker

/**
 * @returns substituted type or [type] if there were no substitution
 */


fun check ( resolvedCall : ResolvedCall < * > , reportOn : PsiElement , context : CallCheckerContext )

/**
 * Note that [reportOn] should only be used as a target element for diagnostics reported by checkers.
 * Logic of the checker should not depend on what element is the target of the diagnostic!
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public infix fun < T : Number > MultiArray < T , D2 > . dot ( b : MultiArray < T , D2 > ) : NDArray < T , D2 >

= mk . linalg . linAlgEx . dotMM ( this , b )

/**
 * Returns the matrix product of two numeric matrices.
 *
 * same as [LinAlg.dot]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public infix fun < T : Complex > MultiArray < T , D2 > . dot ( b : MultiArray < T , D2 > ) : NDArray < T , D2 >

= mk . linalg . linAlgEx . dotMMComplex ( this , b )

/**
 * Returns the matrix product of two complex matrices.
 *
 * same as [LinAlg.dot]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public infix fun < T : Number > MultiArray < T , D2 > . dot ( b : MultiArray < T , D1 > ) : NDArray < T , D1 >

= mk . linalg . linAlgEx . dotMV ( this , b )

/**
 * Returns the matrix product of a numeric matrix and a numeric vector.
 *
 * same as [LinAlg.dot]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public infix fun < T : Complex > MultiArray < T , D2 > . dot ( b : MultiArray < T , D1 > ) : NDArray < T , D1 >

= mk . linalg . linAlgEx . dotMVComplex ( this , b )

/**
 * Returns the matrix product of a complex matrix and a complex vector.
 *
 * same as [LinAlg.dot]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public infix fun < T : Number > MultiArray < T , D1 > . dot ( b : MultiArray < T , D1 > ) : T

= mk . linalg . linAlgEx . dotVV ( this , b )

/**
 * Returns the product of two numeric vectors.
 *
 * same as [LinAlg.dot]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public infix fun < T : Complex > MultiArray < T , D1 > . dot ( b : MultiArray < T , D1 > ) : T

= mk . linalg . linAlgEx . dotVVComplex ( this , b )

/**
 * Returns the product of two complex vectors.
 *
 * same as [LinAlg.dot]
 */


private fun pageId ( dri : DRI , sourceSets : Set < DisplaySourceSet > ) : String

= "<STR_LIT>"

/**
 * Page Id is required to have a sourceSet in order to distinguish between different pages that has same DRI but different sourceSet
 * like main functions that are not expect/actual
 */


protected open fun transformDeserialize ( element : JsonElement ) : JsonElement

= element

/**
 * Transformation that happens during [deserialize] call.
 * Does nothing by default.
 *
 * During deserialization, a value from JSON is firstly decoded to a [JsonElement],
 * user transformation in [transformDeserialize] is applied,
 * and then resulting [JsonElement] is deserialized to [T] with [tSerializer].
 */


protected open fun transformSerialize ( element : JsonElement ) : JsonElement

= element

/**
 * Transformation that happens during [serialize] call.
 * Does nothing by default.
 *
 * During serialization, a value of type [T] is serialized with [tSerializer] to a [JsonElement],
 * user transformation in [transformSerialize] is applied, and then resulting [JsonElement] is encoded to a JSON string.
 */


fun getOverriddenKotlinApiVersion ( project : Project ) : KotlinVersion ?

{ <EOL> val apiVersion = project . rootProject . properties [ "<STR_LIT>" ] as? String <EOL> return if ( apiVersion != null ) { <EOL> LOGGER . info ( """<STR_LIT>""" ) <EOL> KotlinVersion . fromVersion ( apiVersion ) <EOL> } else { <EOL> null <EOL> } <EOL> }

/**
 * Should be used for running against of non-released Kotlin compiler on a system test level.
 *
 * @return a Kotlin API version parametrized from command line nor gradle.properties, null otherwise
 */


fun getOverriddenKotlinLanguageVersion ( project : Project ) : KotlinVersion ?

{ <EOL> val languageVersion = project . rootProject . properties [ "<STR_LIT>" ] as? String <EOL> return if ( languageVersion != null ) { <EOL> LOGGER . info ( """<STR_LIT>""" ) <EOL> KotlinVersion . fromVersion ( languageVersion ) <EOL> } else { <EOL> null <EOL> } <EOL> }

/**
 * Should be used for running against of non-released Kotlin compiler on a system test level
 *
 * @return a Kotlin Language version parametrized from command line nor gradle.properties, null otherwise
 */


fun getKotlinDevRepositoryUrl ( project : Project ) : URI ?

{ <EOL> val url : String ? = project . rootProject . properties [ "<STR_LIT>" ] as? String <EOL> if ( url != null ) { <EOL> LOGGER . info ( """<STR_LIT>""" ) <EOL> return URI . create ( url ) <EOL> } <EOL> return null <EOL> }

/**
 * Should be used for running against of non-released Kotlin compiler on a system test level
 * Kotlin compiler artifacts are expected to be downloaded from maven central by default.
 * In case of compiling with not-published into the MC kotlin compiler artifacts, a kotlin_repo_url gradle parameter should be specified.
 * To reproduce a build locally, a kotlin/dev repo should be passed
 *
 * @return an url for a kotlin compiler repository parametrized from command line nor gradle.properties, empty string otherwise
 */


fun addDevRepositoryIfEnabled ( rh : RepositoryHandler , project : Project )

{ <EOL> val devRepoUrl = getKotlinDevRepositoryUrl ( project ) ? : return <EOL> rh . maven { <EOL> url = devRepoUrl <EOL> } <EOL> }

/**
 * Adds a kotlin-dev space repository with dev versions of Kotlin if Kotlin aggregate build is enabled
 */


fun Project . configureCommunityBuildTweaks ( )

{ <EOL> if ( ! isSnapshotTrainEnabled ( this ) ) return <EOL> allprojects { <EOL> tasks . withType < Test > ( ) . configureEach { <EOL> exclude ( "<STR_LIT>" ) <EOL> exclude ( "<STR_LIT>" ) <EOL> exclude ( "<STR_LIT>" ) <EOL> exclude ( "<STR_LIT>" ) <EOL> exclude ( "<STR_LIT>" ) <EOL> exclude ( "<STR_LIT>" ) <EOL> exclude ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> println ( "<STR_LIT>" ) <EOL> val coreProject = subprojects . single { it . name == coreModule } <EOL> configure ( listOf ( coreProject ) ) { <EOL> configurations . matching { it . name == "<STR_LIT>" } . configureEach { <EOL> val config = resolvedConfiguration . files . single { it . name . contains ( "<STR_LIT>" ) } <EOL> val manifest = zipTree ( config ) . matching { <EOL> include ( "<STR_LIT>" ) <EOL> } . files . single ( ) <EOL> manifest . readLines ( ) . forEach { <EOL> println ( it ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Changes the build config when 'build_snapshot_train' is enabled:
 * Disables flaky and Kotlin-specific tests, prints the real version of Kotlin applied (to be sure overridden version of Kotlin is properly picked).
 */


fun getOverriddenKotlinVersion ( project : Project ) : String ?

= <EOL> if ( isSnapshotTrainEnabled ( project ) ) { <EOL> val snapshotVersion = project . rootProject . properties [ "<STR_LIT>" ] <EOL> ? : error ( "<STR_LIT>" ) <EOL> snapshotVersion . toString ( ) <EOL> } else { <EOL> null <EOL> }

/**
 * Ensures that, if [isSnapshotTrainEnabled] is true, the project is built with a snapshot version of Kotlin compiler.
 */


fun isSnapshotTrainEnabled ( project : Project ) : Boolean

= <EOL> when ( project . rootProject . properties [ "<STR_LIT>" ] ) { <EOL> null -> false <EOL> "<STR_LIT>" -> false <EOL> else -> true <EOL> }

/**
 * Checks if the project is built with a snapshot version of Kotlin compiler.
 */


fun defaultSourceFolder ( project : Project , sourceSetName : String , type : String ) : File

{ <EOL> return project . file ( "<STR_LIT>" ) <EOL> }

/**
 * @return default location of source folders for a kotlin source set
 * e.g. src/jvmMain/kotlin (sourceSetName="jvmMain", type="kotlin")
 */


{ <EOL> appendText ( "<STR_LIT>" ) <EOL> return this <EOL> }

/**
 * Appends top-level `private val` to the content of the file.
 * Throws SecurityException or IOException, if append failed.
 * Every call to [addPrivateVal] or [addPublicVal] generates a new value name.
 */


/**
 * Appends top-level `public val` to the content of the file.
 * Throws SecurityException or IOException, if append failed.
 * Every call to [addPrivateVal] or [addPublicVal] generates a new value name.
 */


@ Test <EOL> fun testSynchronizedObjectBytecode ( )

= checkBytecode ( SynchronizedObjectTest :: class . java , listOf ( KOTLINX_ATOMICFU ) )

/**
 * Test [SynchronizedObjectTest].
 */


@ Test <EOL> fun testAtomicFieldBytecode ( )

= checkBytecode ( AtomicFieldTest :: class . java , listOf ( KOTLINX_ATOMICFU ) )


@ Test <EOL> fun testReentrantLockBytecode ( )

= checkBytecode ( ReentrantLockTest :: class . java , listOf ( KOTLINX_ATOMICFU ) )


@ Test <EOL> fun testTraceUseBytecode ( )

= checkBytecode ( TraceUseTest :: class . java , listOf ( KOTLINX_ATOMICFU ) )


= TODO ( )

/**
 * this is a sample comment for func on class with package
 */


/**
 * [PARAM.<caret_1>anyExt]
 * [PARAM.<caret_2>genericExt]
 */


/**
 * [CLASS_PARAM.<caret_3>anyExt]
 * [CLASS_PARAM.<caret_4>genericExt]
 */


{ <EOL> lineBuffer . add ( string ) <EOL> }

/**
 * Adds solid line to tooltips with given string value.
 *
 * @param string text of the line.
 */


public fun KProperty < * > . tooltipValue ( format : String ? = null ) : String

{ <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> val colID = layerContextInterface . datasetHandler . takeColumn ( this . name ) <EOL> addFormat ( colID , format ) <EOL> return "<STR_LIT>" <EOL> }

/**
 * Inserts value of given column into formatted string.
 *
 * @receiver property with a name of column whose value will be inserted into the tooltip.
 * @param format value format.
 * @return formatted string.
 */


public fun String . tooltipValue ( format : String ? = null ) : String

{ <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> val colID = layerContextInterface . datasetHandler . takeColumn ( this ) <EOL> addFormat ( colID , format ) <EOL> return "<STR_LIT>" <EOL> }

/**
 * Inserts value of given column into formatted string.
 *
 * @receiver name of column whose value will be inserted into the tooltip.
 * @param format value format.
 * @return formatted string.
 */


public fun ColumnReference < * > . tooltipValue ( format : String ? = null ) : String

{ <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> val colID = layerContextInterface . datasetHandler . addColumn ( this ) <EOL> addFormat ( colID , format ) <EOL> return "<STR_LIT>" <EOL> }

/**
 * Inserts value of given column into formatted string.
 *
 * @receiver column whose value will be inserted into the tooltip.
 * @param format value format.
 * @return formatted string.
 */


public fun line ( leftSide : String ? = null , rightSide : String ? = null )

{ <EOL> lineBuffer . add ( "<STR_LIT>" ) <EOL> }

/**
 * Adds two-sided line to tooltips with given string values.
 *
 * @param leftSide text of the left side of line
 * @param rightSide text of the right side of line
 */


public fun line ( column : ColumnReference < * > , format : String ? = null )

{ <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> addVarLine ( layerContextInterface . datasetHandler . addColumn ( column ) . also { <EOL> addFormat ( it , format ) <EOL> } ) <EOL> }

/**
 * Adds standard line for the given column
 * (name of the column on the left side and the corresponding value on the right side).
 *
 * @param column column whose value will be displayed.
 */


public fun line ( property : KProperty < * > , format : String ? = null )

{ <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> addVarLine ( layerContextInterface . datasetHandler . takeColumn ( property . name ) . also { <EOL> addFormat ( it , format ) <EOL> } ) <EOL> }

/**
 * Adds standard line for given column.
 * (Name of the column on the left side and the corresponding value on the right side).
 *
 * @param property property with the name of column whose value will be displayed.
 */


public fun varLine ( columnName : String , format : String ? = null )

{ <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> addVarLine ( layerContextInterface . datasetHandler . takeColumn ( columnName ) . also { <EOL> addFormat ( it , format ) <EOL> } ) <EOL> }

/**
 * Adds standard line for the given column
 * (name of the column on the left side and the corresponding value on the right side).
 *
 * @param columnName name of column whose value will be displayed.
 */


public fun varLine ( property : KProperty < * > , format : String ? = null )

{ <EOL> line ( property , format ) <EOL> }

/**
 * Adds standard line for the given column
 * (name of the column on the left side and the corresponding value on the right side).
 *
 * @param property property with the name of column whose value will be displayed.
 */


public fun varLine ( column : ColumnReference < * > , format : String ? = null )

{ <EOL> line ( column , format ) <EOL> }


@ OptIn ( ExperimentalForeignApi :: class ) <EOL> fun < T : CPointed > printPointerRawValue ( pointer : CPointer < T > )

{ <EOL> println ( pointer . rawValue ) <EOL> }


fun resolveByVersionNumber ( versionNumber : Int ) : AbiSignatureVersion

= AbiSignatureVersions . resolveByVersionNumber ( versionNumber )

/**
 * A function to get an instance of [AbiSignatureVersion] by the unique [versionNumber].
 */


operator fun get ( signatureVersion : AbiSignatureVersion ) : String ?

/**
 * Returns the signature of the specified [AbiSignatureVersion].
 *
 * - If the signature version is not supported by the ABI reader (according to [AbiSignatureVersion.isSupportedByAbiReader])
 * then throw an exception.
 * - If the signature version is supported by the ABI reader, but the signature is unavailable for some other reason
 * (e.g. a particular type of declaration misses a signature of a particular version), then return `null`.
 **/


infix fun isContainerOf ( member : AbiCompoundName ) : Boolean

{ <EOL> val containerName = value <EOL> return when ( val containerNameLength = containerName . length ) { <EOL> <NUM_LIT:0> -> true <EOL> else -> { <EOL> val memberName = member . value <EOL> val memberNameLength = memberName . length <EOL> memberNameLength > containerNameLength + <NUM_LIT:1> && <EOL> memberName . startsWith ( containerName ) && <EOL> memberName [ containerNameLength ] == SEPARATOR <EOL> } <EOL> } <EOL> }

/**
 * Whether a declaration with `this` instance of [AbiCompoundName] is a container of a declaration with `member` [AbiCompoundName].
 *
 * Examples:
 * ```
 * AbiCompoundName("") isContainerOf AbiCompoundName(<any>) == true
 * AbiCompoundName("foo.bar") isContainerOf AbiCompoundName("foo.bar.baz.qux") == true
 * AbiCompoundName("foo.bar") isContainerOf AbiCompoundName("foo.bar.baz") == true
 * AbiCompoundName("foo.bar") isContainerOf AbiCompoundName("foo.barbaz") == false
 * AbiCompoundName("foo.bar") isContainerOf AbiCompoundName("foo.bar") == false
 * AbiCompoundName("foo.bar") isContainerOf AbiCompoundName("foo") == false
 * ```
 */


fun hasAnnotation ( annotationClassName : AbiQualifiedName ) : Boolean

/**
 * Annotations are not a part of ABI. But sometimes it is useful to have the ability to check if some declaration
 * has a specific annotation. See [AbiReadingFilter.NonPublicMarkerAnnotations] as an example.
 */


fun setInlineCallMetadata ( expression : JsExpression , psiElement : KtElement , descriptor : CallableDescriptor , context : TranslationContext )

{ <EOL> assert ( CallExpressionTranslator . shouldBeInlined ( descriptor ) ) { <EOL> "<STR_LIT>" <EOL> } <EOL> val candidateNames = setOf ( context . aliasedName ( descriptor ) , context . getInnerNameForDescriptor ( descriptor ) ) <EOL> val visitor = object : RecursiveJsVisitor ( ) { <EOL> override fun visitInvocation ( invocation : JsInvocation ) { <EOL> super . visitInvocation ( invocation ) <EOL> if ( invocation . name in candidateNames || invocation . name ? . descriptor ? . original == descriptor . original ) { <EOL> invocation . descriptor = descriptor <EOL> invocation . isInline = true <EOL> invocation . psiElement = psiElement <EOL> } <EOL> } <EOL> } <EOL> visitor . accept ( expression ) <EOL> context . addInlineCall ( descriptor ) <EOL> }

/**
 * Recursively walks expression and sets metadata for all invocations of descriptor.
 *
 * When JetExpression is compiled, the resulting JsExpression
 * might not be JsInvocation.
 *
 * For example, extension call with nullable receiver:
 * x?.fn(y)
 * will compile to:
 * (x != null) ? fn.call(x, y) : null
 */


private fun findDeprecatedSinceKotlinAnnotation ( annotations : List < Annotations . Annotation > ) : Annotations . Annotation ?

{ <EOL> return annotations . firstOrNull { <EOL> it . dri . packageName == "<STR_LIT:kotlin>" && it . dri . classNames == "<STR_LIT>" <EOL> } <EOL> }


private fun DocumentableContentBuilder . createKotlinDeprecatedSectionContent ( deprecatedAnnotation : Annotations . Annotation , allAnnotations : List < Annotations . Annotation > )

{ <EOL> val deprecatedSinceKotlinAnnotation = findDeprecatedSinceKotlinAnnotation ( allAnnotations ) <EOL> header ( level = DEPRECATED_HEADER_LEVEL , text = createKotlinDeprecatedHeaderText ( deprecatedAnnotation , deprecatedSinceKotlinAnnotation ) ) <EOL> deprecatedSinceKotlinAnnotation ? . let { <EOL> createDeprecatedSinceKotlinFootnoteContent ( it ) <EOL> } <EOL> deprecatedAnnotation . takeStringParam ( "<STR_LIT:message>" ) ? . let { <EOL> group ( styles = setOf ( TextStyle . Paragraph ) ) { <EOL> text ( it ) <EOL> } <EOL> } <EOL> createReplaceWithSectionContent ( deprecatedAnnotation ) <EOL> }

/**
 * Section with details for Kotlin's [kotlin.Deprecated] annotation
 */


private fun DocumentableContentBuilder . createDeprecatedSinceKotlinFootnoteContent ( deprecatedSinceKotlinAnnotation : Annotations . Annotation )

{ <EOL> group ( styles = setOf ( ContentStyle . Footnote ) ) { <EOL> deprecatedSinceKotlinAnnotation . takeStringParam ( "<STR_LIT>" ) ? . let { <EOL> group ( styles = setOf ( TextStyle . Paragraph ) ) { <EOL> text ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> deprecatedSinceKotlinAnnotation . takeStringParam ( "<STR_LIT>" ) ? . let { <EOL> group ( styles = setOf ( TextStyle . Paragraph ) ) { <EOL> text ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> deprecatedSinceKotlinAnnotation . takeStringParam ( "<STR_LIT>" ) ? . let { <EOL> group ( styles = setOf ( TextStyle . Paragraph ) ) { <EOL> text ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Footnote for [DeprecatedSinceKotlin] annotation used in stdlib
 *
 * Notice that values are empty by default, so it's not guaranteed that all three will be set
 */


private fun DocumentableContentBuilder . createReplaceWithSectionContent ( kotlinDeprecatedAnnotation : Annotations . Annotation )

{ <EOL> val replaceWithAnnotation = ( kotlinDeprecatedAnnotation . params [ "<STR_LIT>" ] as? AnnotationValue ) ? . annotation <EOL> ? : return <EOL> header ( level = DIRECT_PARAM_HEADER_LEVEL , text = "<STR_LIT>" ) <EOL> val imports = ( replaceWithAnnotation . params [ "<STR_LIT>" ] as? ArrayValue ) <EOL> ? . value <EOL> ? . mapNotNull { ( it as? StringValue ) ? . value } <EOL> ? : emptyList ( ) <EOL> if ( imports . isNotEmpty ( ) ) { <EOL> codeBlock ( language = "<STR_LIT:kotlin>" , styles = setOf ( TextStyle . Monospace ) ) { <EOL> imports . forEach { <EOL> text ( "<STR_LIT>" ) <EOL> breakLine ( ) <EOL> } <EOL> } <EOL> } <EOL> replaceWithAnnotation . takeStringParam ( "<STR_LIT>" ) ? . removeSurrounding ( "<STR_LIT>" ) ? . let { <EOL> codeBlock ( language = "<STR_LIT:kotlin>" , styles = setOf ( TextStyle . Monospace ) ) { <EOL> text ( it ) <EOL> } <EOL> } <EOL> }

/**
 * Section for [ReplaceWith] parameter of [kotlin.Deprecated] annotation
 */


private fun DocumentableContentBuilder . createJavaDeprecatedSectionContent ( deprecatedAnnotation : Annotations . Annotation , )

{ <EOL> val isForRemoval = deprecatedAnnotation . takeBooleanParam ( "<STR_LIT>" , default = false ) <EOL> header ( level = DEPRECATED_HEADER_LEVEL , text = if ( isForRemoval ) "<STR_LIT>" else "<STR_LIT>" ) <EOL> deprecatedAnnotation . takeStringParam ( "<STR_LIT>" ) ? . let { <EOL> group ( styles = setOf ( ContentStyle . Footnote ) ) { <EOL> text ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }

/**
 * Section with details for Java's [java.lang.Deprecated] annotation
 */


fun allModulesProvidingActualsFor ( commonModule : ModuleDescriptor , platformModule : ModuleDescriptor ) : ModuleFilter

= { module -> <EOL> when { <EOL> module == commonModule -> true <EOL> commonModule in module . allExpectedByModules -> true <EOL> module == platformModule -> true <EOL> else -> false <EOL> } <EOL> }

/**
 * @param commonModule: The module for which the allowed modules can provide actuals for.
 * Meaning that all allowed modules will have declared a dependsOn edge to said [commonModule]
 *
 * @param platformModule: This parameter is only required to support pre-hmpp IDE
 * consumers. In this mode, leaf/platform modules will get wrapped using PlatformModuleInfo which
 * will be one [ModuleDescriptor] which wrap all dependsOn sources as well.
 * This module will not declare 'proper' [ModuleDescriptor.allExpectedByModules] to the common module
 * and therefore has to be passed into this filter as well to manually check if an actual was provided by this module.
 * This parameter can be dropped and removed once 'non-hmpp' mode shall not be supported anymore.
 */


@ OptIn ( InternalIoApi :: class ) <EOL> public fun Source . readString ( charset : Charset ) : String

{ <EOL> var req = <NUM_LIT:1L> <EOL> while ( request ( req ) ) { <EOL> req *= <NUM_LIT:2> <EOL> } <EOL> return buffer . readStringImpl ( buffer . size , charset ) <EOL> }

/**
 * Decodes whole content of this stream into a string using [charset]. Returns empty string if the source is exhausted.
 *
 * @param charset the [Charset] to use for string decoding.
 *
 * @throws IllegalStateException when the source is closed.
 *
 * @sample kotlinx.io.samples.KotlinxIoSamplesJvm.readWriteStrings
 */


@ OptIn ( InternalIoApi :: class ) <EOL> public fun Source . readString ( byteCount : Long , charset : Charset ) : String

{ <EOL> require ( byteCount ) <EOL> return buffer . readStringImpl ( byteCount , charset ) <EOL> }

/**
 * Decodes [byteCount] bytes of this stream into a string using [charset].
 *
 * @param byteCount the number of bytes to read from the source for decoding.
 * @param charset the [Charset] to use for string decoding.
 *
 * @throws EOFException when the source exhausted before [byteCount] bytes could be read from it.
 * @throws IllegalStateException when the source is closed.
 * @throws IllegalArgumentException if [byteCount] is negative or its value is greater than [Int.MAX_VALUE].
 *
 * @sample kotlinx.io.samples.KotlinxIoSamplesJvm.readStringBounded
 */


@ OptIn ( InternalIoApi :: class ) <EOL> public fun Source . asInputStream ( ) : InputStream

{ <EOL> val isClosed : ( ) -> Boolean = when ( this ) { <EOL> is RealSource -> this :: closed <EOL> is Buffer -> { <EOL> { false } <EOL> } <EOL> } <EOL> return object : InputStream ( ) { <EOL> override fun read ( ) : Int { <EOL> if ( isClosed ( ) ) throw IOException ( "<STR_LIT>" ) <EOL> if ( exhausted ( ) ) { <EOL> return - <NUM_LIT:1> <EOL> } <EOL> return readByte ( ) and <NUM_LIT> <EOL> } <EOL> override fun read ( data : ByteArray , offset : Int , byteCount : Int ) : Int { <EOL> if ( isClosed ( ) ) throw IOException ( "<STR_LIT>" ) <EOL> checkOffsetAndCount ( data . size . toLong ( ) , offset . toLong ( ) , byteCount . toLong ( ) ) <EOL> return this@asInputStream . readAtMostTo ( data , offset , offset + byteCount ) <EOL> } <EOL> override fun available ( ) : Int { <EOL> if ( isClosed ( ) ) throw IOException ( "<STR_LIT>" ) <EOL> return minOf ( buffer . size , Integer . MAX_VALUE ) . toInt ( ) <EOL> } <EOL> override fun close ( ) = this@asInputStream . close ( ) <EOL> override fun toString ( ) = "<STR_LIT>" <EOL> } <EOL> }

/**
 * Returns an input stream that reads from this source. Closing the stream will also close this source.
 *
 * @sample kotlinx.io.samples.KotlinxIoSamplesJvm.asStream
 */


@ OptIn ( InternalIoApi :: class ) <EOL> public fun Source . readAtMostTo ( sink : ByteBuffer ) : Int

{ <EOL> if ( buffer . size == <NUM_LIT:0L> ) { <EOL> request ( Segment . SIZE . toLong ( ) ) <EOL> if ( buffer . size == <NUM_LIT:0L> ) return - <NUM_LIT:1> <EOL> } <EOL> return buffer . readAtMostTo ( sink ) <EOL> }

/**
 * Reads at most [ByteBuffer.remaining] bytes from this source into [sink] and returns the number of bytes read.
 *
 * @param sink the sink to write the data to.
 *
 * @throws IllegalStateException when the source is closed.
 *
 * @sample kotlinx.io.samples.KotlinxIoSamplesJvm.readWriteByteBuffer
 */


public fun Source . asByteChannel ( ) : ReadableByteChannel

{ <EOL> val isClosed : ( ) -> Boolean = when ( this ) { <EOL> is RealSource -> this :: closed <EOL> is Buffer -> { <EOL> { false } <EOL> } <EOL> } <EOL> return object : ReadableByteChannel { <EOL> override fun close ( ) { <EOL> this@asByteChannel . close ( ) <EOL> } <EOL> override fun isOpen ( ) : Boolean = ! isClosed ( ) <EOL> override fun read ( sink : ByteBuffer ) : Int = this@asByteChannel . readAtMostTo ( sink ) <EOL> } <EOL> }

/**
 * Returns [ReadableByteChannel] backed by this source. Closing the source will close the source.
 */


private fun TypeSystemContext . strictEqualTypesInternal ( a : KotlinTypeMarker , b : KotlinTypeMarker ) : Boolean

{ <EOL> if ( a === b ) return true <EOL> val simpleA = a . asSimpleType ( ) <EOL> val simpleB = b . asSimpleType ( ) <EOL> if ( simpleA != null && simpleB != null ) return strictEqualSimpleTypes ( simpleA , simpleB ) <EOL> val flexibleA = a . asFlexibleType ( ) <EOL> val flexibleB = b . asFlexibleType ( ) <EOL> if ( flexibleA != null && flexibleB != null ) { <EOL> return strictEqualSimpleTypes ( flexibleA . lowerBound ( ) , flexibleB . lowerBound ( ) ) && <EOL> strictEqualSimpleTypes ( flexibleA . upperBound ( ) , flexibleB . upperBound ( ) ) <EOL> } <EOL> return false <EOL> }

/**
 * Note that:
 * - `String!` != `String`
 * - `A<String!>` != `A<String>`
 * - `A<in Nothing>` != `A<out Any?>`
 * - `A<*>` != `A<out Any?>`
 *
 * Also different error types are not equal even if errorTypeEqualToAnything is true
 */


fun getInlinedClass ( type : IrType ) : IrClass ?

/**
 * Returns the inlined class for the given type, or `null` if the type is not inlined.
 */


fun IrSymbol . isAccessible ( context : JvmBackendContext , currentScope : ScopeWithIr ? , inlineScopeResolver : IrInlineScopeResolver , withSuper : Boolean , thisObjReference : IrClassSymbol ? , fromOtherClassLoader : Boolean = false ) : Boolean

{ <EOL> val declarationRaw = owner as IrDeclarationWithVisibility <EOL> if ( declarationRaw is IrConstructor && declarationRaw . constructedClass . isEnumEntry ) return true <EOL> val jvmVisibility = AsmUtil . getVisibilityAccessFlag ( declarationRaw . visibility . delegate ) <EOL> if ( jvmVisibility == Opcodes . ACC_PUBLIC && ! withSuper ) return true <EOL> if ( declarationRaw is IrSimpleFunction && ( declarationRaw . isNonGenericToArray ( ) || declarationRaw . isGenericToArray ( context ) ) && declarationRaw . parentAsClass . isCollectionSubClass ) return true <EOL> if ( declarationRaw is IrField && declarationRaw . isAssertionsDisabledField ( context ) ) return true <EOL> if ( declarationRaw is IrFunction && ( declarationRaw . isInline || context . getIntrinsic ( declarationRaw . symbol ) != null ) ) <EOL> return true <EOL> val declaration = when ( declarationRaw ) { <EOL> is IrSimpleFunction -> declarationRaw . resolveFakeOverrideMaybeAbstractOrFail ( ) <EOL> is IrField -> declarationRaw . resolveFieldFakeOverride ( ) <EOL> else -> declarationRaw <EOL> } <EOL> val ownerClass = declaration . parent as? IrClass ? : return true <EOL> val scopeClassOrPackage = inlineScopeResolver . findContainer ( currentScope ! ! . irElement ) ? : return false <EOL> val samePackage = ownerClass . getPackageFragment ( ) . packageFqName == scopeClassOrPackage . getPackageFragment ( ) ? . packageFqName <EOL> return when { <EOL> jvmVisibility == Opcodes . ACC_PRIVATE -> ownerClass == scopeClassOrPackage <EOL> ! withSuper && samePackage && jvmVisibility == <NUM_LIT:0> -> true <EOL> ! withSuper && samePackage && ! fromOtherClassLoader -> true <EOL> else -> ( scopeClassOrPackage is IrClass && scopeClassOrPackage . isSubclassOf ( ownerClass ) ) && <EOL> ( thisObjReference == null || thisObjReference . owner . isSubclassOf ( scopeClassOrPackage ) ) <EOL> } <EOL> }

/**
 * Whether `this` is accessible in [currentScope], according to the platform rules, and with respect to function inlining.
 *
 * @param context The backend context.
 * @param currentScope The scope in which `this` is to be accessed.
 * @param inlineScopeResolver The helper that allows to find the places from which private inline functions are called (useful if
 * `this` is accessed from a private inline function).
 * @param withSuper If an access to this symbol (like [IrCall]) has a `super` qualifier, the access rules will be stricter.
 * @param thisObjReference If this is a member access, the class symbol of the receiver.
 * @param fromOtherClassLoader If `this` is a protected declaration being accessed from the same package but not from a subclass,
 * setting this parameter to `true` marks this declaration as inaccessible, since JVM `protected`, unlike Kotlin `protected`,
 * permits accesses from the same package, _provided the call is not across class loader boundaries_.
 */


private fun modifyFunctionAccessExpression ( oldExpression : IrFunctionAccessExpression , accessorSymbol : IrFunctionSymbol ) : IrFunctionAccessExpression

{ <EOL> val newExpression = when ( oldExpression ) { <EOL> is IrCall -> IrCallImpl . fromSymbolOwner ( oldExpression . startOffset , oldExpression . endOffset , oldExpression . type , accessorSymbol as IrSimpleFunctionSymbol , oldExpression . typeArgumentsCount , origin = oldExpression . origin ) <EOL> is IrDelegatingConstructorCall -> IrDelegatingConstructorCallImpl . fromSymbolOwner ( oldExpression . startOffset , oldExpression . endOffset , context . irBuiltIns . unitType , accessorSymbol as IrConstructorSymbol , oldExpression . typeArgumentsCount ) <EOL> is IrConstructorCall -> <EOL> IrConstructorCallImpl . fromSymbolOwner ( oldExpression . startOffset , oldExpression . endOffset , oldExpression . type , accessorSymbol as IrConstructorSymbol ) <EOL> else -> <EOL> error ( "<STR_LIT>" ) <EOL> } <EOL> newExpression . copyTypeArgumentsFrom ( oldExpression ) <EOL> val receiverAndArgs = oldExpression . receiverAndArgs ( ) <EOL> receiverAndArgs . forEachIndexed { i , irExpression -> <EOL> newExpression . putValueArgument ( i , irExpression ) <EOL> } <EOL> if ( accessorSymbol is IrConstructorSymbol ) { <EOL> newExpression . putValueArgument ( receiverAndArgs . size , createAccessorMarkerArgument ( ) ) <EOL> } <EOL> return newExpression <EOL> }

/**
 * Produces a call to the synthetic accessor [accessorSymbol] to replace the call expression [oldExpression].
 *
 * Before:
 * ```kotlin
 * class C protected constructor(val value: Int) {
 *
 * protected fun protectedFun(a: Int): String = a.toString()
 *
 * internal inline fun foo(x: Int) {
 * println(protectedFun(x))
 * }
 *
 * internal inline fun copy(): C = C(value)
 * }
 * ```
 *
 * After:
 * ```kotlin
 * class C protected constructor(val value: Int) {
 *
 * public constructor(
 * value: Int,
 * constructor_marker: kotlin.jvm.internal.DefaultConstructorMarker?
 * ) : this(value)
 *
 * protected fun protectedFun(a: Int): String = a.toString()
 *
 * public static fun access$protectedFun($this: C, a: Int): String =
 * $this.protectedFun(a)
 *
 * internal inline fun foo(x: Int) {
 * println(C.access$protectedFun(this, x))
 * }
 *
 * internal inline fun copy(): C = C(value, null)
 * }
 * ```
 */


private fun modifyGetterExpression ( oldExpression : IrGetField , accessorSymbol : IrSimpleFunctionSymbol ) : IrCall

{ <EOL> val call = IrCallImpl ( oldExpression . startOffset , oldExpression . endOffset , oldExpression . type , accessorSymbol , <NUM_LIT:0> , accessorSymbol . owner . valueParameters . size , oldExpression . origin ) <EOL> oldExpression . receiver ? . let { <EOL> call . putValueArgument ( <NUM_LIT:0> , oldExpression . receiver ) <EOL> } <EOL> return call <EOL> }

/**
 * Produces a call to the synthetic accessor [accessorSymbol] to replace the field _read_ expression [oldExpression].
 *
 * Before:
 * ```kotlin
 * class C {
 * protected /*field*/ val myField: Int
 *
 * internal inline fun foo(): Int = myField + 1
 * }
 * ```
 *
 * After:
 * ```kotlin
 * class C {
 * protected /*field*/ val myField: Int
 *
 * public static fun access$getMyField$p($this: C): Int =
 * $this.myField
 *
 * internal inline fun foo(): Int =
 * C.access$getMyField$p(this) + 1
 * }
 * ```
 */


private fun modifySetterExpression ( oldExpression : IrSetField , accessorSymbol : IrSimpleFunctionSymbol ) : IrCall

{ <EOL> val call = IrCallImpl ( oldExpression . startOffset , oldExpression . endOffset , oldExpression . type , accessorSymbol , <NUM_LIT:0> , accessorSymbol . owner . valueParameters . size , oldExpression . origin ) <EOL> oldExpression . receiver ? . let { <EOL> call . putValueArgument ( <NUM_LIT:0> , oldExpression . receiver ) <EOL> } <EOL> call . putValueArgument ( call . valueArgumentsCount - <NUM_LIT:1> , oldExpression . value ) <EOL> return call <EOL> }

/**
 * Produces a call to the synthetic accessor [accessorSymbol] to replace the field _write_ expression [oldExpression].
 *
 * Before:
 * ```kotlin
 * class C {
 * protected var myField: Int = 0
 *
 * internal inline fun foo(x: Int) {
 * myField = x
 * }
 * }
 * ```
 *
 * After:
 * ```kotlin
 * class C {
 * protected var myField: Int = 0
 *
 * public static fun access$setMyField$p($this: C, <set-?>: Int) {
 * $this.myField = <set-?>
 * }
 *
 * internal inline fun foo(x: Int) {
 * access$setMyField$p(this, x)
 * }
 * }
 * ```
 */


fun createCallableReferenceProcessor ( factory : CallableReferencesCandidateFactory ) : ScopeTowerProcessor < CallableReferenceResolutionCandidate >

{ <EOL> when ( val lhsResult = factory . kotlinCall . lhsResult ) { <EOL> LHSResult . Empty , LHSResult . Error , is LHSResult . Expression -> { <EOL> val explicitReceiver = ( lhsResult as? LHSResult . Expression ) ? . lshCallArgument ? . receiver <EOL> return factory . createCallableProcessor ( explicitReceiver ) <EOL> } <EOL> is LHSResult . Type -> { <EOL> val static = lhsResult . qualifier ? . let ( factory :: createCallableProcessor ) <EOL> val unbound = factory . createCallableProcessor ( lhsResult . unboundDetailedReceiver ) <EOL> val staticOrUnbound = <EOL> if ( static != null ) <EOL> SamePriorityCompositeScopeTowerProcessor ( static , unbound ) <EOL> else <EOL> unbound <EOL> val asValue = lhsResult . qualifier ? . classValueReceiverWithSmartCastInfo ? : return staticOrUnbound <EOL> return PrioritizedCompositeScopeTowerProcessor ( staticOrUnbound , factory . createCallableProcessor ( asValue ) ) <EOL> } <EOL> is LHSResult . Object -> { <EOL> val static = factory . createCallableProcessor ( lhsResult . qualifier ) <EOL> val boundObjectReference = factory . createCallableProcessor ( lhsResult . objectValueReceiver ) <EOL> return SamePriorityCompositeScopeTowerProcessor ( static , boundObjectReference ) <EOL> } <EOL> } <EOL> }

/**
 * cases: class A {}, class B { companion object }, object C, enum class D { E }
 * A::foo <-> Type
 * a::foo <-> Expression
 * B::foo <-> Type
 * C::foo <-> Object
 * D.E::foo <-> Expression
 */


fun Tuple1 < * > . dropFirst ( ) : EmptyTuple

= EmptyTuple

/**
 * This file contains functions to lower the amount of dimensions of tuples.
 * This can be done using [dropFirst] and [dropLast].
 *
 * For example:
 * ```kotlin
 * val yourTuple: Tuple2<Int, String> = tupleOf(1, "test", a).dropLast()
 * ```
 *
 */


public fun < T > yMax ( column : ColumnReference < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( Y_MAX , column . name ( ) , null ) <EOL> }

/**
 * Maps the `yMax` aesthetic to a data column specified by a [ColumnReference].
 *
 * @param column the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun < T > yMax ( column : KProperty < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( Y_MAX , column . name , null ) <EOL> }

/**
 * Maps the `yMax` aesthetic to a data column specified by a [KProperty].
 *
 * @param column the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun yMax ( column : String ) : PositionalMapping < Any ? >

{ <EOL> return addPositionalMapping ( Y_MAX , column , null ) <EOL> }

/**
 * Maps the `yMax` aesthetic to a data column specified by a [String].
 *
 * @param column the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun < T > yMax ( values : Iterable < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( Y_MAX , values . toList ( ) , null , null ) <EOL> }

/**
 * Maps the `yMax` aesthetic to iterable of values.
 *
 * @param values the iterable of values to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


public fun < T > yMax ( values : DataColumn < T > ) : PositionalMapping < T >

{ <EOL> return addPositionalMapping < T > ( Y_MAX , values , null ) <EOL> }

/**
 * Maps the `yMax` aesthetic to a data column.
 *
 * @param values the data column to be mapped.
 * @return a [PositionalMapping] object representing the mapping.
 */


fun target ( target : TargetWithSanitizer , action : Action < in T > ) : T

{ <EOL> val element = targets . getOrPut ( target ) { factory ( target ) } <EOL> action . execute ( element ) <EOL> return element <EOL> }

/**
 * Create or update configuration [T] for [target] and apply [action] to it.
 *
 * @param target target of the configuration
 * @param action action to apply to the configuration
 * @return resulting configuration
 */


fun target ( target : TargetWithSanitizer ) : T

{ <EOL> return targets [ target ] ? : throw UnknownDomainObjectException ( "<STR_LIT>" ) <EOL> }

/**
 * Get configuration [T] for [target].
 *
 * @param target target of the configuration
 * @return resulting configuration
 * @throws UnknownDomainObjectException if configuration for [target] does not exist
 */


fun allTargets ( action : Action < in T > ) : List < T >

= platformManager . allTargetsWithSanitizers . map { <EOL> this . target ( it , action ) <EOL> }

/**
 * Create or update configurations [T] for all known targets with their sanitizers and apply [action] to each of it.
 *
 * @param action action to apply to the configuration
 * @return list of configurations
 */


fun hostTarget ( action : Action < in T > ) : T

{ <EOL> return target ( HostManager . host . withSanitizer ( ) , action ) <EOL> }

/**
 * Create or update configuration [T] for [host target][HostManager.host] and apply [action] to it.
 *
 * @param action action to apply to the configuration
 * @return resulting configuration
 */


public infix fun < C > ColumnsResolver < C > . and ( other : ColumnsResolver < C > ) : ColumnSet < C >

= ColumnsList ( this , other )

/** @include [ColumnsResolverAndDocs] {@set [ColumnsResolverAndDocs.Argument] [`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`} */


public infix fun < C > ColumnsResolver < C > . and ( other : ( ) -> ColumnsResolver < C > ) : ColumnSet < C >

= this and other ( )

/** @include [ColumnsResolverAndDocs] {@set [ColumnsResolverAndDocs.Argument] `{ colA `[`/`][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" \}`} */


public infix fun < C > ColumnsResolver < C > . and ( other : String ) : ColumnSet < * >

= this and other . toColumnAccessor ( )

/** @include [ColumnsResolverAndDocs] {@set [ColumnsResolverAndDocs.Argument] `"colB"`} */


public infix fun < C > ColumnsResolver < C > . and ( other : KProperty < C > ) : ColumnSet < C >

= this and other . toColumnAccessor ( )

/** @include [ColumnsResolverAndDocs] {@set [ColumnsResolverAndDocs.Argument] `Type::colB`} */


public infix fun < C > String . and ( other : ColumnsResolver < C > ) : ColumnSet < * >

= toColumnAccessor ( ) and other

/** @include [StringAndDocs] {@set [StringAndDocs.Argument] [`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`} */


public infix fun < C > String . and ( other : ( ) -> ColumnsResolver < C > ) : ColumnSet < * >

= toColumnAccessor ( ) and other ( )

/** @include [StringAndDocs] {@set [StringAndDocs.Argument] `{ colA `[`/`][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" \}`} */


public infix fun String . and ( other : String ) : ColumnSet < * >

= toColumnAccessor ( ) and other . toColumnAccessor ( )

/** @include [StringAndDocs] {@set [StringAndDocs.Argument] `"colB"`} */


public infix fun < C > String . and ( other : KProperty < C > ) : ColumnSet < * >

= toColumnAccessor ( ) and other

/** @include [StringAndDocs] {@set [StringAndDocs.Argument] `Type::colB`} */


public infix fun < C > KProperty < C > . and ( other : ColumnsResolver < C > ) : ColumnSet < C >

= toColumnAccessor ( ) and other

/** @include [KPropertyAndDocs] {@set [KPropertyAndDocs.Argument] [`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`} */


public infix fun < C > KProperty < C > . and ( other : ( ) -> ColumnsResolver < C > ) : ColumnSet < C >

= <EOL> toColumnAccessor ( ) and other ( )

/** @include [KPropertyAndDocs] {@set [KPropertyAndDocs.Argument] `{ colA `[/][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" \}`} */


public infix fun < C > KProperty < C > . and ( other : String ) : ColumnSet < * >

= toColumnAccessor ( ) and other

/** @include [KPropertyAndDocs] {@set [KPropertyAndDocs.Argument] `"colB"`} */


public infix fun < C > KProperty < C > . and ( other : KProperty < C > ) : ColumnSet < C >

= <EOL> toColumnAccessor ( ) and other . toColumnAccessor ( )

/** @include [KPropertyAndDocs] {@set [KPropertyAndDocs.Argument] `Type::colB`} */


private fun rewriteIndyLambdaMetafactoryCall ( call : IrCall ) : IrCall

{ <EOL> fun fail ( message : String ) : Nothing = <EOL> throw AssertionError ( "<STR_LIT>" ) <EOL> val startOffset = call . startOffset <EOL> val endOffset = call . endOffset <EOL> val samType = call . getTypeArgument ( <NUM_LIT:0> ) as? IrSimpleType <EOL> ? : fail ( "<STR_LIT>" ) <EOL> val samMethodRef = call . getValueArgument ( <NUM_LIT:0> ) as? IrRawFunctionReference <EOL> ? : fail ( "<STR_LIT>" ) <EOL> val implFunRef = call . getValueArgument ( <NUM_LIT:1> ) as? IrFunctionReference <EOL> ? : fail ( "<STR_LIT>" ) <EOL> val implFunSymbol = implFunRef . symbol <EOL> val instanceMethodRef = call . getValueArgument ( <NUM_LIT:2> ) as? IrRawFunctionReference <EOL> ? : fail ( "<STR_LIT>" ) <EOL> val extraOverriddenMethods = run { <EOL> val extraOverriddenMethodVararg = call . getValueArgument ( <NUM_LIT:3> ) as? IrVararg <EOL> ? : fail ( "<STR_LIT>" ) <EOL> extraOverriddenMethodVararg . elements . map { <EOL> val ref = it as? IrRawFunctionReference <EOL> ? : fail ( "<STR_LIT>" ) <EOL> ref . symbol . owner as? IrSimpleFunction <EOL> ? : fail ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val shouldBeSerializable = call . getBooleanConstArgument ( <NUM_LIT:4> ) <EOL> val samMethod = samMethodRef . symbol . owner as? IrSimpleFunction <EOL> ? : fail ( "<STR_LIT>" ) <EOL> val instanceMethod = instanceMethodRef . symbol . owner as? IrSimpleFunction <EOL> ? : fail ( "<STR_LIT>" ) <EOL> val dynamicCall = wrapClosureInDynamicCall ( samType , samMethod , implFunRef ) <EOL> val requiredBridges = getOverriddenMethodsRequiringBridges ( instanceMethod , samMethod , extraOverriddenMethods ) <EOL> if ( shouldBeSerializable ) { <EOL> getClassContext ( ) . serializableMethodRefInfos . add ( SerializableMethodRefInfo ( samType , samMethod . symbol , implFunSymbol , instanceMethodRef . symbol , requiredBridges , dynamicCall . symbol ) ) <EOL> } <EOL> return backendContext . createJvmIrBuilder ( implFunSymbol , startOffset , endOffset ) <EOL> . createLambdaMetafactoryCall ( samMethod . symbol , implFunSymbol , instanceMethodRef . symbol , shouldBeSerializable , requiredBridges , dynamicCall ) <EOL> }

/**
 * @see FunctionReferenceLowering.wrapWithIndySamConversion
 */


public operator fun not ( ) : Boolean

/**
 * Returns the inverse of this boolean.
 */


infix fun and ( other : Boolean ) : Boolean

/**
 * Performs a logical `and` operation between this Boolean and the [other] one.
 */


infix fun or ( other : Boolean ) : Boolean

/**
 * Performs a logical `or` operation between this Boolean and the [other] one.
 */


infix fun xor ( other : Boolean ) : Boolean

/**
 * Performs a logical `xor` operation between this Boolean and the [other] one.
 */


@ Test <EOL> fun testRunTestActivityNotificationsRace ( )

{ <EOL> val n = <NUM_LIT> * stressTestMultiplier <EOL> for ( i in <NUM_LIT:0> until n ) { <EOL> runTest { <EOL> suspendCancellableCoroutine < Unit > { cont -> <EOL> thread { <EOL> cont . resume ( Unit ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> }

/** Tests that notifications about asynchronous resumptions aren't lost. */


{ <EOL> if ( CompilerSystemProperties . JAVA_RMI_SERVER_HOSTNAME . value == null ) { <EOL> CompilerSystemProperties . JAVA_RMI_SERVER_HOSTNAME . value = LoopbackNetworkInterface . loopbackInetAddressName <EOL> } <EOL> }

/**
 * Needs to be set up on both client and server to prevent localhost resolution,
 * which may be slow and can cause a timeout when there is a network problem/misconfiguration.
 */


@ ExperimentalCoroutinesApi <EOL> public fun TestScope . advanceUntilIdle ( ) : Unit

= testScheduler . advanceUntilIdle ( )

/**
 * Advances the [testScheduler][TestScope.testScheduler] to the point where there are no tasks remaining.
 * @see TestCoroutineScheduler.advanceUntilIdle
 */


@ ExperimentalCoroutinesApi <EOL> public fun TestScope . runCurrent ( ) : Unit

= testScheduler . runCurrent ( )

/**
 * Run any tasks that are pending at the current virtual time, according to
 * the [testScheduler][TestScope.testScheduler].
 *
 * @see TestCoroutineScheduler.runCurrent
 */


@ ExperimentalCoroutinesApi <EOL> public fun TestScope . advanceTimeBy ( delayTimeMillis : Long ) : Unit

= testScheduler . advanceTimeBy ( delayTimeMillis )

/**
 * Moves the virtual clock of this dispatcher forward by [the specified amount][delayTimeMillis], running the
 * scheduled tasks in the meantime.
 *
 * In contrast with `TestCoroutineScope.advanceTimeBy`, this function does not run the tasks scheduled at the moment
 * [currentTime] + [delayTimeMillis].
 *
 * @throws IllegalStateException if passed a negative [delay][delayTimeMillis].
 * @see TestCoroutineScheduler.advanceTimeBy
 */


@ ExperimentalCoroutinesApi <EOL> public fun TestScope . advanceTimeBy ( delayTime : Duration ) : Unit

= testScheduler . advanceTimeBy ( delayTime )

/**
 * Moves the virtual clock of this dispatcher forward by [the specified amount][delayTime], running the
 * scheduled tasks in the meantime.
 *
 * @throws IllegalStateException if passed a negative [delay][delayTime].
 * @see TestCoroutineScheduler.advanceTimeBy
 */


@ Suppress ( "<STR_LIT:FunctionName>" ) <EOL> public fun TestScope ( context : CoroutineContext = EmptyCoroutineContext ) : TestScope

{ <EOL> val ctxWithDispatcher = context . withDelaySkipping ( ) <EOL> var scope : TestScopeImpl ? = null <EOL> val exceptionHandler = when ( ctxWithDispatcher [ CoroutineExceptionHandler ] ) { <EOL> null -> CoroutineExceptionHandler { _ , exception -> <EOL> scope ! ! . reportException ( exception ) <EOL> } <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> return TestScopeImpl ( ctxWithDispatcher + exceptionHandler ) . also { scope = it } <EOL> }

/**
 * Creates a [TestScope].
 *
 * It ensures that all the test module machinery is properly initialized.
 * - If [context] doesn't provide a [TestCoroutineScheduler] for orchestrating the virtual time used for delay-skipping,
 * a new one is created, unless either
 * - a [TestDispatcher] is provided, in which case [TestDispatcher.scheduler] is used;
 * - at the moment of the creation of the scope, [Dispatchers.Main] is delegated to a [TestDispatcher], in which case
 * its [TestCoroutineScheduler] is used.
 * - If [context] doesn't have a [TestDispatcher], a [StandardTestDispatcher] is created.
 * - A [CoroutineExceptionHandler] is created that makes [TestCoroutineScope.cleanupTestCoroutines] throw if there were
 * any uncaught exceptions, or forwards the exceptions further in a platform-specific manner if the cleanup was
 * already performed when an exception happened. Passing a [CoroutineExceptionHandler] is illegal, unless it's an
 * [UncaughtExceptionCaptor], in which case the behavior is preserved for the time being for backward compatibility.
 * If you need to have a specific [CoroutineExceptionHandler], please pass it to [launch] on an already-created
 * [TestCoroutineScope] and share your use case at
 * [our issue tracker](https://github.com/Kotlin/kotlinx.coroutines/issues).
 * - If [context] provides a [Job], that job is used as a parent for the new scope.
 *
 * @throws IllegalArgumentException if [context] has both [TestCoroutineScheduler] and a [TestDispatcher] linked to a
 * different scheduler.
 * @throws IllegalArgumentException if [context] has a [ContinuationInterceptor] that is not a [TestDispatcher].
 * @throws IllegalArgumentException if [context] has an [CoroutineExceptionHandler] that is not an
 * [UncaughtExceptionCaptor].
 */


internal fun CoroutineContext . withDelaySkipping ( ) : CoroutineContext

{ <EOL> val dispatcher : TestDispatcher = when ( val dispatcher = get ( ContinuationInterceptor ) ) { <EOL> is TestDispatcher -> { <EOL> val ctxScheduler = get ( TestCoroutineScheduler ) <EOL> if ( ctxScheduler != null ) { <EOL> require ( dispatcher . scheduler === ctxScheduler ) { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> dispatcher <EOL> } <EOL> null -> StandardTestDispatcher ( get ( TestCoroutineScheduler ) ) <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> return this + dispatcher + dispatcher . scheduler <EOL> }

/**
 * Adds a [TestDispatcher] and a [TestCoroutineScheduler] to the context if there aren't any already.
 *
 * @throws IllegalArgumentException if both a [TestCoroutineScheduler] and a [TestDispatcher] are passed.
 * @throws IllegalArgumentException if a [ContinuationInterceptor] is passed that is not a [TestDispatcher].
 */


{ <EOL> val exceptions = synchronized ( lock ) { <EOL> if ( entered ) <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> entered = true <EOL> check ( ! finished ) <EOL> @ Suppress ( "<STR_LIT:INVISIBLE_REFERENCE>" , "<STR_LIT:INVISIBLE_MEMBER>" ) <EOL> run { ensurePlatformExceptionHandlerLoaded ( ExceptionCollector ) } <EOL> if ( catchNonTestRelatedExceptions ) { <EOL> ExceptionCollector . addOnExceptionCallback ( lock , this :: reportException ) <EOL> } <EOL> uncaughtExceptions <EOL> } <EOL> if ( exceptions . isNotEmpty ( ) ) { <EOL> ExceptionCollector . removeOnExceptionCallback ( lock ) <EOL> throw UncaughtExceptionsBeforeTest ( ) . apply { <EOL> for ( e in exceptions ) <EOL> addSuppressed ( e ) <EOL> } <EOL> } <EOL> }

/** Called upon entry to [runTest]. Will throw if called more than once. */


= synchronized ( lock ) { <EOL> check ( entered && ! finished ) <EOL> ExceptionCollector . removeOnExceptionCallback ( lock ) <EOL> finished = true <EOL> uncaughtExceptions <EOL> }

/** Called at the end of the test. May only be called once. Returns the list of caught unhandled exceptions. */


fun legacyLeave ( ) : List < Throwable >

{ <EOL> val exceptions = synchronized ( lock ) { <EOL> check ( entered && ! finished ) <EOL> ExceptionCollector . removeOnExceptionCallback ( lock ) <EOL> finished = true <EOL> uncaughtExceptions <EOL> } <EOL> val activeJobs = children . filter { it . isActive } . toList ( ) <EOL> if ( exceptions . isEmpty ( ) ) { <EOL> if ( activeJobs . isNotEmpty ( ) ) <EOL> throw UncompletedCoroutinesError ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) <EOL> if ( ! testScheduler . isIdle ( ) ) <EOL> throw UncompletedCoroutinesError ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> return exceptions <EOL> }

/** Called at the end of the test. May only be called once. */


fun reportException ( throwable : Throwable )

{ <EOL> synchronized ( lock ) { <EOL> if ( finished ) { <EOL> throw throwable <EOL> } else { <EOL> @ Suppress ( "<STR_LIT:INVISIBLE_MEMBER>" , "<STR_LIT:INVISIBLE_REFERENCE>" ) <EOL> for ( existingThrowable in uncaughtExceptions ) { <EOL> if ( unwrap ( throwable ) == unwrap ( existingThrowable ) ) <EOL> return <EOL> } <EOL> uncaughtExceptions . add ( throwable ) <EOL> if ( ! entered ) <EOL> throw UncaughtExceptionsBeforeTest ( ) . apply { addSuppressed ( throwable ) } <EOL> } <EOL> } <EOL> }

/** Stores an exception to report after [runTest], or rethrows it if not inside [runTest]. */


fun tryGetCompletionCause ( ) : Throwable ?

= completionCause

/** Throws an exception if the coroutine is not completing. */


@ Suppress ( "<STR_LIT>" ) <EOL> internal fun TestScope . asSpecificImplementation ( ) : TestScopeImpl

= when ( this ) { <EOL> is TestScopeImpl -> this <EOL> }

/** Use the knowledge that any [TestScope] that we receive is necessarily a [TestScopeImpl]. */


= <EOL> when ( this ) { <EOL> is DataTypeWithClass -> DataType . fromJson ( dt ( ) . json ( ) ) <EOL> else -> this <EOL> }


@ PublishedApi <EOL> internal fun KClass < * > . checkForValidType ( parameterName : String )

{ <EOL> if ( this == String :: class || isSubclassOf ( Seq :: class ) ) <EOL> return <EOL> if ( isSubclassOf ( Iterable :: class ) || java . isArray || isSubclassOf ( Char :: class ) || isSubclassOf ( Map :: class ) || isSubclassOf ( Array :: class ) || isSubclassOf ( ByteArray :: class ) || isSubclassOf ( CharArray :: class ) || isSubclassOf ( ShortArray :: class ) || isSubclassOf ( IntArray :: class ) || isSubclassOf ( LongArray :: class ) || isSubclassOf ( FloatArray :: class ) || isSubclassOf ( DoubleArray :: class ) || isSubclassOf ( BooleanArray :: class ) ) throw TypeOfUDFParameterNotSupportedException ( this , parameterName ) <EOL> }

/**
 * Checks if [this] is of a valid type for a UDF, otherwise it throws a [TypeOfUDFParameterNotSupportedException]
 */


inline fun < Return , reified NamedUdf : NamedUserDefinedFunction < Return , * > > UDFRegistration . register ( namedUdf : NamedUdf , ) : NamedUdf

= namedUdf . copy ( udf = register ( namedUdf . name , namedUdf . udf ) )

/**
 * Registers a user-defined function (UDF) with name, for a UDF that's already defined using the Dataset
 * API (i.e. of type [NamedUserDefinedFunction]).
 * @see UDFRegistration.register
 */


fun withName ( name : String ) : NamedUdf

/** Converts this [UserDefinedFunction] to a [NamedUserDefinedFunction]. */


operator fun getValue ( thisRef : Any ? , property : KProperty < * > ) : NamedUdf

/**
 * Converts this [UserDefinedFunction] to a [NamedUserDefinedFunction].
 * @see withName
 */


inline fun < R , reified T : NamedUserDefinedFunction < R , * > > T . copy ( name : String = this . name , udf : SparkUserDefinedFunction = this . udf , encoder : Encoder < R > = this . encoder , ) : T

= T :: class . primaryConstructor ! ! . run { <EOL> callBy ( parameters . associateWith { <EOL> when ( it . name ) { <EOL> NamedUserDefinedFunction < * , * > :: name . name -> name <EOL> NamedUserDefinedFunction < * , * > :: udf . name -> udf <EOL> NamedUserDefinedFunction < * , * > :: encoder . name -> encoder <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } ) <EOL> }

/** Copy method for all [NamedUserDefinedFunction] functions. */


private fun KDoc . findSectionsContainingTag ( tag : KDocKnownTag ) : List < KDocSection >

{ <EOL> return getChildrenOfType < KDocSection > ( ) <EOL> . filter { it . findTagByName ( tag . name . toLowerCaseAsciiOnly ( ) ) != null } <EOL> }

/**
 * Looks for sections that have a deeply nested [tag],
 * as opposed to [KDoc.findSectionByTag], which only looks among the top level
 */


fun render ( x : Float , y : Float , w : Float , h : Float , color : Vector3 )

{ <EOL> this . program . let { <EOL> it . activate ( ) <EOL> it . color . assign ( color ) <EOL> val positions = listOf ( Vector2 ( x , y ) , Vector2 ( x + w , y ) , Vector2 ( x , y + h ) , Vector2 ( x + w , y ) , Vector2 ( x + w , y + h ) , Vector2 ( x , y + h ) ) <EOL> it . position . assign ( positions ) <EOL> glDrawArrays ( GL_TRIANGLES , <NUM_LIT:0> , positions . size ) <EOL> } <EOL> }

/**
 * Draws a 2D rectangle specified in a normalized device coordinates,
 * i.e. the bottom-left corner of the screen is `(-1, -1)` and the top-right is `(1, 1)`.
 */


fun render ( x : Float , y : Float , w : Float , h : Float , texture : Int , texBottomLeft : Vector2 = Vector2 ( <NUM_LIT:0.0f> , <NUM_LIT:0.0f> ) , texUpperRight : Vector2 = Vector2 ( <NUM_LIT> , <NUM_LIT> ) )

{ <EOL> glBindTexture ( GL_TEXTURE_2D , textures [ texture ] ) <EOL> this . program . let { <EOL> it . activate ( ) <EOL> val positions = listOf ( Vector2 ( x , y ) , Vector2 ( x + w , y ) , Vector2 ( x , y + h ) , Vector2 ( x + w , y ) , Vector2 ( x + w , y + h ) , Vector2 ( x , y + h ) ) <EOL> val texCoords = listOf ( texBottomLeft , Vector2 ( texUpperRight . x , texBottomLeft . y ) , Vector2 ( texBottomLeft . x , texUpperRight . y ) , Vector2 ( texUpperRight . x , texBottomLeft . y ) , texUpperRight , Vector2 ( texBottomLeft . x , texUpperRight . y ) ) <EOL> it . position . assign ( positions ) <EOL> it . texcoord . assign ( texCoords ) <EOL> it . tex . assign ( <NUM_LIT:0> ) <EOL> glDrawArrays ( GL_TRIANGLES , <NUM_LIT:0> , positions . size ) <EOL> } <EOL> }


fun render ( x : Float , y : Float , w : Float , h : Float , myTeam : Team ? , counts : List < Int > , digitAspect : Float , screenAspect : Float )

{ <EOL> val barsCount = Team . count <EOL> val allMarginsCount = barsCount - <NUM_LIT:1> <EOL> val highlightedMarginsCount = when { <EOL> myTeam == null -> <NUM_LIT:0> <EOL> myTeam . ordinal == <NUM_LIT:0> || myTeam . ordinal == Team . count - <NUM_LIT:1> -> <NUM_LIT:1> <EOL> else -> <NUM_LIT:2> <EOL> } <EOL> val marginsCount = allMarginsCount - highlightedMarginsCount <EOL> val marginToBar = <NUM_LIT> / <NUM_LIT> <EOL> val highlightedMarginToBar = <NUM_LIT> / <NUM_LIT> <EOL> val barWidth = w / ( barsCount + marginToBar * marginsCount + highlightedMarginToBar * highlightedMarginsCount ) <EOL> val marginWidth = barWidth * marginToBar <EOL> val highlightedMarginWidth = barWidth * highlightedMarginToBar <EOL> var maxCount = counts . max ( ) ? : <NUM_LIT:0> <EOL> if ( maxCount == <NUM_LIT:0> ) maxCount = <NUM_LIT:1> <EOL> val maxBarH = ( h - barWidth / screenAspect - <NUM_LIT:4> * marginWidth / screenAspect ) <EOL> val zh = barWidth / screenAspect + <NUM_LIT:2> * marginWidth / screenAspect <EOL> var barX = x <EOL> for ( team in Team . values ( ) ) { <EOL> val barH = <NUM_LIT> + ( counts [ team . ordinal ] . toFloat ( ) / maxCount * maxBarH ) <EOL> rectRenderer . render ( barX , y + zh , barWidth , barH , team . colorVector ) <EOL> val teamSquareSize = if ( team == myTeam ) barWidth * <NUM_LIT> else barWidth <EOL> val centerY = ( zh - barWidth / screenAspect ) * <NUM_LIT:1> / <NUM_LIT:2> + ( barWidth / screenAspect ) / <NUM_LIT:2> <EOL> val dist = zh - ( centerY + ( teamSquareSize / screenAspect ) * <NUM_LIT> ) <EOL> texturedRectRenderer . renderScore ( barX , y + zh + barH + dist * <NUM_LIT> , barWidth , counts [ team . ordinal ] , if ( team == myTeam ) <NUM_LIT> * <NUM_LIT:12> / <NUM_LIT:16> else <NUM_LIT> , digitAspect , <NUM_LIT> , <NUM_LIT:0> , - <NUM_LIT:1> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> , <NUM_LIT> ) <EOL> rectRenderer . render ( barX + ( barWidth - teamSquareSize ) / <NUM_LIT:2> , y + centerY - ( teamSquareSize / screenAspect / <NUM_LIT:2> ) , teamSquareSize , teamSquareSize / screenAspect , teamNumberColor ) <EOL> val digitSize = if ( team == myTeam ) <NUM_LIT> else <NUM_LIT> <EOL> val digitW = digitSize <EOL> val digitH = digitW / digitAspect <EOL> texturedRectRenderer . render ( barX + ( barWidth - teamSquareSize ) / <NUM_LIT:2> + teamSquareSize * ( <NUM_LIT:1> - digitW ) / <NUM_LIT:2> , y + centerY - ( teamSquareSize / screenAspect / <NUM_LIT:2> ) + ( ( teamSquareSize / screenAspect - teamSquareSize * digitH ) / <NUM_LIT:2> ) , teamSquareSize * digitW , teamSquareSize * digitH , team . ordinal + <NUM_LIT:1> ) <EOL> val curMarginWidth = if ( team == myTeam || team . ordinal + <NUM_LIT:1> == myTeam ? . ordinal ) highlightedMarginWidth else marginWidth <EOL> barX += barWidth + curMarginWidth <EOL> } <EOL> }

/**
 * Renders a stats bar chart inside the specified rectangle.
 * The coordinate system are the same as in [RectRenderer.render].
 *
 * It makes a padding around the chart.
 */


fun render ( sceneState : SceneState , screenWidth : Float , screenHeight : Float )

{ <EOL> glClearColor ( backgroundColor . x , backgroundColor . y , backgroundColor . z , <NUM_LIT> ) <EOL> glClear ( ( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT ) . convert ( ) ) <EOL> val screenAspect = screenHeight / screenWidth <EOL> val stats = sceneState . stats <EOL> val gameOver = sceneState . initialized && stats ? . status == <NUM_LIT:0> <EOL> val showCopyright = stats ? . status == <NUM_LIT:2> <EOL> val squareSize = minOf ( screenWidth , screenHeight ) <EOL> val digitAspect = <NUM_LIT> / <NUM_LIT> * screenAspect <EOL> val projectionMatrix = <EOL> translationMatrix ( squareSize / screenWidth - <NUM_LIT:1> , <NUM_LIT:0.0f> - ( - <NUM_LIT> + <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , <NUM_LIT:0.0f> ) * orthographicProjectionMatrix ( - screenWidth / squareSize , screenWidth / squareSize , - screenHeight / squareSize , screenHeight / squareSize , <NUM_LIT> , <NUM_LIT> ) <EOL> if ( ! gameOver ) { <EOL> kotlinLogoRenderer . render ( translationMatrix ( <NUM_LIT:0.0f> , <NUM_LIT:0.0f> , - <NUM_LIT> ) * Matrix4 ( sceneState . rotationMatrix ) , projectionMatrix ) <EOL> } <EOL> val myContribution = if ( sceneState . initialized && stats != null ) <EOL> stats . myContribution <EOL> else <NUM_LIT:0> <EOL> val myTeam = if ( sceneState . initialized && stats != null ) <EOL> stats . myTeam <EOL> else null <EOL> val counts = if ( sceneState . initialized && stats != null ) <EOL> Team . values ( ) . map { stats . getCount ( it ) } <EOL> else IntArray ( Team . count , { <NUM_LIT:0> } ) . asList ( ) <EOL> fun renderCenteredTexture ( y : Float , w : Float , aspectRatio : Float , textureId : Int ) { <EOL> statsBarChartRenderer . texturedRectRenderer . render ( - <NUM_LIT> + ( <NUM_LIT> - w ) / <NUM_LIT:2> , y , w , w * aspectRatio / screenAspect , textureId ) <EOL> } <EOL> val margin = <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> <EOL> if ( ! gameOver ) { <EOL> if ( sceneState . initialized ) { <EOL> val scoreH = <NUM_LIT> <EOL> val spinsAspect = ( <NUM_LIT> / <NUM_LIT> ) * screenAspect <EOL> val scoreW = scoreH * digitAspect * <NUM_LIT:7> <EOL> statsBarChartRenderer . texturedRectRenderer . renderScore ( - <NUM_LIT> + ( <NUM_LIT> - scoreW ) / <NUM_LIT:2> , <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , scoreW , myContribution , <NUM_LIT> * <NUM_LIT:12> / <NUM_LIT> , digitAspect , <NUM_LIT> , <NUM_LIT:1> , spinsTextureId , spinsAspect , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> } <EOL> } else { <EOL> if ( stats ! ! . winner ) { <EOL> renderCenteredTexture ( <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , <NUM_LIT> - margin * <NUM_LIT:2> , <NUM_LIT> / <NUM_LIT> , winnerTextureId ) <EOL> } else { <EOL> renderCenteredTexture ( <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , <NUM_LIT> * <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , gameOverTextureId ) <EOL> } <EOL> renderCenteredTexture ( <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , <NUM_LIT> * <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , teamPlaceTextureId ) <EOL> val myCount = counts [ myTeam ! ! . ordinal ] <EOL> val place = counts . count { it > myCount } + <NUM_LIT:1> <EOL> val placeH = <NUM_LIT> <EOL> val placeW = placeH * digitAspect <EOL> placeRenderer . renderScore ( <NUM_LIT> , <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , placeW , place , <NUM_LIT> , digitAspect , <NUM_LIT> , <NUM_LIT:0> , - <NUM_LIT:1> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> ) <EOL> val totalH = <NUM_LIT> <EOL> val totalW = totalH * digitAspect * <NUM_LIT:7> <EOL> statsBarChartRenderer . texturedRectRenderer . renderScore ( - <NUM_LIT> + ( <NUM_LIT> - totalW ) / <NUM_LIT:2> , <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , totalW , myCount , <NUM_LIT> * <NUM_LIT:12> / <NUM_LIT:20> , digitAspect , <NUM_LIT> , <NUM_LIT:0> , - <NUM_LIT:1> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> , <NUM_LIT:0.0f> ) <EOL> renderCenteredTexture ( <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , <NUM_LIT> * <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , totalSpinsTextureId ) <EOL> val scoreH = <NUM_LIT> <EOL> val youContributedAspect = ( <NUM_LIT> / <NUM_LIT> ) * screenAspect <EOL> val scoreW = scoreH * digitAspect * <NUM_LIT:7> <EOL> statsBarChartRenderer . texturedRectRenderer . renderScore ( - <NUM_LIT> + ( <NUM_LIT> - scoreW ) / <NUM_LIT:2> , <NUM_LIT> - ( <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , scoreW , myContribution , <NUM_LIT> * <NUM_LIT:12> / <NUM_LIT:11> , digitAspect , <NUM_LIT> , - <NUM_LIT:1> , youContributedTextureId , youContributedAspect , <NUM_LIT> , <NUM_LIT:0.0f> , <NUM_LIT> ) <EOL> } <EOL> statsBarChartRenderer . rectRenderer . render ( ( - <NUM_LIT> + margin ) , ( <NUM_LIT> - <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , ( <NUM_LIT> - margin * <NUM_LIT:2> ) , <NUM_LIT> , Vector3 ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> if ( sceneState . initialized ) { <EOL> if ( screenWidth <= screenHeight ) { <EOL> statsBarChartRenderer . render ( - <NUM_LIT> + margin , - <NUM_LIT> , <NUM_LIT> - margin * <NUM_LIT:2> , ( <NUM_LIT> - <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> ) , myTeam , counts , digitAspect , screenAspect ) <EOL> } else { <EOL> val width = <NUM_LIT:2> * ( screenWidth - squareSize ) / screenWidth <EOL> statsBarChartRenderer . render ( <NUM_LIT> - width , - <NUM_LIT> , width , <NUM_LIT> , myTeam , counts , digitAspect , screenAspect ) <EOL> } <EOL> } <EOL> if ( ! sceneState . initialized ) { <EOL> val startMessageRatio = <NUM_LIT> / <NUM_LIT> <EOL> if ( screenWidth <= screenHeight ) { <EOL> renderCenteredTexture ( <NUM_LIT> - <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> , <NUM_LIT> - margin * <NUM_LIT:2> , startMessageRatio , startScreenTextureId ) <EOL> if ( showCopyright ) { <EOL> renderCenteredTexture ( <NUM_LIT> - <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> , <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , konanTextureId ) <EOL> renderCenteredTexture ( <NUM_LIT> - <NUM_LIT> / <NUM_LIT:100> * <NUM_LIT> , <NUM_LIT> - margin * <NUM_LIT:2> , <NUM_LIT> / <NUM_LIT> , spinnerRepoTextureId ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Renders the entire game scene.
 *
 * @param screenWidth physical width of the screen in any units
 * @param screenHeight physical height of the screen in the same units as [screenWidth]
 */


fun getCollectedNullability ( key : DataFlowValue ) : Nullability

/**
 * Returns collected nullability for the given value, NOT taking its stability into account.
 */


fun getStableNullability ( key : DataFlowValue ) : Nullability

/**
 * Returns collected nullability for the given value if it's stable.
 * Otherwise basic value nullability is returned
 */


fun getCollectedTypes ( key : DataFlowValue , languageVersionSettings : LanguageVersionSettings ) : Set < KotlinType >

/**
 * Returns possible types for the given value, NOT taking its stability into account.
 *
 * IMPORTANT: by default, the original (native) type for this value
 * are NOT included. So it's quite possible to get an empty set here.
 * Also, type order in the result set MAKES SENSE so keep it stable and do not change without reason
 */


fun getStableTypes ( key : DataFlowValue , languageVersionSettings : LanguageVersionSettings ) : Set < KotlinType >

/**
 * Returns possible types for the given value if it's stable.
 * Otherwise, basic value type is returned.
 *
 * IMPORTANT: by default, the original (native) type for this value
 * are NOT included. So it's quite possible to get an empty set here.
 * Also, type order in the result set MAKES SENSE so keep it stable and do not change without reason
 */


fun clearValueInfo ( value : DataFlowValue , languageVersionSettings : LanguageVersionSettings ) : DataFlowInfo

/**
 * Call this function to clear all data flow information about
 * the given data flow value. Useful when we are not sure how this value can be changed, e.g. in a loop.
 */


fun assign ( a : DataFlowValue , b : DataFlowValue , languageVersionSettings : LanguageVersionSettings ) : DataFlowInfo

/**
 * Call this function when b is assigned to a
 */


fun equate ( a : DataFlowValue , b : DataFlowValue , identityEquals : Boolean , languageVersionSettings : LanguageVersionSettings ) : DataFlowInfo

/**
 * Call this function when it's known than a == b.
 */


fun disequate ( a : DataFlowValue , b : DataFlowValue , languageVersionSettings : LanguageVersionSettings ) : DataFlowInfo

/**
 * Call this function when it's known than a != b
 */


fun and ( other : DataFlowInfo ) : DataFlowInfo

/**
 * Call this function to add data flow information from other to this and return sum as the result
 */


fun or ( other : DataFlowInfo ) : DataFlowInfo

/**
 * Call this function to choose data flow information common for this and other and return it as the result
 */


@ OptIn ( ExperimentalSerializationApi :: class ) <EOL> override fun toString ( ) : String

{ <EOL> return "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> }


{ <EOL> val ( train , test ) = mnist ( ) <EOL> SavedModel . load ( PATH_TO_MODEL ) . use { <EOL> println ( it . graphToString ( ) ) <EOL> val prediction = it . predict ( train . getX ( <NUM_LIT:0> ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" + train . getY ( <NUM_LIT:0> ) ) <EOL> val predictions = it . predict ( test , SavedModel :: predict ) <EOL> println ( predictions . toString ( ) ) <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * This examples demonstrates running [SavedModel] for prediction on [mnist] dataset.
 *
 * It uses enum-based tensor names to get access to input/output tensors in TensorFlow static graph.
 */


= lenetOnMnistInference ( )


fun makeObjectFile ( bitcodeFile : File , objectFile : File )

= <EOL> when ( val configurables = platform . configurables ) { <EOL> is ClangFlags -> clang ( configurables , bitcodeFile , objectFile ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> }

/**
 * Compile [bitcodeFile] to [objectFile].
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun Timer . schedule ( delay : Long , crossinline action : TimerTask . ( ) -> Unit ) : TimerTask

{ <EOL> val task = timerTask ( action ) <EOL> schedule ( task , delay ) <EOL> return task <EOL> }

/**
 * Schedules an [action] to be executed after the specified [delay] (expressed in milliseconds).
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun Timer . schedule ( time : Date , crossinline action : TimerTask . ( ) -> Unit ) : TimerTask

{ <EOL> val task = timerTask ( action ) <EOL> schedule ( task , time ) <EOL> return task <EOL> }

/**
 * Schedules an [action] to be executed at the specified [time].
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun Timer . schedule ( delay : Long , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : TimerTask

{ <EOL> val task = timerTask ( action ) <EOL> schedule ( task , delay , period ) <EOL> return task <EOL> }

/**
 * Schedules an [action] to be executed periodically, starting after the specified [delay] (expressed
 * in milliseconds) and with the interval of [period] milliseconds between the end of the previous task
 * and the start of the next one.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun Timer . schedule ( time : Date , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : TimerTask

{ <EOL> val task = timerTask ( action ) <EOL> schedule ( task , time , period ) <EOL> return task <EOL> }

/**
 * Schedules an [action] to be executed periodically, starting at the specified [time] and with the
 * interval of [period] milliseconds between the end of the previous task and the start of the next one.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun Timer . scheduleAtFixedRate ( delay : Long , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : TimerTask

{ <EOL> val task = timerTask ( action ) <EOL> scheduleAtFixedRate ( task , delay , period ) <EOL> return task <EOL> }

/**
 * Schedules an [action] to be executed periodically, starting after the specified [delay] (expressed
 * in milliseconds) and with the interval of [period] milliseconds between the start of the previous task
 * and the start of the next one.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun Timer . scheduleAtFixedRate ( time : Date , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : TimerTask

{ <EOL> val task = timerTask ( action ) <EOL> scheduleAtFixedRate ( task , time , period ) <EOL> return task <EOL> }

/**
 * Schedules an [action] to be executed periodically, starting at the specified [time] and with the
 * interval of [period] milliseconds between the start of the previous task and the start of the next one.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun timer ( name : String ? = null , daemon : Boolean = false , initialDelay : Long = <NUM_LIT:0> . toLong ( ) , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : Timer

{ <EOL> val timer = timer ( name , daemon ) <EOL> timer . schedule ( initialDelay , period , action ) <EOL> return timer <EOL> }

/**
 * Creates a timer that executes the specified [action] periodically, starting after the specified [initialDelay]
 * (expressed in milliseconds) and with the interval of [period] milliseconds between the end of the previous task
 * and the start of the next one.
 *
 * @param name the name to use for the thread which is running the timer.
 * @param daemon if `true`, the thread is started as a daemon thread (the VM will exit when only daemon threads are running).
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun timer ( name : String ? = null , daemon : Boolean = false , startAt : Date , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : Timer

{ <EOL> val timer = timer ( name , daemon ) <EOL> timer . schedule ( startAt , period , action ) <EOL> return timer <EOL> }

/**
 * Creates a timer that executes the specified [action] periodically, starting at the specified [startAt] date
 * and with the interval of [period] milliseconds between the end of the previous task and the start of the next one.
 *
 * @param name the name to use for the thread which is running the timer.
 * @param daemon if `true`, the thread is started as a daemon thread (the VM will exit when only daemon threads are running).
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun fixedRateTimer ( name : String ? = null , daemon : Boolean = false , initialDelay : Long = <NUM_LIT:0> . toLong ( ) , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : Timer

{ <EOL> val timer = timer ( name , daemon ) <EOL> timer . scheduleAtFixedRate ( initialDelay , period , action ) <EOL> return timer <EOL> }

/**
 * Creates a timer that executes the specified [action] periodically, starting after the specified [initialDelay]
 * (expressed in milliseconds) and with the interval of [period] milliseconds between the start of the previous task
 * and the start of the next one.
 *
 * @param name the name to use for the thread which is running the timer.
 * @param daemon if `true`, the thread is started as a daemon thread (the VM will exit when only daemon threads are running).
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun fixedRateTimer ( name : String ? = null , daemon : Boolean = false , startAt : Date , period : Long , crossinline action : TimerTask . ( ) -> Unit ) : Timer

{ <EOL> val timer = timer ( name , daemon ) <EOL> timer . scheduleAtFixedRate ( startAt , period , action ) <EOL> return timer <EOL> }

/**
 * Creates a timer that executes the specified [action] periodically, starting at the specified [startAt] date
 * and with the interval of [period] milliseconds between the start of the previous task and the start of the next one.
 *
 * @param name the name to use for the thread which is running the timer.
 * @param daemon if `true`, the thread is started as a daemon thread (the VM will exit when only daemon threads are running).
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun timerTask ( crossinline action : TimerTask . ( ) -> Unit ) : TimerTask

= object : TimerTask ( ) { <EOL> override fun run ( ) = action ( ) <EOL> }

/**
 * Wraps the specified [action] in a [TimerTask].
 */


{ <EOL> val context : MutableMap < Value , Int > = mutableMapOf ( ) <EOL> var uniqueNumber = <NUM_LIT:0> <EOL> fun mapValues ( scheme : LazyScheme ) { <EOL> val target = scheme . target <EOL> if ( target . token == null ) { <EOL> val value = target . value <EOL> val index = context [ value ] <EOL> if ( index == - <NUM_LIT:1> ) { <EOL> context [ value ] = uniqueNumber ++ <EOL> } else if ( index == null ) { <EOL> context [ value ] = - <NUM_LIT:1> <EOL> } <EOL> } <EOL> scheme . parameters . forEach { mapValues ( it ) } <EOL> scheme . result ? . let { mapValues ( it ) } <EOL> } <EOL> fun itemOf ( binding : Binding ) = binding . token ? . let { Token ( it ) } <EOL> ? : context [ binding . value ] ? . let { Open ( it ) } ? : Open ( - <NUM_LIT:1> ) <EOL> fun schemeOf ( lazyScheme : LazyScheme ) : Scheme = Scheme ( itemOf ( lazyScheme . target ) , lazyScheme . parameters . map { schemeOf ( it ) } , lazyScheme . result ? . let { schemeOf ( it ) } , lazyScheme . anyParameters ) <EOL> mapValues ( this ) <EOL> return schemeOf ( this ) <EOL> }

/**
 * Create a [Scheme] from the current state of this.
 */


= CallBindings ( target , parameters . map { it . toCallBindings ( ) } , result = result ? . toCallBindings ( ) , anyParameters )

/**
 * Create a call binding for use when validating a call to the function this lazy scheme is for.
 */


fun onChange ( callback : ( ) -> Unit ) : ( ) -> Unit

{ <EOL> var previousScheme = toScheme ( ) <EOL> return bindings . onChange { <EOL> val newScheme = toScheme ( ) <EOL> if ( newScheme != previousScheme ) { <EOL> callback ( ) <EOL> previousScheme = newScheme <EOL> } <EOL> } <EOL> }

/**
 * Call [callback] whenever the lazy changes.
 */


fun isExternal ( declaration : IrDeclaration ) : Boolean

{ <EOL> return ! generationState . llvmModuleSpecification . containsDeclaration ( declaration ) <EOL> }

/**
 * TODO: maybe it'd be better to replace with [IrDeclaration::isEffectivelyExternal()],
 * or just drop all [else] branches of corresponding conditionals.
 */


internal fun stringAsBytes ( str : String )

= str . toByteArray ( Charsets . UTF_8 )

/**
 * Converts this string to the sequence of bytes to be used for hashing/storing to binary/etc.
 */


private fun parseValueWithFlags ( str : String ) : ValueWithFlags

{ <EOL> val parts = str . split ( "<STR_LIT:[>" , limit = <NUM_LIT:2> ) <EOL> return if ( parts . size > <NUM_LIT:1> ) { <EOL> val ( value , flags ) = parts <EOL> ValueWithFlags ( value = value . trim ( ) , flags = flags . trim ( ) . removeSuffix ( "<STR_LIT:]>" ) . split ( "<STR_LIT:U+002C>" ) . map { it . trim ( ) } . filter { it . isNotEmpty ( ) } . toSet ( ) ) <EOL> } else ValueWithFlags ( str ) <EOL> }


internal fun splitFunctionsAndInheritedAccessors ( properties : List < PropertyDescriptor > , functions : List < FunctionDescriptor > ) : DescriptorFunctionsHolder

{ <EOL> val ( javaMethods , kotlinFunctions ) = functions . partition { it is JavaMethodDescriptor } <EOL> if ( javaMethods . isEmpty ( ) ) { <EOL> return DescriptorFunctionsHolder ( regularFunctions = kotlinFunctions , emptyMap ( ) ) <EOL> } <EOL> val propertiesByName = properties . associateBy { it . name . asString ( ) } <EOL> val regularFunctions = ArrayList < FunctionDescriptor > ( kotlinFunctions ) <EOL> val accessors = mutableMapOf < PropertyDescriptor , DescriptorAccessorHolder > ( ) <EOL> javaMethods . forEach { function -> <EOL> val possiblePropertyNamesForFunction = function . toPossiblePropertyNames ( ) <EOL> val property = possiblePropertyNamesForFunction . firstNotNullOfOrNull { propertiesByName [ it ] } <EOL> if ( property != null && function . isAccessorFor ( property ) ) { <EOL> accessors . compute ( property ) { prop , accessorHolder -> <EOL> if ( function . isGetterFor ( prop ) ) <EOL> accessorHolder ? . copy ( getter = function ) ? : DescriptorAccessorHolder ( getter = function ) <EOL> else <EOL> accessorHolder ? . copy ( setter = function ) ? : DescriptorAccessorHolder ( setter = function ) <EOL> } <EOL> } else { <EOL> regularFunctions . add ( function ) <EOL> } <EOL> } <EOL> val accessorLookalikes = removeNonAccessorsReturning ( accessors ) <EOL> regularFunctions . addAll ( accessorLookalikes ) <EOL> return DescriptorFunctionsHolder ( regularFunctions , accessors ) <EOL> }

/**
 * Separate regular Kotlin/Java functions and inherited Java accessors
 * to properly display properties inherited from Java.
 *
 * Take this example:
 * ```
 * // java
 * public class JavaClass {
 * private int a = 1;
 * public int getA() { return a; }
 * public void setA(int a) { this.a = a; }
 * }
 *
 * // kotlin
 * class Bar : JavaClass() {
 * fun foo() {}
 * }
 * ```
 *
 * It should result in:
 * - 1 regular function `foo`
 * - Map a=[`getA`, `setA`]
 */


private fun removeNonAccessorsReturning ( propertyAccessors : MutableMap < PropertyDescriptor , DescriptorAccessorHolder > ) : List < FunctionDescriptor >

{ <EOL> val nonAccessors = mutableListOf < FunctionDescriptor > ( ) <EOL> propertyAccessors . entries . removeIf { ( _ , accessors ) -> <EOL> if ( accessors . getter == null && accessors . setter != null ) { <EOL> nonAccessors . add ( accessors . setter ) <EOL> true <EOL> } else { <EOL> false <EOL> } <EOL> } <EOL> return nonAccessors <EOL> }

/**
 * If a field has no getter, it's not accessible as a property from Kotlin's perspective,
 * but it still might have a setter lookalike. In this case, this "setter" should be just a regular function
 *
 * @return removed elements
 */


@ kotlin . internal . InlineOnly <EOL> public actual inline fun Double . isNaN ( ) : Boolean

= java . lang . Double . isNaN ( this )

/**
 * Returns `true` if the specified number is a
 * Not-a-Number (NaN) value, `false` otherwise.
 */


@ kotlin . internal . InlineOnly <EOL> public actual inline fun Float . isNaN ( ) : Boolean

= java . lang . Float . isNaN ( this )


@ kotlin . internal . InlineOnly <EOL> public actual inline fun Double . isInfinite ( ) : Boolean

= java . lang . Double . isInfinite ( this )

/**
 * Returns `true` if this value is infinitely large in magnitude.
 */


@ kotlin . internal . InlineOnly <EOL> public actual inline fun Float . isInfinite ( ) : Boolean

= java . lang . Float . isInfinite ( this )


@ kotlin . internal . InlineOnly <EOL> public actual inline fun Double . isFinite ( ) : Boolean

= ! isInfinite ( ) && ! isNaN ( )

/**
 * Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments).
 */


@ kotlin . internal . InlineOnly <EOL> public actual inline fun Float . isFinite ( ) : Boolean

= ! isInfinite ( ) && ! isNaN ( )


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Double . toBits ( ) : Long

= java . lang . Double . doubleToLongBits ( this )

/**
 * Returns a bit representation of the specified floating-point value as [Long]
 * according to the IEEE 754 floating-point "double format" bit layout.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Double . toRawBits ( ) : Long

= java . lang . Double . doubleToRawLongBits ( this )

/**
 * Returns a bit representation of the specified floating-point value as [Long]
 * according to the IEEE 754 floating-point "double format" bit layout,
 * preserving `NaN` values exact layout.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Double . Companion . fromBits ( bits : Long ) : Double

= java . lang . Double . longBitsToDouble ( bits )

/**
 * Returns the [Double] value corresponding to a given bit representation.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun Float . toBits ( ) : Int

= java . lang . Float . floatToIntBits ( this )

/**
 * Returns a bit representation of the specified floating-point value as [Int]
 * according to the IEEE 754 floating-point "single format" bit layout.
 */