private fun FirCallableDeclaration . loadCallableSpecificExperimentalities ( symbol : FirBasedSymbol < * > , context : CheckerContext , visited : MutableSet < FirDeclaration > , fromSetter : Boolean , dispatchReceiverType : ConeKotlinType ? , result : SmartSet < Experimentality > )

{ <EOL> val parentClassSymbol = containingClassLookupTag ( ) ? . toSymbol ( context . session ) as? FirRegularClassSymbol <EOL> if ( this is FirConstructor ) { <EOL> val ownerClassLikeSymbol = this . typeAliasForConstructor ? : parentClassSymbol <EOL> ownerClassLikeSymbol ? . loadExperimentalities ( context , result , visited , fromSetter = false , dispatchReceiverType = null , fromSupertype = false ) <EOL> } else { <EOL> returnTypeRef . coneTypeSafe < ConeKotlinType > ( ) . addExperimentalities ( context , result , visited ) <EOL> receiverParameter ? . typeRef ? . coneType . addExperimentalities ( context , result , visited ) <EOL> } <EOL> dispatchReceiverType ? . addExperimentalities ( context , result , visited ) <EOL> if ( this is FirFunction ) { <EOL> valueParameters . forEach { <EOL> it . returnTypeRef . coneType . addExperimentalities ( context , result , visited ) <EOL> } <EOL> if ( parentClassSymbol ? . isData == true && DataClassResolver . isComponentLike ( this . nameOrSpecialName ) && parentClassSymbol . classKind == ClassKind . CLASS ) { <EOL> val componentNIndex = DataClassResolver . getComponentIndex ( this . nameOrSpecialName . identifier ) <EOL> val valueParameters = parentClassSymbol . primaryConstructorSymbol ( context . session ) ? . valueParameterSymbols <EOL> val valueParameter = valueParameters ? . getOrNull ( componentNIndex - <NUM_LIT:1> ) <EOL> val properties = parentClassSymbol . declarationSymbols . filterIsInstance < FirPropertySymbol > ( ) <EOL> val property = properties . firstOrNull { it . name == valueParameter ? . name } <EOL> property ? . loadExperimentalities ( context , result , visited , fromSetter = false , dispatchReceiverType , fromSupertype = false ) <EOL> } <EOL> } <EOL> if ( fromSetter && symbol is FirPropertySymbol ) { <EOL> symbol . setterSymbol ? . loadExperimentalities ( context , result , visited , fromSetter = false , dispatchReceiverType , fromSupertype = false ) <EOL> } <EOL> }


private fun FirClassLikeDeclaration . loadClassLikeSpecificExperimentalities ( symbol : FirBasedSymbol < * > , context : CheckerContext , visited : MutableSet < FirDeclaration > , result : SmartSet < Experimentality > )

{ <EOL> when ( this ) { <EOL> is FirRegularClass -> if ( symbol is FirRegularClassSymbol ) { <EOL> val parentClassSymbol = symbol . outerClassSymbol ( context ) <EOL> parentClassSymbol ? . loadExperimentalities ( context , result , visited , fromSetter = false , dispatchReceiverType = null , fromSupertype = false ) <EOL> } <EOL> is FirAnonymousObject , is FirTypeAlias -> { <EOL> } <EOL> } <EOL> }


private fun ConeKotlinType ? . addExperimentalities ( context : CheckerContext , result : SmartSet < Experimentality > , visited : MutableSet < FirDeclaration > = mutableSetOf ( ) )

{ <EOL> if ( this !is ConeClassLikeType ) return <EOL> lookupTag . toSymbol ( context . session ) ? . loadExperimentalities ( context , result , visited , fromSetter = false , dispatchReceiverType = null , fromSupertype = false ) <EOL> fullyExpandedType ( context . session ) . typeArguments . forEach { <EOL> if ( ! it . isStarProjection ) it . type ? . addExperimentalities ( context , result , visited ) <EOL> } <EOL> }


private fun FirRegularClass . loadExperimentalityForMarkerAnnotation ( session : FirSession , annotatedOwnerClassName : String ? = null ) : Experimentality ?

{ <EOL> val experimental = getAnnotationByClassId ( OptInNames . REQUIRES_OPT_IN_CLASS_ID , session ) <EOL> ? : return null <EOL> val levelArgument = experimental . findArgumentByName ( LEVEL ) <EOL> val levelName = levelArgument ? . extractEnumValueArgumentInfo ( ) ? . enumEntryName ? . asString ( ) <EOL> val severity = Experimentality . Severity . entries . firstOrNull { it . name == levelName } ? : Experimentality . DEFAULT_SEVERITY <EOL> val message = ( experimental . findArgumentByName ( MESSAGE ) as? FirLiteralExpression < * > ) ? . value as? String <EOL> return Experimentality ( symbol . classId , severity , message , annotatedOwnerClassName ) <EOL> }


fun reportNotAcceptedExperimentalities ( experimentalities : Collection < Experimentality > , element : FirElement , context : CheckerContext , reporter : DiagnosticReporter , source : KtSourceElement ? = element . source , )

{ <EOL> for ( ( annotationClassId , severity , message , _ , fromSupertype ) in experimentalities ) { <EOL> if ( ! isExperimentalityAcceptableInContext ( annotationClassId , context , fromSupertype ) ) { <EOL> val ( diagnostic , verb ) = when ( severity ) { <EOL> Experimentality . Severity . WARNING -> FirErrors . OPT_IN_USAGE to "<STR_LIT>" <EOL> Experimentality . Severity . ERROR -> FirErrors . OPT_IN_USAGE_ERROR to "<STR_LIT>" <EOL> } <EOL> val reportedMessage = message ? . takeIf { it . isNotBlank ( ) } <EOL> ? : OptInNames . buildDefaultDiagnosticMessage ( OptInNames . buildMessagePrefix ( verb ) , annotationClassId . asFqNameString ( ) ) <EOL> reporter . reportOn ( source , diagnostic , annotationClassId , reportedMessage , context ) <EOL> } <EOL> } <EOL> }


@ SymbolInternals <EOL> fun reportNotAcceptedOverrideExperimentalities ( experimentalities : Collection < Experimentality > , symbol : FirCallableSymbol < * > , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> for ( ( annotationClassId , severity , markerMessage , supertypeName ) in experimentalities ) { <EOL> if ( ! symbol . fir . isExperimentalityAcceptable ( context . session , annotationClassId , fromSupertype = false ) && ! isExperimentalityAcceptableInContext ( annotationClassId , context , fromSupertype = false ) ) { <EOL> val ( diagnostic , verb ) = when ( severity ) { <EOL> Experimentality . Severity . WARNING -> FirErrors . OPT_IN_OVERRIDE to "<STR_LIT>" <EOL> Experimentality . Severity . ERROR -> FirErrors . OPT_IN_OVERRIDE_ERROR to "<STR_LIT>" <EOL> } <EOL> val message = OptInNames . buildOverrideMessage ( supertypeName ? : "<STR_LIT>" , markerMessage , verb , markerName = annotationClassId . asFqNameString ( ) ) <EOL> reporter . reportOn ( symbol . source , diagnostic , annotationClassId , message , context ) <EOL> } <EOL> } <EOL> }


private fun isExperimentalityAcceptableInContext ( annotationClassId : ClassId , context : CheckerContext , fromSupertype : Boolean ) : Boolean

{ <EOL> val languageVersionSettings = context . session . languageVersionSettings <EOL> val fqNameAsString = annotationClassId . asFqNameString ( ) <EOL> if ( fqNameAsString in languageVersionSettings . getFlag ( AnalysisFlags . optIn ) ) { <EOL> return true <EOL> } <EOL> for ( annotationContainer in context . annotationContainers ) { <EOL> if ( annotationContainer . isExperimentalityAcceptable ( context . session , annotationClassId , fromSupertype ) ) { <EOL> return true <EOL> } <EOL> } <EOL> return false <EOL> }


private fun FirAnnotationContainer . isExperimentalityAcceptable ( session : FirSession , annotationClassId : ClassId , fromSupertype : Boolean ) : Boolean

{ <EOL> return getAnnotationByClassId ( annotationClassId , session ) != null || <EOL> isAnnotatedWithOptIn ( annotationClassId , session ) || <EOL> fromSupertype && isAnnotatedWithSubclassOptInRequired ( session , annotationClassId ) || <EOL> primaryConstructorParameterIsExperimentalityAcceptable ( session , annotationClassId ) || <EOL> isImplicitDeclaration ( ) <EOL> }


private fun FirAnnotationContainer . isImplicitDeclaration ( ) : Boolean

{ <EOL> return this is FirDeclaration && this . origin != FirDeclarationOrigin . Source <EOL> }


@ OptIn ( SymbolInternals :: class ) <EOL> private fun FirAnnotationContainer . primaryConstructorParameterIsExperimentalityAcceptable ( session : FirSession , annotationClassId : ClassId ) : Boolean

{ <EOL> if ( this !is FirProperty ) return false <EOL> val parameterSymbol = correspondingValueParameterFromPrimaryConstructor ? : return false <EOL> return parameterSymbol . fir . isExperimentalityAcceptable ( session , annotationClassId , fromSupertype = false ) <EOL> }


private fun FirAnnotationContainer . isAnnotatedWithOptIn ( annotationClassId : ClassId , session : FirSession ) : Boolean

{ <EOL> for ( annotation in annotations ) { <EOL> val coneType = annotation . annotationTypeRef . coneType as? ConeClassLikeType <EOL> if ( coneType ? . lookupTag ? . classId != OptInNames . OPT_IN_CLASS_ID ) { <EOL> continue <EOL> } <EOL> val annotationClasses = annotation . findArgumentByName ( OptInNames . OPT_IN_ANNOTATION_CLASS ) ? : continue <EOL> if ( annotationClasses . extractClassesFromArgument ( session ) . any { it . classId == annotationClassId } ) { <EOL> return true <EOL> } <EOL> } <EOL> return false <EOL> }


private fun FirAnnotationContainer . isAnnotatedWithSubclassOptInRequired ( session : FirSession , annotationClassId : ClassId ) : Boolean

{ <EOL> for ( annotation in annotations ) { <EOL> val coneType = annotation . annotationTypeRef . coneType as? ConeClassLikeType <EOL> if ( coneType ? . lookupTag ? . classId != OptInNames . SUBCLASS_OPT_IN_REQUIRED_CLASS_ID ) { <EOL> continue <EOL> } <EOL> val annotationClass = annotation . findArgumentByName ( OptInNames . OPT_IN_ANNOTATION_CLASS ) ? : continue <EOL> if ( annotationClass . extractClassFromArgument ( session ) ? . classId == annotationClassId ) { <EOL> return true <EOL> } <EOL> } <EOL> return false <EOL> }


{ <EOL> try { <EOL> return "<STR_LIT:OK>" <EOL> if ( <NUM_LIT:1> == <NUM_LIT:1> ) { <EOL> val z = <NUM_LIT:2> <EOL> } <EOL> if ( <NUM_LIT:3> == <NUM_LIT:3> ) { <EOL> val z = <NUM_LIT:4> <EOL> } <EOL> } finally { <EOL> } <EOL> }


fun append ( charCode : Int , categoryId : String ) : Boolean

/**
 * Appends the [charCode] to this range pattern.
 * Returns true if the [charCode] with the specified [categoryId] could be accommodated within this pattern.
 * Returns false otherwise.
 */


fun prepend ( charCode : Int , categoryId : String ) : Boolean

/**
 * Prepends the [charCode] to this range pattern.
 * Returns true if the [charCode] with the specified [categoryId] could be accommodated within this pattern.
 * Returns false otherwise.
 */


fun rangeStart ( ) : Int

/**
 * Char code of the first char in this range.
 */


fun rangeEnd ( ) : Int

/**
 * Char code of the last char in this range.
 */


fun category ( ) : Int

/**
 * An integer value that contains information about the category of each char in this range.
 */


fun categoryIdOf ( charCode : Int ) : String

/**
 * Returns category id of the char with the specified [charCode].
 * Throws an exception if the [charCode] is not in `rangeStart()..rangeEnd()`.
 */


internal fun RangePattern . rangeLength ( ) : Int

= rangeEnd ( ) - rangeStart ( ) + <NUM_LIT:1>


internal fun RangePattern . append ( rangeStart : Int , rangeEnd : Int , categoryIdOf : ( Int ) -> String , charCode : Int , categoryId : String ) : Boolean

{ <EOL> for ( code in rangeStart .. rangeEnd ) { <EOL> if ( ! append ( code , categoryIdOf ( code ) ) ) { <EOL> return false <EOL> } <EOL> } <EOL> if ( ! append ( charCode , categoryId ) ) { <EOL> return false <EOL> } <EOL> return true <EOL> }


