private fun report ( diagnostic : Diagnostic , ctxt : VariableContext )

{ <EOL> val instruction = ctxt . instruction <EOL> if ( instruction . copies . isEmpty ( ) ) { <EOL> trace . report ( diagnostic ) <EOL> return <EOL> } <EOL> val previouslyReported = ctxt . reportedDiagnosticMap <EOL> previouslyReported [ instruction ] = diagnostic . factory <EOL> var alreadyReported = false <EOL> var sameErrorForAllCopies = true <EOL> for ( copy in instruction . copies ) { <EOL> val previouslyReportedErrorFactory = previouslyReported [ copy ] <EOL> if ( previouslyReportedErrorFactory != null ) { <EOL> alreadyReported = true <EOL> } <EOL> if ( previouslyReportedErrorFactory !== diagnostic . factory ) { <EOL> sameErrorForAllCopies = false <EOL> } <EOL> } <EOL> if ( mustBeReportedOnAllCopies ( diagnostic . factory ) ) { <EOL> if ( sameErrorForAllCopies ) { <EOL> trace . report ( diagnostic ) <EOL> } <EOL> } else { <EOL> if ( ! alreadyReported ) { <EOL> trace . report ( diagnostic ) <EOL> } <EOL> } <EOL> }

/**
 * The method provides reporting of the same diagnostic only once for copied instructions
 * (depends on whether it should be reported for all or only for one of the copies)
 */


@ OptIn ( SymbolInternals :: class ) <EOL> fun FirPropertySymbol . requiresInitialization ( isForInitialization : Boolean ) : Boolean

{ <EOL> val hasImplicitBackingField = ! hasExplicitBackingField && hasBackingField <EOL> return when { <EOL> this is FirSyntheticPropertySymbol -> false <EOL> isForInitialization -> hasDelegate || hasImplicitBackingField <EOL> else -> ! hasInitializer && hasImplicitBackingField && fir . isCatchParameter != true <EOL> } <EOL> }

/**
 * [isForInitialization] means that caller is interested in member property in the scope
 * of file or class initialization section. In this case the fact that property has
 * initializer does not mean that it's safe to access this property in any place:
 *
 * ```
 * class A {
 * val b = a // a is not initialized here
 * val a = 10
 * val c = a // but initialized here
 * }
 * ```
 */


private fun ControlFlowGraph . isInline ( until : FirBasedSymbol < * > ? ) : Boolean

{ <EOL> val declaration = declaration <EOL> if ( declaration ? . symbol == until ) return true <EOL> if ( declaration ? . evaluatedInline != true ) return false <EOL> return enterNode . previousNodes . all { it . owner . isInline ( until ) } <EOL> }

/**
 * Checks that [ControlFlowGraph.declaration] is [evaluatedInline], and also recursively check all
 * parent [ControlFlowGraph]s.
 *
 * @param until will stop recursion if [ControlFlowGraph.declaration] matches the specified symbol.
 * This is used to stop recursion when there are nested declarations (like a local class), and we
 * only need to check until that nested declaration.
 */


public abstract fun doesPackageExist ( packageFqName : FqName , platform : TargetPlatform ) : Boolean

/**
 * Checks if a package with given [FqName] exists in current [GlobalSearchScope] with a view from a given [platform].
 *
 * This includes Kotlin packages as well as platform-specific (i.e., JVM packages) that match the [platform].
 * Generally, the result is equal to [doesKotlinOnlyPackageExist] || [doesPlatformSpecificPackageExist].
 */


public abstract fun doesKotlinOnlyPackageExist ( packageFqName : FqName ) : Boolean

/**
 * Checks if a package with a given [FqName] exists in the current [GlobalSearchScope].
 *
 * The package should contain Kotlin declarations inside.
 *
 * Note that for Kotlin, a package doesn't need to correspond to a directory structure like in Java.
 * So, a package [FqName] is determined by a Kotlin file package directive.
 */


public abstract fun doesPlatformSpecificPackageExist ( packageFqName : FqName , platform : TargetPlatform ) : Boolean

/**
 * Checks if a platform-specific (e.g., Java packages for Kotlin/JVM) package with [FqName] exists in the current [GlobalSearchScope].
 */


public abstract fun getSubPackageFqNames ( packageFqName : FqName , platform : TargetPlatform , nameFilter : ( Name ) -> Boolean ) : Set < Name >

/**
 * Returns the list of subpackages for a given package, which satisfies [nameFilter].
 *
 * The returned sub-package list contains sub-packages visible to Kotlin. (e.g., for Kotlin/JVM, it should include Java packages)
 *
 * Generally, the result is equal to [getKotlinOnlySubPackagesFqNames] union with [getPlatformSpecificSubPackagesFqNames]
 */


public abstract fun getKotlinOnlySubPackagesFqNames ( packageFqName : FqName , nameFilter : ( Name ) -> Boolean ) : Set < Name >

/**
 * Returns the list of subpackages for a given package, which satisfies [nameFilter].
 *
 * The returned sub-package list contains all packages with some Kotlin declarations inside.
 */


public abstract fun getPlatformSpecificSubPackagesFqNames ( packageFqName : FqName , platform : TargetPlatform , nameFilter : ( Name ) -> Boolean ) : Set < Name >

/**
 * Returns the platform-specific (e.g., Java packages for Kotlin/JVM) list of subpackages for a given package, which satisfies [nameFilter].
 *
 * The returned sub-package list contains sub-packages visible to Kotlin. (e.g., for Kotlin/JVM, it should include Java packages)
 */


protected open fun backendSpecificFileFilter ( file : IrFile ) : Boolean

= <EOL> true

/**
 * Allows to skip [file] during serialization.
 *
 * For example, some files should be generated anew instead of deserialization.
 */


public inline fun < reified T > body ( ) : T

= runBlocking { ktorResponse . body ( ) }

/**
 * Tries to receive the payload of the response as a specific type [T].
 *
 * @throws NoTransformationFoundException If no transformation is found for the type [T].
 * @throws DoubleReceiveException If already called [body].
 */


public fun < T > body ( typeInfo : TypeInfo ) : T

= runBlocking { ktorResponse . body ( typeInfo ) }

/**
 * Tries to receive the payload of the response as a specific type [T] described in [typeInfo].
 *
 * @throws NoTransformationFoundException If no transformation is found for the type info [typeInfo].
 * @throws DoubleReceiveException If already called [body].
 */


public fun bodyAsText ( fallbackCharset : Charset = Charsets . UTF_8 ) : String

= <EOL> runBlocking { ktorResponse . bodyAsText ( fallbackCharset ) }

/**
 * Reads the [HttpResponse.content] as a String. You can pass an optional [fallbackCharset]
 * to specify a charset in the case no one is specified as part of the `Content-Type` response.
 * If no charset specified either as parameter or as part of the response,
 * [io.ktor.client.plugins.HttpPlainText] settings will be used.
 *
 * Note that [fallbackCharset] parameter will be ignored if the response already has a charset.
 * So it just acts as a fallback, honoring the server preference.
 */


= runBlocking { ktorResponse . readBytes ( ) }

/**
 * Reads the whole [HttpResponse.content] if `Content-Length` is specified.
 * Otherwise, it just reads one byte.
 */


public fun readBytes ( count : Int ) : ByteArray

= runBlocking { ktorResponse . readBytes ( count ) }

/**
 * Reads exactly [count] bytes of the [HttpResponse.content].
 */


fun renderValue ( host : ExecutionHost , value : Any ? , ) : Any ?

/**
 * Renders [value] in context of this execution [host]
 */


fun registerWithoutOptimizing ( renderer : RendererFieldHandler )

/**
 * Adds new [renderer] for this notebook.
 * Don't turn on the optimizations for [PrecompiledRendererTypeHandler]
 */


internal fun CallableMemberDescriptor . mustNotBeWrittenToDecompiledText ( ) : Boolean