{ <EOL> assertArrayEquals ( arrayOf ( arrayOf ( <NUM_LIT:1> , <NUM_LIT:2> ) , arrayOf ( <NUM_LIT:3> , <NUM_LIT:4> ) ) , arrayOf ( arrayOf ( fizz ( <NUM_LIT:1> ) , buzz ( <NUM_LIT:2> ) ) , arrayOf ( fizz ( <NUM_LIT:3> ) , buzz ( <NUM_LIT:4> ) ) ) ) <EOL> assertEquals ( "<STR_LIT>" , pullLog ( ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


fun withAttributes ( changeAttributes : KotlinHighlightingAttributes . ( ) -> Unit ) : KotlinHighlightingAttributes

{ <EOL> val attributes = KotlinHighlightingAttributes ( ) <EOL> attributes . changeAttributes ( ) <EOL> return attributes <EOL> }


override fun transformFlat ( declaration : IrDeclaration ) : List < IrDeclaration > ?

{ <EOL> if ( declaration !is IrConstructor || ! declaration . isPrimary ) return null <EOL> val irClass = declaration . parentAsClass <EOL> if ( irClass . kind != ClassKind . ANNOTATION_CLASS ) return null <EOL> declaration . body = declaration . factory . createBlockBody ( declaration . startOffset , declaration . endOffset ) { <EOL> if ( context . es6mode ) { <EOL> statements += IrDelegatingConstructorCallImpl ( startOffset , endOffset , context . irBuiltIns . anyType , anyConstructor , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> } <EOL> statements += IrInstanceInitializerCallImpl ( startOffset , endOffset , irClass . symbol , unitType ) <EOL> } <EOL> return null <EOL> }


override fun configure ( target : KotlinAndroidTarget , kotlinSourceSet : KotlinSourceSet , @ Suppress ( "<STR_LIT:TYPEALIAS_EXPANSION_DEPRECATION>" ) androidSourceSet : DeprecatedAndroidSourceSet )

{ <EOL> if ( ! androidSourceSet . name . startsWith ( target . disambiguationClassifier ) ) { <EOL> kotlinSourceSet . kotlin . srcDir ( "<STR_LIT>" ) <EOL> } <EOL> }


operator fun Product . contains ( item : Any ? ) : Boolean

= productIterator ( ) . contains ( item )

/** Tests whether this iterator contains a given value as an element.
 * Note: may not terminate for infinite iterators.
 *
 * @param item the element to test.
 * @return `true` if this iterator produces some value that
 * is equal (as determined by `==`) to `elem`, `false` otherwise.
 * @note Reuse: After calling this method, one should discard the iterator it was called on.
 * Using it is undefined and subject to change.
 */


operator fun Product . iterator ( ) : Iterator < Any ? >

= JavaConverters . asJavaIterator ( productIterator ( ) )

/**
 * An iterator over all the elements of this product.
 * @return in the default implementation, an `Iterator<Any?>`
 */


fun Product . asIterable ( ) : Iterable < Any ? >

= object : Iterable < Any ? > { <EOL> override fun iterator ( ) : Iterator < Any ? > = JavaConverters . asJavaIterator ( productIterator ( ) ) <EOL> }

/**
 * Converts this product to an `Any?` iterable.
 */


@ Throws ( IndexOutOfBoundsException :: class ) <EOL> operator fun Product . get ( n : Int ) : Any ?

= productElement ( n )

/** The n'th element of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 *
 * @param n the index of the element to return
 * @throws IndexOutOfBoundsException
 * @return the element `n` elements after the first element
 */


fun Product . getOrNull ( n : Int ) : Any ?

= if ( n in <NUM_LIT:0> until size ) productElement ( n ) else null

/** The n'th element of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 *
 * @param n the index of the element to return
 * @return the element `n` elements after the first element, `null` if out of bounds
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> @ Throws ( IndexOutOfBoundsException :: class , ClassCastException :: class ) <EOL> inline fun < reified T > Product . getAs ( n : Int ) : T

= productElement ( n ) as T

/** The n'th element of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 * The result is cast to the given type [T].
 *
 * @param n the index of the element to return
 * @throws IndexOutOfBoundsException
 * @throws ClassCastException
 * @return the element `n` elements after the first element
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> inline fun < reified T > Product . getAsOrNull ( n : Int ) : T ?

= getOrNull ( n ) as? T

/** The n'th element of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 * The result is cast to the given type [T].
 *
 * @param n the index of the element to return
 * @return the element `n` elements after the first element, `null` if out of bounds or unable to be cast
 */


@ Throws ( IndexOutOfBoundsException :: class ) <EOL> operator fun Product . get ( indexRange : IntRange ) : List < Any ? >

= indexRange . map ( :: get )

/** The range of n'th elements of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 *
 * @param indexRange the indices of the elements to return
 * @throws IndexOutOfBoundsException
 * @return the elements in [indexRange]
 */


fun Product . getOrNull ( indexRange : IntRange ) : List < Any ? >

= indexRange . map ( :: getOrNull )

/** The range of n'th elements of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 *
 * @param indexRange the indices of the elements to return
 * @return the elements in [indexRange], `null` if out of bounds
 */


@ Throws ( IndexOutOfBoundsException :: class , ClassCastException :: class ) <EOL> inline fun < reified T > Product . getAs ( indexRange : IntRange ) : List < T >

= indexRange . map ( :: getAs )

/** The range of n'th elements of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 * The results are cast to the given type [T].
 *
 * @param indexRange the indices of the elements to return
 * @throws IndexOutOfBoundsException
 * @throws ClassCastException
 * @return the elements in [indexRange]
 */


inline fun < reified T > Product . getAsOrNull ( indexRange : IntRange ) : List < T ? >

= indexRange . map ( :: getAsOrNull )

/** The range of n'th elements of this product, 0-based. In other words, for a
 * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 <= n < k`.
 * The results are cast to the given type [T].
 *
 * @param indexRange the indices of the elements to return
 * @return the elements in [indexRange], `null` is out of bounds or unable to be cast
 */


fun RepositoryHandler . mavenCentralCacheRedirector ( ) : MavenArtifactRepository

= <EOL> maven { it . setUrl ( "<STR_LIT>" ) }


{ <EOL> check ( Base ( "<STR_LIT:O>" , Base ( "<STR_LIT:K>" ) ) , "<STR_LIT:OK>" ) <EOL> check ( Override ( "<STR_LIT:OK>" ) , "<STR_LIT>" ) <EOL> check ( OverOverride ( "<STR_LIT:OK>" ) , "<STR_LIT>" ) <EOL> return "<STR_LIT:OK>" <EOL> }


fun check ( t : Throwable , msg : String )

{ <EOL> try { <EOL> throw t <EOL> } catch ( e : Throwable ) { <EOL> val c = t . cause <EOL> val m = if ( c != null ) t . message ! ! + c . message ! ! else t . message ! ! <EOL> if ( m != msg ) throw AssertionError ( m ) <EOL> } <EOL> }


= <NUM_LIT>


{ <EOL> val x = A ( ) <EOL> val y = A ( ) <EOL> val map = mutableMapOf < A , Int > ( ) <EOL> map [ x ] = <NUM_LIT:1> <EOL> assertEquals ( <NUM_LIT:1> , map . size ) <EOL> map . remove ( y ) <EOL> assertEquals ( <NUM_LIT:1> , map . size ) <EOL> map . remove ( x ) <EOL> assertEquals ( <NUM_LIT:0> , map . size ) <EOL> return "<STR_LIT:OK>" <EOL> }


= println ( "<STR_LIT:Hello>" )


fun compare ( o1 : String ? , o2 : String ? ) : Int

{ <EOL> val l1 = o1 ? . length ? : <NUM_LIT:0> <EOL> val l2 = o2 ? . length ? : <NUM_LIT:0> <EOL> return l1 - l2 <EOL> }


{ <EOL> ( System . getProperty ( "<STR_LIT>" ) ? . length ? : <NUM_LIT:4> ) * <NUM_LIT> + <NUM_LIT:5> <EOL> val x = System . getProperty ( "<STR_LIT>" ) ? . length ? : <NUM_LIT:4> <EOL> x * <NUM_LIT> + <NUM_LIT:5> <EOL> }


{ <EOL> f { println ( "<STR_LIT>" ) } <EOL> }


private fun readFrom ( json : JsonReader ) : State ?

{ <EOL> val result = State ( ) <EOL> json . obj { <EOL> check ( json . nextName ( ) == "<STR_LIT>" ) <EOL> val version = json . nextString ( ) <EOL> if ( version != this . version ) return null <EOL> check ( json . nextName ( ) == "<STR_LIT>" ) <EOL> json . obj { <EOL> while ( json . peek ( ) == JsonToken . NAME ) { <EOL> val key = json . nextName ( ) <EOL> json . beginObject ( ) <EOL> check ( json . nextName ( ) == "<STR_LIT:src>" ) <EOL> val src = json . nextString ( ) <EOL> var target : String ? = null <EOL> if ( json . peek ( ) == JsonToken . NAME ) { <EOL> check ( json . nextName ( ) == "<STR_LIT>" ) <EOL> if ( json . peek ( ) != JsonToken . NULL ) { <EOL> target = json . nextString ( ) <EOL> } <EOL> } <EOL> json . endObject ( ) <EOL> result [ decodeHexString ( key ) ] = Element ( src , target ) <EOL> } <EOL> } <EOL> } <EOL> return result <EOL> }


private fun State . writeTo ( json : JsonWriter )

{ <EOL> json . obj { <EOL> json . name ( "<STR_LIT>" ) . value ( version ) <EOL> json . name ( "<STR_LIT>" ) <EOL> json . obj { <EOL> byHash . forEach { <EOL> json . name ( it . key . contents . toHex ( ) ) <EOL> json . obj { <EOL> json . name ( "<STR_LIT:src>" ) . value ( it . value . src ) <EOL> json . name ( "<STR_LIT>" ) <EOL> if ( it . value . target == null ) json . nullValue ( ) else json . value ( it . value . target ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> }


private inline fun JsonReader . obj ( body : ( ) -> Unit )

{ <EOL> beginObject ( ) <EOL> body ( ) <EOL> endObject ( ) <EOL> }


private inline fun JsonWriter . obj ( body : ( ) -> Unit )


private fun decodeHexString ( hexString : String ) : ByteArray

{ <EOL> check ( hexString . length % <NUM_LIT:2> == <NUM_LIT:0> ) <EOL> val bytes = ByteArray ( hexString . length / <NUM_LIT:2> ) <EOL> var i = <NUM_LIT:0> <EOL> var o = <NUM_LIT:0> <EOL> while ( i < hexString . length ) { <EOL> bytes [ o ++ ] = hexToByte ( hexString [ i ++ ] , hexString [ i ++ ] ) <EOL> } <EOL> return bytes <EOL> }


private fun hexToByte ( a : Char , b : Char ) : Byte

= ( ( a . toDigit ( ) shl <NUM_LIT:4> ) + b . toDigit ( ) ) . toByte ( )


= Character . digit ( this , <NUM_LIT:16> ) . also { check ( it != - <NUM_LIT:1> ) }


override fun equals ( other : Any ? ) : Boolean

{ <EOL> if ( this === other ) return true <EOL> if ( javaClass != other ? . javaClass ) return false <EOL> other as ByteArrayWrapper <EOL> if ( ! contents . contentEquals ( other . contents ) ) return false <EOL> return true <EOL> }


{ <EOL> return contents . contentHashCode ( ) <EOL> }


operator fun get ( elementHash : ByteArray )

= byHash [ ByteArrayWrapper ( elementHash ) ]


operator fun set ( elementHash : ByteArray , element : Element )

{ <EOL> byHash [ ByteArrayWrapper ( elementHash ) ] = element <EOL> val target = element . target <EOL> if ( target != null ) { <EOL> byTarget [ target ] = element <EOL> } <EOL> }


{ <EOL> if ( element . target != null ) { <EOL> byTarget . remove ( element . target ) <EOL> } <EOL> byHash . values . removeIf { it == element } <EOL> }


internal fun getOrCompute ( file : File , compute : ( ) -> File ? <EOL> ) : File ?

= getOrComputeKey ( file , compute ) ? . let { File ( targetDir , it ) }


private fun getOrComputeKey ( file : File , compute : ( ) -> File ? <EOL> ) : String ?

{ <EOL> if ( ! file . exists ( ) ) { <EOL> return null <EOL> } <EOL> val hash = fileHasher . hash ( file ) . toByteArray ( ) <EOL> val old = state [ hash ] <EOL> if ( old != null ) { <EOL> if ( checkTarget ( old . target ) ) return old . target <EOL> else System . err . println ( "<STR_LIT>" ) <EOL> } <EOL> val key = compute ( ) ? . relativeTo ( targetDir ) ? . toString ( ) <EOL> val existedTarget = state . byTarget [ key ] <EOL> if ( key != null && existedTarget != null ) { <EOL> if ( ! File ( existedTarget . src ) . exists ( ) ) { <EOL> System . err . println ( "<STR_LIT>" ) <EOL> state . remove ( existedTarget ) <EOL> } <EOL> } <EOL> state [ hash ] = Element ( file . normalize ( ) . absolutePath , key ) <EOL> return key <EOL> }


private fun checkTarget ( target : String ? ) : Boolean

{ <EOL> if ( target == null ) return true <EOL> return targetDir . resolve ( target ) . exists ( ) <EOL> }


{ <EOL> stateFile . parentFile . mkdirs ( ) <EOL> GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) . newJsonWriter ( stateFile . writer ( ) ) . use { <EOL> state . writeTo ( it ) <EOL> } <EOL> }


{ <EOL> targetDir . walkTopDown ( ) . filter { it . isDirectory && it . name == "<STR_LIT:build>" } . forEach { <EOL> checkReferences ( it ) <EOL> } <EOL> }


protected abstract fun checkReferences ( buildDir : File )


protected fun ByteArray . findAtomicfuRef ( ) : Boolean

{ <EOL> loop @ for ( i in <NUM_LIT:0> .. this . size - ATOMIC_FU_REF . size ) { <EOL> for ( j in ATOMIC_FU_REF . indices ) { <EOL> if ( this [ i + j ] != ATOMIC_FU_REF [ j ] ) continue@loop <EOL> } <EOL> return true <EOL> } <EOL> return false <EOL> }


override fun checkReferences ( buildDir : File )

{ <EOL> if ( gradleBuild . enableJvmIrTransformation ) { <EOL> buildDir . walkDirAndCheckBytecode ( skipMetadata = true ) <EOL> } else { <EOL> val atomicfuDir = buildDir . resolve ( "<STR_LIT>" ) <EOL> if ( atomicfuDir . exists ( ) && atomicfuDir . isDirectory ) { <EOL> atomicfuDir . walkDirAndCheckBytecode ( skipMetadata = false ) <EOL> } <EOL> } <EOL> }


private fun File . walkDirAndCheckBytecode ( skipMetadata : Boolean )

{ <EOL> walkBottomUp ( ) . filter { it . isFile && it . name . endsWith ( "<STR_LIT>" ) } . forEach { clazz -> <EOL> val atomicfuRefFound = clazz . readBytes ( ) . let { <EOL> if ( skipMetadata ) it . eraseMetadata ( ) . findAtomicfuRef ( ) else it . findAtomicfuRef ( ) <EOL> } <EOL> assertFalse ( atomicfuRefFound , "<STR_LIT>" ) <EOL> } <EOL> }


private fun ByteArray . eraseMetadata ( ) : ByteArray

{ <EOL> val cw = ClassWriter ( <NUM_LIT:0> ) <EOL> ClassReader ( this ) . accept ( object : ClassVisitor ( Opcodes . ASM9 , cw ) { <EOL> override fun visitAnnotation ( descriptor : String ? , visible : Boolean ) : AnnotationVisitor ? { <EOL> return if ( descriptor == KOTLIN_METADATA_DESC ) null else super . visitAnnotation ( descriptor , visible ) <EOL> } <EOL> } , ClassReader . SKIP_FRAMES ) <EOL> return cw . toByteArray ( ) <EOL> }


private fun invokeKlibTool ( kotlinNativeClassLoader : ClassLoader ? , klibFile : File , functionName : String , hasOutput : Boolean , vararg args : Any ) : String

{ <EOL> val libraryClass = Class . forName ( "<STR_LIT>" , true , kotlinNativeClassLoader ) <EOL> val entryPoint = libraryClass . declaredMethods . single { it . name == functionName } <EOL> val lib = libraryClass . getDeclaredConstructor ( String :: class . java , String :: class . java , String :: class . java ) <EOL> . newInstance ( klibFile . canonicalPath , null , "<STR_LIT>" ) <EOL> val output = StringBuilder ( ) <EOL> if ( args . isNotEmpty ( ) ) { <EOL> entryPoint . invoke ( lib , output , * args ) <EOL> } else if ( hasOutput ) { <EOL> entryPoint . invoke ( lib , output ) <EOL> } else { <EOL> entryPoint . invoke ( lib ) <EOL> } <EOL> return output . toString ( ) <EOL> }


{ <EOL> val classesDir = buildDir . resolve ( "<STR_LIT>" ) <EOL> if ( classesDir . exists ( ) && classesDir . isDirectory ) { <EOL> classesDir . walkBottomUp ( ) . singleOrNull { it . isFile && it . name == "<STR_LIT>" } ? . let { klib -> <EOL> val klibIr = invokeKlibTool ( kotlinNativeClassLoader = classLoader , klibFile = klib , functionName = "<STR_LIT>" , hasOutput = true , false ) <EOL> assertFalse ( klibIr . toByteArray ( ) . findAtomicfuRef ( ) , "<STR_LIT>" ) <EOL> } ? : error ( "<STR_LIT>" ) <EOL> } <EOL> }


internal fun GradleBuild . buildAndCheckBytecode ( )

{ <EOL> val buildResult = cleanAndBuild ( ) <EOL> require ( buildResult . isSuccessful ) { "<STR_LIT>" } <EOL> BytecodeChecker ( this ) . checkClassesInBuildDirectories ( ) <EOL> }


internal fun GradleBuild . buildAndCheckNativeKlib ( )

{ <EOL> val buildResult = cleanAndBuild ( ) <EOL> require ( buildResult . isSuccessful ) { "<STR_LIT>" } <EOL> KlibChecker ( this . targetDir ) . checkClassesInBuildDirectories ( ) <EOL> }


override fun iterator ( ) : MutableIterator < T >

= it . iterator ( )


override fun reportMetric ( name : String , value : Boolean , subprojectName : String ? )


override fun reportMetric ( name : String , value : Number , subprojectName : String ? )


override fun reportMetric ( name : String , value : String , subprojectName : String ? )


suspend fun < T > suspendWithResult ( value : T ) : T

= suspendCoroutineUninterceptedOrReturn { c -> <EOL> c . resume ( value ) <EOL> COROUTINE_SUSPENDED <EOL> }


fun builder ( c : suspend Controller . ( ) -> Unit ) : String

{ <EOL> val controller = Controller ( ) <EOL> c . startCoroutine ( controller , EmptyContinuation ) <EOL> return controller . result <EOL> }


{ <EOL> var value = builder { <EOL> outer @ for ( x in listOf ( "<STR_LIT:O>" , "<STR_LIT:K>" ) ) { <EOL> result += suspendWithResult ( x ) <EOL> for ( y in listOf ( "<STR_LIT>" , "<STR_LIT>" ) ) { <EOL> result += suspendWithResult ( y ) <EOL> if ( y == "<STR_LIT>" ) { <EOL> break@outer <EOL> } <EOL> } <EOL> } <EOL> result += "<STR_LIT:.>" <EOL> } <EOL> if ( value != "<STR_LIT>" ) return "<STR_LIT>" <EOL> value = builder { <EOL> for ( x in listOf ( "<STR_LIT:O>" , "<STR_LIT:K>" ) ) { <EOL> result += suspendWithResult ( x ) <EOL> for ( y in listOf ( "<STR_LIT>" , "<STR_LIT>" ) ) { <EOL> if ( y == "<STR_LIT>" ) { <EOL> break <EOL> } <EOL> result += suspendWithResult ( y ) <EOL> } <EOL> } <EOL> result += "<STR_LIT:.>" <EOL> } <EOL> if ( value != "<STR_LIT>" ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


override fun equals ( other : Any ? ) : Boolean

= <EOL> super . equals ( other )


override operator fun equals ( other : Any ? ) : Boolean

= <EOL> super . equals ( other )


= <EOL> super . equals ( other )


fun Collection < Int > . sumIndices ( ) : Int

{ <EOL> var sum = <NUM_LIT:0> <EOL> for ( i in indices ) { <EOL> sum += i <EOL> } <EOL> return sum <EOL> }


{ <EOL> Any ( ) as String <EOL> }


{ <EOL> try { <EOL> foo ( ) <EOL> } catch ( e : Throwable ) { <EOL> return "<STR_LIT:OK>" <EOL> } <EOL> return "<STR_LIT:Fail>" <EOL> }


= throw Exception ( )


@ Test <EOL> fun `test - jvm project - kotlin with java compilation - setting classpath on javaSourceSet` ( )

{ <EOL> val project = buildProjectWithJvm { <EOL> enableDefaultStdlibDependency ( false ) <EOL> } <EOL> val customJavaSourceSet = project . javaSourceSets . create ( "<STR_LIT>" ) <EOL> val customKotlinSourceSet = project . kotlinJvmExtension . sourceSets . getByName ( "<STR_LIT>" ) <EOL> val customKotlinCompilation = project . kotlinJvmExtension . target . compilations . getByName ( "<STR_LIT>" ) <EOL> assertSame ( customKotlinSourceSet , customKotlinCompilation . defaultSourceSet ) <EOL> assertSame ( customJavaSourceSet , customKotlinCompilation . javaSourceSet ) <EOL> customJavaSourceSet . compileClasspath = project . files ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> customJavaSourceSet . runtimeClasspath = project . files ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> assertEquals ( project . files ( "<STR_LIT>" , "<STR_LIT>" ) . files , customKotlinCompilation . compileDependencyFiles . files ) <EOL> assertEquals ( project . files ( "<STR_LIT>" , "<STR_LIT>" ) . files , customKotlinCompilation . runtimeDependencyFiles . files ) <EOL> }


@ GCUnsafeCall ( "<STR_LIT>" ) <EOL> @ ObsoleteWorkersApi <EOL> @ Escapes ( <NUM_LIT> ) <EOL> external private fun createWorkerBoundReference ( value : Any ) : NativePtr


@ GCUnsafeCall ( "<STR_LIT>" ) <EOL> @ ObsoleteWorkersApi <EOL> external private fun derefWorkerBoundReference ( ref : NativePtr ) : Any ?


@ GCUnsafeCall ( "<STR_LIT>" ) <EOL> @ ObsoleteWorkersApi <EOL> external private fun describeWorkerBoundReference ( ref : NativePtr ) : String


@ ExportForCppRuntime ( "<STR_LIT>" ) <EOL> private fun freezeHook ( )

{ <EOL> if ( valueBeforeFreezing == null ) <EOL> return <EOL> ptr = createWorkerBoundReference ( valueBeforeFreezing ! ! ) <EOL> valueBeforeFreezing = null <EOL> }


fun bar ( a : Any ) : Number


external fun withObjectTypeParam ( opt : `T$0` )


external fun returnsObjectType ( ) : `T$1`


fun baz ( a : Any , b : Any , c : String ) : Boolean


fun setTextColorWithAnotherMethod ( color : Int )

{ <EOL> this . textColor = color <EOL> setTextColor ( textColor ! ! ) <EOL> }


override fun onRestoreInstanceState ( state : Parcelable )

{ <EOL> super . onRestoreInstanceState ( state ) <EOL> if ( textColor != null ) { <EOL> setTextColorWithAnotherMethod ( textColor ! ! ) <EOL> } <EOL> }


internal fun nextafter ( _x : Double , _y : Double ) : Double

{ <EOL> var x : Double = _x <EOL> var y : Double = _y <EOL> var hx : Int <EOL> var hy : Int <EOL> var ix : Int <EOL> var iy : Int <EOL> var lx : UInt <EOL> var ly : UInt <EOL> hx = __HI ( x ) <EOL> lx = __LOu ( x ) <EOL> hy = __HI ( y ) <EOL> ly = __LOu ( y ) <EOL> ix = hx and <NUM_LIT> <EOL> iy = hy and <NUM_LIT> <EOL> if ( ( ( ix >= <NUM_LIT> ) && ( ( ix - <NUM_LIT> ) or lx . toInt ( ) ) != <NUM_LIT:0> ) || ( ( iy >= <NUM_LIT> ) && ( ( iy - <NUM_LIT> ) or ly . toInt ( ) ) != <NUM_LIT:0> ) ) <EOL> return x + y <EOL> if ( x == y ) return x <EOL> if ( ( ix or lx . toInt ( ) ) == <NUM_LIT:0> ) { <EOL> x = doubleSetWord ( d = x , hi = hy and Int . MIN_VALUE ) <EOL> x = doubleSetWord ( d = x , lo = <NUM_LIT:1> ) <EOL> y = x * x <EOL> if ( y == x ) return y ; else return x <EOL> } <EOL> if ( hx >= <NUM_LIT:0> ) { <EOL> if ( hx > hy || ( ( hx == hy ) && ( lx > ly ) ) ) { <EOL> if ( lx == <NUM_LIT> ) hx -= <NUM_LIT:1> <EOL> lx -= <NUM_LIT> <EOL> } else { <EOL> lx += <NUM_LIT> <EOL> if ( lx == <NUM_LIT> ) hx += <NUM_LIT:1> <EOL> } <EOL> } else { <EOL> if ( hy >= <NUM_LIT:0> || hx > hy || ( ( hx == hy ) && ( lx > ly ) ) ) { <EOL> if ( lx == <NUM_LIT> ) hx -= <NUM_LIT:1> <EOL> lx -= <NUM_LIT> <EOL> } else { <EOL> lx += <NUM_LIT> <EOL> if ( lx == <NUM_LIT> ) hx += <NUM_LIT:1> <EOL> } <EOL> } <EOL> hy = hx and <NUM_LIT> <EOL> if ( hy >= <NUM_LIT> ) return x + x <EOL> if ( hy < <NUM_LIT> ) { <EOL> y = x * x <EOL> if ( y != x ) { <EOL> y = doubleSetWord ( d = y , hi = hx , lo = lx . toInt ( ) ) <EOL> return y <EOL> } <EOL> } <EOL> x = doubleSetWord ( d = x , hi = hx , lo = lx . toInt ( ) ) <EOL> return x <EOL> }


{ <EOL> Test :: class . java . declaredConstructors . forEach { it . isAccessible = true } <EOL> Test . Test1 :: class . java . declaredConstructors . forEach { it . isAccessible = true } <EOL> val instance = Test . Test1 :: class . java . newInstance ( ) <EOL> Demo . Foo :: class . java . newInstance ( ) <EOL> Demo . Free :: class . java . newInstance ( ) <EOL> A . Free :: class . java . newInstance ( ) <EOL> return "<STR_LIT:OK>" <EOL> }


= E1 . x + O . y + C . z


{ <EOL> fun bar ( ) { <EOL> val baz = <NUM_LIT:0> <EOL> } <EOL> }


private fun HttpRequestBuilder . applyCommonProperties ( )

{ <EOL> headers { <EOL> bearerAuth ( token ) <EOL> append ( HttpHeaders . Accept , "<STR_LIT>" ) <EOL> } <EOL> timeout { requestTimeoutMillis = REQUEST_TIMEOUT . inWholeMilliseconds } <EOL> }


internal suspend fun getMutedTestsOnTeamcityForRootProject ( rootScopeId : String ) : List < MuteTestJson >

{ <EOL> val requestHref = "<STR_LIT>" <EOL> val requestParams = mapOf ( "<STR_LIT>" to "<STR_LIT>" , "<STR_LIT>" to "<STR_LIT>" ) <EOL> val jsonResponses = traverseAll ( requestHref , requestParams ) <EOL> val alreadyMutedTestsOnTeamCity = jsonResponses . flatMap { <EOL> it . get ( "<STR_LIT>" ) . filter { jn -> jn . get ( "<STR_LIT>" ) . get ( "<STR_LIT:text>" ) ? . textValue ( ) . toString ( ) . startsWith ( TAG ) } <EOL> } <EOL> return alreadyMutedTestsOnTeamCity . mapNotNull { jsonObjectMapper . treeToValue < MuteTestJson > ( it ) } <EOL> }


private suspend fun traverseAll ( @ Suppress ( "<STR_LIT>" ) requestHref : String , requestParams : Map < String , String > , ) : List < JsonNode >

{ <EOL> val jsonResponses = mutableListOf < JsonNode > ( ) <EOL> suspend fun request ( url : String , params : Map < String , String > ) : String { <EOL> val currentResponse = httpClient . get ( url ) { <EOL> applyCommonProperties ( ) <EOL> url { <EOL> for ( entry in params ) { <EOL> parameters . append ( entry . key , entry . value ) <EOL> } <EOL> } <EOL> } <EOL> checkResponseAndLog ( currentResponse ) <EOL> val currentJsonResponse = jsonObjectMapper . readTree ( currentResponse . bodyAsText ( ) ) <EOL> jsonResponses . add ( currentJsonResponse ) <EOL> return currentJsonResponse . get ( "<STR_LIT>" ) ? . textValue ( ) ? : "<STR_LIT>" <EOL> } <EOL> var nextHref = request ( "<STR_LIT>" , requestParams ) <EOL> while ( nextHref . isNotBlank ( ) ) { <EOL> nextHref = request ( "<STR_LIT>" , emptyMap ( ) ) <EOL> } <EOL> return jsonResponses <EOL> }


internal suspend fun uploadMutedTests ( uploadMap : Map < String , MuteTestJson > )

{ <EOL> for ( ( _ , muteTestJson ) in uploadMap ) { <EOL> val response = httpClient . post ( "<STR_LIT>" ) { <EOL> applyCommonProperties ( ) <EOL> contentType ( ContentType . Application . Json ) <EOL> setBody ( muteTestJson ) <EOL> } <EOL> checkResponseAndLog ( response ) <EOL> } <EOL> }


internal suspend fun deleteMutedTests ( deleteMap : Map < String , MuteTestJson > )

{ <EOL> for ( ( _ , muteTestJson ) in deleteMap ) { <EOL> val response = httpClient . delete ( "<STR_LIT>" ) { <EOL> applyCommonProperties ( ) <EOL> } <EOL> try { <EOL> checkResponseAndLog ( response ) <EOL> } catch ( e : Exception ) { <EOL> System . err . println ( e . message ) <EOL> } <EOL> } <EOL> }


private suspend fun checkResponseAndLog ( response : HttpResponse )

{ <EOL> val isResponseBad = response . status . value !in <NUM_LIT> .. <NUM_LIT> <EOL> if ( isResponseBad ) { <EOL> throw Exception ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> }


public fun canConvert ( content : DocumentationContent ) : Boolean


public fun convertToHtml ( content : DocumentationContent , docTagParserContext : DocTagParserContext ) : String


fun `test Byte and Byte - typealias` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:a>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:b>" , "<STR_LIT>" ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


fun `test Byte and Short - typealias` ( )


fun `test Byte and Long - typealias` ( )


fun `test Short and Byte - typealias` ( )


fun `test Short and Short - typealias` ( )


fun `test Short and Int - typealias` ( )


fun `test Short and Long - typealias` ( )


fun `test Int and Short - typealias` ( )


fun `test Long and Byte - typealias` ( )


fun `test Long and Short - typealias` ( )


fun `test Long and Long - typealias` ( )


fun `test UByte and UByte - typealias` ( )


fun `test UByte and UShort - typealias` ( )


fun `test UByte and UInt - typealias` ( )


fun `test UByte and ULong - typealias` ( )


fun `test UShort and UByte - typealias` ( )


fun `test UShort and UShort - typealias` ( )


fun `test UShort and UInt - typealias` ( )


fun `test UShort and ULong - typealias` ( )


fun `test UInt and UByte - typealias` ( )


fun `test UInt and UShort - typealias` ( )


fun `test UInt and UInt - typealias` ( )


fun `test UInt and ULong - typealias` ( )


fun `test ULong and UByte - typealias` ( )


fun `test ULong and UShort - typealias` ( )


fun `test ULong and UInt - typealias` ( )


fun `test ULong and ULong - typealias` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:a>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:b>" , "<STR_LIT>" ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" ) <EOL> }


fun `test UInt and Long - typealias` ( )


fun `test UIntVarOf and ULongVarOf - typealias` ( )


fun `test IntVarOf and LongVarOf - typealias` ( )


fun `test Int and Long - typealias chain` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:a>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:b>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


fun `test function with pure number types parameter` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:a>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:b>" , "<STR_LIT>" ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" ) <EOL> }


fun `test function with aliased number value parameter` ( )


fun `test property with pure number return type` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> registerDependency ( "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:(aU+002CU+0020b)>" ) { unsignedIntegers ( ) } <EOL> simpleSingleSourceTarget ( "<STR_LIT:a>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:b>" , "<STR_LIT>" ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


fun `test property with aliased number return type` ( )


{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:a>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:b>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:c>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:d>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:e>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:f>" , "<STR_LIT>" ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> result . assertCommonized ( "<STR_LIT>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> result . assertCommonized ( "<STR_LIT>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> result . assertCommonized ( "<STR_LIT>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> result . assertCommonized ( "<STR_LIT>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


fun `test optimistic commonization in function return types` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( ( "<STR_LIT:(aU+002CU+0020b)>" ) ) <EOL> "<STR_LIT:a>" withSource """<STR_LIT>""" . trimIndent ( ) <EOL> "<STR_LIT:b>" withSource """<STR_LIT>""" . trimIndent ( ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


fun `test optimistic commonization in property return types` ( )


fun `test optimistic commonization inside parameterized types` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> "<STR_LIT:a>" withSource """<STR_LIT>""" . trimIndent ( ) <EOL> "<STR_LIT:b>" withSource """<STR_LIT>""" . trimIndent ( ) <EOL> "<STR_LIT:c>" withSource """<STR_LIT>""" . trimIndent ( ) <EOL> "<STR_LIT:d>" withSource """<STR_LIT>""" . trimIndent ( ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> result . assertCommonized ( "<STR_LIT>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> result . assertCommonized ( "<STR_LIT>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


fun `test KT-64376 - UnsafeNumber annotation - isn't applied to a commonization type that isn't a number - when commonizing hierarchically` ( )

{ <EOL> val result = commonize { <EOL> outputTarget ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" ) <EOL> setting ( OptimisticNumberCommonizationEnabledKey , true ) <EOL> registerFakeStdlibIntegersDependency ( "<STR_LIT:(aU+002CU+0020b)>" , "<STR_LIT>" ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:a>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:b>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> simpleSingleSourceTarget ( "<STR_LIT:c>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> } <EOL> result . assertCommonized ( "<STR_LIT:(aU+002CU+0020b)>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> result . assertCommonized ( "<STR_LIT>" , """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


override fun createLexer ( project : Project ) : Lexer

= KotlinLexer ( )


override fun createParser ( project : Project ) : PsiParser

= KotlinParser ( project )


override fun getFileNodeType ( ) : IFileElementType

= KtFileElementType . INSTANCE


override fun getWhitespaceTokens ( ) : TokenSet

= KtTokens . WHITESPACES


override fun getCommentTokens ( ) : TokenSet

= KtTokens . COMMENTS


override fun getStringLiteralElements ( ) : TokenSet

= KtTokens . STRINGS


override fun createElement ( astNode : ASTNode ) : PsiElement

{ <EOL> val elementType = astNode . elementType <EOL> return when ( elementType ) { <EOL> is KtStubElementType < * , * > -> elementType . createPsiFromAst ( astNode ) <EOL> KtNodeTypes . TYPE_CODE_FRAGMENT , KtNodeTypes . EXPRESSION_CODE_FRAGMENT , KtNodeTypes . BLOCK_CODE_FRAGMENT -> ASTWrapperPsiElement ( astNode ) <EOL> is KDocElementType -> elementType . createPsi ( astNode ) <EOL> KDocTokens . MARKDOWN_LINK -> KDocLink ( astNode ) <EOL> else -> ( elementType as KtNodeType ) . createPsi ( astNode ) <EOL> } <EOL> }


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> override fun createFile ( fileViewProvider : FileViewProvider ) : PsiFile

= org . jetbrains . kotlin . psi . KtCommonFile ( fileViewProvider , false )


@ Deprecated ( "<STR_LIT>" ) <EOL> override fun spaceExistanceTypeBetweenTokens ( left : ASTNode , right : ASTNode ) : ParserDefinition . SpaceRequirements

{ <EOL> val rightTokenType = right . elementType <EOL> if ( rightTokenType == KtTokens . GET_KEYWORD || rightTokenType == KtTokens . SET_KEYWORD ) { <EOL> return MUST_LINE_BREAK <EOL> } <EOL> val leftTokenType = left . elementType <EOL> if ( leftTokenType is KtKeywordToken && rightTokenType is KtKeywordToken ) return MUST <EOL> val rightWhenEntry = right . psi . getNonStrictParentOfType < KtWhenEntry > ( ) <EOL> if ( rightWhenEntry != null ) { <EOL> val leftWhenEntry = left . psi . getNonStrictParentOfType < KtWhenEntry > ( ) <EOL> if ( leftWhenEntry != null && leftWhenEntry != rightWhenEntry && leftTokenType != KtTokens . SEMICOLON ) { <EOL> return MUST_LINE_BREAK <EOL> } <EOL> } <EOL> return MAY <EOL> }


override fun createFile ( fileViewProvider : FileViewProvider ) : PsiFile

{ <EOL> return KtFile ( fileViewProvider , false ) <EOL> }


override fun lower ( module : ModuleModel ) : ModuleModel

= module


override fun lower ( source : SourceSetModel ) : SourceSetModel

{ <EOL> translationContext . initModelContext ( ModelContext ( source ) ) <EOL> translationContext . initInheritanceContext ( InheritanceContext ( translationContext . modelContext . buildInheritanceGraph ( ) ) ) <EOL> return super . lower ( source ) <EOL> }


private fun ModelContext . buildInheritanceGraph ( ) : Graph < ClassLikeModel >

{ <EOL> val graph = Graph < ClassLikeModel > ( ) <EOL> getClassLikeIterable ( ) . forEach { classLike -> <EOL> getAllParents ( classLike ) . forEach { resolvedClassLike -> <EOL> graph . addEdge ( classLike , resolvedClassLike . classLike ) <EOL> } <EOL> } <EOL> return graph <EOL> }


{ <EOL> var a : Int <EOL> a = <NUM_LIT:12> <EOL> fun f ( ) { <EOL> foo ( a ) <EOL> } <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> return { t : T -> t } . toString ( ) <EOL> }


{ <EOL> return ( fun ( t : List < T > ) : V = v ) . toString ( ) <EOL> }


{ <EOL> assertEquals ( "<STR_LIT>" , bar < String > ( ) ) <EOL> assertEquals ( "<STR_LIT>" , Baz < String , Int > ( ) . baz < String > ( "<STR_LIT>" ) ) <EOL> assertEquals ( "<STR_LIT>" , Bar < Int > ( ) . lambda . toString ( ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


abstract fun abstractFun ( )


{ <EOL> assertFalse ( Interface :: openFun . isFinal ) <EOL> assertTrue ( Interface :: openFun . isOpen ) <EOL> assertFalse ( Interface :: openFun . isAbstract ) <EOL> assertFalse ( Interface :: abstractFun . isFinal ) <EOL> assertFalse ( Interface :: abstractFun . isOpen ) <EOL> assertTrue ( Interface :: abstractFun . isAbstract ) <EOL> assertTrue ( AbstractClass :: finalVal . isFinal ) <EOL> assertFalse ( AbstractClass :: finalVal . isOpen ) <EOL> assertFalse ( AbstractClass :: finalVal . isAbstract ) <EOL> assertTrue ( AbstractClass :: finalVal . getter . isFinal ) <EOL> assertFalse ( AbstractClass :: finalVal . getter . isOpen ) <EOL> assertFalse ( AbstractClass :: finalVal . getter . isAbstract ) <EOL> assertFalse ( AbstractClass :: openVal . isFinal ) <EOL> assertTrue ( AbstractClass :: openVal . isOpen ) <EOL> assertFalse ( AbstractClass :: openVal . isAbstract ) <EOL> assertFalse ( AbstractClass :: openVal . getter . isFinal ) <EOL> assertTrue ( AbstractClass :: openVal . getter . isOpen ) <EOL> assertFalse ( AbstractClass :: openVal . getter . isAbstract ) <EOL> assertFalse ( AbstractClass :: abstractVar . isFinal ) <EOL> assertFalse ( AbstractClass :: abstractVar . isOpen ) <EOL> assertTrue ( AbstractClass :: abstractVar . isAbstract ) <EOL> assertFalse ( AbstractClass :: abstractVar . getter . isFinal ) <EOL> assertFalse ( AbstractClass :: abstractVar . getter . isOpen ) <EOL> assertTrue ( AbstractClass :: abstractVar . getter . isAbstract ) <EOL> assertFalse ( AbstractClass :: abstractVar . setter . isFinal ) <EOL> assertFalse ( AbstractClass :: abstractVar . setter . isOpen ) <EOL> assertTrue ( AbstractClass :: abstractVar . setter . isAbstract ) <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> super . updateFrom ( from ) <EOL> containerSource = from . containerSource <EOL> isInline = from . isInline <EOL> isExternal = from . isExternal <EOL> isExpect = from . isExpect <EOL> if ( from is IrSimpleFunction ) { <EOL> modality = from . modality <EOL> isTailrec = from . isTailrec <EOL> isSuspend = from . isSuspend <EOL> isOperator = from . isOperator <EOL> isInfix = from . isInfix <EOL> isFakeOverride = from . isFakeOverride <EOL> } else { <EOL> modality = Modality . FINAL <EOL> isTailrec = false <EOL> isSuspend = false <EOL> isOperator = false <EOL> isInfix = false <EOL> } <EOL> if ( from is IrConstructor ) { <EOL> isPrimary = from . isPrimary <EOL> } <EOL> }


= nodes . first ( )


operator fun get ( nodeId : Int ) : Node

= nodes . getOrElse ( nodeId ) { nodes . add ( it , Node ( it ) ) ; nodes [ it ] }


fun parseData ( content : List < String > ) : Graph

{ <EOL> val graph = Graph ( ) <EOL> content . filter ( String :: isNotBlank ) . forEachIndexed { lineNumber , line -> <EOL> addNeighbors ( line , graph , lineNumber ) <EOL> } <EOL> return graph <EOL> }


private fun getClosest ( node : Node ) : ClosestNode ?

{ <EOL> val nodes = node . neighbors <EOL> . filter { it . value != <NUM_LIT:0> && ! visitedNodes . contains ( it . key ) } <EOL> val clostest = nodes <EOL> . minByOrNull { it . value } ! ! <EOL> return ClosestNode ( clostest . key , clostest . value ) <EOL> }


{ <EOL> var previousNode = graph . first ( ) <EOL> visitedNodes . add ( graph . first ( ) ) <EOL> var cost = <NUM_LIT:0> <EOL> while ( visitedNodes . size != graph . size ) { <EOL> val closest = getClosest ( previousNode ) ! ! <EOL> visitedNodes . add ( closest . node ) <EOL> cost += closest . distance <EOL> previousNode = closest . node <EOL> } <EOL> cost += visitedNodes . last ( ) . neighbors [ graph . first ( ) ] ! ! <EOL> }


fun addNeighbors ( line : String , graph : Graph , lineNumber : Int ) : Node

{ <EOL> val node = graph [ lineNumber ] <EOL> line . split ( '<CHAR_LIT:U+002C>' ) . forEachIndexed { index , value -> <EOL> node . neighbors . put ( graph [ index ] , value . trim ( ) . toInt ( ) ) <EOL> } <EOL> return node <EOL> }


{ <EOL> Greedy ( graph ) . solve ( ) <EOL> }


override fun apply ( bitmap : ImageBitmap ) : ImageBitmap

= <EOL> applyBlurFilter ( bitmap . asAndroidBitmap ( ) , context ) . asImageBitmap ( )


@ OptIn ( ExperimentalContracts :: class ) <EOL> fun exactlyOnceContract ( block : ( ) -> Unit )

{ <EOL> contr < caret > act { <EOL> callsInPlace ( block , InvocationKind . EXACTLY_ONCE ) <EOL> } <EOL> block ( ) <EOL> }


fun classpathFromClassloader ( currentClassLoader : ClassLoader , unpackJarCollections : Boolean = false ) : List < File > ?

{ <EOL> val processedJars = hashSetOf < File > ( ) <EOL> val unpackJarCollectionsDir by lazy { <EOL> File . createTempFile ( "<STR_LIT>" , null ) . canonicalFile . apply { <EOL> delete ( ) <EOL> mkdir ( ) <EOL> setReadable ( false , false ) <EOL> setWritable ( false , false ) <EOL> setExecutable ( false , false ) <EOL> setReadable ( true , true ) <EOL> setWritable ( true , true ) <EOL> setExecutable ( true , true ) <EOL> Runtime . getRuntime ( ) . addShutdownHook ( Thread { <EOL> deleteRecursively ( ) <EOL> } ) <EOL> } <EOL> } <EOL> return allRelatedClassLoaders ( currentClassLoader ) . flatMap { classLoader -> <EOL> var classPath = emptySequence < File > ( ) <EOL> if ( unpackJarCollections && JAR_COLLECTIONS_KEY_PATHS . any { classLoader . getResource ( it ) ? . file ? . isNotEmpty ( ) == true } ) { <EOL> val jarCollections = JAR_COLLECTIONS_KEY_PATHS . asSequence ( ) . flatMap { currentClassLoader . getResources ( it ) . asSequence ( ) } <EOL> . mapNotNull { <EOL> it . toContainingJarOrNull ( ) ? . takeIf { file -> <EOL> file . extension in validJarCollectionFilesExtensions && processedJars . add ( file ) <EOL> } <EOL> } <EOL> classPath += jarCollections . flatMap { it . unpackJarCollection ( unpackJarCollectionsDir ) } . filter { it . isValidClasspathFile ( ) } <EOL> } <EOL> classPath += when ( classLoader ) { <EOL> is URLClassLoader -> { <EOL> classLoader . urLs . asSequence ( ) . mapNotNull { url -> url . toValidClasspathFileOrNull ( ) } <EOL> } <EOL> else -> { <EOL> classLoader . classPathFromGetUrlsMethodOrNull ( ) <EOL> ? : classLoader . classPathFromTypicalResourceUrls ( ) <EOL> } <EOL> } <EOL> classPath <EOL> } . filter { processedJars . add ( it ) } <EOL> . toList ( ) . takeIf { it . isNotEmpty ( ) } <EOL> }


internal fun URL . toValidClasspathFileOrNull ( ) : File ?

= <EOL> ( toContainingJarOrNull ( ) ? : toFileOrNull ( ) ) ? . takeIf { it . isValidClasspathFile ( ) }


internal fun File . isValidClasspathFile ( ) : Boolean

= <EOL> isDirectory || ( isFile && extension in validClasspathFilesExtensions )


private fun ClassLoader . classPathFromGetUrlsMethodOrNull ( ) : Sequence < File > ?

{ <EOL> return try { <EOL> val getUrls = this :: class . java . getMethod ( "<STR_LIT>" ) <EOL> getUrls . isAccessible = true <EOL> val result = getUrls . invoke ( this ) as? List < Any ? > <EOL> result ? . asSequence ( ) ? . filterIsInstance < URL > ( ) ? . mapNotNull { it . toValidClasspathFileOrNull ( ) } <EOL> } catch ( e : Throwable ) { <EOL> null <EOL> } <EOL> }


operator fun invoke ( resourceFile : File ) : File

{ <EOL> if ( keyResourcePathDepth < <NUM_LIT:0> ) { <EOL> keyResourcePathDepth = if ( keyResourcePath . isBlank ( ) ) <NUM_LIT:0> else ( keyResourcePath . trim ( '<CHAR_LIT:/>' ) . count { it == '<CHAR_LIT:/>' } + <NUM_LIT:1> ) <EOL> } <EOL> var root = resourceFile <EOL> for ( i in <NUM_LIT:0> until keyResourcePathDepth ) { <EOL> root = root . parentFile <EOL> } <EOL> return root <EOL> }


internal fun ClassLoader . rawClassPathFromKeyResourcePath ( keyResourcePath : String ) : Sequence < File >

{ <EOL> val resourceRootCalc = ClassLoaderResourceRootFIlePathCalculator ( keyResourcePath ) <EOL> return getResources ( keyResourcePath ) . asSequence ( ) . mapNotNull { url -> <EOL> if ( url . protocol == "<STR_LIT>" ) { <EOL> ( url . openConnection ( ) as? JarURLConnection ) ? . jarFileURL ? . toFileOrNull ( ) <EOL> } else { <EOL> url . toFileOrNull ( ) ? . let { resourceRootCalc ( it ) } <EOL> } <EOL> } <EOL> }


fun ClassLoader . classPathFromTypicalResourceUrls ( ) : Sequence < File >

= <EOL> ( rawClassPathFromKeyResourcePath ( "<STR_LIT>" ) + rawClassPathFromKeyResourcePath ( JAR_MANIFEST_RESOURCE_NAME ) ) <EOL> . distinct ( ) <EOL> . filter { it . isValidClasspathFile ( ) }


private fun File . unpackJarCollection ( rootTempDir : File ) : Sequence < File >

{ <EOL> val targetDir = File . createTempFile ( nameWithoutExtension , null , rootTempDir ) . apply { <EOL> delete ( ) <EOL> mkdir ( ) <EOL> } <EOL> return try { <EOL> ArrayList < File > ( ) . apply { <EOL> JarInputStream ( FileInputStream ( this @ unpackJarCollection ) ) . use { jarInputStream -> <EOL> for ( classesDir in JAR_COLLECTIONS_CLASSES_PATHS ) { <EOL> add ( File ( targetDir , classesDir ) ) <EOL> } <EOL> do { <EOL> val entry = jarInputStream . nextJarEntry <EOL> if ( entry != null ) { <EOL> try { <EOL> if ( ! entry . isDirectory ) { <EOL> val file = File ( targetDir , entry . name ) <EOL> if ( JAR_COLLECTIONS_LIB_PATHS . any { entry . name . startsWith ( "<STR_LIT>" ) } ) { <EOL> add ( file ) <EOL> } <EOL> file . parentFile . mkdirs ( ) <EOL> file . outputStream ( ) . use { outputStream -> <EOL> jarInputStream . copyTo ( outputStream ) <EOL> outputStream . flush ( ) <EOL> } <EOL> } <EOL> } finally { <EOL> jarInputStream . closeEntry ( ) <EOL> } <EOL> } <EOL> } while ( entry != null ) <EOL> } <EOL> } . asSequence ( ) <EOL> } catch ( e : Throwable ) { <EOL> targetDir . deleteRecursively ( ) <EOL> throw e <EOL> } <EOL> }


fun classpathFromClasspathProperty ( ) : List < File > ?

= <EOL> System . getProperty ( "<STR_LIT>" ) <EOL> ? . split ( String . format ( "<STR_LIT>" , File . pathSeparatorChar ) . toRegex ( ) ) <EOL> ? . dropLastWhile ( String :: isEmpty ) <EOL> ? . map ( :: File )


fun classpathFromClass ( classLoader : ClassLoader , klass : KClass < out Any > ) : List < File > ?

= <EOL> classpathFromFQN ( classLoader , klass . qualifiedName ! ! )


fun classpathFromClass ( klass : KClass < out Any > ) : List < File > ?

= <EOL> classpathFromClass ( klass . java . classLoader , klass )


inline fun < reified T : Any > classpathFromClass ( ) : List < File > ?

= classpathFromClass ( T :: class )


fun classpathFromFQN ( classLoader : ClassLoader , fqn : String ) : List < File > ?

{ <EOL> val clp = "<STR_LIT>" <EOL> return classLoader . rawClassPathFromKeyResourcePath ( clp ) . filter { it . isValidClasspathFile ( ) } . toList ( ) . takeIf { it . isNotEmpty ( ) } <EOL> }


fun File . matchMaybeVersionedFile ( baseName : String )

= <EOL> name == baseName || <EOL> name == baseName . removeSuffix ( "<STR_LIT>" ) || <EOL> Regex ( Regex . escape ( baseName . removeSuffix ( "<STR_LIT>" ) ) + "<STR_LIT>" ) . matches ( name )


fun File . hasParentNamed ( baseName : String ) : Boolean

= <EOL> nameWithoutExtension == baseName || parentFile ? . hasParentNamed ( baseName ) ? : false


private fun allRelatedClassLoaders ( clsLoader : ClassLoader , visited : MutableSet < ClassLoader > = HashSet ( ) ) : Sequence < ClassLoader >

{ <EOL> if ( ! visited . add ( clsLoader ) ) return emptySequence ( ) <EOL> val singleParent = clsLoader . parent <EOL> if ( singleParent != null ) <EOL> return sequenceOf ( singleParent ) . flatMap { allRelatedClassLoaders ( it , visited ) } + clsLoader <EOL> return try { <EOL> val arrayOfClassLoaders = getParentClassLoaders ( clsLoader ) <EOL> arrayOfClassLoaders . asSequence ( ) . flatMap { allRelatedClassLoaders ( it , visited ) } + clsLoader <EOL> } catch ( e : Throwable ) { <EOL> sequenceOf ( clsLoader ) <EOL> } <EOL> }


private fun getParentClassLoaders ( clsLoader : ClassLoader ) : Array < ClassLoader >

{ <EOL> return try { <EOL> getParentsForNewClassLoader ( clsLoader ) <EOL> } catch ( exception : NoSuchMethodException ) { <EOL> try { <EOL> getParentsForOldClassLoader ( clsLoader ) <EOL> } catch ( exception : NoSuchFieldException ) { <EOL> emptyArray ( ) <EOL> } <EOL> } <EOL> }


@ Throws ( NoSuchFieldException :: class ) <EOL> private fun getParentsForOldClassLoader ( clsLoader : ClassLoader ) : Array < ClassLoader >

{ <EOL> val field = clsLoader . javaClass . getDeclaredField ( "<STR_LIT>" ) <EOL> field . isAccessible = true <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return field . get ( clsLoader ) as Array < ClassLoader > <EOL> }


@ Throws ( NoSuchMethodException :: class ) <EOL> private fun getParentsForNewClassLoader ( clsLoader : ClassLoader ) : Array < ClassLoader >

{ <EOL> val method = clsLoader . javaClass . getDeclaredMethod ( "<STR_LIT>" ) <EOL> method . isAccessible = true <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return method . invoke ( clsLoader ) as Array < ClassLoader > <EOL> }


internal fun List < File > . takeIfContainsAll ( vararg keyNames : String ) : List < File > ?

= <EOL> takeIf { classpath -> <EOL> keyNames . all { key -> classpath . any { it . matchMaybeVersionedFile ( key ) } } <EOL> }


internal fun List < File > . filterIfContainsAll ( vararg keyNames : String ) : List < File > ?

{ <EOL> val foundKeys = mutableSetOf < String > ( ) <EOL> val res = arrayListOf < File > ( ) <EOL> for ( cpentry in this ) { <EOL> for ( prefix in keyNames ) { <EOL> if ( cpentry . matchMaybeVersionedFile ( prefix ) || ( cpentry . isDirectory && cpentry . hasParentNamed ( prefix ) ) ) { <EOL> foundKeys . add ( prefix ) <EOL> res . add ( cpentry ) <EOL> break <EOL> } <EOL> } <EOL> } <EOL> return res . takeIf { foundKeys . containsAll ( keyNames . asList ( ) ) } <EOL> }


internal fun List < File > . takeIfContainsAny ( vararg keyNames : String ) : List < File > ?

= <EOL> takeIf { classpath -> <EOL> keyNames . any { key -> classpath . any { it . matchMaybeVersionedFile ( key ) } } <EOL> }


fun scriptCompilationClasspathFromContextOrNull ( vararg keyNames : String , classLoader : ClassLoader = Thread . currentThread ( ) . contextClassLoader , wholeClasspath : Boolean = false , unpackJarCollections : Boolean = false ) : List < File > ?

{ <EOL> fun List < File > . takeAndFilter ( ) = when { <EOL> isEmpty ( ) -> null <EOL> wholeClasspath -> takeIfContainsAll ( * keyNames ) <EOL> else -> filterIfContainsAll ( * keyNames ) <EOL> } <EOL> val fromProperty = System . getProperty ( KOTLIN_SCRIPT_CLASSPATH_PROPERTY ) ? . split ( File . pathSeparator ) ? . map ( :: File ) <EOL> if ( fromProperty != null ) return fromProperty <EOL> return classpathFromClassloader ( classLoader , unpackJarCollections ) ? . takeAndFilter ( ) <EOL> ? : classpathFromClasspathProperty ( ) ? . takeAndFilter ( ) <EOL> }


fun scriptCompilationClasspathFromContextOrStdlib ( vararg keyNames : String , classLoader : ClassLoader = Thread . currentThread ( ) . contextClassLoader , wholeClasspath : Boolean = false ) : List < File >

= <EOL> scriptCompilationClasspathFromContextOrNull ( * keyNames , classLoader = classLoader , wholeClasspath = wholeClasspath ) <EOL> ? : KotlinJars . kotlinScriptStandardJars


fun scriptCompilationClasspathFromContext ( vararg keyNames : String , classLoader : ClassLoader = Thread . currentThread ( ) . contextClassLoader , wholeClasspath : Boolean = false , unpackJarCollections : Boolean = false ) : List < File >

= <EOL> scriptCompilationClasspathFromContextOrNull ( * keyNames , classLoader = classLoader , wholeClasspath = wholeClasspath , unpackJarCollections = unpackJarCollections ) <EOL> ? : throw ClasspathExtractionException ( "<STR_LIT>" )


private fun findCompilerClasspath ( withScripting : Boolean ) : List < File >

{ <EOL> val kotlinCompilerJars = listOf ( KOTLIN_COMPILER_JAR , KOTLIN_COMPILER_EMBEDDABLE_JAR ) <EOL> val kotlinLibsJars = listOf ( KOTLIN_JAVA_STDLIB_JAR , KOTLIN_JAVA_REFLECT_JAR , KOTLIN_JAVA_SCRIPT_RUNTIME_JAR , TROVE4J_JAR ) <EOL> val kotlinScriptingJars = if ( withScripting ) listOf ( KOTLIN_SCRIPTING_COMPILER_JAR , KOTLIN_SCRIPTING_COMPILER_EMBEDDABLE_JAR , KOTLIN_SCRIPTING_COMPILER_IMPL_JAR , KOTLIN_SCRIPTING_COMPILER_IMPL_EMBEDDABLE_JAR , KOTLIN_SCRIPTING_COMMON_JAR , KOTLIN_SCRIPTING_JVM_JAR ) else emptyList ( ) <EOL> val kotlinBaseJars = kotlinCompilerJars + kotlinLibsJars + kotlinScriptingJars <EOL> val classpath = explicitCompilerClasspath <EOL> ? : ( classpathFromFQN ( Thread . currentThread ( ) . contextClassLoader , "<STR_LIT>" ) ? : classpathFromClassloader ( Thread . currentThread ( ) . contextClassLoader ) ? . takeIf { it . isNotEmpty ( ) } ? : classpathFromClasspathProperty ( ) ) ? . filter { f -> kotlinBaseJars . any { f . matchMaybeVersionedFile ( it ) } } ? . takeIf { it . isNotEmpty ( ) } <EOL> if ( classpath == null || ( explicitCompilerClasspath == null && classpath . none { f -> <EOL> kotlinCompilerJars . any { <EOL> f . matchMaybeVersionedFile ( it ) <EOL> } <EOL> } ) ) { <EOL> throw FileNotFoundException ( "<STR_LIT>" ) <EOL> } <EOL> return classpath <EOL> }


fun getLib ( propertyName : String , jarName : String , markerClass : KClass < * > , classLoader : ClassLoader ? = null ) : File ?

= <EOL> getExplicitLib ( propertyName , jarName ) <EOL> ? : run { <EOL> val requestedClassloader = classLoader ? : Thread . currentThread ( ) . contextClassLoader <EOL> val byName = <EOL> if ( requestedClassloader == markerClass . java . classLoader ) null <EOL> else tryGetResourcePathForClassByName ( markerClass . java . name , requestedClassloader ) <EOL> byName ? : tryGetResourcePathForClass ( markerClass . java ) <EOL> } ? . takeIf ( File :: exists )


fun getLib ( propertyName : String , jarName : String , markerClassName : String , classLoader : ClassLoader ? = null ) : File ?

= <EOL> getExplicitLib ( propertyName , jarName ) <EOL> ? : tryGetResourcePathForClassByName ( markerClassName , classLoader ? : Thread . currentThread ( ) . contextClassLoader ) ? . takeIf ( File :: exists )


private fun getExplicitLib ( propertyName : String , jarName : String )

= <EOL> System . getProperty ( propertyName ) ? . let ( :: File ) ? . takeIf ( File :: exists ) <EOL> ? : explicitCompilerClasspath ? . firstOrNull { it . matchMaybeVersionedFile ( jarName ) } ? . takeIf ( File :: exists )


override fun loadAnnotation ( proto : ProtoBuf . Annotation , nameResolver : NameResolver ) : AnnotationDescriptor

{ <EOL> return deserializer . deserializeAnnotation ( proto , nameResolver ) <EOL> }


override fun loadPropertyConstant ( container : ProtoContainer , proto : ProtoBuf . Property , expectedType : KotlinType ) : ConstantValue < * > ?

{ <EOL> val value = proto . getExtensionOrNull ( protocol . compileTimeValue ) ? : return null <EOL> return deserializer . resolveValue ( expectedType , value , container . nameResolver ) <EOL> }


override fun loadAnnotationDefaultValue ( container : ProtoContainer , proto : ProtoBuf . Property , expectedType : KotlinType ) : ConstantValue < * > ?

{ <EOL> return null <EOL> }


{ <EOL> Outer < Boolean > ( ) . run { <EOL> val i = Inner ( true , false ) <EOL> i . prop = true <EOL> } <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> return when ( a ) { <EOL> is X -> a <EOL> is Y -> a <EOL> } <EOL> }


{ <EOL> return when ( a ) { <EOL> is X , is Y -> a <EOL> } <EOL> }


private fun getMatchingFirExpressionWithSmartCast ( expression : KtExpression ) : FirSmartCastExpression ?

{ <EOL> if ( ! expression . isExplicitSmartCastInfoTarget ) return null <EOL> val possibleFunctionCall = expression . getPossiblyQualifiedCallExpressionForCallee ( ) ? : expression <EOL> return when ( val firExpression = possibleFunctionCall . getOrBuildFir ( analysisSession . firResolveSession ) ) { <EOL> is FirSmartCastExpression -> firExpression <EOL> is FirSafeCallExpression -> firExpression . selector as? FirSmartCastExpression <EOL> is FirImplicitInvokeCall -> firExpression . explicitReceiver as? FirSmartCastExpression <EOL> else -> null <EOL> } <EOL> }


override fun getSmartCastedInfo ( expression : KtExpression ) : KtSmartCastInfo ?

{ <EOL> val firSmartCastExpression = getMatchingFirExpressionWithSmartCast ( expression ) ? : return null <EOL> return getSmartCastedInfo ( firSmartCastExpression ) <EOL> }


private fun getSmartCastedInfo ( expression : FirSmartCastExpression ) : KtSmartCastInfo ?

{ <EOL> val type = expression . smartcastType . coneTypeSafe < ConeKotlinType > ( ) ? . asKtType ( ) ? : return null <EOL> return KtSmartCastInfo ( type , expression . isStable , token ) <EOL> }


private fun getMatchingFirQualifiedAccessExpression ( expression : KtExpression ) : FirQualifiedAccessExpression ?

{ <EOL> if ( ! expression . isImplicitSmartCastInfoTarget ) return null <EOL> val wholeExpression = expression . getOperationExpressionForOperationReference ( ) <EOL> ? : expression . getPossiblyQualifiedCallExpressionForCallee ( ) <EOL> ? : expression . getQualifiedExpressionForSelector ( ) <EOL> ? : expression <EOL> return when ( val firExpression = wholeExpression . getOrBuildFir ( analysisSession . firResolveSession ) ) { <EOL> is FirQualifiedAccessExpression -> firExpression <EOL> is FirSafeCallExpression -> firExpression . selector as? FirQualifiedAccessExpression <EOL> is FirSmartCastExpression -> firExpression . originalExpression as? FirQualifiedAccessExpression <EOL> else -> null <EOL> } <EOL> }


override fun getImplicitReceiverSmartCast ( expression : KtExpression ) : Collection < KtImplicitReceiverSmartCast >

{ <EOL> val firQualifiedExpression = getMatchingFirQualifiedAccessExpression ( expression ) ? : return emptyList ( ) <EOL> return listOfNotNull ( smartCastedImplicitReceiver ( firQualifiedExpression , KtImplicitReceiverSmartCastKind . DISPATCH ) , smartCastedImplicitReceiver ( firQualifiedExpression , KtImplicitReceiverSmartCastKind . EXTENSION ) , ) <EOL> }


private fun smartCastedImplicitReceiver ( firExpression : FirQualifiedAccessExpression , kind : KtImplicitReceiverSmartCastKind , ) : KtImplicitReceiverSmartCast ?

{ <EOL> val receiver = when ( kind ) { <EOL> KtImplicitReceiverSmartCastKind . DISPATCH -> firExpression . dispatchReceiver <EOL> KtImplicitReceiverSmartCastKind . EXTENSION -> firExpression . extensionReceiver <EOL> } <EOL> if ( receiver == null || receiver == firExpression . explicitReceiver ) return null <EOL> if ( ! receiver . isStableSmartcast ( ) ) return null <EOL> val type = receiver . resolvedType . asKtType ( ) <EOL> return KtImplicitReceiverSmartCast ( type , kind , token ) <EOL> }


private fun KtExpression . getPossiblyQualifiedCallExpressionForCallee ( ) : KtExpression ?

{ <EOL> val expressionParent = this . parent <EOL> return if ( expressionParent is KtCallExpression && expressionParent . calleeExpression == this ) { <EOL> expressionParent . getQualifiedExpressionForSelectorOrThis ( ) <EOL> } else { <EOL> null <EOL> } <EOL> }


private fun KtExpression . getOperationExpressionForOperationReference ( ) : KtOperationExpression ?

= <EOL> ( this as? KtOperationReferenceExpression ) ? . parent as? KtOperationExpression


= UserKlass ( ) as CT


fun < FT > build ( instructions : Buildee < FT > . ( ) -> Unit ) : Buildee < FT >

{ <EOL> return Buildee < FT > ( ) . apply ( instructions ) <EOL> }


operator fun getValue ( reference : Nothing ? , property : KProperty < * > ) : T

= value


{ <EOL> fun consume ( arg : UserKlass ) { } <EOL> val buildee = build { <EOL> val temp by Delegate ( materialize ( ) ) <EOL> consume ( temp ) <EOL> } <EOL> checkExactType < Buildee < UserKlass > > ( buildee ) <EOL> }


override fun getClassLikeSymbolByClassId ( classId : ClassId ) : FirClassLikeSymbol < * > ?

{ <EOL> if ( classId !in includedForwardDeclarations ) return null <EOL> if ( classId . isNestedClass ) return null <EOL> return syntheticForwardDeclarationClassCache . getValue ( classId ) <EOL> }


private fun createSyntheticForwardDeclarationClass ( classId : ClassId ) : FirClassLikeSymbol < * > ?

{ <EOL> val forwardDeclarationKind = NativeForwardDeclarationKind . packageFqNameToKind [ classId . packageFqName ] ? : return null <EOL> val symbol = FirRegularClassSymbol ( classId ) <EOL> buildRegularClass { <EOL> moduleData = forwardDeclarationsModuleData <EOL> origin = FirDeclarationOrigin . Synthetic . ForwardDeclaration <EOL> check ( ! classId . isNestedClass ) { "<STR_LIT>" } <EOL> name = classId . shortClassName <EOL> status = FirResolvedDeclarationStatusImpl ( Visibilities . Public , Modality . FINAL , EffectiveVisibility . Public ) . apply { <EOL> isExpect = false <EOL> isActual = false <EOL> isCompanion = false <EOL> isInner = false <EOL> isData = false <EOL> isInline = false <EOL> isExternal = false <EOL> isFun = false <EOL> } <EOL> classKind = forwardDeclarationKind . classKind <EOL> scopeProvider = kotlinScopeProvider <EOL> this . symbol = symbol <EOL> resolvePhase = FirResolvePhase . ANALYZED_DEPENDENCIES <EOL> superTypeRefs += buildResolvedTypeRef { <EOL> type = ConeClassLikeLookupTagImpl ( forwardDeclarationKind . superClassId ) <EOL> . constructClassType ( emptyArray ( ) , isNullable = false ) <EOL> } <EOL> annotations += buildAnnotation { <EOL> annotationTypeRef = buildResolvedTypeRef { <EOL> val annotationClassId = ClassId ( NativeStandardInteropNames . cInteropPackage , NativeStandardInteropNames . ExperimentalForeignApi ) <EOL> type = annotationClassId . toLookupTag ( ) <EOL> . constructClassType ( typeArguments = ConeTypeProjection . EMPTY_ARRAY , isNullable = false ) <EOL> } <EOL> argumentMapping = FirEmptyAnnotationArgumentMapping <EOL> } <EOL> } . apply { <EOL> replaceDeprecationsProvider ( getDeprecationsProvider ( session ) ) <EOL> } <EOL> return symbol <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelCallableSymbolsTo ( destination : MutableList < FirCallableSymbol < * > > , packageFqName : FqName , name : Name )

{ <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelFunctionSymbolsTo ( destination : MutableList < FirNamedFunctionSymbol > , packageFqName : FqName , name : Name )

{ <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelPropertySymbolsTo ( destination : MutableList < FirPropertySymbol > , packageFqName : FqName , name : Name )

{ <EOL> }


override fun getPackage ( fqName : FqName ) : FqName ?

{ <EOL> if ( fqName in includedForwardDeclarationsByPackage ) { <EOL> return fqName <EOL> } <EOL> return null <EOL> }


override fun getPackageNamesWithTopLevelClassifiers ( ) : Set < String > ?

= <EOL> includedForwardDeclarationsByPackage . keys . mapToSetOrEmpty ( FqName :: asString )


override fun getTopLevelClassifierNamesInPackage ( packageFqName : FqName ) : Set < Name >

= <EOL> includedForwardDeclarationsByPackage [ packageFqName ] . orEmpty ( )


override fun deserialize ( decoder : Decoder ) : LargeStringData

{ <EOL> require ( decoder is ChunkedDecoder ) { "<STR_LIT>" } <EOL> val outStringBuilder = StringBuilder ( ) <EOL> decoder . decodeStringChunked { chunk -> <EOL> outStringBuilder . append ( chunk ) <EOL> } <EOL> return LargeStringData ( outStringBuilder . toString ( ) ) <EOL> }


override fun serialize ( encoder : Encoder , value : LargeStringData )

{ <EOL> encoder . encodeString ( value . largeString ) <EOL> }


@ Test <EOL> fun decodePlainLenientString ( )

{ <EOL> val longString = "<STR_LIT:abcd>" . repeat ( <NUM_LIT> ) <EOL> val sourceObject = ClassWithLargeStringDataField ( LargeStringData ( longString ) ) <EOL> val serializedObject = "<STR_LIT>" <EOL> val jsonWithLenientMode = Json { isLenient = true } <EOL> testDecodeInAllModes ( jsonWithLenientMode , serializedObject , sourceObject ) <EOL> }


{ <EOL> val longStringWithEscape = "<STR_LIT>" <EOL> val sourceObject = ClassWithLargeStringDataField ( LargeStringData ( longStringWithEscape ) ) <EOL> val serializedObject = Json . encodeToString ( sourceObject ) <EOL> testDecodeInAllModes ( Json , serializedObject , sourceObject ) <EOL> }


private fun testDecodeInAllModes ( seralizer : Json , serializedObject : String , sourceObject : ClassWithLargeStringDataField )

{ <EOL> JsonTestingMode . values ( ) . filterNot { it == JsonTestingMode . JAVA_STREAMS } . forEach { mode -> <EOL> if ( mode == JsonTestingMode . TREE ) { <EOL> assertFailsWithMessage < IllegalArgumentException > ( "<STR_LIT>" , "<STR_LIT>" ) { <EOL> seralizer . decodeFromString < ClassWithLargeStringDataField > ( serializedObject , mode ) <EOL> } <EOL> } else { <EOL> val deserializedObject = <EOL> seralizer . decodeFromString < ClassWithLargeStringDataField > ( serializedObject , mode ) <EOL> assertEquals ( sourceObject . largeStringField , deserializedObject . largeStringField ) <EOL> } <EOL> } <EOL> }


= <NUM_LIT:1>


{ <EOL> checkSubtype < Int > ( foo ( <NUM_LIT:1> ) ) <EOL> checkSubtype < Unit > ( foo ( "<STR_LIT:s>" ) ) <EOL> }


= this == LOWER


= this == UPPER


= this == EQUALITY


= when ( this ) { <EOL> LOWER -> UPPER <EOL> UPPER -> LOWER <EOL> EQUALITY -> EQUALITY <EOL> }


override fun equals ( other : Any ? ) : Boolean

{ <EOL> if ( this === other ) return true <EOL> if ( other ? . javaClass != javaClass ) return false <EOL> other as Constraint <EOL> if ( typeHashCode != other . typeHashCode ) return false <EOL> if ( kind != other . kind ) return false <EOL> if ( position != other . position ) return false <EOL> if ( type != other . type ) return false <EOL> return true <EOL> }


= typeHashCode


= "<STR_LIT>"


fun getConstraintsContainedSpecifiedTypeVariable ( typeVariableConstructor : TypeConstructorMarker ) : Collection < Constraint >

/**
 * Only necessary for incorporation optimization
 */


fun asStringWithoutPosition ( ) : String

{ <EOL> val sign = <EOL> when ( constraintKind ) { <EOL> ConstraintKind . EQUALITY -> "<STR_LIT>" <EOL> ConstraintKind . LOWER -> "<STR_LIT>" <EOL> ConstraintKind . UPPER -> "<STR_LIT>" <EOL> } <EOL> return "<STR_LIT>" <EOL> }


fun checkConstraint ( context : TypeCheckerProviderContext , constraintType : KotlinTypeMarker , constraintKind : ConstraintKind , resultType : KotlinTypeMarker ) : Boolean

{ <EOL> val typeChecker = AbstractTypeChecker <EOL> return when ( constraintKind ) { <EOL> ConstraintKind . EQUALITY -> typeChecker . equalTypes ( context , constraintType , resultType ) <EOL> ConstraintKind . LOWER -> typeChecker . isSubtypeOf ( context , constraintType , resultType ) <EOL> ConstraintKind . UPPER -> typeChecker . isSubtypeOf ( context , resultType , constraintType ) <EOL> } <EOL> }


fun Constraint . replaceType ( newType : KotlinTypeMarker )

= <EOL> Constraint ( kind , newType , position , typeHashCode , derivedFrom , isNullabilityConstraint , inputTypePositionBeforeIncorporation )


fun getFunctionClassKind ( functionTypeKind : FunctionTypeKind ) : FunctionClassKind

= when ( functionTypeKind ) { <EOL> FunctionTypeKind . Function -> Function <EOL> FunctionTypeKind . SuspendFunction -> SuspendFunction <EOL> FunctionTypeKind . KFunction -> KFunction <EOL> FunctionTypeKind . KSuspendFunction -> KSuspendFunction <EOL> else -> UNKNOWN <EOL> }


{ <EOL> Test ( ) . remove ( null , "<STR_LIT>" ) <EOL> return "<STR_LIT:OK>" <EOL> }


override fun < T > Json . encode ( value : T , serializer : KSerializer < T > ) : String

{ <EOL> return encodeToJsonElement ( serializer , value ) . toString ( ) <EOL> }


override fun < T > Json . decode ( json : String , serializer : KSerializer < T > ) : T

{ <EOL> val jsonElement = parseToJsonElement ( json ) <EOL> return decodeFromJsonElement ( serializer , jsonElement ) <EOL> }


fun < T > withLock ( action : ( lockFile : File ) -> T ) : T

{ <EOL> intraProcessLock . withLock { <EOL> val lockFile = outputDirectory . resolve ( "<STR_LIT>" ) <EOL> if ( outputDirectory in lockedOutputDirectories ) { <EOL> return action ( lockFile ) <EOL> } <EOL> outputDirectory . mkdirs ( ) <EOL> logInfo ( "<STR_LIT>" ) <EOL> FileOutputStream ( outputDirectory . resolve ( "<STR_LIT>" ) ) . use { stream -> <EOL> val lock : FileLock = stream . channel . lockWithRetries ( lockFile ) <EOL> assert ( lock . isValid ) <EOL> return try { <EOL> logInfo ( "<STR_LIT>" ) <EOL> lockedOutputDirectories . add ( outputDirectory ) <EOL> action ( lockFile ) <EOL> } finally { <EOL> lockedOutputDirectories . remove ( outputDirectory ) <EOL> lock . release ( ) <EOL> logInfo ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> }


private fun FileChannel . lockWithRetries ( file : File ) : FileLock

{ <EOL> var retries = <NUM_LIT:0> <EOL> while ( true ) { <EOL> try { <EOL> return lock ( ) <EOL> } <EOL> catch ( t : OverlappingFileLockException ) { <EOL> Thread . sleep ( <NUM_LIT> ) <EOL> retries ++ <EOL> if ( retries % <NUM_LIT:10> == <NUM_LIT:0> ) { <EOL> logInfo ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> }


fun checkLocked ( outputDirectory : File )

{ <EOL> check ( intraProcessLock . isHeldByCurrentThread ) { <EOL> "<STR_LIT>" <EOL> } <EOL> check ( outputDirectory in lockedOutputDirectories ) { <EOL> "<STR_LIT>" <EOL> } <EOL> }


override fun < E : FirElement > transformElement ( element : E , data : Any ? ) : E

{ <EOL> error ( "<STR_LIT>" ) <EOL> }


override fun transformFile ( file : FirFile , data : Any ? ) : FirFile

{ <EOL> return withFileAnalysisExceptionWrapping ( file ) { <EOL> file . transform ( transformer , ResolutionMode . ContextIndependent ) <EOL> } <EOL> }


{ <EOL> kotlin = project . applyMultiplatformPlugin ( ) <EOL> }


protected fun enableCInteropCommonization ( )

{ <EOL> project . enableCInteropCommonization ( ) <EOL> }


internal suspend fun expectCInteropCommonizerDependent ( compilation : KotlinSharedNativeCompilation ) : CInteropCommonizerDependent

{ <EOL> return assertNotNull ( CInteropCommonizerDependent . from ( compilation ) , "<STR_LIT>" ) <EOL> }


internal suspend fun expectCInteropCommonizerDependent ( sourceSet : KotlinSourceSet ) : CInteropCommonizerDependent

{ <EOL> return assertNotNull ( CInteropCommonizerDependent . from ( sourceSet ) , "<STR_LIT>" ) <EOL> }


internal suspend fun findCInteropCommonizerDependent ( compilation : KotlinSharedNativeCompilation ) : CInteropCommonizerDependent ?

{ <EOL> return CInteropCommonizerDependent . from ( compilation ) <EOL> }


internal suspend fun findCInteropCommonizerDependent ( sourceSet : KotlinSourceSet ) : CInteropCommonizerDependent ?

{ <EOL> return CInteropCommonizerDependent . from ( sourceSet ) <EOL> }


internal suspend fun expectSharedNativeCompilation ( sourceSet : KotlinSourceSet ) : KotlinSharedNativeCompilation

{ <EOL> val compilation = project . findMetadataCompilation ( sourceSet ) ? : fail ( "<STR_LIT>" ) <EOL> return assertIsInstance < KotlinSharedNativeCompilation > ( compilation ) <EOL> }


internal fun KotlinNativeTarget . mainCinteropIdentifier ( name : String ) : CInteropIdentifier

{ <EOL> return compilations . getByName ( "<STR_LIT:main>" ) . cinteropIdentifier ( name ) <EOL> }


internal fun KotlinNativeTarget . testCinteropIdentifier ( name : String ) : CInteropIdentifier

{ <EOL> return compilations . getByName ( "<STR_LIT:test>" ) . cinteropIdentifier ( name ) <EOL> }


internal fun KotlinCompilation < * > . cinteropIdentifier ( name : String ) : CInteropIdentifier

{ <EOL> return CInteropIdentifier ( CInteropIdentifier . Scope . create ( this ) , name ) <EOL> }


external fun require ( module : String ) : dynamic


private fun insertCode ( testCaseCode : TestCase , helperFilesContent : Set < String > ? = null )

{ <EOL> val code = StringBuilder ( ) <EOL> helperFilesContent ? . forEach { helperFile -> <EOL> code . append ( "<STR_LIT>" ) <EOL> } <EOL> code . append ( SAMPLE_WRAP_CODE . format ( testCaseCode . code ) ) <EOL> code . append ( MAIN_FUN_CODE ) <EOL> `$` ( TEST_CODE_WRAPPER_SELECTOR ) . html ( TEST_CODE_TEMPLATE . format ( code . toString ( ) . escapeHtml ( ) ) ) <EOL> KotlinPlayground ( TEST_CODE_SELECTOR , json ( "<STR_LIT>" to { testPopup . computeSizes ( ) } , "<STR_LIT>" to { testPopup . computeSizes ( ) } ) ) <EOL> }


private fun showTestCaseCode ( specTest : SpecTest , helperFilesContent : Set < String > ? = null )

{ <EOL> `$` ( TEST_CASE_INFO_SELECTOR ) . remove ( ) <EOL> `$` ( TESTS_VIEWER_SELECTOR ) . append ( TEST_VIEWER_BODY_TEMPLATE . format ( specTest . testInfo . description ) ) <EOL> val testCases = specTest . testCases <EOL> insertCode ( testCases . first ( ) , helperFilesContent ) <EOL> if ( testCases . size == <NUM_LIT:1> ) { <EOL> `$` ( NEXT_TESTCASE_SELECTOR ) . addClass ( "<STR_LIT>" ) <EOL> } <EOL> }


private fun getHelpers ( helperNames : Set < String > , testArea : TestArea ) : Promise < Array < out String > >

{ <EOL> val helperFilesPromises = mutableListOf < Promise < String > > ( ) <EOL> helperNames . forEach { helperName -> <EOL> helperFilesPromises . add ( SpecTestsLoader . loadHelperFile ( helperName , testArea ) ) <EOL> } <EOL> return Promise . all ( helperFilesPromises . toTypedArray ( ) ) <EOL> }


fun showViewer ( sentenceElement : JQuery )

{ <EOL> val tests = sentenceElement . data ( "<STR_LIT>" ) as? SpecSentence ? : return <EOL> val sentenceText = "<STR_LIT>" . format ( sentenceElement . clone ( ) . children ( "<STR_LIT>" ) . text ( ) ) <EOL> currentSpecSentenceTests = tests <EOL> testPopup = Popup ( PopupConfig ( title = "<STR_LIT>" , content = SpecCoverageHighlighter . TEMPLATE , width = <NUM_LIT> , height = <NUM_LIT> ) ) . apply { open ( ) } <EOL> `$` ( TEST_AREA_OPTION_SELECTOR ) . each { _ , el -> <EOL> val testArea = `$` ( el ) <EOL> if ( tests . getTests ( TestArea . getByShortName ( testArea . attr ( "<STR_LIT:value>" ) ) ) == null ) { <EOL> testArea . remove ( ) <EOL> } <EOL> } <EOL> `$` ( TEST_AREA_SELECTOR ) . `val` ( `$` ( TEST_AREA_OPTION_SELECTOR ) . eq ( <NUM_LIT:0> ) . `val` ( ) . toString ( ) ) <EOL> onTestAreaChange ( ) <EOL> }


{ <EOL> val testArea = TestArea . getByShortName ( `$` ( TEST_AREA_SELECTOR ) . `val` ( ) . toString ( ) . apply { if ( isEmpty ( ) ) return } ) <EOL> currentSpecSentenceTests . getTests ( testArea ) ? : return <EOL> TestType . values ( ) . forEach { testType -> <EOL> val tests = currentSpecSentenceTests . getTests ( testArea , testType ) ? : return@forEach <EOL> if ( tests . isNotEmpty ( ) ) <EOL> `$` ( TEST_TYPE_SELECTOR ) . append ( TEST_TYPE_OPTION_TEMPLATE . format ( testType . shortName , testType . name ) ) <EOL> } <EOL> `$` ( TEST_TYPE_SELECTOR ) . show ( ) . `val` ( `$` ( TEST_TYPE_OPTION_SELECTOR ) . eq ( <NUM_LIT:0> ) . `val` ( ) . toString ( ) ) <EOL> onTestTypeChange ( ) <EOL> }


{ <EOL> val testType = TestType . getByShortName ( `$` ( TEST_TYPE_SELECTOR ) . `val` ( ) . toString ( ) . apply { if ( isEmpty ( ) ) return } ) <EOL> val testArea = TestArea . getByShortName ( `$` ( TEST_AREA_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val tests = currentSpecSentenceTests . getTests ( testArea , testType ) <EOL> ? : return <EOL> `$` ( TEST_PRIORITY_OPTION_SELECTOR ) . each { _ , el -> <EOL> val testPriority = `$` ( el ) <EOL> if ( tests . getTestsByTestPriority ( LinkType . valueOf ( testPriority . attr ( "<STR_LIT:value>" ) ) ) . isEmpty ( ) ) { <EOL> testPriority . remove ( ) <EOL> } <EOL> } <EOL> `$` ( TEST_PRIORITY_SELECTOR ) . `val` ( `$` ( TEST_PRIORITY_OPTION_SELECTOR ) . eq ( <NUM_LIT:0> ) . `val` ( ) . toString ( ) ) <EOL> onTestPriorityChange ( ) <EOL> }


private fun List < SpecTest > . getTestsByTestPriority ( attr : LinkType ) : List < SpecTest >

{ <EOL> return this . filter { test -> test . testInfo . linkType == attr } <EOL> }


{ <EOL> val testPriority = LinkType . valueOf ( `$` ( TEST_PRIORITY_SELECTOR ) . `val` ( ) . toString ( ) . apply { if ( isEmpty ( ) ) return } ) <EOL> val testArea = TestArea . getByShortName ( `$` ( TEST_AREA_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val testType = TestType . getByShortName ( `$` ( TEST_TYPE_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val tests = currentSpecSentenceTests . getTests ( testArea , testType , testPriority ) ? : return <EOL> `$` ( TEST_NUMBER_SELECTOR ) . empty ( ) <EOL> tests . forEach { test -> <EOL> `$` ( TEST_NUMBER_SELECTOR ) . append ( TEST_NUMBER_OPTION_TEMPLATE . format ( test . testInfo . testNumber , test . testInfo . description ) ) <EOL> } <EOL> `$` ( TEST_NUMBER_SELECTOR ) . show ( ) . `val` ( `$` ( TEST_NUMBER_OPTION_SELECTOR ) . eq ( <NUM_LIT:0> ) . `val` ( ) . toString ( ) ) <EOL> onTestNumberChange ( ) <EOL> }


{ <EOL> val testNumber = `$` ( TEST_NUMBER_SELECTOR ) . `val` ( ) . toString ( ) . apply { if ( isEmpty ( ) ) return } . toInt ( ) <EOL> val testPriority = LinkType . valueOf ( `$` ( TEST_PRIORITY_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val testArea = TestArea . getByShortName ( `$` ( TEST_AREA_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val testType = TestType . getByShortName ( `$` ( TEST_TYPE_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val specTest = currentSpecSentenceTests . getTest ( testArea , testType , testPriority , testNumber ) ? : return <EOL> if ( specTest . testInfo . helpers . isNotEmpty ( ) ) { <EOL> getHelpers ( specTest . testInfo . helpers , testArea ) . then { <EOL> showTestCaseCode ( specTest , it . toSet ( ) ) <EOL> } <EOL> } else { <EOL> showTestCaseCode ( specTest ) <EOL> } <EOL> }


fun navigateTestCase ( navigationLink : JQuery , navigationType : NavigationType )

{ <EOL> if ( navigationLink . hasClass ( "<STR_LIT>" ) ) return <EOL> val testArea = TestArea . getByShortName ( `$` ( TEST_AREA_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val testType = TestType . getByShortName ( `$` ( TEST_TYPE_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val testNumber = `$` ( TEST_NUMBER_SELECTOR ) . `val` ( ) . toString ( ) . toInt ( ) <EOL> val testPriority = LinkType . valueOf ( `$` ( TEST_PRIORITY_SELECTOR ) . `val` ( ) . toString ( ) ) <EOL> val specTest = currentSpecSentenceTests . getTest ( testArea , testType , testPriority , testNumber ) ? : return <EOL> val currentNumber = `$` ( TESTCASE_NUMBER_SELECTOR ) . text ( ) . toInt ( ) <EOL> val caseNumber = if ( navigationType == NavigationType . PREV ) currentNumber - <NUM_LIT:2> else currentNumber <EOL> val testCases = specTest . testCases <EOL> `$` ( TESTCASE_NUMBER_SELECTOR ) . html ( ( caseNumber + <NUM_LIT:1> ) . toString ( ) ) <EOL> if ( specTest . testInfo . helpers . isNotEmpty ( ) ) { <EOL> getHelpers ( specTest . testInfo . helpers , testArea ) . then { <EOL> insertCode ( testCases [ caseNumber ] , it . toSet ( ) ) <EOL> } <EOL> } else { <EOL> insertCode ( testCases [ caseNumber ] ) <EOL> } <EOL> if ( caseNumber + <NUM_LIT:1> >= testCases . size ) { <EOL> `$` ( NEXT_TESTCASE_SELECTOR ) . addClass ( "<STR_LIT>" ) <EOL> } else if ( navigationType == NavigationType . PREV && `$` ( NEXT_TESTCASE_SELECTOR ) . hasClass ( "<STR_LIT>" ) ) { <EOL> `$` ( NEXT_TESTCASE_SELECTOR ) . removeClass ( "<STR_LIT>" ) <EOL> } <EOL> if ( navigationType == NavigationType . NEXT && `$` ( PREV_TESTCASE_SELECTOR ) . hasClass ( "<STR_LIT>" ) ) { <EOL> `$` ( PREV_TESTCASE_SELECTOR ) . removeClass ( "<STR_LIT>" ) <EOL> } else if ( caseNumber + <NUM_LIT:1> == <NUM_LIT:1> ) { <EOL> `$` ( PREV_TESTCASE_SELECTOR ) . addClass ( "<STR_LIT>" ) <EOL> } <EOL> }


inline fun < reified A > isDocumented ( ) : Boolean

= <EOL> A :: class . java . getDeclaredAnnotation ( Documented :: class . java ) != null


{ <EOL> if ( isDocumented < NoDocumented > ( ) ) return "<STR_LIT>" <EOL> if ( ! isDocumented < ExplicitMustBeDocumented > ( ) ) return "<STR_LIT>" <EOL> if ( ! isDocumented < ExplicitJavaDocumented > ( ) ) return "<STR_LIT>" <EOL> if ( ! isDocumented < ExplicitBoth > ( ) ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


external fun __promisify__ ( hostname : String ) : Promise < Array < dns . NaptrRecord > >


fun < T > runBlocking ( c : suspend ( ) -> T ) : T

{ <EOL> var res : T ? = null <EOL> c . startCoroutine ( Continuation ( EmptyCoroutineContext ) { <EOL> res = it . getOrThrow ( ) <EOL> } ) <EOL> return res ! ! <EOL> }


= runBlocking { <EOL> action . invoke ( ) <EOL> }


fun < W > withExponentialBackoff ( action : ( ) -> W ) : Builder < W >

{ <EOL> return Builder ( action ) <EOL> }


{ <EOL> return Owner ( "<STR_LIT>" ) . withExponentialBackoff { "<STR_LIT:OK>" } . foo ( ) <EOL> }


fun make ( x : String ) : C


= makeC . make ( "<STR_LIT:OK>" )


= make ( :: C ) . test


{ <EOL> ( f ) ( ) <EOL> }


fun addAll ( other : BuildPerformanceMetrics < T > )

{ <EOL> for ( ( bt , timeNs ) in other . myBuildMetrics ) { <EOL> add ( bt , timeNs ) <EOL> } <EOL> }


fun add ( metric : T , value : Long = <NUM_LIT:1> )

{ <EOL> myBuildMetrics [ metric ] = myBuildMetrics . getOrDefault ( metric , <NUM_LIT:0> ) + value <EOL> }


= myBuildMetrics


{ <EOL> val plusZero : Any = <NUM_LIT:0.0> <EOL> val minusZero : Any = - <NUM_LIT:0.0> <EOL> val nullDouble : Double ? = null <EOL> if ( plusZero is Double ) { <EOL> when ( plusZero ) { <EOL> nullDouble -> { <EOL> return "<STR_LIT:failU+00201>" <EOL> } <EOL> - <NUM_LIT:0.0> -> { <EOL> } <EOL> else -> { <EOL> return "<STR_LIT:failU+00202>" <EOL> } <EOL> } <EOL> if ( minusZero is Double ) { <EOL> when ( plusZero ) { <EOL> nullDouble -> { <EOL> return "<STR_LIT:failU+00203>" <EOL> } <EOL> minusZero -> { <EOL> } <EOL> else -> { <EOL> return "<STR_LIT:failU+00204>" <EOL> } <EOL> } <EOL> } <EOL> } <EOL> return "<STR_LIT:OK>" <EOL> }


fun render ( analysisSession : KtAnalysisSession , type : KtType ? , variance : Variance = Variance . INVARIANT , ) : String ?

{ <EOL> with ( analysisSession ) { <EOL> return type ? . render ( position = variance ) <EOL> } <EOL> }


fun render ( type : PsiType ? ) : String ?

= type ? . let ( PsiClassRenderer :: renderType )


internal fun getContainingKtLightClass ( declaration : KtDeclaration , ktFile : KtFile , ) : KtLightClass

{ <EOL> val project = ktFile . project <EOL> return createLightClassByContainingClass ( declaration , project ) <EOL> ? : getFacadeLightClass ( ktFile , project ) <EOL> ? : error ( "<STR_LIT>" ) <EOL> }


private fun getFacadeLightClass ( ktFile : KtFile , project : Project , ) : KtLightClass ?

= project . getService ( KotlinAsJavaSupport :: class . java ) . getLightFacade ( ktFile )


private fun createLightClassByContainingClass ( declaration : KtDeclaration , project : Project ) : KtLightClass ?

{ <EOL> val containingClass = declaration . parents . firstIsInstanceOrNull < KtClassOrObject > ( ) ? : return null <EOL> return KotlinAsJavaSupport . getInstance ( project ) . getLightClass ( containingClass ) <EOL> }


internal fun KtLightClass . findLightDeclarationContext ( ktDeclaration : KtDeclaration ) : KtLightElement < * , * > ?

{ <EOL> val selfOrParents = listOf ( ktDeclaration ) + ktDeclaration . parents . filterIsInstance < KtDeclaration > ( ) <EOL> var result : KtLightElement < * , * > ? = null <EOL> val visitor = object : PsiElementVisitor ( ) { <EOL> override fun visitElement ( element : PsiElement ) { <EOL> if ( element !is KtLightElement < * , * > ) return <EOL> if ( element is PsiClass ) { <EOL> element . fields . forEach { it . accept ( this ) } <EOL> element . methods . forEach { it . accept ( this ) } <EOL> element . innerClasses . forEach { it . accept ( this ) } <EOL> } <EOL> if ( result == null && element . kotlinOrigin in selfOrParents ) { <EOL> result = element <EOL> return <EOL> } <EOL> } <EOL> } <EOL> accept ( visitor ) <EOL> return result <EOL> }


override fun DokkatooFormatPluginContext . configure ( )

{ <EOL> project . dependencies { <EOL> dokkaPlugin ( dokka ( "<STR_LIT>" ) ) <EOL> } <EOL> }


{ <EOL> val i = <NUM_LIT:1> <EOL> if ( i . getter != <NUM_LIT:1> ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


fun foo ( ) : CharSequence ?


fun foo ( ) : String


{ <EOL> if ( c is B && c is A ) { <EOL> c . foo ( ) . checkType { _ < String > ( ) } <EOL> } <EOL> }


override fun resolveFunctionTypeIfSamInterface ( classDescriptor : ClassDescriptor ) : SimpleType ?

{ <EOL> return resolver . resolveFunctionTypeIfSamInterface ( classDescriptor ) <EOL> }


{ <EOL> return functionTypesForSamInterfaces . computeIfAbsent ( classDescriptor ) { <EOL> val abstractMethod = getSingleAbstractMethodOrNull ( classDescriptor ) ? : return@computeIfAbsent null <EOL> val shouldConvertFirstParameterToDescriptor = samWithReceiverResolvers . any { it . shouldConvertFirstSamParameterToReceiver ( abstractMethod ) } <EOL> getFunctionTypeForAbstractMethod ( abstractMethod , shouldConvertFirstParameterToDescriptor ) <EOL> } <EOL> }


fun getSingleAbstractMethodOrNull ( klass : ClassDescriptor ) : FunctionDescriptor ?

{ <EOL> if ( klass . fqNameSafe . asString ( ) . endsWith ( "<STR_LIT>" ) ) return null <EOL> if ( klass . isDefinitelyNotSamInterface ) return null <EOL> val abstractMember = getAbstractMembers ( klass ) . singleOrNull ( ) ? : return null <EOL> return if ( abstractMember is SimpleFunctionDescriptor && abstractMember . typeParameters . isEmpty ( ) ) <EOL> abstractMember <EOL> else <EOL> null <EOL> }


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> fun getAbstractMembers ( classDescriptor : ClassDescriptor ) : List < CallableMemberDescriptor >

{ <EOL> return DescriptorUtils <EOL> . getAllDescriptors ( classDescriptor . unsubstitutedMemberScope ) <EOL> . filter { it is CallableMemberDescriptor && it . modality == Modality . ABSTRACT } as List < CallableMemberDescriptor > <EOL> }


fun getFunctionTypeForAbstractMethod ( function : FunctionDescriptor , shouldConvertFirstParameterToDescriptor : Boolean ) : SimpleType

{ <EOL> val returnType = function . returnType ? : error ( "<STR_LIT>" ) <EOL> val valueParameters = function . valueParameters <EOL> val parameterTypes = ArrayList < KotlinType > ( valueParameters . size ) <EOL> val parameterNames = ArrayList < Name > ( valueParameters . size ) <EOL> val contextReceiversTypes = function . contextReceiverParameters . map { it . type } <EOL> var startIndex = <NUM_LIT:0> <EOL> var receiverType : KotlinType ? = null <EOL> val extensionReceiver = function . extensionReceiverParameter <EOL> if ( extensionReceiver != null ) { <EOL> receiverType = extensionReceiver . type <EOL> } else if ( shouldConvertFirstParameterToDescriptor && function . valueParameters . isNotEmpty ( ) ) { <EOL> receiverType = valueParameters [ <NUM_LIT:0> ] . type <EOL> startIndex = <NUM_LIT:1> <EOL> } <EOL> for ( i in startIndex until valueParameters . size ) { <EOL> val parameter = valueParameters [ i ] <EOL> parameterTypes . add ( parameter . type ) <EOL> parameterNames . add ( if ( function . hasSynthesizedParameterNames ( ) ) SpecialNames . NO_NAME_PROVIDED else parameter . name ) <EOL> } <EOL> return createFunctionType ( function . builtIns , EMPTY , receiverType , contextReceiversTypes , parameterTypes , parameterNames , returnType , function . isSuspend ) <EOL> }


fun SamConversionResolver . getFunctionTypeForPossibleSamType ( possibleSamType : UnwrappedType , samConversionOracle : SamConversionOracle ) : UnwrappedType ?

= getFunctionTypeForSamType ( possibleSamType , this , samConversionOracle ) ? . unwrap ( )


fun getFunctionTypeForSamType ( samType : KotlinType , samResolver : SamConversionResolver , samConversionOracle : SamConversionOracle ) : KotlinType ?

{ <EOL> val unwrappedType = samType . unwrap ( ) <EOL> if ( unwrappedType is FlexibleType ) { <EOL> val lower = getFunctionTypeForSamType ( unwrappedType . lowerBound , samResolver , samConversionOracle ) <EOL> val upper = getFunctionTypeForSamType ( unwrappedType . upperBound , samResolver , samConversionOracle ) <EOL> assert ( ( lower == null ) == ( upper == null ) ) { "<STR_LIT>" } <EOL> if ( lower == null || upper == null ) return null <EOL> return KotlinTypeFactory . flexibleType ( lower , upper ) <EOL> } else { <EOL> return getFunctionTypeForSamType ( unwrappedType as SimpleType , samResolver , samConversionOracle ) <EOL> } <EOL> }