{ <EOL> return when ( kind ) { <EOL> CallableMemberDescriptor . Kind . DECLARATION , CallableMemberDescriptor . Kind . DELEGATION -> false <EOL> CallableMemberDescriptor . Kind . FAKE_OVERRIDE -> true <EOL> CallableMemberDescriptor . Kind . SYNTHESIZED -> syntheticMemberMustNotBeWrittenToDecompiledText ( ) <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.analysis.decompiler.stub.mustNotBeWrittenToStubs
 */


public fun < DomainType : Comparable < DomainType > > continuousColorViridis ( colormap : ViridisColormap = ViridisColormap . VIRIDIS , hueRange : ClosedRange < Double > = <NUM_LIT:0.0> .. <NUM_LIT:1.0> , direction : WheelDirection = WheelDirection . CLOCKWISE , domain : ClosedRange < DomainType > , nullValue : Color ? = null , transform : Transformation ? = null ) : ScaleContinuousColorViridis < DomainType >

= ScaleContinuousColorViridis ( domain . let { <EOL> listOf ( it . start , it . endInclusive ) <EOL> } , colormap , hueRange , direction , nullValue , transform )

/**
 * Creates color scale with viridis color maps, designed to be perceptually-uniform,
 * both in regular form and also when converted to black-and-white.
 *
 * @param colormap [ViridisColormap] colormap
 * @param DomainType scale domain type.
 * @param hueRange [ClosedRange] of color hue, in [0, 1]
 * @param direction colormap direction
 * @param domain [ClosedRange] defining the scale domain.
 * @param nullValue value which null is mapped to.
 * @param transform the transformation of scale.
 *
 * @return new continuous color scale.
 */


public fun < DomainType > continuousColorViridis ( colormap : ViridisColormap = ViridisColormap . VIRIDIS , hueRange : ClosedRange < Double > = <NUM_LIT:0.0> .. <NUM_LIT:1.0> , direction : WheelDirection = WheelDirection . CLOCKWISE , domainMin : DomainType ? = null , domainMax : DomainType ? = null , nullValue : Color ? = null , transform : Transformation ? = null ) : ScaleContinuousColorViridis < DomainType >

= ScaleContinuousColorViridis ( listOf ( domainMin , domainMax ) , colormap , hueRange , direction , nullValue , transform )

/**
 * Color scale with viridis color maps, designed to be perceptually-uniform,
 * both in regular form and also when converted to black-and-white.
 *
 * @param colormap [ViridisColormap] colormap
 * @param DomainType scale domain type.
 * @param hueRange [ClosedRange] of color hue, in [0, 1]
 * @param direction colormap direction
 * @param domainMin scale domain minimum.
 * @param domainMax scale domain maximum.
 * @param nullValue value which null is mapped to.
 * @param transform scale transformation.
 *
 * @return new continuous color scale.
 */


public fun < DomainType > categoricalColorViridis ( colormap : ViridisColormap = ViridisColormap . VIRIDIS , hueRange : ClosedRange < Double > = <NUM_LIT:0.0> .. <NUM_LIT:1.0> , direction : WheelDirection = WheelDirection . CLOCKWISE , domain : List < DomainType > ? = null , ) : ScaleCategoricalColorViridis < DomainType >

= ScaleCategoricalColorViridis ( domain , colormap , hueRange , direction )

/**
 * Color scale with viridis color maps, designed to be perceptually-uniform,
 * both in regular form and also when converted to black-and-white.
 *
 * @param colormap [ViridisColormap] colormap
 * @param DomainType scale domain type.
 * @param hueRange [ClosedRange] of color hue, in [0, 1]
 * @param direction colormap direction @param DomainType scale domain type.
 * @param domain [List] defining the scale domain.
 *
 * @return new categorical color scale.
 */


fun captureFromTypeParameterUpperBoundIfNeeded ( argumentType : UnwrappedType , expectedType : UnwrappedType ) : UnwrappedType

{ <EOL> val expectedTypeConstructor = expectedType . upperIfFlexible ( ) . constructor <EOL> if ( argumentType . lowerIfFlexible ( ) . constructor . declarationDescriptor is TypeParameterDescriptor ) { <EOL> val chosenSupertype = argumentType . lowerIfFlexible ( ) . supertypes ( ) . singleOrNull { <EOL> it . constructor . declarationDescriptor is ClassifierDescriptorWithTypeParameters && <EOL> it . unwrap ( ) . hasSupertypeWithGivenTypeConstructor ( expectedTypeConstructor ) <EOL> } <EOL> if ( chosenSupertype != null ) { <EOL> val capturedType = captureFromExpression ( chosenSupertype . unwrap ( ) ) <EOL> return if ( capturedType != null && argumentType . isDefinitelyNotNullType ) <EOL> capturedType . makeDefinitelyNotNullOrNotNull ( ) <EOL> else <EOL> capturedType ? : argumentType <EOL> } <EOL> } <EOL> return argumentType <EOL> }

/**
 * interface Inv<T>
 * fun <Y> bar(l: Inv<Y>): Y = ...
 *
 * fun <X : Inv<out Int>> foo(x: X) {
 * val xr = bar(x)
 * }
 * Here we try to capture from upper bound from type parameter.
 * We replace type of `x` to `Inv<out Int>`(we chose supertype which contains supertype with expectedTypeConstructor) and capture from this type.
 * It is correct, because it is like this code:
 * fun <X : Inv<out Int>> foo(x: X) {
 * val inv: Inv<out Int> = x
 * val xr = bar(inv)
 * }
 *
 */


private fun Project . appleFrameworkDir ( frameworkTaskName : String ) : Provider < File >

{ <EOL> return if ( project . kotlinPropertiesProvider . appleCopyFrameworkToBuiltProductsDir ) { <EOL> project . provider { XcodeEnvironment . builtProductsDir ? : fireEnvException ( frameworkTaskName ) } <EOL> } else { <EOL> layout . buildDirectory . dir ( "<STR_LIT>" ) . map { <EOL> it . asFile . resolve ( XcodeEnvironment . frameworkSearchDir ? : fireEnvException ( frameworkTaskName ) ) <EOL> } <EOL> } <EOL> }

/**
 * [XcodeEnvironment.builtProductsDir] if not disabled.
 *
 * Or if [XcodeEnvironment.frameworkSearchDir] is absolute use it, otherwise make it relative to buildDir/xcode-frameworks
 */


@ ExperimentalSerializationApi <EOL> public fun generateSchemaText ( rootDescriptor : SerialDescriptor , packageName : String ? = null , options : Map < String , String > = emptyMap ( ) ) : String

= generateSchemaText ( listOf ( rootDescriptor ) , packageName , options )

/**
 * Generate text of protocol buffers schema version 2 for the given [rootDescriptor].
 * The resulting schema will contain all types referred by [rootDescriptor].
 *
 * [packageName] define common protobuf package for all messages and enum in the schema, it may contain `'a'`..`'z'`
 * letters in upper and lower case, decimal digits, `'.'` or `'_'` chars, but must be started only by a letter and
 * not finished by a dot.
 *
 * [options] define values for protobuf options. Option value (map value) is an any string, option name (map key)
 * should be the same format as [packageName].
 *
 * The method throws [IllegalArgumentException] if any of the restrictions imposed by [ProtoBufSchemaGenerator] is violated.
 */


@ ExperimentalSerializationApi <EOL> public fun generateSchemaText ( descriptors : List < SerialDescriptor > , packageName : String ? = null , options : Map < String , String > = emptyMap ( ) ) : String

{ <EOL> packageName ? . let { p -> p . checkIsValidFullIdentifier { "<STR_LIT>" } } <EOL> checkDoubles ( descriptors ) <EOL> val builder = StringBuilder ( ) <EOL> builder . generateProto2SchemaText ( descriptors , packageName , options ) <EOL> return builder . toString ( ) <EOL> }

/**
 * Generate text of protocol buffers schema version 2 for the given serializable [descriptors].
 * [packageName] define common protobuf package for all messages and enum in the schema, it may contain `'a'`..`'z'`
 * letters in upper and lower case, decimal digits, `'.'` or `'_'` chars, but started only from a letter and
 * not finished by dot.
 *
 * [options] define values for protobuf options. Option value (map value) is an any string, option name (map key)
 * should be the same format as [packageName].
 *
 * The method throws [IllegalArgumentException] if any of the restrictions imposed by [ProtoBufSchemaGenerator] is violated.
 */


fun dirtySetTouchesNonLeafFragments ( dirtySet : Iterable < File > ) : Boolean

{ <EOL> return dirtySet . any { file -> <EOL> ! leafFragments . contains ( fileToFragment [ file . absolutePath ] ) <EOL> } <EOL> }

/**
 * Returns true, if any file from dirtySet is a part of refined fragment (for example: common, apple, linux).
 * It is relevant to KT-62686, because in k2 "refined" fragments aren't supposed to see symbols from "refining" fragments,
 * but they do.
 *
 * Use of `absolutePath` is coordinated with K2MultiplatformStructure.fragmentSourcesCompilerArgs
 */


{ <EOL> val ( _ , 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> println ( it . kGraph ) <EOL> val accuracy = it . evaluate ( dataset = test , batchSize = <NUM_LIT> ) . metrics [ Metrics . ACCURACY ] <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/** Just loading ToyResNet trained in Keras. */


internal fun getKotlinJvmStdlibJarPath ( ) : String

{ <EOL> return lazyKotlinJvmStdlibJar <EOL> }

/**
 * Returns an absolute path to the JAR file of Kotlin's standard library for the JVM platform.
 *
 * Example: `~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.10/xx/kotlin-stdlib-1.9.10.jar`
 */


override fun isAccessorWithExplicitImplementation ( accessor : IrSimpleFunction ) : Boolean

{ <EOL> if ( accessor is AbstractFir2IrLazyDeclaration < * > ) { <EOL> val fir = accessor . fir <EOL> if ( fir is FirFunction && fir . hasBody ) { <EOL> return true <EOL> } <EOL> } <EOL> return false <EOL> }

/**
 * This method is used from [org.jetbrains.kotlin.backend.jvm.lower.ReflectiveAccessLowering.visitCall]
 * (via generateReflectiveAccessForGetter) and it is called for the private access member lowered to the getter/setter call.
 * If a private property has no getter/setter (the typical situation for simple private properties without explicitly defined
 * getter/setter) then this method is not used at all. Instead
 * [org.jetbrains.kotlin.backend.jvm.lower.ReflectiveAccessLowering.visitGetField] (or visitSetField) generates the access without
 * asking.
 */


private fun ConeTypeProjection . removeOutProjection ( isCovariant : Boolean ) : ConeTypeProjection

{ <EOL> return when ( this ) { <EOL> is ConeKotlinTypeProjectionOut -> if ( isCovariant ) type else this <EOL> is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn ( type . removeOutProjection ( ! isCovariant ) ) <EOL> is ConeStarProjection -> if ( isCovariant ) StandardTypes . NullableAny else this <EOL> is ConeKotlinTypeConflictingProjection , <EOL> is ConeKotlinType -> this <EOL> } <EOL> }

/**
 * @param isCovariant true if the current context is covariant and false if contravariant.
 *
 * This function only remove out projections in covariant context.
 * 'in' projections are never removed, nor would an out projection in a contravariant context.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MultiArray < T , D > . unaryMinus ( ) : NDArray < T , D >

= <EOL> when ( dtype ) { <EOL> DataType . DoubleDataType -> ( this as NDArray < Double , D > ) . map { - it } <EOL> DataType . FloatDataType -> ( this as NDArray < Float , D > ) . map { - it } <EOL> DataType . IntDataType -> ( this as NDArray < Int , D > ) . map { - it } <EOL> DataType . LongDataType -> ( this as NDArray < Long , D > ) . map { - it } <EOL> DataType . ComplexFloatDataType -> ( this as NDArray < ComplexFloat , D > ) . map { - it } <EOL> DataType . ComplexDoubleDataType -> ( this as NDArray < ComplexDouble , D > ) . map { - it } <EOL> DataType . ShortDataType -> ( this as NDArray < Short , D > ) . map { - it } <EOL> DataType . ByteDataType -> ( this as NDArray < Byte , D > ) . map { - it } <EOL> } as NDArray < T , D >

/**
 * Returns a new NDArray object with all elements negated for the given MultiArray object.
 *
 * @return The NDArray object with all elements negated.
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . plus ( other : MultiArray < T , D > ) : NDArray < T , D >

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret += other <EOL> return ret <EOL> }

/**
 * Calculates the sum of [this] MultiArray and [other] MultiArray, resulting in a new NDArray with the same
 * Dimension type as the input arrays.
 *
 * @param other MultiArray to be added to [this] MultiArray
 * @return NDArray<T, D>, the sum of [this] MultiArray and [other] MultiArray
 * @throws IllegalArgumentException if the shape of [this] and [other] [MultiArray] are not equal.
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . plus ( other : T ) : NDArray < T , D >

{ <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret += other <EOL> return ret <EOL> }

/**
 * Returns a new NDArray with the elements of this MultiArray added with the given element value
 *
 * @param other the element to be added. Must be of the same type as the elements in MultiArray
 * @return a new NDArray object with the same dimensions as this MultiArray but with passed element added to each element
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . plusAssign ( other : MultiArray < T , D > )

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> if ( this . consistent && other . consistent ) { <EOL> this . data += ( other . data as MemoryView ) <EOL> } else { <EOL> when ( dtype ) { <EOL> DataType . DoubleDataType -> ( this as NDArray < Double , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Double > ) { a , b -> a + b } <EOL> DataType . FloatDataType -> ( this as NDArray < Float , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Float > ) { a , b -> a + b } <EOL> DataType . IntDataType -> ( this as NDArray < Int , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Int > ) { a , b -> a + b } <EOL> DataType . LongDataType -> ( this as NDArray < Long , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Long > ) { a , b -> a + b } <EOL> DataType . ComplexFloatDataType -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexFloat > ) { a , b -> a + b } <EOL> DataType . ComplexDoubleDataType -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexDouble > ) { a , b -> a + b } <EOL> DataType . ShortDataType -> ( this as NDArray < Short , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Short > ) { a , b -> ( a + b ) . toShort ( ) } <EOL> DataType . ByteDataType -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Byte > ) { a , b -> ( a + b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Adds the elements of [other] to [this] MultiArray instance and returns this instance.
 * This is an in-place operation.
 *
 * @param other the MultiArray instance to add
 * @throws IllegalArgumentException if the shapes of both arrays are not equal
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . plusAssign ( other : T )

{ <EOL> if ( this . consistent ) { <EOL> this . data += other <EOL> } else { <EOL> when ( other ) { <EOL> is Double -> ( this as NDArray < Double , D > ) . commonAssignOp ( other ) { a , b -> a + b } <EOL> is Float -> ( this as NDArray < Float , D > ) . commonAssignOp ( other ) { a , b -> a + b } <EOL> is Int -> ( this as NDArray < Int , D > ) . commonAssignOp ( other ) { a , b -> a + b } <EOL> is Long -> ( this as NDArray < Long , D > ) . commonAssignOp ( other ) { a , b -> a + b } <EOL> is ComplexFloat -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other ) { a , b -> a + b } <EOL> is ComplexDouble -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other ) { a , b -> a + b } <EOL> is Short -> ( this as NDArray < Short , D > ) . commonAssignOp ( other ) { a , b -> ( a + b ) . toShort ( ) } <EOL> is Byte -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other ) { a , b -> ( a + b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Adds an element [other] element-wise to the current [MutableMultiArray], modifying it in-place.
 *
 * @param other The element to be added to the [MutableMultiArray].
 * @throws ClassCastException If [other] is not one of the following types: Double, Float,
 * Int, Long, ComplexFloat, ComplexDouble, Short, or Byte.
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . minus ( other : MultiArray < T , D > ) : NDArray < T , D >

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret -= other <EOL> return ret <EOL> }

/**
 * Calculates the difference of [this] MultiArray and [other] MultiArray, resulting in a new NDArray with the same
 * Dimension type as the input arrays.
 *
 * @param other MultiArray to be subtracted from [this] [MultiArray].
 * @return Returns a new [NDArray] object which is the difference between [this] and [other] [MultiArray].
 * @throws IllegalArgumentException if the shape of [this] and [other] [MultiArray] are not equal.
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . minus ( other : T ) : NDArray < T , D >

{ <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret -= other <EOL> return ret <EOL> }

/**
 * Returns a new NDArray resulting from the subtraction of the given value from all the elements of the MultiArray.
 *
 * @param other the value to subtract from the elements of the MultiArray
 * @return a new NDArray representing the result of the subtraction
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . minusAssign ( other : MultiArray < T , D > )

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> if ( this . consistent && other . consistent ) { <EOL> this . data -= ( other . data as MemoryView ) <EOL> } else { <EOL> when ( dtype ) { <EOL> DataType . DoubleDataType -> ( this as NDArray < Double , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Double > ) { a , b -> a - b } <EOL> DataType . FloatDataType -> ( this as NDArray < Float , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Float > ) { a , b -> a - b } <EOL> DataType . IntDataType -> ( this as NDArray < Int , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Int > ) { a , b -> a - b } <EOL> DataType . LongDataType -> ( this as NDArray < Long , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Long > ) { a , b -> a - b } <EOL> DataType . ComplexFloatDataType -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexFloat > ) { a , b -> a - b } <EOL> DataType . ComplexDoubleDataType -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexDouble > ) { a , b -> a - b } <EOL> DataType . ShortDataType -> ( this as NDArray < Short , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Short > ) { a , b -> ( a - b ) . toShort ( ) } <EOL> DataType . ByteDataType -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Byte > ) { a , b -> ( a - b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Subtract [other] from [this] element-wise in place.
 *
 * * If both the arrays have the same shape, this method performs an in-place subtract operation and assigns the
 * * result to this [MutableMultiArray].
 * * Otherwise, it performs element-wise subtraction of this array and [other] array,
 * * and assigns the result to this [MutableMultiArray].
 *
 * @param other The array to subtract from this.
 * @throws IllegalArgumentException If the shapes of [this] and [other] are not equal.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . minusAssign ( other : T )

{ <EOL> if ( this . consistent ) { <EOL> this . data -= other <EOL> } else { <EOL> when ( other ) { <EOL> is Double -> ( this as NDArray < Double , D > ) . commonAssignOp ( other ) { a , b -> a - b } <EOL> is Float -> ( this as NDArray < Float , D > ) . commonAssignOp ( other ) { a , b -> a - b } <EOL> is Int -> ( this as NDArray < Int , D > ) . commonAssignOp ( other ) { a , b -> a - b } <EOL> is Long -> ( this as NDArray < Long , D > ) . commonAssignOp ( other ) { a , b -> a - b } <EOL> is ComplexFloat -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other ) { a , b -> a - b } <EOL> is ComplexDouble -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other ) { a , b -> a - b } <EOL> is Short -> ( this as NDArray < Short , D > ) . commonAssignOp ( other ) { a , b -> ( a - b ) . toShort ( ) } <EOL> is Byte -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other ) { a , b -> ( a - b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Subtract [other] element-wise from the current array. This is an inplace operator.
 *
 * @param other The element to subtract from the current array.
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . times ( other : MultiArray < T , D > ) : NDArray < T , D >

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret *= other <EOL> return ret <EOL> }

/**
 * Multiplies this [MultiArray] with [other] [MultiArray] element-wise to produce a new [NDArray].
 *
 * @param other the [MultiArray] to be multiplied with [this]
 * @return an [NDArray] formed by the element-wise multiplication of [this] and [other] [MultiArray]
 * @throws IllegalArgumentException in case the shapes of [this] and [other] [MultiArray] do not match.
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . times ( other : T ) : NDArray < T , D >

{ <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret *= other <EOL> return ret <EOL> }

/**
 * Performs multiplication operation between MultiArray and scalar value.
 * @param other The scalar value of type T to be multiplied.
 * @return NDArray object of type T and dimension D after performing multiplication operation.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . timesAssign ( other : MultiArray < T , D > )

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> if ( this . consistent && other . consistent ) { <EOL> this . data *= ( other . data as MemoryView ) <EOL> } else { <EOL> when ( dtype ) { <EOL> DataType . DoubleDataType -> ( this as NDArray < Double , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Double > ) { a , b -> a * b } <EOL> DataType . FloatDataType -> ( this as NDArray < Float , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Float > ) { a , b -> a * b } <EOL> DataType . IntDataType -> ( this as NDArray < Int , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Int > ) { a , b -> a * b } <EOL> DataType . LongDataType -> ( this as NDArray < Long , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Long > ) { a , b -> a * b } <EOL> DataType . ComplexFloatDataType -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexFloat > ) { a , b -> a * b } <EOL> DataType . ComplexDoubleDataType -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexDouble > ) { a , b -> a * b } <EOL> DataType . ShortDataType -> ( this as NDArray < Short , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Short > ) { a , b -> ( a * b ) . toShort ( ) } <EOL> DataType . ByteDataType -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Byte > ) { a , b -> ( a * b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Multiplies this [MutableMultiArray] by the [other] [MultiArray] element-wise in place.
 *
 * If both the arrays have the same shape, this method performs an in-place multiplication operation and assigns the
 * result to this [MutableMultiArray].
 * Otherwise, it performs element-wise multiplication of this array and [other] array,
 * and assigns the result to this [MutableMultiArray].
 *
 * @param other the [MultiArray] to be multiplied element-wise with this [MutableMultiArray]
 * @throws IllegalArgumentException if both arrays do not have the same shape.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . timesAssign ( other : T )

{ <EOL> if ( this . consistent ) { <EOL> this . data *= other <EOL> } else { <EOL> when ( other ) { <EOL> is Double -> ( this as NDArray < Double , D > ) . commonAssignOp ( other ) { a , b -> a * b } <EOL> is Float -> ( this as NDArray < Float , D > ) . commonAssignOp ( other ) { a , b -> a * b } <EOL> is Int -> ( this as NDArray < Int , D > ) . commonAssignOp ( other ) { a , b -> a * b } <EOL> is Long -> ( this as NDArray < Long , D > ) . commonAssignOp ( other ) { a , b -> a * b } <EOL> is ComplexFloat -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other ) { a , b -> a * b } <EOL> is ComplexDouble -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other ) { a , b -> a * b } <EOL> is Short -> ( this as NDArray < Short , D > ) . commonAssignOp ( other ) { a , b -> ( a * b ) . toShort ( ) } <EOL> is Byte -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other ) { a , b -> ( a * b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Multiplies the [other] element-wise with the current [MutableMultiArray] and updates the current array in place.
 *
 * @param other the value to be multiplied element-wise with [MutableMultiArray]
 * @throws ClassCastException if [other] is not a compatible data type for the operation
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . div ( other : MultiArray < T , D > ) : NDArray < T , D >

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret /= other <EOL> return ret <EOL> }

/**
 * Creates a new NDArray as a division of [this] MultiArray object by [other] MultiArray.
 *
 * @param other The MultiArray object to be divided by.
 * @return A new NDArray object containing the result of the division operation.
 * @throws IllegalArgumentException if the shape of [this] and [other] are not equal.
 */


public operator fun < T , D : Dimension > MultiArray < T , D > . div ( other : T ) : NDArray < T , D >

{ <EOL> val ret = if ( this . consistent ) ( this as NDArray ) . copy ( ) else ( this as NDArray ) . deepCopy ( ) <EOL> ret /= other <EOL> return ret <EOL> }

/**
 * Returns a new NDArray<T, D> resulting from each element of the MultiArray<T, D>
 * being divided by the specified `other` element.
 *
 * @param other The element to divide each element of the MultiArray by.
 * @return A new NDArray<T, D> with the result of the division operation.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . divAssign ( other : MultiArray < T , D > )

{ <EOL> requireEqualShape ( this . shape , other . shape ) <EOL> if ( this . consistent && other . consistent ) { <EOL> this . data /= ( other . data as MemoryView ) <EOL> } else { <EOL> when ( dtype ) { <EOL> DataType . DoubleDataType -> ( this as NDArray < Double , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Double > ) { a , b -> a / b } <EOL> DataType . FloatDataType -> ( this as NDArray < Float , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Float > ) { a , b -> a / b } <EOL> DataType . IntDataType -> ( this as NDArray < Int , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Int > ) { a , b -> a / b } <EOL> DataType . LongDataType -> ( this as NDArray < Long , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Long > ) { a , b -> a / b } <EOL> DataType . ComplexFloatDataType -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexFloat > ) { a , b -> a / b } <EOL> DataType . ComplexDoubleDataType -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < ComplexDouble > ) { a , b -> a / b } <EOL> DataType . ShortDataType -> ( this as NDArray < Short , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Short > ) { a , b -> ( a / b ) . toShort ( ) } <EOL> DataType . ByteDataType -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other . iterator ( ) as Iterator < Byte > ) { a , b -> ( a / b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Divide this [MutableMultiArray] by another [MultiArray] element-wise.
 * This method performs the division operation in place, and modifies the original array.
 *
 * If both the arrays have the same shape, this method performs an in-place division operation and assigns the
 * result to this [MutableMultiArray].
 * Otherwise, it performs element-wise division of this array and [other] array,
 * and assigns the result to this [MutableMultiArray].
 *
 * @param other the MultiArray to divide by
 * @throws IllegalArgumentException if [this] and [other] have different shapes
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public operator fun < T , D : Dimension > MutableMultiArray < T , D > . divAssign ( other : T )

{ <EOL> if ( this . consistent ) { <EOL> this . data /= other <EOL> } else { <EOL> when ( other ) { <EOL> is Double -> ( this as NDArray < Double , D > ) . commonAssignOp ( other ) { a , b -> a / b } <EOL> is Float -> ( this as NDArray < Float , D > ) . commonAssignOp ( other ) { a , b -> a / b } <EOL> is Int -> ( this as NDArray < Int , D > ) . commonAssignOp ( other ) { a , b -> a / b } <EOL> is Long -> ( this as NDArray < Long , D > ) . commonAssignOp ( other ) { a , b -> a / b } <EOL> is ComplexFloat -> ( this as NDArray < ComplexFloat , D > ) . commonAssignOp ( other ) { a , b -> a / b } <EOL> is ComplexDouble -> ( this as NDArray < ComplexDouble , D > ) . commonAssignOp ( other ) { a , b -> a / b } <EOL> is Short -> ( this as NDArray < Short , D > ) . commonAssignOp ( other ) { a , b -> ( a / b ) . toShort ( ) } <EOL> is Byte -> ( this as NDArray < Byte , D > ) . commonAssignOp ( other ) { a , b -> ( a / b ) . toByte ( ) } <EOL> } <EOL> } <EOL> }

/**
 * Divide each element of the multi-dimensional array in place by another element [other].
 *
 * @param other The element to divide by.
 * @throws ArithmeticException if [other] is zero or causes an overflow during the division
 */


internal inline fun < T : Any , D : Dimension > MutableMultiArray < T , D > . commonAssignOp ( other : Iterator < T > , op : ( T , T ) -> T )

{ <EOL> if ( this . consistent ) { <EOL> for ( i in this . indices ) <EOL> this . data [ i ] = op ( this . data [ i ] , other . next ( ) ) <EOL> } else { <EOL> this . multiIndices . forEach { index -> <EOL> this [ index ] = op ( this [ index ] , other . next ( ) ) <EOL> } <EOL> } <EOL> }

/**
 * Performs a common assignment operation on a MutableMultiArray.
 *
 * @param other An iterator of data is the same type as the MutableMultiArray.
 * @param op A lambda function that takes two arguments of type T and returns a value of the same type.
 * This function is used to perform the common assignment operation.
 * @throws NoSuchElementException If the iterator passed as `other` does not contain enough elements.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> private inline fun < T : Any , D : Dimension > MutableMultiArray < T , D > . commonAssignOp ( other : T , op : ( T , T ) -> T )

{ <EOL> if ( dim . d == <NUM_LIT:1> ) { <EOL> this as MutableMultiArray < T , D1 > <EOL> for ( i in this . indices ) <EOL> this [ i ] = op ( this [ i ] , other ) <EOL> } else { <EOL> this . multiIndices . forEach { index -> <EOL> this [ index ] = op ( this [ index ] , other ) <EOL> } <EOL> } <EOL> }

/**
 * Applies the given operator `op` to each element of `this` and `other` and
 * stores the result in `this`.
 *
 * @param other The element to apply the operator to.
 * @param op The operator function to apply.
 * @throws IndexOutOfBoundsException If `this` and `other` are not the same size.
 */


{ <EOL> TODO ( "<STR_LIT:NotU+0020yetU+0020implemented>" ) <EOL> }

/**
 * MacOS actual implementation for `getCurrentDate`
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public fun < C > ColumnSet < C > . simplify ( ) : ColumnSet < C >

= simplifyInternal ( ) as ColumnSet < C >

/**
 * ## Simplify [ColumnSet]
 *
 * Given a [this] [ColumnSet], [simplify] simplifies the structure by removing columns that are already present in
 * column groups, returning only these groups plus columns not belonging in any of the groups.
 *
 * In other words, this means that if a column in [this] is inside another column group in [this],
 * it will not be included in the result.
 *
 * ### Check out: [Grammar]
 *
 * ## For example:
 *
 * [cols][ColumnsSelectionDsl.cols]`(a, a.b, d.c).`[simplify][SimplifyColumnsSelectionDsl.simplify]`() == `[cols][ColumnsSelectionDsl.cols]`(a, d.c)`
 * {@include [LineBreak]}
 * `df.`[select][DataFrame.select]` { `[colsAtAnyDepth][ColumnsSelectionDsl.colsAtAnyDepth]` { "e" `[in][String.contains]` it.`[name][DataColumn.name]` }.`[simplify][ColumnSet.simplify]`() }`
 *
 * @return A [ColumnSet][ColumnSet]`<`[C][C]`>` containing only the columns that are not inside any column group in [this].
 */


internal fun ColumnsResolver < * > . simplifyInternal ( ) : ColumnSet < * >

= <EOL> allColumnsInternal ( ) . transform { it . simplify ( ) }

/**
 * Simplifies structure by removing columns that are already present in
 * column groups in [this].
 *
 * A.k.a. it gets a sub-list of columns that are roots of the trees of columns.
 */


public fun KtElement . collectCallCandidates ( ) : List < KtCallCandidateInfo >

= <EOL> withValidityAssertion { analysisSession . callResolver . collectCallCandidates ( this ) }

/**
 * Returns all the candidates considered during [overload resolution](https://kotlinlang.org/spec/overload-resolution.html) for the call
 * corresponding to this [KtElement].
 *
 * [resolveCall] only returns the final result of overload resolution, i.e., the selected callable after considering candidate
 * applicability and choosing the most specific candidate.
 */


fun ScriptEvaluationConfiguration ? . with ( body : ScriptEvaluationConfiguration . Builder . ( ) -> Unit ) : ScriptEvaluationConfiguration

{ <EOL> val newConfiguration = <EOL> if ( this == null ) ScriptEvaluationConfiguration ( body = body ) <EOL> else ScriptEvaluationConfiguration ( this , body = body ) <EOL> return if ( newConfiguration != this ) newConfiguration else this <EOL> }

/**
 * An alternative to the constructor with base configuration, which returns a new configuration only if [body] adds anything
 * to the original one, otherwise returns original
 */


fun < T > ScriptEvaluationConfiguration . Builder . scriptExecutionWrapper ( wrapper : ( ( ) -> T ) -> T )

{ <EOL> ScriptEvaluationConfiguration . scriptExecutionWrapper . put ( object : ScriptExecutionWrapper < T > { <EOL> override fun invoke ( block : ( ) -> T ) : T = wrapper ( block ) <EOL> } ) <EOL> }

/**
 * A helper to enable passing lambda directly to the scriptExecutionWrapper "keyword"
 */


fun ScriptEvaluationConfiguration . Builder . enableScriptsInstancesSharing ( )

{ <EOL> this { <EOL> scriptsInstancesSharing ( true ) <EOL> } <EOL> }

/**
 * A helper to enable scriptsInstancesSharingMap with default implementation
 */


fun ScriptEvaluationConfiguration . Builder . refineConfigurationBeforeEvaluate ( handler : RefineScriptEvaluationConfigurationHandler )

{ <EOL> ScriptEvaluationConfiguration . refineConfigurationBeforeEvaluate . append ( RefineEvaluationConfigurationData ( handler ) ) <EOL> }

/**
 * A helper to enable passing lambda directly to the refinement "keyword"
 */


suspend operator fun invoke ( compiledScript : CompiledScript , scriptEvaluationConfiguration : ScriptEvaluationConfiguration = ScriptEvaluationConfiguration . Default ) : ResultWithDiagnostics < EvaluationResult >

/**
 * Evaluates [compiledScript] using the data from [scriptEvaluationConfiguration]
 * @param compiledScript the compiled script class
 * @param scriptEvaluationConfiguration evaluation configuration
 */


public fun KtReference . isImplicitReferenceToCompanion ( ) : Boolean

= withValidityAssertion { <EOL> analysisSession . referenceResolveProvider . isImplicitReferenceToCompanion ( this ) <EOL> }

/**
 * Checks if the reference is an implicit reference to a companion object via the containing class.
 *
 * Example:
 * ```
 * class A {
 * companion object {
 * fun foo() {}
 * }
 * }
 * ```
 *
 * For the case provided, inside the call `A.foo()`,
 * the `A` is an implicit reference to the companion object, so `isImplicitReferenceToCompanion` returns `true`
 *
 * @return `true` if the reference is an implicit reference to a companion object, `false` otherwise.
 */


public fun merge ( dumpFile : File , configurableTargetName : String ? = null )

{ <EOL> if ( ! dumpFile . exists ( ) ) { throw FileNotFoundException ( "<STR_LIT>" ) } <EOL> require ( dumpFile . isFile ) { "<STR_LIT>" } <EOL> merger . merge ( dumpFile , configurableTargetName ) <EOL> }

/**
 * Loads a textual KLib dump and merges it into this dump.
 *
 * If a dump contains only a single target, it's possible to specify a custom configurable target name.
 * Please refer to [KlibTarget.configurableName] for more details on the meaning of that name.
 *
 * By default, [configurableTargetName] is null and information about a target will be taken directly from
 * the loaded dump.
 *
 * It's an error to specify non-null [configurableTargetName] for a dump containing multiple targets.
 * It's also an error to merge dumps having some targets in common.
 *
 * @throws IllegalArgumentException if this dump and [dumpFile] shares same targets.
 * @throws IllegalArgumentException if [dumpFile] contains multiple targets
 * and [configurableTargetName] is not null.
 * @throws IllegalArgumentException if [dumpFile] is not a file.
 * @throws FileNotFoundException if [dumpFile] does not exist.
 *
 * @sample samples.KlibDumpSamples.mergeDumps
 */


{ <EOL> val intersection = targets . intersect ( other . targets ) <EOL> require ( intersection . isEmpty ( ) ) { <EOL> "<STR_LIT>" <EOL> } <EOL> merger . merge ( other . merger ) <EOL> }

/**
 * Merges [other] dump with this one.
 *
 * It's also an error to merge dumps having some targets in common.
 *
 * The operation does not modify [other].
 *
 * @throws IllegalArgumentException if this dump and [other] shares same targets.
 *
 * @sample samples.KlibDumpSamples.mergeDumpObjects
 */


public fun retain ( targets : Iterable < KlibTarget > )

{ <EOL> val toRemove = merger . targets . subtract ( targets . toSet ( ) ) <EOL> remove ( toRemove ) <EOL> }

/**
 * Removes all declarations that do not belong to specified targets and removes these targets from the dump.
 *
 * All targets in the [targets] collection not contained within this dump will be ignored.
 *
 * @sample samples.KlibDumpSamples.extractTargets
 */


public fun remove ( targets : Iterable < KlibTarget > )

{ <EOL> targets . forEach { <EOL> merger . remove ( it ) <EOL> } <EOL> }

/**
 * Remove all declarations that do belong to specified targets and remove these targets from the dump.
 *
 * All targets in the [targets] collection not contained within this dump will be ignored.
 *
 * @sample samples.KlibDumpSamples.mergeDumpObjects
 */


= KlibDump ( ) . also { it . merge ( this ) }


{ <EOL> merger . dump ( to ) <EOL> }

/**
 * Serializes the dump and writes it to [to].
 *
 * @sample samples.KlibDumpSamples.mergeDumps
 */


public fun from ( dumpFile : File , configurableTargetName : String ? = null ) : KlibDump

{ <EOL> if ( ! dumpFile . exists ( ) ) { throw FileNotFoundException ( "<STR_LIT>" ) } <EOL> require ( dumpFile . isFile ) { "<STR_LIT>" } <EOL> return KlibDump ( ) . apply { merge ( dumpFile , configurableTargetName ) } <EOL> }

/**
 * Loads a dump from a textual form.
 *
 * If a dump contains only a single target, it's possible to specify a custom configurable target name.
 * Please refer to [KlibTarget.configurableName] for more details on the meaning of that name.
 *
 * By default, [configurableTargetName] is null and information about a target will be taken directly from
 * the loaded dump.
 *
 * It's an error to specify non-null [configurableTargetName] for a dump containing multiple targets.
 *
 * @throws IllegalArgumentException if [dumpFile] contains multiple targets
 * and [configurableTargetName] is not null.
 * @throws IllegalArgumentException if [dumpFile] is empty.
 * @throws IllegalArgumentException if [dumpFile] is not a file.
 * @throws FileNotFoundException if [dumpFile] does not exist.
 *
 * @sample samples.KlibDumpSamples.mergeDumpObjects
 */


public fun fromKlib ( klibFile : File , configurableTargetName : String ? = null , filters : KlibDumpFilters = KlibDumpFilters . DEFAULT ) : KlibDump

{ <EOL> val dump = buildString { <EOL> dumpTo ( this , klibFile , filters ) <EOL> } <EOL> return KlibDump ( ) . apply { <EOL> merger . merge ( dump . splitToSequence ( '<CHAR_LIT:\n>' ) . iterator ( ) , configurableTargetName ) <EOL> } <EOL> }

/**
 * Dumps a public ABI of a klib represented by [klibFile] using [filters]
 * and returns a [KlibDump] representing it.
 *
 * To control which declarations are dumped, [filters] could be used. By default, no filters will be applied.
 *
 * If a klib contains only a single target, it's possible to specify a custom configurable target name.
 * Please refer to [KlibTarget.configurableName] for more details on the meaning of that name.
 *
 * By default, [configurableTargetName] is null and information about a target will be taken directly from
 * the klib.
 *
 * It's an error to specify non-null [configurableTargetName] for a klib containing multiple targets.
 *
 * @throws IllegalArgumentException if [klibFile] contains multiple targets
 * and [configurableTargetName] is not null.
 * @throws IllegalStateException if a klib could not be loaded from [klibFile].
 * @throws FileNotFoundException if [klibFile] does not exist.
 */


@ ExperimentalBCVApi <EOL> public fun inferAbi ( unsupportedTarget : KlibTarget , supportedTargetDumps : Iterable < KlibDump > , oldMergedDump : KlibDump ? = null ) : KlibDump

{ <EOL> require ( supportedTargetDumps . iterator ( ) . hasNext ( ) || oldMergedDump != null ) { <EOL> "<STR_LIT>" <EOL> } <EOL> supportedTargetDumps . asSequence ( ) . flatMap { it . targets } . toSet ( ) . also { <EOL> require ( ! it . contains ( unsupportedTarget ) ) { <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> val retainedDump = KlibDump ( ) . apply { <EOL> if ( oldMergedDump != null ) { <EOL> merge ( oldMergedDump ) <EOL> merger . retainTargetSpecificAbi ( unsupportedTarget ) <EOL> } <EOL> } <EOL> val commonDump = KlibDump ( ) . apply { <EOL> supportedTargetDumps . forEach { <EOL> merge ( it ) <EOL> } <EOL> merger . retainCommonAbi ( ) <EOL> } <EOL> commonDump . merge ( retainedDump ) <EOL> commonDump . merger . overrideTargets ( setOf ( unsupportedTarget ) ) <EOL> return commonDump <EOL> }

/**
 * Infer a possible public ABI for [unsupportedTarget] as an ABI common across all [supportedTargetDumps].
 * If there's an [oldMergedDump] consisting of declarations of multiple targets, including [unsupportedTarget],
 * a portion of that dump specific to the [unsupportedTarget] will be extracted and merged to the common ABI
 * build from [supportedTargetDumps].
 *
 * Returned dump contains only declarations for [unsupportedTarget].
 *
 * The function aimed to facilitate ABI dumps generation for targets that are not supported by a host compiler.
 * In practice, it means generating dumps for Apple targets on non-Apple hosts.
 *
 * @throws IllegalArgumentException when one of [supportedTargetDumps] contains [unsupportedTarget]
 * @throws IllegalArgumentException when [supportedTargetDumps] are empty and [oldMergedDump] is null
 *
 * @sample samples.KlibDumpSamples.inferDump
 */


@ ExperimentalBCVApi <EOL> public fun KlibDump . mergeFromKlib ( klibFile : File , configurableTargetName : String ? = null , filters : KlibDumpFilters = KlibDumpFilters . DEFAULT )

{ <EOL> this . merge ( KlibDump . fromKlib ( klibFile , configurableTargetName , filters ) ) <EOL> }

/**
 * Dumps a public ABI of a klib represented by [klibFile] using [filters] and merges it into this dump.
 *
 * To control which declarations are dumped, [filters] could be used. By default, no filters will be applied.
 *
 * If a klib contains only a single target, it's possible to specify a custom configurable target name.
 * Please refer to [KlibTarget.configurableName] for more details on the meaning of that name.
 *
 * By default, [configurableTargetName] is null and information about a target will be taken directly from
 * the klib.
 *
 * It's an error to specify non-null [configurableTargetName] for a klib containing multiple targets.
 * It's also an error to merge dumps having some targets in common.
 *
 * @throws IllegalArgumentException if this dump and [klibFile] shares same targets.
 * @throws IllegalArgumentException if [klibFile] contains multiple targets
 * and [configurableTargetName] is not null.
 * @throws IllegalStateException if a klib could not be loaded from [klibFile].
 * @throws FileNotFoundException if [klibFile] does not exist.
 */


@ ExperimentalBCVApi <EOL> public fun KlibDump . saveTo ( file : File ) : Unit

= file . bufferedWriter ( ) . use { saveTo ( it ) }

/**
 * Serializes the dump and writes it to [file].
 */


public fun initializeWith ( vararg executionProviders : ExecutionProvider = arrayOf ( CPU ( true ) ) )

/**
 * Initialize the model with the specified executions providers.
 */


private fun BaseKotlinScope . createProjectHierarchyWithPluginOnRoot ( )

{ <EOL> settingsGradleKts { <EOL> resolve ( "<STR_LIT>" ) <EOL> } <EOL> buildGradleKts { <EOL> resolve ( "<STR_LIT>" ) <EOL> } <EOL> dir ( "<STR_LIT>" ) { <EOL> buildGradleKts { <EOL> resolve ( "<STR_LIT>" ) <EOL> } <EOL> dir ( "<STR_LIT>" ) { <EOL> buildGradleKts { <EOL> resolve ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> dir ( "<STR_LIT>" ) { <EOL> buildGradleKts { <EOL> resolve ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> dir ( "<STR_LIT>" ) { <EOL> buildGradleKts { <EOL> resolve ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }

/**
 * Sets up a project hierarchy like this:
 * ```
 * build.gradle.kts (with the plugin)
 * settings.gradle.kts (including refs to 4 subprojects)
 * sub1/
 * build.gradle.kts
 * subsub1/build.gradle.kts
 * subsub2/build.gradle.kts
 * sub2/build.gradle.kts
 * ```
 */


@ InternalCoroutinesApi <EOL> public actual inline fun < T > synchronizedImpl ( lock : SynchronizedObject , block : ( ) -> T ) : T

= <EOL> kotlin . synchronized ( lock , block )

/**
 * @suppress **This an internal API and should not be used from general code.**
 */


fun explicitVisibilityIsNotRequired ( descriptor : DeclarationDescriptor ) : Boolean

{ <EOL> if ( ( descriptor as? ClassConstructorDescriptor ) ? . isPrimary == true ) return true <EOL> if ( descriptor is PropertyDescriptor && ( descriptor . containingDeclaration as? ClassDescriptor ) ? . isData == true ) return true <EOL> if ( ( descriptor as? CallableDescriptor ) ? . overriddenDescriptors ? . isNotEmpty ( ) == true ) return true <EOL> if ( descriptor is PropertyAccessorDescriptor ) return true <EOL> if ( descriptor is PropertyDescriptor && ( descriptor . containingDeclaration as? ClassDescriptor ) ? . kind == ClassKind . ANNOTATION_CLASS ) return true <EOL> return false <EOL> }

/**
 * Exclusion list:
 * 1. Primary constructors of public API classes
 * 2. Properties of data classes in public API
 * 3. Overrides of public API. Effectively, this means 'no report on overrides at all'
 * 4. Getters and setters (because getters can't change visibility and setter-only explicit visibility looks ugly)
 * 5. Properties of annotations in public API
 *
 * Do we need something like @PublicApiFile to disable (or invert) this inspection per-file?
 */


@ HtmlTagMarker <EOL> inline fun FlowOrMetaDataOrPhrasingContent . link ( href : String ? = null , rel : String ? = null , type : String ? = null , crossinline block : LINK . ( ) -> Unit = { } ) : Unit

= LINK ( attributesMapOf ( "<STR_LIT>" , href , "<STR_LIT>" , rel , "<STR_LIT:type>" , type ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrMetaDataOrPhrasingContent . meta ( name : String ? = null , content : String ? = null , charset : String ? = null , crossinline block : META . ( ) -> Unit = { } ) : Unit

= META ( attributesMapOf ( "<STR_LIT:name>" , name , "<STR_LIT>" , content , "<STR_LIT>" , charset ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrMetaDataOrPhrasingContent . noScript ( classes : String ? = null , crossinline block : NOSCRIPT . ( ) -> Unit = { } ) : Unit

= NOSCRIPT ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrMetaDataOrPhrasingContent . script ( type : String ? = null , src : String ? = null , crossorigin : ScriptCrossorigin ? = null , crossinline block : SCRIPT . ( ) -> Unit = { } ) : Unit

= SCRIPT ( attributesMapOf ( "<STR_LIT:type>" , type , "<STR_LIT:src>" , src , "<STR_LIT>" , crossorigin ? . enumEncode ( ) ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrHeadingContent . h1 ( classes : String ? = null , crossinline block : H1 . ( ) -> Unit = { } ) : Unit

= H1 ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrHeadingContent . h2 ( classes : String ? = null , crossinline block : H2 . ( ) -> Unit = { } ) : Unit

= H2 ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrHeadingContent . h3 ( classes : String ? = null , crossinline block : H3 . ( ) -> Unit = { } ) : Unit

= H3 ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrHeadingContent . h4 ( classes : String ? = null , crossinline block : H4 . ( ) -> Unit = { } ) : Unit

= H4 ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrHeadingContent . h5 ( classes : String ? = null , crossinline block : H5 . ( ) -> Unit = { } ) : Unit

= H5 ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrHeadingContent . h6 ( classes : String ? = null , crossinline block : H6 . ( ) -> Unit = { } ) : Unit

= H6 ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrMetaDataContent . style ( type : String ? = null , crossinline block : STYLE . ( ) -> Unit = { } ) : Unit

= STYLE ( attributesMapOf ( "<STR_LIT:type>" , type ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveContent . details ( classes : String ? = null , crossinline block : DETAILS . ( ) -> Unit = { } ) : Unit

= DETAILS ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Disclosure control for hiding details
 */


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . abbr ( classes : String ? = null , crossinline block : ABBR . ( ) -> Unit = { } ) : Unit

= ABBR ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Abbreviated form (e.g., WWW, HTTP,etc.)
 */


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . area ( shape : AreaShape ? = null , alt : String ? = null , classes : String ? = null , crossinline block : AREA . ( ) -> Unit = { } ) : Unit

= AREA ( attributesMapOf ( "<STR_LIT>" , shape ? . enumEncode ( ) , "<STR_LIT>" , alt , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . b ( classes : String ? = null , crossinline block : B . ( ) -> Unit = { } ) : Unit

= B ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . bdi ( classes : String ? = null , crossinline block : BDI . ( ) -> Unit = { } ) : Unit

= BDI ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Text directionality isolation
 */


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . bdo ( classes : String ? = null , crossinline block : BDO . ( ) -> Unit = { } ) : Unit

= BDO ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . br ( classes : String ? = null , crossinline block : BR . ( ) -> Unit = { } ) : Unit

= BR ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . canvas ( classes : String ? = null , crossinline block : CANVAS . ( ) -> Unit = { } ) : Unit

= CANVAS ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> fun FlowOrPhrasingContent . canvas ( classes : String ? = null , content : String = "<STR_LIT>" ) : Unit

= CANVAS ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( { + content } )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . cite ( classes : String ? = null , crossinline block : CITE . ( ) -> Unit = { } ) : Unit

= CITE ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . code ( classes : String ? = null , crossinline block : CODE . ( ) -> Unit = { } ) : Unit

= CODE ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . dataList ( classes : String ? = null , crossinline block : DATALIST . ( ) -> Unit = { } ) : Unit

= DATALIST ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . del ( classes : String ? = null , crossinline block : DEL . ( ) -> Unit = { } ) : Unit

= DEL ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . dfn ( classes : String ? = null , crossinline block : DFN . ( ) -> Unit = { } ) : Unit

= DFN ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . em ( classes : String ? = null , crossinline block : EM . ( ) -> Unit = { } ) : Unit

= EM ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . i ( classes : String ? = null , crossinline block : I . ( ) -> Unit = { } ) : Unit

= I ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . ins ( classes : String ? = null , crossinline block : INS . ( ) -> Unit = { } ) : Unit

= INS ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . kbd ( classes : String ? = null , crossinline block : KBD . ( ) -> Unit = { } ) : Unit

= KBD ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Text to be entered by the user
 */


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . map ( name : String ? = null , classes : String ? = null , crossinline block : MAP . ( ) -> Unit = { } ) : Unit

= MAP ( attributesMapOf ( "<STR_LIT:name>" , name , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . mark ( classes : String ? = null , crossinline block : MARK . ( ) -> Unit = { } ) : Unit

= MARK ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . meter ( classes : String ? = null , crossinline block : METER . ( ) -> Unit = { } ) : Unit

= METER ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . output ( classes : String ? = null , crossinline block : OUTPUT . ( ) -> Unit = { } ) : Unit

= OUTPUT ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . progress ( classes : String ? = null , crossinline block : PROGRESS . ( ) -> Unit = { } ) : Unit

= PROGRESS ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . q ( classes : String ? = null , crossinline block : Q . ( ) -> Unit = { } ) : Unit

= Q ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . ruby ( classes : String ? = null , crossinline block : RUBY . ( ) -> Unit = { } ) : Unit

= RUBY ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . samp ( classes : String ? = null , crossinline block : SAMP . ( ) -> Unit = { } ) : Unit

= SAMP ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . small ( classes : String ? = null , crossinline block : SMALL . ( ) -> Unit = { } ) : Unit

= SMALL ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . span ( classes : String ? = null , crossinline block : SPAN . ( ) -> Unit = { } ) : Unit

= SPAN ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Generic language/style container
 */


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . strong ( classes : String ? = null , crossinline block : STRONG . ( ) -> Unit = { } ) : Unit

= STRONG ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . sub ( classes : String ? = null , crossinline block : SUB . ( ) -> Unit = { } ) : Unit

= SUB ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . sup ( classes : String ? = null , crossinline block : SUP . ( ) -> Unit = { } ) : Unit

= SUP ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . time ( classes : String ? = null , crossinline block : TIME . ( ) -> Unit = { } ) : Unit

= TIME ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Machine-readable equivalent of date- or time-related data
 */


@ HtmlTagMarker <EOL> inline fun FlowOrPhrasingContent . htmlVar ( classes : String ? = null , crossinline block : VAR . ( ) -> Unit = { } ) : Unit

= VAR ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun SectioningOrFlowContent . article ( classes : String ? = null , crossinline block : ARTICLE . ( ) -> Unit = { } ) : Unit

= ARTICLE ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Self-contained syndicatable or reusable composition
 */


@ HtmlTagMarker <EOL> inline fun SectioningOrFlowContent . aside ( classes : String ? = null , crossinline block : ASIDE . ( ) -> Unit = { } ) : Unit

= ASIDE ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Sidebar for tangentially related content
 */


@ HtmlTagMarker <EOL> inline fun SectioningOrFlowContent . main ( classes : String ? = null , crossinline block : MAIN . ( ) -> Unit = { } ) : Unit

= MAIN ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Container for the dominant contents of another element
 */


@ HtmlTagMarker <EOL> inline fun SectioningOrFlowContent . nav ( classes : String ? = null , crossinline block : NAV . ( ) -> Unit = { } ) : Unit

= NAV ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Section with navigational links
 */


@ HtmlTagMarker <EOL> inline fun SectioningOrFlowContent . section ( classes : String ? = null , crossinline block : SECTION . ( ) -> Unit = { } ) : Unit

= SECTION ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Generic document or application section
 */


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . a ( href : String ? = null , target : String ? = null , classes : String ? = null , crossinline block : A . ( ) -> Unit = { } ) : Unit

= A ( attributesMapOf ( "<STR_LIT>" , href , "<STR_LIT>" , target , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . audio ( classes : String ? = null , crossinline block : AUDIO . ( ) -> Unit = { } ) : Unit

= AUDIO ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . button ( formEncType : ButtonFormEncType ? = null , formMethod : ButtonFormMethod ? = null , name : String ? = null , type : ButtonType ? = null , classes : String ? = null , crossinline block : BUTTON . ( ) -> Unit = { } ) : Unit

= BUTTON ( attributesMapOf ( "<STR_LIT>" , formEncType ? . enumEncode ( ) , "<STR_LIT>" , formMethod ? . enumEncode ( ) , "<STR_LIT:name>" , name , "<STR_LIT:type>" , type ? . enumEncode ( ) , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . embed ( classes : String ? = null , crossinline block : EMBED . ( ) -> Unit = { } ) : Unit

= EMBED ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . iframe ( sandbox : IframeSandbox ? = null , classes : String ? = null , crossinline block : IFRAME . ( ) -> Unit = { } ) : Unit

= IFRAME ( attributesMapOf ( "<STR_LIT>" , sandbox ? . enumEncode ( ) , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> fun FlowOrInteractiveOrPhrasingContent . iframe ( sandbox : IframeSandbox ? = null , classes : String ? = null , content : String = "<STR_LIT>" ) : Unit

= IFRAME ( attributesMapOf ( "<STR_LIT>" , sandbox ? . enumEncode ( ) , "<STR_LIT:class>" , classes ) , consumer ) . visit ( { + content } )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . img ( alt : String ? = null , src : String ? = null , loading : ImgLoading ? = null , classes : String ? = null , crossinline block : IMG . ( ) -> Unit = { } ) : Unit

= IMG ( attributesMapOf ( "<STR_LIT>" , alt , "<STR_LIT:src>" , src , "<STR_LIT>" , loading ? . enumEncode ( ) , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . picture ( crossinline block : PICTURE . ( ) -> Unit = { } ) : Unit

= PICTURE ( emptyMap , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . input ( type : InputType ? = null , formEncType : InputFormEncType ? = null , formMethod : InputFormMethod ? = null , name : String ? = null , classes : String ? = null , crossinline block : INPUT . ( ) -> Unit = { } ) : Unit

= INPUT ( attributesMapOf ( "<STR_LIT:type>" , type ? . enumEncode ( ) , "<STR_LIT>" , formEncType ? . enumEncode ( ) , "<STR_LIT>" , formMethod ? . enumEncode ( ) , "<STR_LIT:name>" , name , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . keyGen ( keyType : KeyGenKeyType ? = null , classes : String ? = null , crossinline block : KEYGEN . ( ) -> Unit = { } ) : Unit

= KEYGEN ( attributesMapOf ( "<STR_LIT>" , keyType ? . enumEncode ( ) , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )

/**
 * Cryptographic key-pair generator form control
 */


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . label ( classes : String ? = null , crossinline block : LABEL . ( ) -> Unit = { } ) : Unit

= LABEL ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . htmlObject ( classes : String ? = null , crossinline block : OBJECT . ( ) -> Unit = { } ) : Unit

= OBJECT ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . select ( classes : String ? = null , crossinline block : SELECT . ( ) -> Unit = { } ) : Unit

= SELECT ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . textArea ( rows : String ? = null , cols : String ? = null , wrap : TextAreaWrap ? = null , classes : String ? = null , crossinline block : TEXTAREA . ( ) -> Unit = { } ) : Unit

= TEXTAREA ( attributesMapOf ( "<STR_LIT>" , rows , "<STR_LIT>" , cols , "<STR_LIT>" , wrap ? . enumEncode ( ) , "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


@ HtmlTagMarker <EOL> fun FlowOrInteractiveOrPhrasingContent . textArea ( rows : String ? = null , cols : String ? = null , wrap : TextAreaWrap ? = null , classes : String ? = null , content : String = "<STR_LIT>" ) : Unit

= TEXTAREA ( attributesMapOf ( "<STR_LIT>" , rows , "<STR_LIT>" , cols , "<STR_LIT>" , wrap ? . enumEncode ( ) , "<STR_LIT:class>" , classes ) , consumer ) . visit ( { + content } )


@ HtmlTagMarker <EOL> inline fun FlowOrInteractiveOrPhrasingContent . video ( classes : String ? = null , crossinline block : VIDEO . ( ) -> Unit = { } ) : Unit

= VIDEO ( attributesMapOf ( "<STR_LIT:class>" , classes ) , consumer ) . visit ( block )


public fun findAsJava ( kotlinDri : DRI ) : DRI ?

/**
 * E.g.
 * kotlin.Throwable -> java.lang.Throwable
 * kotlin.Int -> java.lang.Integer
 * kotlin.Int.Companion -> kotlin.jvm.internal.IntCompanionObject
 * kotlin.Nothing -> java.lang.Void
 * kotlin.IntArray -> null
 * kotlin.Function3 -> kotlin.jvm.functions.Function3
 * kotlin.coroutines.SuspendFunction3 -> kotlin.jvm.functions.Function4
 * kotlin.Function42 -> kotlin.jvm.functions.FunctionN
 * kotlin.coroutines.SuspendFunction42 -> kotlin.jvm.functions.FunctionN
 * kotlin.reflect.KFunction3 -> kotlin.reflect.KFunction
 * kotlin.reflect.KSuspendFunction3 -> kotlin.reflect.KFunction
 * kotlin.reflect.KFunction42 -> kotlin.reflect.KFunction
 * kotlin.reflect.KSuspendFunction42 -> kotlin.reflect.KFunction
 */


@ ExperimentalSerializationApi <EOL> public fun getElementName ( index : Int ) : String

/**
 * Returns a positional name of the child at the given [index].
 * Positional name represents a corresponding property name in the class, associated with
 * the current descriptor.
 *
 * @throws IndexOutOfBoundsException for an illegal [index] values.
 * @throws IllegalStateException if the current descriptor does not support children elements (e.g. is a primitive)
 */


@ ExperimentalSerializationApi <EOL> public fun getElementIndex ( name : String ) : Int

/**
 * Returns an index in the children list of the given element by its name or [CompositeDecoder.UNKNOWN_NAME]
 * if there is no such element.
 * The resulting index, if it is not [CompositeDecoder.UNKNOWN_NAME], is guaranteed to be usable with [getElementName].
 */


@ ExperimentalSerializationApi <EOL> public fun getElementAnnotations ( index : Int ) : List < Annotation >

/**
 * Returns serial annotations of the child element at the given [index].
 * This method differs from `getElementDescriptor(index).annotations` by reporting only
 * declaration-specific annotations:
 * ```
 * @Serializable
 * @SomeSerialAnnotation
 * class Nested(...)
 *
 * @Serializable
 * class Outer(@AnotherSerialAnnotation val nested: Nested)
 *
 * outerDescriptor.getElementAnnotations(0) // Returns [@AnotherSerialAnnotation]
 * outerDescriptor.getElementDescriptor(0).annotations // Returns [@SomeSerialAnnotation]
 * ```
 * Only annotations marked with [SerialInfo] are added to the resulting list.
 *
 * @throws IndexOutOfBoundsException for an illegal [index] values.
 * @throws IllegalStateException if the current descriptor does not support children elements (e.g. is a primitive).
 */


@ ExperimentalSerializationApi <EOL> public fun getElementDescriptor ( index : Int ) : SerialDescriptor

/**
 * Retrieves the descriptor of the child element for the given [index].
 * For the property of type `T` on the position `i`, `getElementDescriptor(i)` yields the same result
 * as for `T.serializer().descriptor`, if the serializer for this property is not explicitly overridden
 * with `@Serializable(with = ...`)`, [Polymorphic] or [Contextual].
 * This method can be used to completely introspect the type that the current descriptor describes.
 *
 * @throws IndexOutOfBoundsException for illegal [index] values.
 * @throws IllegalStateException if the current descriptor does not support children elements (e.g. is a primitive).
 */


@ ExperimentalSerializationApi <EOL> public fun isElementOptional ( index : Int ) : Boolean

/**
 * Whether the element at the given [index] is optional (can be absent in serialized form).
 * For generated descriptors, all elements that have a corresponding default parameter value are
 * marked as optional. Custom serializers can treat optional values in a serialization-specific manner
 * without default parameters constraint.
 *
 * Example of optionality:
 * ```
 * @Serializable
 * class Holder(
 * val a: Int, // Optional == false
 * val b: Int?, // Optional == false
 * val c: Int? = null, // Optional == true
 * val d: List<Int>, // Optional == false
 * val e: List<Int> = listOf(1), // Optional == true
 * )
 * ```
 * Returns `false` for valid indices of collections, maps and enums.
 *
 * @throws IndexOutOfBoundsException for an illegal [index] values.
 * @throws IllegalStateException if the current descriptor does not support children elements (e.g. is a primitive).
 */


override fun createPointer ( ) : KtSymbolPointer < KtFirEnumEntryInitializerSymbol >

= withValidityAssertion { <EOL> KtPsiBasedSymbolPointer . createForSymbolFromSource < KtFirEnumEntryInitializerSymbol > ( this ) <EOL> ? : KtFirEnumEntryInitializerSymbolPointer ( analysisSession . createOwnerPointer ( this ) ) <EOL> }

/**
 * [KtFirEnumEntryInitializerSymbol] is the required return type instead of [KtEnumEntryInitializerSymbol] to fulfill return type
 * subtyping requirements, as [KtEnumEntryInitializerSymbol] is not a subtype of
 * [org.jetbrains.kotlin.analysis.api.symbols.KtAnonymousObjectSymbol]. (It cannot be a subtype in the general Analysis API because enum
 * entry initializers are classes in FE10.)
 */


@ Test <EOL> fun testObservableCollectThrowingObservable ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> var sum = <NUM_LIT:0> <EOL> try { <EOL> rxObservable { <EOL> for ( i in <NUM_LIT:0> .. <NUM_LIT:100> ) { <EOL> send ( i ) <EOL> } <EOL> throw TestException ( ) <EOL> } . collect { <EOL> sum += it <EOL> } <EOL> } catch ( e : TestException ) { <EOL> assertTrue ( sum > <NUM_LIT:0> ) <EOL> finish ( <NUM_LIT:2> ) <EOL> } <EOL> }

/** Tests the behavior of [collect] when the publisher raises an error. */


@ Test <EOL> fun testObservableCollectThrowingAction ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> var sum = <NUM_LIT:0> <EOL> val expectedSum = <NUM_LIT:5> <EOL> try { <EOL> var disposed = false <EOL> ObservableSource < Int > { observer -> <EOL> launch ( Dispatchers . Default ) { <EOL> observer . onSubscribe ( object : Disposable { <EOL> override fun dispose ( ) { <EOL> disposed = true <EOL> expect ( expectedSum + <NUM_LIT:2> ) <EOL> } <EOL> override fun isDisposed ( ) : Boolean = disposed <EOL> } ) <EOL> while ( ! disposed ) { <EOL> observer . onNext ( <NUM_LIT:1> ) <EOL> } <EOL> } <EOL> } . collect { <EOL> expect ( sum + <NUM_LIT:2> ) <EOL> sum += it <EOL> if ( sum == expectedSum ) { <EOL> throw TestException ( ) <EOL> } <EOL> } <EOL> } catch ( e : TestException ) { <EOL> assertEquals ( expectedSum , sum ) <EOL> finish ( expectedSum + <NUM_LIT:3> ) <EOL> } <EOL> }

/** Tests the behavior of [collect] when the action throws. */


= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val publisher = publish < Int > ( Dispatchers . Unconfined ) { <EOL> expect ( <NUM_LIT:3> ) <EOL> close ( ) <EOL> assert ( isClosedForSend ) <EOL> expect ( <NUM_LIT:4> ) <EOL> } <EOL> try { <EOL> expect ( <NUM_LIT:2> ) <EOL> publisher . awaitFirstOrNull ( ) <EOL> } catch ( e : CancellationException ) { <EOL> expect ( <NUM_LIT:5> ) <EOL> } <EOL> finish ( <NUM_LIT:6> ) <EOL> }

/** Tests that, as soon as `ProducerScope.close` is called, `isClosedForSend` starts returning `true`. */


@ Test <EOL> fun testOnNextErrorAfterCancellation ( )

= runTest { <EOL> assertCallsExceptionHandlerWith < TestException > { handler -> <EOL> var producerScope : ProducerScope < Int > ? = null <EOL> CompletableDeferred < Unit > ( ) <EOL> expect ( <NUM_LIT:1> ) <EOL> var job : Job ? = null <EOL> val publisher = publish < Int > ( handler + Dispatchers . Unconfined ) { <EOL> producerScope = this <EOL> expect ( <NUM_LIT:4> ) <EOL> job = launch { <EOL> delay ( Long . MAX_VALUE ) <EOL> } <EOL> } <EOL> expect ( <NUM_LIT:2> ) <EOL> publisher . subscribe ( object : Subscriber < Int > { <EOL> override fun onSubscribe ( s : Subscription ) { <EOL> expect ( <NUM_LIT:3> ) <EOL> s . request ( Long . MAX_VALUE ) <EOL> } <EOL> override fun onNext ( t : Int ) { <EOL> expect ( <NUM_LIT:6> ) <EOL> assertEquals ( <NUM_LIT:1> , t ) <EOL> job ! ! . cancel ( ) <EOL> throw TestException ( ) <EOL> } <EOL> override fun onError ( t : Throwable ? ) { <EOL> assertIs < CancellationException > ( t ) <EOL> } <EOL> override fun onComplete ( ) { <EOL> expectUnreached ( ) <EOL> } <EOL> } ) <EOL> expect ( <NUM_LIT:5> ) <EOL> val result : ChannelResult < Unit > = producerScope ! ! . trySend ( <NUM_LIT:1> ) <EOL> val e = result . exceptionOrNull ( ) ! ! <EOL> assertIs < CancellationException > ( e , "<STR_LIT>" ) <EOL> assertTrue ( producerScope ! ! . isClosedForSend ) <EOL> assertTrue ( result . isFailure ) <EOL> } <EOL> finish ( <NUM_LIT:7> ) <EOL> }

/** Tests the behavior when a call to `onNext` fails after the channel is already closed. */


@ Test <EOL> fun testTrySendNotThrowing ( )

= runTest { <EOL> var producerScope : ProducerScope < Int > ? = null <EOL> expect ( <NUM_LIT:1> ) <EOL> val publisher = publish < Int > ( Dispatchers . Unconfined ) { <EOL> producerScope = this <EOL> expect ( <NUM_LIT:3> ) <EOL> delay ( Long . MAX_VALUE ) <EOL> } <EOL> val job = launch ( start = CoroutineStart . UNDISPATCHED ) { <EOL> expect ( <NUM_LIT:2> ) <EOL> publisher . awaitFirstOrNull ( ) <EOL> expectUnreached ( ) <EOL> } <EOL> job . cancel ( ) <EOL> expect ( <NUM_LIT:4> ) <EOL> val result = producerScope ! ! . trySend ( <NUM_LIT:1> ) <EOL> assertTrue ( result . isFailure ) <EOL> finish ( <NUM_LIT:5> ) <EOL> }

/** Tests that `trySend` doesn't throw in `publish`. */


= runTest { <EOL> val publisher = publish { <EOL> assertFailsWith < NullPointerException > { send ( null ) } <EOL> assertFailsWith < NullPointerException > { trySend ( null ) } <EOL> send ( "<STR_LIT:OK>" ) <EOL> } <EOL> assertEquals ( "<STR_LIT:OK>" , publisher . awaitFirstOrNull ( ) ) <EOL> }

/** Tests that all methods on `publish` fail without closing the channel when attempting to emit `null`. */


fun runTest ( swiftFilePath : String , )

{ <EOL> Assumptions . assumeTrue ( targets . hostTarget . family . isAppleFamily && targets . testTarget . family . isAppleFamily ) <EOL> val testDirectory = getAbsoluteFile ( swiftFilePath ) . resolve ( "<STR_LIT>" ) <EOL> require ( testDirectory . exists ( ) && testDirectory . isDirectory ( ) ) <EOL> val swiftFile = testDirectory . walk ( ) . find { it . extension == "<STR_LIT>" } <EOL> ? : error ( "<STR_LIT>" ) <EOL> val cHeader = testDirectory . walk ( ) . find { it . extension == "<STR_LIT>" } <EOL> ? : error ( "<STR_LIT>" ) <EOL> val configs = testRunSettings . configurables as AppleConfigurables <EOL> val swiftTarget = configs . targetTriple . withOSVersion ( configs . osVersionMin ) . toString ( ) <EOL> val bridgeModuleFile = createModuleMap ( buildDir , cHeader ) <EOL> val kotlinRuntimeModuleMapFile = Distribution ( KotlinNativePaths . homePath . absolutePath ) <EOL> . kotlinRuntimeForSwiftModuleMap <EOL> val args = listOf ( "<STR_LIT>" , swiftFile . absolutePath , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , configs . absoluteTargetSysRoot , "<STR_LIT>" , swiftTarget ) <EOL> val ( exitCode , swiftcOutput , _ , _ ) = <EOL> invokeSwiftC ( testRunSettings , args ) <EOL> assertEquals ( ExitCode . OK , exitCode , "<STR_LIT>" ) <EOL> }

/**
 This test is the simplest possible solutions for task KT-65559

 One reading this test could find themselves confused, with following questions:
 1/ what does it do
 2/ why it is placed in native-test infra
 3/ what actually we do test

 This comment wil try to answer all those questions.

 What we are trying to achieve:
 There is a SwiftExport artefact, and we have some integration tests for it.
 But our integration tests check only one thing - that our current implementation generates expected source files.
 But we do not compile that resulted files, as that actions requires macOS agents with swift installed,
 and we want to keep our day2day tests as quick as possible.

 So, we have construct this test - it will take golden data that we are expecting to receive from SwiftExport,
 and verify with swift compiler that we expect valid code. This way we have separated tests that verify code generation
 from tests that verify code validity. That separation may not be desired, but that separation allows us to keep tests for
 code generation fast and TeamCity agent agnostic.

 We do plan to refactor this, and extract infra for running swiftc and xcode into separate module, that will be shared
 between SwiftExport, ObjectiveCExport, Kotlin/Native and KGP tests. But currently - the following solution is the simplest one.
 */


internal fun KoverContext . finalizing ( origins : AllVariantOrigins )

{ <EOL> projectExtension . finalizeActions . forEach { action -> <EOL> try { <EOL> action ( ) <EOL> } catch ( e : Exception ) { <EOL> throw KoverCriticalException ( "<STR_LIT>" , e ) <EOL> } <EOL> } <EOL> val jvmVariant = <EOL> origins . jvm ? . createVariant ( this , variantConfig ( JVM_VARIANT_NAME ) ) <EOL> if ( jvmVariant != null ) { <EOL> VariantReportsSet ( project , JVM_VARIANT_NAME , ReportVariantType . JVM , toolProvider , reportsConfig ( JVM_VARIANT_NAME , project . path ) , reporterClasspath , projectExtension . koverDisabled ) . assign ( jvmVariant ) <EOL> } <EOL> val androidVariants = origins . android . map { providedDetails -> <EOL> providedDetails . createVariant ( this , variantConfig ( providedDetails . buildVariant . buildVariant ) ) <EOL> } <EOL> val variantArtifacts = mutableMapOf < String , AbstractVariantArtifacts > ( ) <EOL> jvmVariant ? . let { variantArtifacts [ JVM_VARIANT_NAME ] = it } <EOL> androidVariants . forEach { variantArtifacts [ it . variantName ] = it } <EOL> val availableVariants = variantArtifacts . keys + projectExtension . current . customVariants . keys <EOL> projectExtension . reports . byName . forEach { ( requestedVariant , _ ) -> <EOL> if ( requestedVariant !in availableVariants ) { <EOL> throw KoverIllegalConfigException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val totalVariant = <EOL> TotalVariantArtifacts ( project , toolProvider , koverBucketConfiguration , variantConfig ( TOTAL_VARIANT_NAME ) , projectExtension ) <EOL> variantArtifacts . values . forEach { totalVariant . mergeWith ( it ) } <EOL> totalReports . assign ( totalVariant ) <EOL> projectExtension . current . providedVariants . forEach { ( name , _ ) -> <EOL> if ( name !in variantArtifacts ) { <EOL> throw KoverIllegalConfigException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> projectExtension . current . customVariants . forEach { ( name , config ) -> <EOL> if ( name == JVM_VARIANT_NAME ) { <EOL> throw KoverIllegalConfigException ( "<STR_LIT>" ) <EOL> } <EOL> if ( name in variantArtifacts ) { <EOL> throw KoverIllegalConfigException ( "<STR_LIT>" ) <EOL> } <EOL> val customVariant = <EOL> CustomVariantArtifacts ( project , name , toolProvider , koverBucketConfiguration , config , projectExtension ) <EOL> config . variantsByName . forEach { ( mergedName , optionality ) -> <EOL> val mergedVariant = variantArtifacts [ mergedName ] <EOL> if ( mergedVariant != null ) { <EOL> if ( optionality . withDependencies ) { <EOL> customVariant . mergeWithDependencies ( mergedVariant ) <EOL> } else { <EOL> customVariant . mergeWith ( mergedVariant ) <EOL> } <EOL> } else { <EOL> if ( ! optionality . optional ) { <EOL> throw KoverIllegalConfigException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> VariantReportsSet ( project , name , ReportVariantType . CUSTOM , toolProvider , reportsConfig ( name , project . path ) , reporterClasspath , projectExtension . koverDisabled ) . assign ( customVariant ) <EOL> } <EOL> androidVariants . forEach { androidVariant -> <EOL> VariantReportsSet ( project , androidVariant . variantName , ReportVariantType . ANDROID , toolProvider , reportsConfig ( androidVariant . variantName , project . path ) , reporterClasspath , projectExtension . koverDisabled ) . assign ( androidVariant ) <EOL> } <EOL> }

/**
 * The second stage of applying the Kover plugin.
 *
 * Objects are created that depend on the full configuration of the project: the availability of Kotlin plugins,
 * the availability and settings of the Android plugin, the user settings of the Kover plugin itself.
 */


fun processHeader ( headerMetadata : ByteArray )

/** processes new header metadata (serialized [JsProtoBuf.Header]) */


fun processPackagePart ( sourceFile : File , packagePartMetadata : ByteArray , binaryAst : ByteArray , inlineData : ByteArray )

/** processes new package part metadata and binary tree for compiled source file */


fun processInlineFunction ( sourceFile : File , fqName : String , inlineFunction : Any , line : Int , column : Int )

/**
 * [inlineFunction] is expected to be a body of inline function (an instance of [JsNode]),
 * but [Any] is used to avoid classloader conflicts in tests where the compiler is isolated
 * (such as [JsProtoComparisonTestGenerated]).
 */


fun processInlineFunctions ( functions : Collection < JsInlineFunctionHash > )

/**
 * Alternative to [processInlineFunction]: record all inline functions after it was processed.
 * Used in daemon RPC.
 */


{ <EOL> val jsonConfigFile = getVGG16JSONConfigFile ( ) <EOL> val model = Sequential . loadModelConfiguration ( jsonConfigFile ) <EOL> val imageNetClassLabels = Imagenet . V1k . labels ( ) <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( ) , loss = Losses . MAE , metric = Metrics . ACCURACY ) <EOL> println ( it . kGraph ) <EOL> it . logSummary ( ) <EOL> val hdfFile = getVGG16WeightsFile ( ) <EOL> it . loadWeights ( hdfFile ) <EOL> val fileLoader = pipeline < BufferedImage > ( ) <EOL> . convert { colorMode = ColorMode . BGR } <EOL> . toFloatArray { } <EOL> . call ( InputType . CAFFE . preprocessing ( ) ) <EOL> . fileLoader ( ) <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:8> ) { <EOL> val inputData = fileLoader . load ( getFileFromResource ( "<STR_LIT>" ) ) <EOL> val res = it . predict ( inputData , "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> val top5 = it . predictTop5Labels ( inputData , imageNetClassLabels ) <EOL> println ( top5 . toString ( ) ) <EOL> } <EOL> } <EOL> }

/**
 * This example demonstrates the inference concept on VGG'16 model:
 * - Weights are loaded from .h5 file, configuration is loaded from .json file.
 * - Model predicts on a few images located in resources.
 * - Special preprocessing (used in VGG'16 during training on ImageNet dataset) is applied to each image before prediction.
 * - No additional training.
 * - No new layers are added.
 *
 * @see
 * Very Deep Convolutional Networks for Large-Scale Image Recognition (ICLR 2015).
 * @see
 * Detailed description of VGG'16 model and an approach to build it in Keras.
 */


private fun getVGG16JSONConfigFile ( ) : File

{ <EOL> val properties = Properties ( ) <EOL> val reader = FileReader ( "<STR_LIT>" ) <EOL> properties . load ( reader ) <EOL> val vgg16JSONModelPath = properties [ "<STR_LIT>" ] as String <EOL> return File ( vgg16JSONModelPath ) <EOL> }

/** Returns JSON file with model configuration, saved from Keras 2.x. */


private fun getVGG16WeightsFile ( ) : HdfFile

{ <EOL> val properties = Properties ( ) <EOL> val reader = FileReader ( "<STR_LIT>" ) <EOL> properties . load ( reader ) <EOL> val vgg16h5WeightsPath = properties [ "<STR_LIT>" ] as String <EOL> return HdfFile ( File ( vgg16h5WeightsPath ) ) <EOL> }

/** Returns .h5 file with model weights, saved from Keras 2.x. */


@ Test <EOL> fun testConsumeJsMiscompilation ( )

= runTest { <EOL> val channel = Channel < Int > ( ) <EOL> assertFailsWith < IndexOutOfBoundsException > { <EOL> try { <EOL> channel . consume { null } ? : throw IndexOutOfBoundsException ( ) <EOL> } catch ( e : Exception ) { <EOL> throw e <EOL> } <EOL> } <EOL> }

/** Check that [ReceiveChannel.consume] does not suffer from KT-58685 */


@ Test <EOL> fun testConsumeClosesOnSuccess ( )

= runTest { <EOL> val channel = Channel < Int > ( ) <EOL> channel . consume { } <EOL> assertTrue ( channel . isClosedForReceive ) <EOL> }

/** Checks that [ReceiveChannel.consume] closes the channel when the block executes successfully. */


@ Test <EOL> fun testConsumeClosesOnFailure ( )

= runTest { <EOL> val channel = Channel < Int > ( ) <EOL> try { <EOL> channel . consume { throw TestException ( ) } <EOL> } catch ( e : TestException ) { <EOL> } <EOL> assertTrue ( channel . isClosedForReceive ) <EOL> }


@ Test <EOL> fun testConsumeClosesOnEarlyReturn ( )

= runTest { <EOL> val channel = Channel < Int > ( ) <EOL> fun f ( ) { <EOL> try { <EOL> channel . consume { return } <EOL> } catch ( e : TestException ) { <EOL> } <EOL> } <EOL> f ( ) <EOL> assertTrue ( channel . isClosedForReceive ) <EOL> }

/** Checks that [ReceiveChannel.consume] closes the channel when the block does an early return. */


@ Test <EOL> fun testConsumeEachClosesOnSuccess ( )

= runTest { <EOL> val channel = Channel < Int > ( Channel . UNLIMITED ) <EOL> launch { channel . close ( ) } <EOL> channel . consumeEach { fail ( "<STR_LIT>" ) } <EOL> assertTrue ( channel . isClosedForReceive ) <EOL> }


@ Test <EOL> fun testConsumeEachClosesOnFailure ( )

= runTest { <EOL> val channel = Channel < Unit > ( Channel . UNLIMITED ) <EOL> channel . send ( Unit ) <EOL> try { <EOL> channel . consumeEach { throw TestException ( ) } <EOL> } catch ( e : TestException ) { <EOL> } <EOL> assertTrue ( channel . isClosedForReceive ) <EOL> }


@ Test <EOL> fun testConsumeEachClosesOnEarlyReturn ( )

= runTest { <EOL> val channel = Channel < Unit > ( Channel . UNLIMITED ) <EOL> channel . send ( Unit ) <EOL> suspend fun f ( ) { <EOL> channel . consumeEach { <EOL> return@f <EOL> } <EOL> } <EOL> f ( ) <EOL> assertTrue ( channel . isClosedForReceive ) <EOL> }


@ Suppress ( "<STR_LIT:DEPRECATION>" , "<STR_LIT:DEPRECATION_ERROR>" ) <EOL> @ Test <EOL> fun testBroadcastChannelConsumeJsMiscompilation ( )

= runTest { <EOL> val channel = BroadcastChannel < Int > ( <NUM_LIT:1> ) <EOL> assertFailsWith < IndexOutOfBoundsException > { <EOL> try { <EOL> channel . consume { null } ? : throw IndexOutOfBoundsException ( ) <EOL> } catch ( e : Exception ) { <EOL> throw e <EOL> } <EOL> } <EOL> }

/** Check that [BroadcastChannel.consume] does not suffer from KT-58685 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun LinAlg . eig ( mat : MultiArray < Float , D2 > ) : Pair < D1Array < ComplexFloat > , D2Array < ComplexFloat > >

= <EOL> this . linAlgEx . eigF ( mat )

/**
 * Calculates the eigenvalues and eigenvectors of a float matrix
 * @return a pair of a vector of eigenvalues and a matrix of eigenvectors
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Number > LinAlg . eig ( mat : MultiArray < T , D2 > ) : Pair < D1Array < ComplexDouble > , D2Array < ComplexDouble > >

= <EOL> this . linAlgEx . eig ( mat )

/**
 * Calculates the eigenvalues and eigenvectors of a numeric matrix
 * @return a pair of a vector of eigenvalues and a matrix of eigenvectors
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Complex > LinAlg . eig ( mat : MultiArray < T , D2 > ) : Pair < D1Array < T > , D2Array < T > >

= <EOL> this . linAlgEx . eigC ( mat )

/**
 * Calculates the eigenvalues and eigenvectors of a complex matrix
 * @return a pair of a vector of eigenvalues and a matrix of eigenvectors
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun LinAlg . eigVals ( mat : MultiArray < Float , D2 > ) : D1Array < ComplexFloat >

= this . linAlgEx . eigValsF ( mat )

/**
 * Calculates the eigenvalues of a float matrix
 * @return [ComplexFloat] vector
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Number > LinAlg . eigVals ( mat : MultiArray < T , D2 > ) : D1Array < ComplexDouble >

= this . linAlgEx . eigVals ( mat )

/**
 * Calculates the eigenvalues of a numeric matrix.
 * @return [ComplexDouble] vector
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Complex > LinAlg . eigVals ( mat : MultiArray < T , D2 > ) : D1Array < T >

= this . linAlgEx . eigValsC ( mat )

/**
 * Calculates the eigenvalues of a float matrix
 * @return complex vector
 */