{ <EOL> val map = mutableMapOf < String , String > ( ) . apply { entries . forEach { this [ it . key ] = it . value } } <EOL> return persistentMapOf < String , String > ( ) . putAll ( map ) <EOL> }


override fun create ( entries : Array < out Map . Entry < String , String > > ) : Map < String , String >

{ <EOL> return entries . fold ( persistentMapOf ( ) ) { map , entry -> map . put ( entry . key , entry . value ) } <EOL> }


{ <EOL> val map = mutableMapOf < String , String > ( ) . apply { entries . forEach { this [ it . key ] = it . value } } <EOL> return persistentMapOf < String , String > ( ) . mutate { it . putAll ( map ) } <EOL> }


{ <EOL> return persistentMapOf < String , String > ( ) . mutate { builder -> entries . forEach { builder [ it . key ] = it . value } } <EOL> }


override fun create ( entries : Array < out Map . Entry < String , String > > ) : MutableMap < String , String >

{ <EOL> return persistentMapOf ( * entries . map { it . key to it . value } . toTypedArray ( ) ) . builder ( ) <EOL> }


{ <EOL> val map = mutableMapOf < String , String > ( ) . apply { entries . forEach { this [ it . key ] = it . value } } <EOL> return persistentMapOf < String , String > ( ) . builder ( ) . apply { putAll ( map ) } <EOL> }


{ <EOL> return persistentMapOf < String , String > ( ) . builder ( ) . apply { entries . forEach { this [ it . key ] = it . value } } <EOL> }


public fun < T : Number , D : Dimension > MultiArray < T , D > . toSortedSet ( ) : java . util . SortedSet < T >

{ <EOL> return toCollection ( java . util . TreeSet ( ) ) <EOL> }

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */


public fun < T , D : Dimension > MultiArray < T , D > . toSortedSet ( comparator : Comparator < in T > ) : java . util . SortedSet < T >

{ <EOL> return toCollection ( java . util . TreeSet ( comparator ) ) <EOL> }

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 *
 * Elements in the set returned are sorted according to the given [comparator].
 */


fun < T : In < T > > foo ( o : Out < T > ) : Recursive < T > ?

= null


{ <EOL> foo ( o ) ? : return <EOL> }


private inline fun < reified T : NativeBinary > getBinary ( namePrefix : String , buildType : NativeBuildType , outputKind : NativeOutputKind ) : T

{ <EOL> val classifier = outputKind . taskNameClassifier <EOL> val name = generateBinaryName ( namePrefix , buildType , classifier ) <EOL> val binary = getByName ( name ) <EOL> require ( binary is T && binary . buildType == buildType ) { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> return binary <EOL> }


private inline fun < reified T : NativeBinary > findBinary ( namePrefix : String , buildType : NativeBuildType , outputKind : NativeOutputKind ) : T ?

{ <EOL> val classifier = outputKind . taskNameClassifier <EOL> val name = generateBinaryName ( namePrefix , buildType , classifier ) <EOL> val binary = findByName ( name ) <EOL> return if ( binary is T && binary . buildType == buildType ) { <EOL> binary <EOL> } else { <EOL> null <EOL> } <EOL> }


override fun getByName ( name : String ) : NativeBinary

= nameToBinary . getValue ( name )


override fun findByName ( name : String ) : NativeBinary ?

= nameToBinary [ name ]


override fun getExecutable ( namePrefix : String , buildType : NativeBuildType ) : Executable

{ <EOL> return getBinary ( namePrefix , buildType , NativeOutputKind . EXECUTABLE ) <EOL> }


override fun getStaticLib ( namePrefix : String , buildType : NativeBuildType ) : StaticLibrary

= <EOL> getBinary ( namePrefix , buildType , NativeOutputKind . STATIC )


override fun getSharedLib ( namePrefix : String , buildType : NativeBuildType ) : SharedLibrary

= <EOL> getBinary ( namePrefix , buildType , NativeOutputKind . DYNAMIC )


override fun getFramework ( namePrefix : String , buildType : NativeBuildType ) : Framework

= <EOL> getBinary ( namePrefix , buildType , NativeOutputKind . FRAMEWORK )


override fun getTest ( namePrefix : String , buildType : NativeBuildType ) : TestExecutable

= <EOL> getBinary ( namePrefix , buildType , NativeOutputKind . TEST )


override fun findExecutable ( namePrefix : String , buildType : NativeBuildType ) : Executable ?

{ <EOL> return findBinary ( namePrefix , buildType , NativeOutputKind . EXECUTABLE ) <EOL> }


override fun findStaticLib ( namePrefix : String , buildType : NativeBuildType ) : StaticLibrary ?

= <EOL> findBinary ( namePrefix , buildType , NativeOutputKind . STATIC )


override fun findSharedLib ( namePrefix : String , buildType : NativeBuildType ) : SharedLibrary ?

= <EOL> findBinary ( namePrefix , buildType , NativeOutputKind . DYNAMIC )


override fun findFramework ( namePrefix : String , buildType : NativeBuildType ) : Framework ?

= <EOL> findBinary ( namePrefix , buildType , NativeOutputKind . FRAMEWORK )


override fun findTest ( namePrefix : String , buildType : NativeBuildType ) : TestExecutable ?

= <EOL> findBinary ( namePrefix , buildType , NativeOutputKind . TEST )


override fun < T : NativeBinary > createBinaries ( namePrefix : String , baseName : String , outputKind : NativeOutputKind , buildTypes : Collection < NativeBuildType > , create : ( name : String , baseName : String , buildType : NativeBuildType , compilation : KotlinNativeCompilation ) -> T , configure : T . ( ) -> Unit )

{ <EOL> val prefixGroup = prefixGroups . findByName ( namePrefix ) ? : PrefixGroup ( namePrefix ) . also { <EOL> prefixGroups . add ( it ) <EOL> } <EOL> buildTypes . forEach { buildType -> <EOL> val name = generateBinaryName ( namePrefix , buildType , outputKind . taskNameClassifier ) <EOL> require ( name !in nameToBinary ) { <EOL> "<STR_LIT>" <EOL> } <EOL> require ( outputKind . availableFor ( target . konanTarget ) ) { <EOL> "<STR_LIT>" <EOL> } <EOL> val compilation = if ( outputKind == NativeOutputKind . TEST ) defaultTestCompilation else defaultCompilation <EOL> val binary = create ( name , baseName , buildType , compilation ) <EOL> add ( binary ) <EOL> prefixGroup . binaries . add ( binary ) <EOL> nameToBinary [ binary . name ] = binary <EOL> if ( this is ExtensionAware ) { <EOL> extensions . add ( binary . name , binary ) <EOL> } <EOL> binary . configure ( ) <EOL> } <EOL> }


internal fun generateBinaryName ( prefix : String , buildType : NativeBuildType , outputKindClassifier : String )

= <EOL> lowerCamelCaseName ( prefix , buildType . getName ( ) , outputKindClassifier )


internal fun extractPrefixFromBinaryName ( name : String , buildType : NativeBuildType , outputKindClassifier : String ) : String

{ <EOL> val suffix = lowerCamelCaseName ( buildType . getName ( ) , outputKindClassifier ) <EOL> return if ( name == suffix ) <EOL> "<STR_LIT>" <EOL> else <EOL> name . substringBeforeLast ( suffix . capitalizeAsciiOnly ( ) ) <EOL> }


= name


@ PublishedApi <EOL> internal fun < T : Enum < T > > enumValuesIntrinsic ( ) : Array < T >

= <EOL> throw IllegalStateException ( "<STR_LIT>" )


@ PublishedApi <EOL> internal fun < T : Enum < T > > enumValueOfIntrinsic ( @ Suppress ( "<STR_LIT:UNUSED_PARAMETER>" ) name : String ) : T


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . HIDDEN ) <EOL> internal fun safePropertyGet ( self : dynamic , getterName : String , propName : String ) : dynamic

{ <EOL> val getter = self [ getterName ] <EOL> return if ( getter != null ) getter . call ( self ) else self [ propName ] <EOL> }


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . HIDDEN ) <EOL> internal fun safePropertySet ( self : dynamic , setterName : String , propName : String , value : dynamic )

{ <EOL> val setter = self [ setterName ] <EOL> if ( setter != null ) setter . call ( self , value ) else self [ propName ] = value <EOL> }


{ <EOL> fun foo ( ) { } <EOL> fun bar ( x : Int ) { } <EOL> fun baz ( ) = "<STR_LIT:OK>" <EOL> val x = :: foo <EOL> val y = :: bar <EOL> val z = :: baz <EOL> checkSubtype < KFunction0 < Unit > > ( x ) <EOL> checkSubtype < KFunction1 < Int , Unit > > ( y ) <EOL> checkSubtype < KFunction0 < String > > ( z ) <EOL> }


override fun invoke ( modules : List < DModule > ) : List < DModule >

{ <EOL> return modules . filter { it . children . isNotEmpty ( ) } <EOL> }


internal fun __ieee754_log ( _x : Double ) : Double

{ <EOL> var x : Double = _x <EOL> var hfsq : Double <EOL> var f : Double <EOL> var s : Double <EOL> var z : Double <EOL> var R : Double <EOL> var w : Double <EOL> var t1 : Double <EOL> var t2 : Double <EOL> var dk : Double <EOL> var k : Int <EOL> var hx : Int <EOL> var i : Int <EOL> var j : Int <EOL> var lx : UInt <EOL> hx = __HI ( x ) <EOL> lx = __LOu ( x ) <EOL> k = <NUM_LIT:0> <EOL> if ( hx < <NUM_LIT> ) { <EOL> if ( ( ( hx and <NUM_LIT> ) or lx . toInt ( ) ) == <NUM_LIT:0> ) <EOL> return Double . NEGATIVE_INFINITY <EOL> if ( hx < <NUM_LIT:0> ) return Double . NaN <EOL> k -= <NUM_LIT> ; x *= two54 <EOL> hx = __HI ( x ) <EOL> } <EOL> if ( hx >= <NUM_LIT> ) return x + x <EOL> k += ( hx shr <NUM_LIT:20> ) - <NUM_LIT> <EOL> hx = hx and <NUM_LIT> <EOL> i = ( hx + <NUM_LIT> ) and <NUM_LIT> <EOL> x = doubleSetWord ( d = x , hi = hx or ( i xor <NUM_LIT> ) ) <EOL> k += ( i shr <NUM_LIT:20> ) <EOL> f = x - <NUM_LIT:1.0> <EOL> if ( ( <NUM_LIT> and ( <NUM_LIT:2> + hx ) ) < <NUM_LIT:3> ) { <EOL> if ( f == zero ) if ( k == <NUM_LIT:0> ) return zero ; else { <EOL> dk = k . toDouble ( ) <EOL> return dk * ln2_hi + dk * ln2_lo <EOL> } <EOL> R = f * f * ( <NUM_LIT> - <NUM_LIT> * f ) <EOL> if ( k == <NUM_LIT:0> ) return f - R ; else { <EOL> dk = k . toDouble ( ) <EOL> return dk * ln2_hi - ( ( R - dk * ln2_lo ) - f ) <EOL> } <EOL> } <EOL> s = f / ( <NUM_LIT:2.0> + f ) <EOL> dk = k . toDouble ( ) <EOL> z = s * s <EOL> i = hx - <NUM_LIT> <EOL> w = z * z <EOL> j = <NUM_LIT> - hx <EOL> t1 = w * ( Lg2 + w * ( Lg4 + w * Lg6 ) ) <EOL> t2 = z * ( Lg1 + w * ( Lg3 + w * ( Lg5 + w * Lg7 ) ) ) <EOL> i = i or j <EOL> R = t2 + t1 <EOL> if ( i > <NUM_LIT:0> ) { <EOL> hfsq = <NUM_LIT> * f * f <EOL> if ( k == <NUM_LIT:0> ) return f - ( hfsq - s * ( hfsq + R ) ) ; else <EOL> return dk * ln2_hi - ( ( hfsq - ( s * ( hfsq + R ) + dk * ln2_lo ) ) - f ) <EOL> } else { <EOL> if ( k == <NUM_LIT:0> ) return f - s * ( f - R ) ; else <EOL> return dk * ln2_hi - ( ( s * ( f - R ) - dk * ln2_lo ) - f ) <EOL> } <EOL> }


= fn ( )


{ <EOL> return eval { <EOL> eval { <EOL> class Local : Inner ( ) { <EOL> override fun toString ( ) = foo ( ) <EOL> } <EOL> Local ( ) <EOL> } <EOL> } <EOL> }


= "<STR_LIT:OK>"


= A ( ) . bar ( ) . toString ( )


{ <EOL> when ( x ) { <EOL> <NUM_LIT:0> -> <NUM_LIT:0> <EOL> } <EOL> }


{ <EOL> val s = StringBuilder ( ) <EOL> for ( ( index , x ) in xs . withIndex ( ) ) { <EOL> return "<STR_LIT>" <EOL> } <EOL> return "<STR_LIT:OK>" <EOL> }


= ArrayList ( )


fun f ( x : String = "<STR_LIT:1>" ) : String


fun g ( x : String = "<STR_LIT:2>" ) : String


fun h ( x : T = prop ) : T


override fun f ( x : String ) : String


override fun g ( x : String ) : String


override fun h ( x : T ) : T


= x


{ <EOL> val i : I < String > = B ( ) <EOL> var result = i . f ( ) + i . g ( ) + i . h ( ) <EOL> if ( result != "<STR_LIT:123>" ) return "<STR_LIT>" <EOL> val b = B ( ) <EOL> result = b . f ( ) + b . g ( ) + b . h ( ) <EOL> if ( result != "<STR_LIT:123>" ) return "<STR_LIT>" <EOL> val a : A < String > = B ( ) <EOL> result = a . f ( "<STR_LIT>" ) + a . g ( "<STR_LIT>" ) + a . h ( "<STR_LIT:e>" ) <EOL> if ( result != "<STR_LIT>" ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> z = "<STR_LIT:OK>" <EOL> return z <EOL> }


{ <EOL> return Test ( ) . test ( ) <EOL> }


fun Project . overridePublicationArtifactId ( artifactId : String , publicationName : String = PublicationName . JVM )

{ <EOL> extensions . configure < PublishingExtension > { <EOL> publications . withType < MavenPublication > ( ) . named ( publicationName ) { <EOL> this . artifactId = artifactId <EOL> } <EOL> } <EOL> }


= <EOL> throw NotImplementedError ( "<STR_LIT>" + toString ( ) )


= ok


{ <EOL> val x = "<STR_LIT:OK>" <EOL> return x <EOL> }


= ok3


= okext


override fun check ( declaration : FirSimpleFunction , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> if ( ! declaration . isTailRec ) return <EOL> if ( ! ( declaration . isEffectivelyFinal ( context ) || declaration . visibility == Visibilities . Private ) ) { <EOL> reporter . reportOn ( declaration . source , FirErrors . TAILREC_ON_VIRTUAL_MEMBER_ERROR , context ) <EOL> } <EOL> val graph = declaration . controlFlowGraphReference ? . controlFlowGraph ? : return <EOL> var tryScopeCount = <NUM_LIT:0> <EOL> var catchScopeCount = <NUM_LIT:0> <EOL> var finallyScopeCount = <NUM_LIT:0> <EOL> var tailrecCount = <NUM_LIT:0> <EOL> graph . traverse ( object : ControlFlowGraphVisitorVoid ( ) { <EOL> override fun visitNode ( node : CFGNode < * > ) { } <EOL> override fun visitTryMainBlockEnterNode ( node : TryMainBlockEnterNode ) { <EOL> tryScopeCount ++ <EOL> } <EOL> override fun visitTryMainBlockExitNode ( node : TryMainBlockExitNode ) { <EOL> tryScopeCount -- <EOL> } <EOL> override fun visitCatchClauseEnterNode ( node : CatchClauseEnterNode ) { <EOL> catchScopeCount ++ <EOL> } <EOL> override fun visitCatchClauseExitNode ( node : CatchClauseExitNode ) { <EOL> catchScopeCount -- <EOL> } <EOL> override fun visitFinallyBlockEnterNode ( node : FinallyBlockEnterNode ) { <EOL> finallyScopeCount ++ <EOL> } <EOL> override fun visitFinallyBlockExitNode ( node : FinallyBlockExitNode ) { <EOL> finallyScopeCount -- <EOL> } <EOL> override fun visitFunctionCallNode ( node : FunctionCallNode ) { <EOL> val functionCall = node . fir <EOL> val resolvedSymbol = functionCall . calleeReference . toResolvedCallableSymbol ( ) as? FirNamedFunctionSymbol ? : return <EOL> if ( resolvedSymbol != declaration . symbol ) return <EOL> if ( functionCall . arguments . size != resolvedSymbol . valueParameterSymbols . size && resolvedSymbol . isOverride ) { <EOL> reporter . reportOn ( functionCall . source , FirErrors . NON_TAIL_RECURSIVE_CALL , context ) <EOL> return <EOL> } <EOL> val dispatchReceiver = functionCall . dispatchReceiver <EOL> val dispatchReceiverOwner = declaration . dispatchReceiverType ? . toSymbol ( context . session ) as? FirClassSymbol < * > <EOL> val sameReceiver = dispatchReceiver == null || <EOL> ( dispatchReceiver is FirThisReceiverExpression && dispatchReceiver . calleeReference . boundSymbol == dispatchReceiverOwner ) || <EOL> dispatchReceiverOwner ? . classKind ? . isSingleton == true <EOL> if ( ! sameReceiver ) { <EOL> reporter . reportOn ( functionCall . source , FirErrors . NON_TAIL_RECURSIVE_CALL , context ) <EOL> } else if ( tryScopeCount > <NUM_LIT:0> || catchScopeCount > <NUM_LIT:0> || finallyScopeCount > <NUM_LIT:0> ) { <EOL> reporter . reportOn ( functionCall . source , FirErrors . TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED , context ) <EOL> } else if ( node . hasMoreFollowingInstructions ( declaration ) ) { <EOL> reporter . reportOn ( functionCall . source , FirErrors . NON_TAIL_RECURSIVE_CALL , context ) <EOL> } else if ( ! node . isDead ) { <EOL> tailrecCount ++ <EOL> } <EOL> } <EOL> } ) <EOL> if ( tailrecCount == <NUM_LIT:0> ) { <EOL> reporter . reportOn ( declaration . source , FirErrors . NO_TAIL_CALLS_FOUND , context ) <EOL> } <EOL> }


private fun CFGNode < * > . hasMoreFollowingInstructions ( tailrecFunction : FirSimpleFunction ) : Boolean

{ <EOL> for ( next in followingNodes ) { <EOL> val edge = edgeTo ( next ) <EOL> if ( ! edge . kind . usedInCfa || edge . kind . isDead ) continue <EOL> if ( edge . kind . isBack ) return true <EOL> val hasMore = when ( next ) { <EOL> is FunctionExitNode -> return next . fir != tailrecFunction <EOL> is JumpNode , is BinaryAndExitNode , is BinaryOrExitNode , is WhenBranchResultExitNode , is WhenExitNode , is BlockExitNode , <EOL> is ExitSafeCallNode <EOL> -> next . hasMoreFollowingInstructions ( tailrecFunction ) <EOL> else -> return true <EOL> } <EOL> if ( hasMore ) return hasMore <EOL> } <EOL> return false <EOL> }


override fun create ( typeSpecificityComparator : TypeSpecificityComparator , components : InferenceComponents , transformerComponents : BodyResolveComponents ) : ConeCompositeConflictResolver

{ <EOL> val specificityComparator = TypeSpecificityComparator . NONE <EOL> return ConeCompositeConflictResolver ( ConeEquivalentCallConflictResolver ( specificityComparator , components , transformerComponents ) , ConeIntegerOperatorConflictResolver , ConeOverloadConflictResolver ( specificityComparator , components , transformerComponents ) , ) <EOL> }


{ <EOL> c . startCoroutine ( EmptyContinuation ) <EOL> }


= TODO ( )


suspend fun < T > fooReturnLong ( x : T ) : Long

= <NUM_LIT:1L>


suspend fun Int . suspendToString ( ) : String

= toString ( )


suspend inline fun < reified T , reified R > check ( x : T , y : R , f : suspend ( T ) -> R , tType : String , rType : String )

{ <EOL> assertEquals ( tType , T :: class . simpleName ) <EOL> assertEquals ( rType , R :: class . simpleName ) <EOL> }


suspend inline fun < reified T , reified R > check ( f : suspend ( T ) -> R , g : suspend ( T ) -> R , tType : String , rType : String )


{ <EOL> builder { <EOL> check ( "<STR_LIT>" , <NUM_LIT:1> , :: foo , "<STR_LIT:String>" , "<STR_LIT:Int>" ) <EOL> check ( "<STR_LIT>" , <NUM_LIT:1L> , :: fooReturnLong , "<STR_LIT:String>" , "<STR_LIT>" ) <EOL> check ( "<STR_LIT>" , "<STR_LIT>" , :: fooReturnLong , "<STR_LIT:String>" , "<STR_LIT>" ) <EOL> check ( Int :: suspendToString , :: foo , "<STR_LIT:Int>" , "<STR_LIT:String>" ) <EOL> } <EOL> return "<STR_LIT:OK>" <EOL> }


override fun write ( rangeStart : List < Int > , rangeEnd : List < Int > , rangeCategory : List < Int > , writer : FileWriter )

{ <EOL> check ( rangeStart . indices . all { rangeEnd [ it ] - rangeStart [ it ] == <NUM_LIT:9> } ) <EOL> strategy . beforeWritingRanges ( writer ) <EOL> writer . writeIntArray ( "<STR_LIT>" , rangeStart , strategy ) <EOL> strategy . afterWritingRanges ( writer ) <EOL> writer . appendLine ( ) <EOL> writer . appendLine ( binarySearchRange ( ) ) <EOL> writer . appendLine ( ) <EOL> writer . appendLine ( digitToIntImpl ( ) ) <EOL> writer . appendLine ( ) <EOL> writer . appendLine ( isDigitImpl ( ) ) <EOL> }


private fun binarySearchRange ( ) : String

= """<STR_LIT>""" . trimIndent ( )


{ <EOL> val rangeStart = strategy . rangeRef ( "<STR_LIT>" ) <EOL> return """<STR_LIT>""" . trimIndent ( ) <EOL> }


{ <EOL> return """<STR_LIT>""" . trimIndent ( ) <EOL> }


fun serializeTo ( element : Element ) : Element


override fun serializeTo ( element : Element ) : Element

= Element ( COMPILER_ARGUMENTS_ELEMENT_NAME ) . apply { <EOL> val newInstance = arguments :: class . java . getConstructor ( ) . newInstance ( ) <EOL> val flagArgumentsByName = CompilerArgumentsContentProspector . getFlagCompilerArgumentProperties ( arguments :: class ) <EOL> . mapNotNull { prop -> <EOL> prop . safeAs < KProperty1 < T , Boolean ? > > ( ) <EOL> ? . takeIf { it . get ( arguments ) != it . get ( newInstance ) } <EOL> ? . get ( arguments ) <EOL> ? . let { prop . name to it } <EOL> } . toMap ( ) <EOL> saveFlagArguments ( this , flagArgumentsByName ) <EOL> val stringArgumentsByName = CompilerArgumentsContentProspector . getStringCompilerArgumentProperties ( arguments :: class ) <EOL> . mapNotNull { prop -> <EOL> prop . safeAs < KProperty1 < T , String ? > > ( ) <EOL> ? . takeIf { it . get ( arguments ) != it . get ( newInstance ) } <EOL> ? . get ( arguments ) <EOL> ? . let { prop . name to it } <EOL> } . toMap ( ) <EOL> saveStringArguments ( this , stringArgumentsByName ) <EOL> val arrayArgumentsByName = CompilerArgumentsContentProspector . getArrayCompilerArgumentProperties ( arguments :: class ) <EOL> . mapNotNull { prop -> <EOL> prop . safeAs < KProperty1 < T , Array < String > ? > > ( ) <EOL> ? . takeIf { it . get ( arguments ) ? . contentEquals ( it . get ( newInstance ) ) != true } <EOL> ? . get ( arguments ) <EOL> ? . let { prop . name to it } <EOL> } . toMap ( ) <EOL> saveArrayArguments ( this , arrayArgumentsByName ) <EOL> val freeArgs = CompilerArgumentsContentProspector . freeArgsProperty . get ( arguments ) <EOL> saveElementsList ( this , FREE_ARGS_ROOT_ELEMENTS_NAME , FREE_ARGS_ELEMENT_NAME , freeArgs ) <EOL> val internalArguments = CompilerArgumentsContentProspector . internalArgumentsProperty . get ( arguments ) . map { it . stringRepresentation } <EOL> saveElementsList ( this , INTERNAL_ARGS_ROOT_ELEMENTS_NAME , INTERNAL_ARGS_ELEMENT_NAME , internalArguments ) <EOL> restoreNormalOrdering ( arguments ) <EOL> element . addContent ( this ) <EOL> }


private fun saveElementConfigurable ( element : Element , rootElementName : String , configurable : Element . ( ) -> Unit )

{ <EOL> element . addContent ( Element ( rootElementName ) . apply { configurable ( this ) } ) <EOL> }


private fun saveStringArguments ( element : Element , argumentsByName : Map < String , String > )

{ <EOL> if ( argumentsByName . isEmpty ( ) ) return <EOL> saveElementConfigurable ( element , STRING_ROOT_ELEMENTS_NAME ) { <EOL> argumentsByName . entries . forEach { ( name , arg ) -> <EOL> Element ( STRING_ELEMENT_NAME ) . also { <EOL> it . setAttribute ( NAME_ATTR_NAME , name ) <EOL> if ( name == "<STR_LIT>" ) { <EOL> saveElementsList ( it , ARGS_ATTR_NAME , ARG_ATTR_NAME , arg . split ( File . pathSeparator ) ) <EOL> } else { <EOL> it . setAttribute ( ARG_ATTR_NAME , arg ) <EOL> } <EOL> addContent ( it ) <EOL> } <EOL> } <EOL> } <EOL> }


private fun saveFlagArguments ( element : Element , argumentsByName : Map < String , Boolean > )

{ <EOL> if ( argumentsByName . isEmpty ( ) ) return <EOL> saveElementConfigurable ( element , FLAG_ROOT_ELEMENTS_NAME ) { <EOL> argumentsByName . entries . forEach { ( name , arg ) -> <EOL> Element ( FLAG_ELEMENT_NAME ) . also { <EOL> it . setAttribute ( NAME_ATTR_NAME , name ) <EOL> it . setAttribute ( ARG_ATTR_NAME , arg . toString ( ) ) <EOL> addContent ( it ) <EOL> } <EOL> } <EOL> } <EOL> }


private fun saveElementsList ( element : Element , rootElementName : String , elementName : String , elementList : List < String > )

{ <EOL> if ( elementList . isEmpty ( ) ) return <EOL> saveElementConfigurable ( element , rootElementName ) { <EOL> val singleModule = elementList . singleOrNull ( ) <EOL> if ( singleModule != null ) { <EOL> addContent ( singleModule ) <EOL> } else { <EOL> elementList . forEach { elementValue -> addContent ( Element ( elementName ) . also { it . addContent ( elementValue ) } ) } <EOL> } <EOL> } <EOL> }


private fun saveArrayArguments ( element : Element , arrayArgumentsByName : Map < String , Array < String > > )

{ <EOL> if ( arrayArgumentsByName . isEmpty ( ) ) return <EOL> saveElementConfigurable ( element , ARRAY_ROOT_ELEMENTS_NAME ) { <EOL> arrayArgumentsByName . entries . forEach { ( name , arg ) -> <EOL> Element ( ARRAY_ELEMENT_NAME ) . also { <EOL> it . setAttribute ( NAME_ATTR_NAME , name ) <EOL> saveElementsList ( it , ARGS_ATTR_NAME , ARG_ATTR_NAME , arg . toList ( ) ) <EOL> addContent ( it ) <EOL> } <EOL> } <EOL> } <EOL> }


override fun check ( declarations : List < JsKlibExportingDeclaration > , context : JsKlibDiagnosticContext , reporter : IrDiagnosticReporter )

{ <EOL> val allExportedNameClashes = declarations . groupBy { it . exportingName } . filterValues { it . size > <NUM_LIT:1> } <EOL> for ( exportedDeclarationClashes in allExportedNameClashes . values ) { <EOL> for ( ( index , exportedDeclaration ) in exportedDeclarationClashes . withIndex ( ) ) { <EOL> val declaration = exportedDeclaration . declaration ? : continue <EOL> val clashedWith = exportedDeclarationClashes . filterIndexed { i , _ -> i != index } <EOL> reporter . at ( declaration , context ) . report ( JsKlibErrors . EXPORTING_JS_NAME_CLASH_ES , exportedDeclaration . exportingName , clashedWith ) <EOL> } <EOL> } <EOL> }


fun getDescriptorByPath ( path : String ) : ModuleDescriptor

{ <EOL> return stdlibPathToDescriptor [ path ] ? : testServices . assertions . fail { <EOL> "<STR_LIT>" <EOL> } <EOL> }


fun setDescriptorAndLibraryByName ( name : String , descriptor : ModuleDescriptor , library : KotlinLibrary )

{ <EOL> stdlibPathToDescriptor [ name ] = descriptor <EOL> descriptorToLibrary [ descriptor ] = library <EOL> }


fun getCompiledLibraryByDescriptor ( descriptor : ModuleDescriptor ) : KotlinLibrary

{ <EOL> return descriptorToLibrary [ descriptor ] ? : testServices . assertions . fail { <EOL> "<STR_LIT>" <EOL> } <EOL> }


fun getPathByDescriptor ( descriptor : ModuleDescriptor ) : String

{ <EOL> return stdlibPathToDescriptor . entries . single { it . value == descriptor } . key <EOL> }


fun getDescriptorByCompiledLibrary ( library : KotlinLibrary ) : ModuleDescriptor

{ <EOL> return descriptorToLibrary . filterValues { it == library } . keys . singleOrNull ( ) ? : testServices . assertions . fail { <EOL> "<STR_LIT>" <EOL> } <EOL> }


fun getOrCreateStdlibByPath ( path : String , create : ( String ) -> Pair < ModuleDescriptor , KotlinLibrary > ) : ModuleDescriptor

{ <EOL> return stdlibPathToDescriptor . getOrPut ( path ) { <EOL> create ( path ) . let { <EOL> descriptorToLibrary += it <EOL> it . first <EOL> } <EOL> } <EOL> }


{ <EOL> assertEquals ( TestEnum :: class . java , TestEnum . E . declaringJavaClass ) <EOL> assertEquals ( TimeUnit :: class . java , TimeUnit . MILLISECONDS . declaringJavaClass ) <EOL> assertEquals ( DurationUnit :: class . java , DurationUnit . MILLISECONDS . declaringJavaClass ) <EOL> }


private inline fun < reified E : Enum < E > > E . declaring ( )

= declaringJavaClass


{ <EOL> assertEquals ( TestEnum :: class . java , TestEnum . E . declaring ( ) ) <EOL> assertEquals ( TimeUnit :: class . java , TimeUnit . MILLISECONDS . declaring ( ) ) <EOL> }


{ <EOL> val set = EnumSet . noneOf ( TestEnum . E . declaringJavaClass ) <EOL> set . addAll ( TestEnum . E . declaringJavaClass . enumConstants . toList ( ) ) <EOL> assertEquals ( EnumSet . of ( TestEnum . E ) , set ) <EOL> }


{ <EOL> fun < T : Enum < T > > check ( e : Enum < T > ) { <EOL> assertEquals < Class < * > > ( e . declaringJavaClass , TestEnum :: class . java ) <EOL> } <EOL> check ( TestEnum . E ) <EOL> }


public abstract fun provideExtensionsFor ( module : KtModule ) : List < KtResolveExtension >

/**
 * Provides a list of [KtResolveExtension]s for a given [KtModule].
 *
 * Should not perform any heavy analysis and the generation of the actual files. All file generation should be performed only in [KtResolveExtensionFile.buildFileText].
 *
 * Implementations should consider caching the results, so the subsequent invocations should be performed instantly.
 *
 * Implementation cannot use the Kotlin resolve inside, as this function is called during session initialization, so Analysis API access is forbidden.
 */


public fun provideExtensionsFor ( module : KtModule ) : List < KtResolveExtension >

{ <EOL> return EP_NAME . getExtensionList ( module . project ) . flatMap { it . provideExtensionsFor ( module ) } <EOL> }


{ <EOL> return param <EOL> }


{ <EOL> return Father ( "<STR_LIT:fail>" ) . Child ( "<STR_LIT:OK>" ) . Child2 ( ) . work ( ) <EOL> }


= when ( ext ) { <EOL> "<STR_LIT>" -> SVG <EOL> "<STR_LIT>" -> PNG <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> }


override fun visit ( b : Block . CodeBlock ) : Block

{ <EOL> if ( "<STR_LIT>" !in b . attr . classes ) return super . visit ( b ) <EOL> val props = b . attr . propertiesMap <EOL> val altText = props [ "<STR_LIT>" ] <EOL> val imageFormat = props [ "<STR_LIT>" ] ? : defaultFormat ? : "<STR_LIT>" <EOL> val scaling = if ( format . isHTML ( ) ) <NUM_LIT> else <NUM_LIT> <EOL> val dprops = DiagramProperties ( fontSpec = "<STR_LIT>" , textScale = <NUM_LIT> , diagramScale = scaling ) <EOL> val diag = Diagram . fromMatrix ( CharMatrix . read ( b . text . reader ( ) . buffered ( ) ) , dprops ) <EOL> return blocks { <EOL> div { <EOL> clazz = "<STR_LIT>" <EOL> id = b . attr . id <EOL> plain { <EOL> renderToFile ( ImgFormat . fromExtension ( imageFormat ) , diag , altText , imageDirectory , embed , format ) <EOL> } <EOL> } <EOL> } . first ( ) <EOL> }


private fun InlineBuilder . renderToFile ( imageFormat : ImgFormat , diag : Diagram , altText : String ? , imageDirectory : File ? , embed : Boolean , format : Format )

{ <EOL> if ( format . isHTML ( ) && embed ) { <EOL> when ( imageFormat ) { <EOL> ImgFormat . SVG -> rawInline ( format = Format . HTML ) { <EOL> "<STR_LIT>" <EOL> } <EOL> ImgFormat . PNG -> rawInline ( format = Format . HTML ) { <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> return <EOL> } <EOL> val file = File . createTempFile ( "<STR_LIT>" , imageFormat . suffix , imageDirectory ) <EOL> when ( imageFormat ) { <EOL> ImgFormat . SVG -> exportAsSVG ( diag , file ) <EOL> ImgFormat . PNG -> exportAsPNG ( diag , file ) <EOL> } <EOL> image ( Target ( file . absolutePath , altText ? : file . absolutePath ) ) <EOL> }


{ <EOL> makeFilter ( SpecInlineDiagramFilterVisitor ( defaultFormat , format , imageDirectory , embed ) ) <EOL> }


= Main . main ( args )


override fun apply ( input : Bitmap ) : FloatData

{ <EOL> require ( input . config == Bitmap . Config . ARGB_8888 ) { "<STR_LIT>" } <EOL> val w = input . width <EOL> val h = input . height <EOL> val encodedPixels = IntArray ( w * h ) <EOL> input . getPixels ( encodedPixels , <NUM_LIT:0> , w , <NUM_LIT:0> , <NUM_LIT:0> , w , h ) <EOL> val tensor = when ( layout ) { <EOL> NCHW -> argB8888ToNCHWArray ( encodedPixels , w , h , channels ) <EOL> NHWC -> argB8888ToNHWCArray ( encodedPixels , w , h , channels ) <EOL> } <EOL> val shape = when ( layout ) { <EOL> NCHW -> TensorShape ( channels . toLong ( ) , h . toLong ( ) , w . toLong ( ) ) <EOL> NHWC -> TensorShape ( h . toLong ( ) , w . toLong ( ) , channels . toLong ( ) ) <EOL> } <EOL> return tensor to shape <EOL> }


override fun getOutputShape ( inputShape : TensorShape ) : TensorShape

{ <EOL> return when ( inputShape . rank ( ) ) { <EOL> <NUM_LIT:2> , <NUM_LIT:3> -> when ( layout ) { <EOL> NCHW -> TensorShape ( channels . toLong ( ) , inputShape [ <NUM_LIT:0> ] , inputShape [ <NUM_LIT:1> ] ) <EOL> NHWC -> TensorShape ( inputShape [ <NUM_LIT:0> ] , inputShape [ <NUM_LIT:1> ] , channels . toLong ( ) ) <EOL> } <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> }


internal expect fun ensurePlatformExceptionHandlerLoaded ( callback : CoroutineExceptionHandler )

/**
 * Ensures that the given [callback] is present in the [platformExceptionHandlers] list.
 */


internal expect fun propagateExceptionFinalResort ( exception : Throwable )

/**
 * The platform-dependent global exception handler, used so that the exception is logged at least *somewhere*.
 */


internal fun handleUncaughtCoroutineException ( context : CoroutineContext , exception : Throwable )

{ <EOL> for ( handler in platformExceptionHandlers ) { <EOL> try { <EOL> handler . handleException ( context , exception ) <EOL> } catch ( _ : ExceptionSuccessfullyProcessed ) { <EOL> return <EOL> } catch ( t : Throwable ) { <EOL> propagateExceptionFinalResort ( handlerException ( exception , t ) ) <EOL> } <EOL> } <EOL> try { <EOL> exception . addSuppressed ( DiagnosticCoroutineContextException ( context ) ) <EOL> } catch ( e : Throwable ) { <EOL> } <EOL> propagateExceptionFinalResort ( exception ) <EOL> }

/**
 * Deal with exceptions that happened in coroutines and weren't programmatically dealt with.
 *
 * First, it notifies every [CoroutineExceptionHandler] in the [platformExceptionHandlers] list.
 * If one of them throws [ExceptionSuccessfullyProcessed], it means that that handler believes that the exception was
 * dealt with sufficiently well and doesn't need any further processing.
 * Otherwise, the platform-dependent global exception handler is also invoked.
 */


{ <EOL> Foo ( ) <EOL> }


override fun configure ( builder : TestConfigurationBuilder )

{ <EOL> super . configure ( builder ) <EOL> builder . commonFirWithPluginFrontendConfiguration ( ) <EOL> }


{ <EOL> super . configure ( builder ) <EOL> with ( builder ) { <EOL> commonFirWithPluginFrontendConfiguration ( ) <EOL> configureIrHandlersStep { <EOL> useHandlers ( :: IrPrettyKotlinDumpHandler ) <EOL> } <EOL> } <EOL> }


fun TestConfigurationBuilder . commonFirWithPluginFrontendConfiguration ( )

{ <EOL> enableLazyResolvePhaseChecking ( ) <EOL> defaultDirectives { <EOL> + ENABLE_PLUGIN_PHASES <EOL> + FIR_DUMP <EOL> } <EOL> useConfigurators ( :: PluginAnnotationsProvider , :: ExtensionRegistrarConfigurator ) <EOL> useCustomRuntimeClasspathProviders ( :: PluginRuntimeAnnotationsProvider ) <EOL> }


public fun getFloatArray ( result : R , index : Int ) : FloatArray

/**
 * Returns the output at [index] as a [FloatArray].
 */


public fun getLongArray ( result : R , index : Int ) : LongArray

/**
 * Returns the output at [index] as a [LongArray].
 */


@ JvmOverloads <EOL> fun initialize ( typeParameters : List < TypeParameterDescriptor > = emptyList ( ) )

{ <EOL> this . typeParameters = typeParameters <EOL> }


= modality


= visibility


= kind


= isCompanionObject


= false


override fun getCompanionObjectDescriptor ( ) : ClassDescriptorWithResolutionScopes ?

= null


override fun getTypeConstructor ( ) : TypeConstructor

= typeConstructor


override fun getUnsubstitutedPrimaryConstructor ( )

= _unsubstitutedPrimaryConstructor ( )


= listOf ( _unsubstitutedPrimaryConstructor ( ) ) + secondaryConstructors


override fun getDeclaredTypeParameters ( )

= typeParameters


= MemberScope . Empty


override fun getUnsubstitutedMemberScope ( kotlinTypeRefiner : KotlinTypeRefiner )

= unsubstitutedMemberScope


= emptyList < ClassDescriptor > ( )


override fun getValueClassRepresentation ( ) : ValueClassRepresentation < SimpleType > ?

= null


override fun getDeclaredCallableMembers ( ) : List < CallableMemberDescriptor >

= <EOL> DescriptorUtils . getAllDescriptors ( unsubstitutedMemberScope ) . filterIsInstance < CallableMemberDescriptor > ( ) . filter { <EOL> it . kind != CallableMemberDescriptor . Kind . FAKE_OVERRIDE <EOL> }


override fun getScopeForClassHeaderResolution ( ) : LexicalScope

= resolutionScopesSupport . scopeForClassHeaderResolution ( )


override fun getScopeForConstructorHeaderResolution ( ) : LexicalScope

= resolutionScopesSupport . scopeForConstructorHeaderResolution ( )


override fun getScopeForCompanionObjectHeaderResolution ( ) : LexicalScope

= <EOL> resolutionScopesSupport . scopeForCompanionObjectHeaderResolution ( )


override fun getScopeForMemberDeclarationResolution ( ) : LexicalScope

= resolutionScopesSupport . scopeForMemberDeclarationResolution ( )


override fun getScopeForStaticMemberDeclarationResolution ( ) : LexicalScope

= <EOL> resolutionScopesSupport . scopeForStaticMemberDeclarationResolution ( )


override fun getScopeForInitializerResolution ( ) : LexicalScope

= <EOL> throw UnsupportedOperationException ( "<STR_LIT>" )


= "<STR_LIT>" + name . toString ( ) + "<STR_LIT>" + containingDeclaration


private fun createUnsubstitutedPrimaryConstructor ( constructorVisibility : DescriptorVisibility ) : ClassConstructorDescriptor

{ <EOL> val constructor = DescriptorFactory . createPrimaryConstructorForObject ( thisDescriptor , source ) <EOL> constructor . visibility = constructorVisibility <EOL> constructor . returnType = getDefaultType ( ) <EOL> return constructor <EOL> }


override fun getParameters ( ) : List < TypeParameterDescriptor >

= typeParameters


= true


override fun getDeclarationDescriptor ( ) : ClassDescriptor

= thisDescriptor


override fun computeSupertypes ( ) : Collection < KotlinType >

= syntheticSupertypes


override fun getDeclarations ( kindFilter : DescriptorKindFilter , nameFilter : ( Name ) -> Boolean ) : List < KtDeclaration >

= emptyList ( )


override fun getFunctionDeclarations ( name : Name ) : Collection < KtNamedFunction >

= emptyList ( )


override fun getPropertyDeclarations ( name : Name ) : Collection < KtProperty >

= emptyList ( )


override fun getDestructuringDeclarationsEntries ( name : Name ) : Collection < KtDestructuringDeclarationEntry >

= emptyList ( )


override fun getClassOrObjectDeclarations ( name : Name ) : Collection < KtClassOrObjectInfo < * > >

= emptyList ( )


override fun getScriptDeclarations ( name : Name ) : Collection < KtScriptInfo >

= emptyList ( )


override fun getTypeAliasDeclarations ( name : Name ) : Collection < KtTypeAlias >

= emptyList ( )


= emptySet < Name > ( )


= thisDescriptor


= _name


= false


override fun getDeclarations ( ) : List < KtDeclaration >

= emptyList ( )


override fun getSuperTypeListEntries ( ) : List < KtSuperTypeListEntry >

= emptyList ( )


override fun getCompanionObjects ( ) : List < KtObjectDeclaration >

= emptyList ( )


override fun hasExplicitPrimaryConstructor ( ) : Boolean

= false


override fun hasPrimaryConstructor ( ) : Boolean

= false


override fun getPrimaryConstructor ( ) : KtPrimaryConstructor ?

= null


override fun getPrimaryConstructorModifierList ( ) : KtModifierList ?

= null


override fun getPrimaryConstructorParameters ( ) : List < KtParameter >

= emptyList ( )


override fun getSecondaryConstructors ( ) : List < KtSecondaryConstructor >

= emptyList ( )


override fun getContextReceivers ( ) : List < KtContextReceiver >

= emptyList ( )


= _parent . psiOrParent


@ Suppress ( "<STR_LIT>" ) <EOL> override fun getContainingKtFile ( )

= <EOL> _parent . containingKtFile ? : throw IllegalStateException ( "<STR_LIT>" )


override fun getBody ( ) : KtClassBody ?

= null


fun KtPureElement . findClassDescriptor ( bindingContext : BindingContext ) : ClassDescriptor

= when ( this ) { <EOL> is PsiElement -> BindingContextUtils . getNotNull ( bindingContext , BindingContext . CLASS , this ) <EOL> is SyntheticClassOrObjectDescriptor . SyntheticDeclaration -> descriptor ( ) <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> }


fun create ( data : Buffer ) : Sink


override fun create ( data : Buffer ) : Sink

{ <EOL> return data <EOL> }


{ <EOL> return ( data as RawSink ) . buffered ( ) <EOL> }


= <NUM_LIT:42>


{ <EOL> if ( A . foo ( ) != <NUM_LIT:42> ) return "<STR_LIT>" <EOL> return A . bar <EOL> }


open fun `access$getBar$p` ( d : Derived ) : Int

= <NUM_LIT:1>


open fun `access$setBar$p` ( d : Derived , i : Int )


open fun `access$getBaz$p` ( d : Derived ) : Int

= <NUM_LIT:1>


open fun `access$getBoo$p` ( d : Derived ) : Int

= <NUM_LIT:1>


open fun `access$setBar1$p` ( d : Derived , i : Int )


{ <EOL> foo ( ) <EOL> bar += <NUM_LIT:1> <EOL> baz += <NUM_LIT:1> <EOL> val s = boo <EOL> bar1 += <NUM_LIT:1> <EOL> }


fun getRendererForDiagnostic ( diagnostic : KtDiagnostic ) : KtDiagnosticRenderer

{ <EOL> val factory = diagnostic . factory <EOL> return MAP [ factory ] ? : factory . ktRenderer <EOL> }


fun foo ( x : Out < out Open > , y : Out < out Final > ) : Out < out Open >

= Out ( )


fun bar ( x : In < in Open > , y : In < in Any ? > ) : In < in Open >

= In ( )


{ <EOL> X . C ( ) <EOL> }


@ Test <EOL> fun freezeIsNoopForObjects ( )

{ <EOL> val a = A ( <NUM_LIT:1> ) <EOL> a . freeze ( ) <EOL> a . x = <NUM_LIT:2> <EOL> assertEquals ( <NUM_LIT:2> , a . x ) <EOL> }


@ Test <EOL> fun freezeIsNoopForArrays ( )

{ <EOL> val a = arrayOf ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> a . freeze ( ) <EOL> a [ <NUM_LIT:0> ] = <NUM_LIT:4> <EOL> assertContentEquals ( arrayOf ( <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:3> ) , a ) <EOL> }


@ Test <EOL> fun freezeIsNoopForPrimitiveArrays ( )

{ <EOL> val a = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> a . freeze ( ) <EOL> a [ <NUM_LIT:0> ] = <NUM_LIT:4> <EOL> assertContentEquals ( intArrayOf ( <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:3> ) , a ) <EOL> }


{ <EOL> fun foo ( ) : String { <EOL> return bar { baz ( ) } <EOL> } <EOL> return foo ( ) <EOL> }


= "<STR_LIT:OK>"


= p ( )


{ <EOL> return `(X)` ( ) . `(Y)` ( ) <EOL> }


{ <EOL> val step1 = DataFrame <EOL> . read ( pathToCsv ) . convertTo < Movie > ( ) <EOL> . split { genres } . by ( "<STR_LIT>" ) . inplace ( ) <EOL> . split { title } . by { <EOL> listOf ( """<STR_LIT>""" . toRegex ( ) . replace ( it , "<STR_LIT>" ) , "<STR_LIT>" . toRegex ( ) . findAll ( it ) . lastOrNull ( ) ? . value ? . toIntOrNull ( ) ? : - <NUM_LIT:1> ) <EOL> } . into ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> . explode ( "<STR_LIT>" ) <EOL> step1 . print ( ) <EOL> val step2 = step1 <EOL> . filter { "<STR_LIT>" < Int > ( ) >= <NUM_LIT:0> && genres != "<STR_LIT>" } <EOL> . groupBy ( "<STR_LIT>" ) <EOL> . sortBy ( "<STR_LIT>" ) <EOL> . pivot ( "<STR_LIT>" , inward = false ) <EOL> . aggregate { <EOL> count ( ) into "<STR_LIT>" <EOL> mean ( ) into "<STR_LIT>" <EOL> } <EOL> step2 . print ( <NUM_LIT:10> ) <EOL> }


override fun equals ( other : Any ? ) : Boolean

{ <EOL> if ( this === other ) return true <EOL> if ( javaClass != other ? . javaClass ) return false <EOL> other as MovieExpanded <EOL> return if ( id != other . id ) false else genres . contentEquals ( other . genres ) <EOL> }


{ <EOL> var result = id . hashCode ( ) <EOL> result = <NUM_LIT:31> * result + genres . contentHashCode ( ) <EOL> return result <EOL> }


@ Throws ( E1 :: class ) <EOL> fun one ( )


@ Throws ( E1 :: class , E2 :: class ) <EOL> fun two ( )


fun tryRenderStructOrUnion ( def : StructDef ) : String ?

= when ( def . kind ) { <EOL> StructDef . Kind . STRUCT -> tryRenderStruct ( def ) <EOL> StructDef . Kind . UNION -> tryRenderUnion ( def ) <EOL> StructDef . Kind . CLASS -> null <EOL> }


private fun tryRenderStruct ( def : StructDef ) : String ?

{ <EOL> val baseOffset = def . fields . firstOrNull ( ) ? . offsetBytes ? : <NUM_LIT:0L> <EOL> var offset = <NUM_LIT:0L> <EOL> val isPackedStruct = def . isPacked <EOL> val maxAlign = def . members . filterIsInstance < Field > ( ) . maxOfOrNull { it . typeAlign } <EOL> val forceAlign = maxAlign ? . let { def . align > maxAlign } <EOL> ? : ( def . align > <NUM_LIT:1> ) <EOL> return buildString { <EOL> append ( "<STR_LIT>" ) <EOL> def . members . forEach { it -> <EOL> val decl = when ( it ) { <EOL> is Field -> { <EOL> val immediateOffset = it . offsetBytes - baseOffset <EOL> val defaultAlignment = if ( isPackedStruct ) <NUM_LIT:1L> else it . typeAlign <EOL> val alignment = guessAlignment ( offset , immediateOffset , defaultAlignment ) ? : return null <EOL> offset = immediateOffset + it . typeSize <EOL> tryRenderVar ( it . type , it . name ) <EOL> ? . plus ( if ( alignment == defaultAlignment ) "<STR_LIT>" else "<STR_LIT>" ) <EOL> } <EOL> is BitField , <EOL> is IncompleteField -> null <EOL> is AnonymousInnerRecord -> { <EOL> assert ( it . offsetBytes != null || it . typeSize == <NUM_LIT:0L> ) <EOL> it . offsetBytes ? . let { offsetBytes -> <EOL> offset = offsetBytes - baseOffset + it . typeSize <EOL> } <EOL> tryRenderStructOrUnion ( it . def ) <EOL> } <EOL> } ? : return null <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> append ( "<STR_LIT:}>" ) <EOL> if ( isPackedStruct ) append ( "<STR_LIT>" ) <EOL> if ( forceAlign ) append ( "<STR_LIT>" ) <EOL> } <EOL> }


private fun guessAlignment ( offset : Long , paddedOffset : Long , defaultAlignment : Long ) : Long ?

= <EOL> longArrayOf ( defaultAlignment , <NUM_LIT:1L> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) . firstOrNull { <EOL> alignUp ( offset , it ) == paddedOffset <EOL> }


private fun alignUp ( x : Long , alignment : Long ) : Long

= ( x + alignment - <NUM_LIT:1> ) and ( ( alignment - <NUM_LIT:1> ) . inv ( ) )


private fun tryRenderUnion ( def : StructDef ) : String ?

{ <EOL> val maxAlign = def . members . filterIsInstance < Field > ( ) . maxOfOrNull { it . typeAlign } <EOL> val forceAlign = maxAlign ? . let { def . align > maxAlign } <EOL> ? : ( def . align > <NUM_LIT:1> ) <EOL> return buildString { <EOL> append ( "<STR_LIT>" ) <EOL> def . members . forEach { it -> <EOL> val name = it . name <EOL> val decl = when ( it ) { <EOL> is Field -> tryRenderVar ( it . type , name ) <EOL> is BitField , is IncompleteField -> null <EOL> is AnonymousInnerRecord -> tryRenderStructOrUnion ( it . def ) <EOL> } ? : return null <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> append ( "<STR_LIT:}>" ) <EOL> if ( forceAlign ) append ( "<STR_LIT>" ) <EOL> } <EOL> }


private fun tryRenderVar ( type : Type , name : String ) : String ?

= when ( type ) { <EOL> CharType , is BoolType -> "<STR_LIT>" <EOL> is IntegerType -> "<STR_LIT>" <EOL> is FloatingType -> "<STR_LIT>" <EOL> is VectorType -> "<STR_LIT>" <EOL> is RecordType -> tryRenderStructOrUnion ( type . decl . def ! ! ) ? . let { "<STR_LIT>" } <EOL> is EnumType -> tryRenderVar ( type . def . baseType , name ) <EOL> is PointerType -> "<STR_LIT>" <EOL> is ConstArrayType -> tryRenderVar ( type . elemType , "<STR_LIT>" ) <EOL> is IncompleteArrayType -> tryRenderVar ( type . elemType , "<STR_LIT>" ) <EOL> is Typedef -> tryRenderVar ( type . def . aliased , name ) <EOL> is ObjCPointer -> "<STR_LIT>" <EOL> else -> null <EOL> }


fun clear ( byteByffer : java . nio . ByteBuffer )

= byteByffer . clear ( )


{ <EOL> if ( clear ( java . nio . ByteBuffer . allocateDirect ( <NUM_LIT:10> ) ) . capacity ( ) != <NUM_LIT:10> ) return "<STR_LIT:fail>" <EOL> return "<STR_LIT:OK>" <EOL> }


abstract fun isVisible ( receiver : ReceiverValue ? , what : DeclarationDescriptorWithVisibility , from : DeclarationDescriptor , useSpecialRulesForPrivateSealedConstructors : Boolean ) : Boolean

/**
 * @param receiver can be used to determine callee accessibility for some special receiver value
 *
 * 'null'-value basically means that receiver is absent in current call
 *
 * In case if it's needed to perform basic checks ignoring ones considering receiver (e.g. when checks happen beyond any call),
 * special value Visibilities.ALWAYS_SUITABLE_RECEIVER should be used.
 * If it's needed to determine whether visibility accepts any receiver, Visibilities.IRRELEVANT_RECEIVER should be used.
 *
 * NB: Currently Visibilities.IRRELEVANT_RECEIVER has the same effect as 'null'
 *
 * Also it's important that implementation that take receiver into account do aware about these special values.
 */


abstract fun mustCheckInImports ( ) : Boolean

/**
 * True, if it makes sense to check this visibility in imports and not import inaccessible declarations with such visibility.
 * Hint: return true, if this visibility can be checked on file's level.
 * Examples:
 * it returns false for PROTECTED because protected members of classes can be imported to be used in subclasses of their containers,
 * so when we are looking at the import, we don't know whether it is legal somewhere in this file or not.
 * it returns true for INTERNAL, because an internal declaration is either visible everywhere in a file, or invisible everywhere in the same file.
 * it returns true for PRIVATE, because there's no point in importing privates: they are inaccessible unless their short name is
 * already available without an import
 */


fun compareTo ( visibility : DescriptorVisibility ) : Int ?

{ <EOL> return delegate . compareTo ( visibility . delegate ) <EOL> }

/**
 * @return null if the answer is unknown
 */


final override fun toString ( ) : String

= delegate . toString ( )


abstract fun normalize ( ) : DescriptorVisibility


fun customEffectiveVisibility ( ) : EffectiveVisibility ?

= delegate . customEffectiveVisibility ( )


open fun visibleFromPackage ( fromPackage : FqName , myPackage : FqName ) : Boolean

= true


override fun mustCheckInImports ( ) : Boolean

{ <EOL> return delegate . mustCheckInImports ( ) <EOL> }


override fun normalize ( ) : DescriptorVisibility

= DescriptorVisibilities . toDescriptorVisibility ( delegate . normalize ( ) )


inline fun < reified R : FirExpression > getAsFirExpression ( expression : LighterASTNode ? , errorReason : String = "<STR_LIT>" , sourceWhenInvalidExpression : LighterASTNode ? = expression , isValidExpression : ( R ) -> Boolean = { ! it . isStatementLikeExpression } , ) : R

{ <EOL> val converted = expression ? . let { convertExpression ( it , errorReason ) } <EOL> return when { <EOL> converted is R -> when { <EOL> isValidExpression ( converted ) -> converted <EOL> else -> buildErrorExpression ( sourceWhenInvalidExpression ? . toFirSourceElement ( ) , ConeSimpleDiagnostic ( errorReason , DiagnosticKind . ExpressionExpected ) , converted , ) <EOL> } <EOL> else -> buildErrorExpression ( converted ? . source ? . realElement ( ) ? : expression ? . toFirSourceElement ( ) , if ( expression == null ) ConeSyntaxDiagnostic ( errorReason ) else ConeSimpleDiagnostic ( errorReason , DiagnosticKind . ExpressionExpected ) , converted , ) <EOL> } as R <EOL> }


fun getAsFirStatement ( expression : LighterASTNode , errorReason : String = "<STR_LIT>" ) : FirStatement

{ <EOL> return when ( val converted = convertExpression ( expression , errorReason ) ) { <EOL> is FirStatement -> converted <EOL> else -> buildErrorExpression ( expression . toFirSourceElement ( ) , ConeSimpleDiagnostic ( errorReason , DiagnosticKind . ExpressionExpected ) , converted , ) <EOL> } <EOL> }


fun convertExpression ( expression : LighterASTNode , errorReason : String ) : FirElement

{ <EOL> return when ( expression . tokenType ) { <EOL> LAMBDA_EXPRESSION -> convertLambdaExpression ( expression ) <EOL> BINARY_EXPRESSION -> convertBinaryExpression ( expression ) <EOL> BINARY_WITH_TYPE -> convertBinaryWithTypeRHSExpression ( expression ) { <EOL> this . getOperationSymbol ( ) . toFirOperation ( ) <EOL> } <EOL> IS_EXPRESSION -> convertBinaryWithTypeRHSExpression ( expression ) { <EOL> if ( this == "<STR_LIT>" ) FirOperation . IS else FirOperation . NOT_IS <EOL> } <EOL> LABELED_EXPRESSION -> convertLabeledExpression ( expression ) <EOL> PREFIX_EXPRESSION , POSTFIX_EXPRESSION -> convertUnaryExpression ( expression ) <EOL> ANNOTATED_EXPRESSION -> convertAnnotatedExpression ( expression ) <EOL> CLASS_LITERAL_EXPRESSION -> convertClassLiteralExpression ( expression ) <EOL> CALLABLE_REFERENCE_EXPRESSION -> convertCallableReferenceExpression ( expression ) <EOL> in QUALIFIED_ACCESS -> convertQualifiedExpression ( expression ) <EOL> CALL_EXPRESSION -> convertCallExpression ( expression ) <EOL> WHEN -> convertWhenExpression ( expression ) <EOL> ARRAY_ACCESS_EXPRESSION -> convertArrayAccessExpression ( expression ) <EOL> COLLECTION_LITERAL_EXPRESSION -> convertCollectionLiteralExpression ( expression ) <EOL> STRING_TEMPLATE -> convertStringTemplate ( expression ) <EOL> is KtConstantExpressionElementType -> convertConstantExpression ( expression ) <EOL> REFERENCE_EXPRESSION -> convertSimpleNameExpression ( expression ) <EOL> DO_WHILE -> convertDoWhile ( expression ) <EOL> WHILE -> convertWhile ( expression ) <EOL> FOR -> convertFor ( expression ) <EOL> TRY -> convertTryExpression ( expression ) <EOL> IF -> convertIfExpression ( expression ) <EOL> BREAK , CONTINUE -> convertLoopJump ( expression ) <EOL> RETURN -> convertReturn ( expression ) <EOL> THROW -> convertThrow ( expression ) <EOL> PARENTHESIZED -> { <EOL> val content = expression . getExpressionInParentheses ( ) <EOL> context . forwardLabelUsagePermission ( expression , content ) <EOL> getAsFirExpression ( content , "<STR_LIT>" ) <EOL> } <EOL> PROPERTY_DELEGATE , INDICES , CONDITION , LOOP_RANGE -> <EOL> getAsFirExpression ( expression . getChildExpression ( ) , errorReason ) <EOL> THIS_EXPRESSION -> convertThisExpression ( expression ) <EOL> SUPER_EXPRESSION -> convertSuperExpression ( expression ) <EOL> OBJECT_LITERAL -> declarationBuilder . convertObjectLiteral ( expression ) <EOL> FUN -> declarationBuilder . convertFunctionDeclaration ( expression ) <EOL> DESTRUCTURING_DECLARATION -> declarationBuilder . convertDestructingDeclaration ( expression ) . toFirDestructingDeclaration ( this , baseModuleData ) <EOL> else -> buildErrorExpression ( expression . toFirSourceElement ( KtFakeSourceElementKind . ErrorTypeRef ) , ConeSimpleDiagnostic ( errorReason , DiagnosticKind . ExpressionExpected ) ) <EOL> } <EOL> }


private fun convertLambdaExpression ( lambdaExpression : LighterASTNode ) : FirExpression

{ <EOL> val valueParameterList = mutableListOf < ValueParameter > ( ) <EOL> var block : LighterASTNode ? = null <EOL> var hasArrow = false <EOL> val functionSymbol = FirAnonymousFunctionSymbol ( ) <EOL> lambdaExpression . getChildNodesByType ( FUNCTION_LITERAL ) . first ( ) . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> VALUE_PARAMETER_LIST -> valueParameterList += declarationBuilder . convertValueParameters ( it , functionSymbol , ValueParameterDeclaration . LAMBDA ) <EOL> BLOCK -> block = it <EOL> ARROW -> hasArrow = true <EOL> } <EOL> } <EOL> val expressionSource = lambdaExpression . toFirSourceElement ( ) <EOL> val target : FirFunctionTarget <EOL> val anonymousFunction = buildAnonymousFunction { <EOL> source = expressionSource <EOL> moduleData = baseModuleData <EOL> origin = FirDeclarationOrigin . Source <EOL> returnTypeRef = implicitType <EOL> receiverParameter = expressionSource . asReceiverParameter ( ) <EOL> symbol = functionSymbol <EOL> isLambda = true <EOL> hasExplicitParameterList = hasArrow <EOL> label = context . getLastLabel ( lambdaExpression ) ? : context . calleeNamesForLambda . lastOrNull ( ) ? . let { <EOL> buildLabel { <EOL> source = expressionSource . fakeElement ( KtFakeSourceElementKind . GeneratedLambdaLabel ) <EOL> name = it . asString ( ) <EOL> } <EOL> } <EOL> target = FirFunctionTarget ( labelName = label ? . name , isLambda = true ) <EOL> context . firFunctionTargets += target <EOL> val destructuringStatements = mutableListOf < FirStatement > ( ) <EOL> for ( valueParameter in valueParameterList ) { <EOL> val multiDeclaration = valueParameter . destructuringDeclaration <EOL> valueParameters += if ( multiDeclaration != null ) { <EOL> val name = SpecialNames . DESTRUCT <EOL> val multiParameter = buildValueParameter { <EOL> source = valueParameter . firValueParameter . source <EOL> containingFunctionSymbol = functionSymbol <EOL> moduleData = baseModuleData <EOL> origin = FirDeclarationOrigin . Source <EOL> returnTypeRef = valueParameter . firValueParameter . returnTypeRef <EOL> this . name = name <EOL> symbol = FirValueParameterSymbol ( name ) <EOL> defaultValue = null <EOL> isCrossinline = false <EOL> isNoinline = false <EOL> isVararg = false <EOL> } <EOL> addDestructuringStatements ( destructuringStatements , baseModuleData , multiDeclaration , multiParameter , tmpVariable = false , forceLocal = true , ) <EOL> multiParameter <EOL> } else { <EOL> valueParameter . firValueParameter <EOL> } <EOL> } <EOL> body = withForcedLocalContext { <EOL> if ( block != null ) { <EOL> val kind = runIf ( destructuringStatements . isNotEmpty ( ) ) { <EOL> KtFakeSourceElementKind . LambdaDestructuringBlock <EOL> } <EOL> val bodyBlock = declarationBuilder . convertBlockExpressionWithoutBuilding ( block ! ! , kind ) . apply { <EOL> statements . firstOrNull ( ) ? . let { <EOL> if ( it . isContractBlockFirCheck ( ) ) { <EOL> this@buildAnonymousFunction . contractDescription = it . toLegacyRawContractDescription ( ) <EOL> statements [ <NUM_LIT:0> ] = FirContractCallBlock ( it ) <EOL> } <EOL> } <EOL> if ( statements . isEmpty ( ) ) { <EOL> statements . add ( buildReturnExpression { <EOL> source = expressionSource . fakeElement ( KtFakeSourceElementKind . ImplicitReturn . FromExpressionBody ) <EOL> this . target = target <EOL> result = buildUnitExpression { <EOL> source = expressionSource . fakeElement ( KtFakeSourceElementKind . ImplicitUnit . LambdaCoercion ) <EOL> } <EOL> } ) <EOL> } <EOL> } . build ( ) <EOL> if ( destructuringStatements . isNotEmpty ( ) ) { <EOL> buildBlock { <EOL> source = bodyBlock . source ? . realElement ( ) <EOL> statements . addAll ( destructuringStatements ) <EOL> statements . add ( bodyBlock ) <EOL> } <EOL> } else { <EOL> bodyBlock <EOL> } <EOL> } else { <EOL> buildSingleExpressionBlock ( buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) ) <EOL> } <EOL> } <EOL> context . firFunctionTargets . removeLast ( ) <EOL> } . also { <EOL> target . bind ( it ) <EOL> } <EOL> return buildAnonymousFunctionExpression { <EOL> source = expressionSource <EOL> this . anonymousFunction = anonymousFunction <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseFunctionLiteral
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitLambdaExpression
 */


private fun convertBinaryExpression ( binaryExpression : LighterASTNode ) : FirStatement

{ <EOL> var isLeftArgument = true <EOL> lateinit var operationTokenName : String <EOL> var leftArgNode : LighterASTNode ? = null <EOL> var rightArg : LighterASTNode ? = null <EOL> var operationReferenceSource : KtLightSourceElement ? = null <EOL> binaryExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> OPERATION_REFERENCE -> { <EOL> isLeftArgument = false <EOL> operationTokenName = it . asText <EOL> operationReferenceSource = it . toFirSourceElement ( ) <EOL> } <EOL> else -> if ( it . isExpression ( ) ) { <EOL> if ( isLeftArgument ) { <EOL> leftArgNode = it <EOL> } else { <EOL> rightArg = it <EOL> } <EOL> } <EOL> } <EOL> } <EOL> val baseSource = binaryExpression . toFirSourceElement ( ) <EOL> val operationToken = operationTokenName . getOperationSymbol ( ) <EOL> if ( operationToken == IDENTIFIER ) { <EOL> context . calleeNamesForLambda += operationTokenName . nameAsSafeName ( ) <EOL> } else { <EOL> context . calleeNamesForLambda += null <EOL> } <EOL> val rightArgAsFir = <EOL> if ( rightArg != null ) <EOL> getAsFirExpression < FirExpression > ( rightArg , "<STR_LIT>" ) <EOL> else <EOL> buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> val leftArgAsFir = getAsFirExpression < FirExpression > ( leftArgNode , "<STR_LIT>" ) <EOL> context . calleeNamesForLambda . removeLast ( ) <EOL> when ( operationToken ) { <EOL> ELVIS -> <EOL> return leftArgAsFir . generateNotNullOrOther ( rightArgAsFir , baseSource ) <EOL> ANDAND , OROR -> <EOL> return leftArgAsFir . generateLazyLogicalOperation ( rightArgAsFir , operationToken == ANDAND , baseSource ) <EOL> in OperatorConventions . IN_OPERATIONS -> <EOL> return rightArgAsFir . generateContainsOperation ( leftArgAsFir , operationToken == NOT_IN , baseSource , operationReferenceSource ) <EOL> in OperatorConventions . COMPARISON_OPERATIONS -> <EOL> return leftArgAsFir . generateComparisonExpression ( rightArgAsFir , operationToken , baseSource , operationReferenceSource ) <EOL> } <EOL> val conventionCallName = operationToken . toBinaryName ( ) <EOL> return if ( conventionCallName != null || operationToken == IDENTIFIER ) { <EOL> buildFunctionCall { <EOL> source = binaryExpression . toFirSourceElement ( ) <EOL> calleeReference = buildSimpleNamedReference { <EOL> source = operationReferenceSource ? : this@buildFunctionCall . source <EOL> name = conventionCallName ? : operationTokenName . nameAsSafeName ( ) <EOL> } <EOL> explicitReceiver = leftArgAsFir <EOL> argumentList = buildUnaryArgumentList ( rightArgAsFir ) <EOL> origin = if ( conventionCallName != null ) FirFunctionCallOrigin . Operator else FirFunctionCallOrigin . Infix <EOL> } <EOL> } else { <EOL> val firOperation = operationToken . toFirOperation ( ) <EOL> if ( firOperation in FirOperation . ASSIGNMENTS ) { <EOL> return leftArgNode . generateAssignment ( binaryExpression . toFirSourceElement ( ) , leftArgNode ? . toFirSourceElement ( ) , rightArgAsFir , firOperation , leftArgAsFir . annotations , rightArg , ) { <EOL> getAsFirExpression < FirExpression > ( this , "<STR_LIT>" , sourceWhenInvalidExpression = binaryExpression , isValidExpression = { ! it . isStatementLikeExpression || it . isArraySet } , ) <EOL> } <EOL> } else { <EOL> buildEqualityOperatorCall { <EOL> source = binaryExpression . toFirSourceElement ( ) <EOL> operation = firOperation <EOL> argumentList = buildBinaryArgumentList ( leftArgAsFir , rightArgAsFir ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitBinaryExpression
 */


private fun convertBinaryWithTypeRHSExpression ( binaryExpression : LighterASTNode , toFirOperation : String . ( ) -> FirOperation ) : FirTypeOperatorCall

{ <EOL> lateinit var operationTokenName : String <EOL> var leftArgAsFir : FirExpression ? = null <EOL> lateinit var firType : FirTypeRef <EOL> binaryExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> OPERATION_REFERENCE -> operationTokenName = it . asText <EOL> TYPE_REFERENCE -> firType = declarationBuilder . convertType ( it ) <EOL> else -> if ( it . isExpression ( ) ) leftArgAsFir = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> return buildTypeOperatorCall { <EOL> source = binaryExpression . toFirSourceElement ( ) <EOL> operation = operationTokenName . toFirOperation ( ) <EOL> conversionTypeRef = firType <EOL> argumentList = buildUnaryArgumentList ( leftArgAsFir ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) ) <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.Precedence.parseRightHandSide
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitBinaryWithTypeRHSExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitIsExpression
 */


private fun convertLabeledExpression ( labeledExpression : LighterASTNode ) : FirElement

{ <EOL> var firExpression : FirElement ? = null <EOL> var labelSource : KtSourceElement ? = null <EOL> var forbiddenLabelKind : ForbiddenLabelKind ? = null <EOL> val isRepetitiveLabel = labeledExpression . getLabeledExpression ( ) ? . tokenType == LABELED_EXPRESSION <EOL> labeledExpression . forEachChildren { <EOL> context . setNewLabelUserNode ( it ) <EOL> when ( it . tokenType ) { <EOL> LABEL_QUALIFIER -> { <EOL> val name = it . asText . dropLast ( <NUM_LIT:1> ) <EOL> labelSource = it . getChildNodesByType ( LABEL ) . single ( ) . toFirSourceElement ( ) <EOL> context . addNewLabel ( buildLabel ( name , labelSource ! ! ) ) <EOL> forbiddenLabelKind = getForbiddenLabelKind ( name , isRepetitiveLabel ) <EOL> } <EOL> BLOCK -> firExpression = declarationBuilder . convertBlock ( it ) <EOL> PROPERTY -> firExpression = declarationBuilder . convertPropertyDeclaration ( it ) <EOL> else -> if ( it . isExpression ( ) ) firExpression = getAsFirStatement ( it ) <EOL> } <EOL> } <EOL> context . dropLastLabel ( ) <EOL> return buildExpressionHandlingErrors ( firExpression , labeledExpression . toFirSourceElement ( ) , forbiddenLabelKind , labelSource ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseLabeledExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitLabeledExpression
 */


private fun convertUnaryExpression ( unaryExpression : LighterASTNode ) : FirExpression

{ <EOL> lateinit var operationTokenName : String <EOL> var argument : LighterASTNode ? = null <EOL> var operationReference : LighterASTNode ? = null <EOL> unaryExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> OPERATION_REFERENCE -> { <EOL> operationReference = it <EOL> operationTokenName = it . asText <EOL> } <EOL> else -> if ( it . isExpression ( ) ) argument = it <EOL> } <EOL> } <EOL> val operationToken = operationTokenName . getOperationSymbol ( ) <EOL> val conventionCallName = operationToken . toUnaryName ( ) <EOL> return when { <EOL> operationToken == EXCLEXCL -> { <EOL> buildCheckNotNullCall { <EOL> source = unaryExpression . toFirSourceElement ( ) <EOL> argumentList = buildUnaryArgumentList ( getAsFirExpression < FirExpression > ( argument , "<STR_LIT>" ) ) <EOL> } <EOL> } <EOL> conventionCallName != null -> { <EOL> if ( operationToken in OperatorConventions . INCREMENT_OPERATIONS ) { <EOL> return generateIncrementOrDecrementBlock ( unaryExpression , operationReference , argument , callName = conventionCallName , prefix = unaryExpression . tokenType == PREFIX_EXPRESSION ) { getAsFirExpression ( this ) } <EOL> } <EOL> val receiver = getAsFirExpression < FirExpression > ( argument , "<STR_LIT>" ) <EOL> convertUnaryPlusMinusCallOnIntegerLiteralIfNecessary ( unaryExpression , receiver , operationToken ) ? . let { return it } <EOL> buildFunctionCall { <EOL> source = unaryExpression . toFirSourceElement ( ) <EOL> calleeReference = buildSimpleNamedReference { <EOL> source = operationReference ? . toFirSourceElement ( ) ? : this@buildFunctionCall . source <EOL> name = conventionCallName <EOL> } <EOL> explicitReceiver = receiver <EOL> origin = FirFunctionCallOrigin . Operator <EOL> } <EOL> } <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parsePostfixExpression
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parsePrefixExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitUnaryExpression
 */


private fun convertAnnotatedExpression ( annotatedExpression : LighterASTNode ) : FirElement

{ <EOL> var firExpression : FirElement ? = null <EOL> val firAnnotationList = mutableListOf < FirAnnotation > ( ) <EOL> annotatedExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> ANNOTATION -> firAnnotationList += declarationBuilder . convertAnnotation ( it ) <EOL> ANNOTATION_ENTRY -> firAnnotationList += declarationBuilder . convertAnnotationEntry ( it ) <EOL> BLOCK -> firExpression = declarationBuilder . convertBlockExpression ( it ) <EOL> else -> if ( it . isExpression ( ) ) { <EOL> context . forwardLabelUsagePermission ( annotatedExpression , it ) <EOL> firExpression = getAsFirStatement ( it ) <EOL> } <EOL> } <EOL> } <EOL> val result = firExpression ? : buildErrorExpression ( null , ConeNotAnnotationContainer ( "<STR_LIT>" ) ) <EOL> require ( result is FirAnnotationContainer ) <EOL> result . replaceAnnotations ( result . annotations . smartPlus ( firAnnotationList ) ) <EOL> return result <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parsePrefixExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitAnnotatedExpression
 */


private fun convertClassLiteralExpression ( classLiteralExpression : LighterASTNode ) : FirExpression

{ <EOL> var firReceiverExpression : FirExpression ? = null <EOL> classLiteralExpression . forEachChildren { <EOL> if ( it . isExpression ( ) ) firReceiverExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> val classLiteralSource = classLiteralExpression . toFirSourceElement ( ) <EOL> return buildGetClassCall { <EOL> source = classLiteralSource <EOL> argumentList = buildUnaryArgumentList ( firReceiverExpression ? : buildErrorExpression ( classLiteralSource , ConeUnsupportedClassLiteralsWithEmptyLhs ) ) <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseDoubleColonSuffix
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitClassLiteralExpression
 */


private fun convertCallableReferenceExpression ( callableReferenceExpression : LighterASTNode ) : FirExpression

{ <EOL> var isReceiver = true <EOL> var hasQuestionMarkAtLHS = false <EOL> var firReceiverExpression : FirExpression ? = null <EOL> lateinit var namedReference : FirNamedReference <EOL> callableReferenceExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> COLONCOLON -> isReceiver = false <EOL> QUEST -> hasQuestionMarkAtLHS = true <EOL> else -> if ( it . isExpression ( ) ) { <EOL> if ( isReceiver ) { <EOL> firReceiverExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } else { <EOL> namedReference = createSimpleNamedReference ( it . toFirSourceElement ( ) , it ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> return buildCallableReferenceAccess { <EOL> source = callableReferenceExpression . toFirSourceElement ( ) <EOL> calleeReference = namedReference <EOL> explicitReceiver = firReceiverExpression <EOL> this . hasQuestionMarkAtLHS = hasQuestionMarkAtLHS <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseDoubleColonSuffix
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitCallableReferenceExpression
 */


private fun convertQualifiedExpression ( dotQualifiedExpression : LighterASTNode ) : FirExpression

{ <EOL> var isSelector = false <EOL> var isSafe = false <EOL> var firSelector : FirExpression ? = null <EOL> var firReceiver : FirExpression ? = null <EOL> dotQualifiedExpression . forEachChildren { <EOL> when ( val tokenType = it . tokenType ) { <EOL> DOT -> isSelector = true <EOL> SAFE_ACCESS -> { <EOL> isSafe = true <EOL> isSelector = true <EOL> } <EOL> else -> { <EOL> val isEffectiveSelector = isSelector && tokenType != TokenType . ERROR_ELEMENT <EOL> val firExpression = <EOL> getAsFirExpression < FirExpression > ( it , "<STR_LIT>" ) <EOL> if ( isEffectiveSelector ) { <EOL> val callExpressionCallee = if ( tokenType == CALL_EXPRESSION ) it . getFirstChildExpressionUnwrapped ( ) else null <EOL> firSelector = <EOL> if ( tokenType is KtNameReferenceExpressionElementType || ( tokenType == CALL_EXPRESSION && callExpressionCallee ? . tokenType != LAMBDA_EXPRESSION ) ) { <EOL> firExpression <EOL> } else { <EOL> buildErrorExpression { <EOL> source = callExpressionCallee ? . toFirSourceElement ( ) ? : it . toFirSourceElement ( ) <EOL> diagnostic = ConeSimpleDiagnostic ( "<STR_LIT>" , if ( callExpressionCallee == null ) DiagnosticKind . IllegalSelector else DiagnosticKind . NoReceiverAllowed ) <EOL> expression = firExpression <EOL> } <EOL> } <EOL> } else { <EOL> firReceiver = firExpression <EOL> } <EOL> } <EOL> } <EOL> } <EOL> var result = firSelector <EOL> ( firSelector as? FirQualifiedAccessExpression ) ? . let { <EOL> if ( isSafe ) { <EOL> @ OptIn ( FirImplementationDetail :: class ) <EOL> it . replaceSource ( dotQualifiedExpression . toFirSourceElement ( KtFakeSourceElementKind . DesugaredSafeCallExpression ) ) <EOL> return it . createSafeCall ( firReceiver ! ! , dotQualifiedExpression . toFirSourceElement ( ) ) <EOL> } <EOL> result = convertFirSelector ( it , dotQualifiedExpression . toFirSourceElement ( ) , firReceiver ! ! ) <EOL> } <EOL> val receiver = firReceiver <EOL> if ( receiver != null ) { <EOL> ( firSelector as? FirErrorExpression ) ? . let { errorExpression -> <EOL> return buildQualifiedErrorAccessExpression { <EOL> this . receiver = receiver <EOL> this . selector = errorExpression <EOL> source = dotQualifiedExpression . toFirSourceElement ( ) <EOL> diagnostic = ConeSyntaxDiagnostic ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> return result ? : buildErrorExpression { <EOL> source = dotQualifiedExpression . toFirSourceElement ( ) <EOL> diagnostic = ConeSyntaxDiagnostic ( "<STR_LIT>" ) <EOL> expression = firReceiver <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parsePostfixExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitQualifiedExpression
 */


private fun convertCallExpression ( callSuffix : LighterASTNode ) : FirExpression

{ <EOL> var name : String ? = null <EOL> val firTypeArguments = mutableListOf < FirTypeProjection > ( ) <EOL> val valueArguments = mutableListOf < LighterASTNode > ( ) <EOL> var additionalArgument : FirExpression ? = null <EOL> var hasArguments = false <EOL> var superNode : LighterASTNode ? = null <EOL> callSuffix . forEachChildren { child -> <EOL> fun process ( node : LighterASTNode ) { <EOL> when ( node . tokenType ) { <EOL> REFERENCE_EXPRESSION -> { <EOL> name = node . asText <EOL> } <EOL> SUPER_EXPRESSION -> { <EOL> superNode = node <EOL> } <EOL> PARENTHESIZED -> if ( node . tokenType != TokenType . ERROR_ELEMENT ) { <EOL> additionalArgument = getAsFirExpression ( node . getExpressionInParentheses ( ) , "<STR_LIT>" ) <EOL> } <EOL> TYPE_ARGUMENT_LIST -> { <EOL> firTypeArguments += declarationBuilder . convertTypeArguments ( node , allowedUnderscoredTypeArgument = true ) <EOL> } <EOL> VALUE_ARGUMENT_LIST , LAMBDA_ARGUMENT -> { <EOL> hasArguments = true <EOL> valueArguments += node <EOL> } <EOL> else -> if ( node . tokenType != TokenType . ERROR_ELEMENT ) { <EOL> additionalArgument = getAsFirExpression ( node , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> process ( child ) <EOL> } <EOL> val source = callSuffix . toFirSourceElement ( ) <EOL> val ( calleeReference , explicitReceiver , isImplicitInvoke ) = when { <EOL> name != null -> CalleeAndReceiver ( buildSimpleNamedReference { <EOL> this . source = callSuffix . getFirstChildExpressionUnwrapped ( ) ? . toFirSourceElement ( ) ? : source <EOL> this . name = name . nameAsSafeName ( ) <EOL> } ) <EOL> superNode != null || ( additionalArgument as? FirResolvable ) ? . calleeReference is FirSuperReference -> { <EOL> CalleeAndReceiver ( buildErrorNamedReference { <EOL> this . source = superNode ? . toFirSourceElement ( ) ? : ( additionalArgument as? FirResolvable ) ? . calleeReference ? . source <EOL> diagnostic = ConeSimpleDiagnostic ( "<STR_LIT>" , DiagnosticKind . SuperNotAllowed ) <EOL> } ) <EOL> } <EOL> additionalArgument != null -> { <EOL> CalleeAndReceiver ( buildSimpleNamedReference { <EOL> this . source = source <EOL> this . name = OperatorNameConventions . INVOKE <EOL> } , additionalArgument ! ! , isImplicitInvoke = true ) <EOL> } <EOL> else -> CalleeAndReceiver ( buildErrorNamedReference { <EOL> this . source = source <EOL> diagnostic = ConeSyntaxDiagnostic ( "<STR_LIT>" ) <EOL> } ) <EOL> } <EOL> val builder : FirQualifiedAccessExpressionBuilder = if ( hasArguments ) { <EOL> val builder = if ( isImplicitInvoke ) FirImplicitInvokeCallBuilder ( ) else FirFunctionCallBuilder ( ) <EOL> builder . apply { <EOL> this . source = source <EOL> this . calleeReference = calleeReference <EOL> context . calleeNamesForLambda += calleeReference . name <EOL> this . extractArgumentsFrom ( valueArguments . flatMap { convertValueArguments ( it ) } ) <EOL> context . calleeNamesForLambda . removeLast ( ) <EOL> } <EOL> } else { <EOL> FirPropertyAccessExpressionBuilder ( ) . apply { <EOL> this . source = source <EOL> this . calleeReference = calleeReference <EOL> } <EOL> } <EOL> return builder . apply { <EOL> this . explicitReceiver = explicitReceiver <EOL> typeArguments += firTypeArguments <EOL> } . build ( ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseCallSuffix
 */


private fun convertStringTemplate ( stringTemplate : LighterASTNode ) : FirExpression

{ <EOL> return stringTemplate . getChildrenAsArray ( ) . toInterpolatingCall ( stringTemplate ) { convertShortOrLongStringTemplate ( it ) } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseStringTemplate
 */


private fun LighterASTNode ? . convertShortOrLongStringTemplate ( errorReason : String ) : FirExpression

{ <EOL> var firExpression : FirExpression ? = null <EOL> this ? . forEachChildren ( LONG_TEMPLATE_ENTRY_START , LONG_TEMPLATE_ENTRY_END ) { <EOL> firExpression = getAsFirExpression ( it , errorReason ) <EOL> } <EOL> return firExpression ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( errorReason ) ) <EOL> }


private fun convertConstantExpression ( constantExpression : LighterASTNode ) : FirExpression

{ <EOL> return generateConstantExpressionByLiteral ( constantExpression ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseLiteralConstant
 */


private fun convertWhenExpression ( whenExpression : LighterASTNode ) : FirExpression

{ <EOL> var subjectExpression : FirExpression ? = null <EOL> var subjectVariable : FirVariable ? = null <EOL> val whenEntryNodes = mutableListOf < LighterASTNode > ( ) <EOL> val whenEntries = mutableListOf < WhenEntry > ( ) <EOL> whenExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> PROPERTY -> subjectVariable = ( declarationBuilder . convertPropertyDeclaration ( it ) as FirVariable ) . let { variable -> <EOL> buildProperty { <EOL> source = it . toFirSourceElement ( ) <EOL> origin = FirDeclarationOrigin . Source <EOL> moduleData = baseModuleData <EOL> returnTypeRef = variable . returnTypeRef <EOL> name = variable . name <EOL> initializer = variable . initializer <EOL> isVar = false <EOL> symbol = FirPropertySymbol ( variable . name ) <EOL> isLocal = true <EOL> status = FirDeclarationStatusImpl ( Visibilities . Local , Modality . FINAL ) <EOL> annotations += variable . annotations <EOL> } <EOL> } <EOL> DESTRUCTURING_DECLARATION -> subjectExpression = <EOL> getAsFirExpression ( it , "<STR_LIT>" ) <EOL> WHEN_ENTRY -> whenEntryNodes += it <EOL> else -> if ( it . isExpression ( ) ) subjectExpression = <EOL> getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> subjectExpression = subjectVariable ? . initializer ? : subjectExpression <EOL> val hasSubject = subjectExpression != null <EOL> @ OptIn ( FirContractViolation :: class ) <EOL> val subject = FirExpressionRef < FirWhenExpression > ( ) <EOL> var shouldBind = hasSubject <EOL> whenEntryNodes . mapTo ( whenEntries ) { <EOL> convertWhenEntry ( it , subject , hasSubject ) <EOL> } <EOL> return buildWhenExpression { <EOL> source = whenExpression . toFirSourceElement ( ) <EOL> this . subject = subjectExpression <EOL> this . subjectVariable = subjectVariable <EOL> usedAsExpression = whenExpression . usedAsExpression <EOL> for ( entry in whenEntries ) { <EOL> shouldBind = shouldBind || entry . shouldBindSubject <EOL> val branch = entry . firBlock <EOL> val entrySource = entry . node . toFirSourceElement ( ) <EOL> branches += if ( ! entry . isElse ) { <EOL> if ( hasSubject ) { <EOL> val firCondition = entry . toFirWhenCondition ( ) <EOL> buildWhenBranch { <EOL> source = entrySource <EOL> condition = firCondition <EOL> result = branch <EOL> } <EOL> } else { <EOL> val firCondition = entry . toFirWhenConditionWithoutSubject ( ) <EOL> buildWhenBranch { <EOL> source = entrySource <EOL> condition = firCondition <EOL> result = branch <EOL> } <EOL> } <EOL> } else { <EOL> buildWhenBranch { <EOL> source = entrySource <EOL> condition = buildElseIfTrueCondition ( ) <EOL> result = branch <EOL> } <EOL> } <EOL> } <EOL> } . also { <EOL> if ( shouldBind ) { <EOL> subject . bind ( it ) <EOL> } <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseWhen
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitWhenExpression
 */


private fun convertWhenEntry ( whenEntry : LighterASTNode , whenRefWithSubject : FirExpressionRef < FirWhenExpression > , hasSubject : Boolean , ) : WhenEntry

{ <EOL> var isElse = false <EOL> var firBlock : FirBlock = buildEmptyExpressionBlock ( ) <EOL> val conditions = mutableListOf < FirExpression > ( ) <EOL> var shouldBindSubject = false <EOL> whenEntry . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> WHEN_CONDITION_EXPRESSION -> conditions += convertWhenConditionExpression ( it , whenRefWithSubject . takeIf { hasSubject } ) <EOL> WHEN_CONDITION_IN_RANGE -> { <EOL> val ( condition , shouldBind ) = convertWhenConditionInRange ( it , whenRefWithSubject , hasSubject ) <EOL> conditions += condition <EOL> shouldBindSubject = shouldBindSubject || shouldBind <EOL> } <EOL> WHEN_CONDITION_IS_PATTERN -> { <EOL> val ( condition , shouldBind ) = convertWhenConditionIsPattern ( it , whenRefWithSubject , hasSubject ) <EOL> conditions += condition <EOL> shouldBindSubject = shouldBindSubject || shouldBind <EOL> } <EOL> ELSE_KEYWORD -> isElse = true <EOL> BLOCK -> firBlock = declarationBuilder . convertBlock ( it ) <EOL> else -> if ( it . isExpression ( ) ) firBlock = declarationBuilder . convertBlock ( it ) <EOL> } <EOL> } <EOL> return WhenEntry ( conditions , firBlock , whenEntry , isElse , shouldBindSubject ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseWhenEntry
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseWhenEntryNotElse
 */


private fun convertWhenConditionExpression ( whenCondition : LighterASTNode , whenRefWithSubject : FirExpressionRef < FirWhenExpression > ? <EOL> ) : FirExpression

{ <EOL> var firExpression : FirExpression ? = null <EOL> whenCondition . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> else -> if ( it . isExpression ( ) ) firExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val calculatedFirExpression = firExpression ? : buildErrorExpression ( source = null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> if ( whenRefWithSubject == null ) { <EOL> return calculatedFirExpression <EOL> } <EOL> return buildEqualityOperatorCall { <EOL> source = whenCondition . toFirSourceElement ( KtFakeSourceElementKind . WhenCondition ) <EOL> operation = FirOperation . EQ <EOL> argumentList = buildBinaryArgumentList ( left = buildWhenSubjectExpression { <EOL> source = whenCondition . toFirSourceElement ( ) <EOL> whenRef = whenRefWithSubject <EOL> } , right = calculatedFirExpression ) <EOL> } <EOL> }


private fun convertWhenConditionInRange ( whenCondition : LighterASTNode , whenRefWithSubject : FirExpressionRef < FirWhenExpression > , hasSubject : Boolean , ) : WhenConditionConvertedResults

{ <EOL> var isNegate = false <EOL> var firExpression : FirExpression ? = null <EOL> var conditionSource : KtLightSourceElement ? = null <EOL> whenCondition . forEachChildren { <EOL> when { <EOL> it . tokenType == OPERATION_REFERENCE && it . asText == NOT_IN . value -> { <EOL> conditionSource = it . toFirSourceElement ( ) <EOL> isNegate = true <EOL> } <EOL> it . tokenType == OPERATION_REFERENCE -> { <EOL> conditionSource = it . toFirSourceElement ( ) <EOL> } <EOL> else -> if ( it . isExpression ( ) ) firExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val subjectExpression = buildWhenSubjectExpression { <EOL> whenRef = whenRefWithSubject <EOL> source = whenCondition . toFirSourceElement ( ) <EOL> } <EOL> val calculatedFirExpression = firExpression ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> val result = calculatedFirExpression . generateContainsOperation ( subjectExpression , inverted = isNegate , baseSource = whenCondition . toFirSourceElement ( ) , operationReferenceSource = conditionSource ) <EOL> return createWhenConditionConvertedResults ( hasSubject , result , whenCondition ) <EOL> }


private fun convertWhenConditionIsPattern ( whenCondition : LighterASTNode , whenRefWithSubject : FirExpressionRef < FirWhenExpression > , hasSubject : Boolean , ) : WhenConditionConvertedResults

{ <EOL> lateinit var firOperation : FirOperation <EOL> var firType : FirTypeRef ? = null <EOL> whenCondition . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> TYPE_REFERENCE -> firType = declarationBuilder . convertType ( it ) <EOL> IS_KEYWORD -> firOperation = FirOperation . IS <EOL> NOT_IS -> firOperation = FirOperation . NOT_IS <EOL> } <EOL> } <EOL> val subjectExpression = buildWhenSubjectExpression { <EOL> source = whenCondition . toFirSourceElement ( ) <EOL> whenRef = whenRefWithSubject <EOL> } <EOL> val result = buildTypeOperatorCall { <EOL> source = whenCondition . toFirSourceElement ( ) <EOL> operation = firOperation <EOL> conversionTypeRef = firType ? : buildErrorTypeRef { diagnostic = ConeSyntaxDiagnostic ( "<STR_LIT>" ) } <EOL> argumentList = buildUnaryArgumentList ( subjectExpression ) <EOL> } <EOL> return createWhenConditionConvertedResults ( hasSubject , result , whenCondition ) <EOL> }


private fun createWhenConditionConvertedResults ( hasSubject : Boolean , result : FirExpression , whenCondition : LighterASTNode , ) : WhenConditionConvertedResults

{ <EOL> return if ( hasSubject ) { <EOL> WhenConditionConvertedResults ( result , false ) <EOL> } else { <EOL> WhenConditionConvertedResults ( buildErrorExpression { <EOL> source = whenCondition . toFirSourceElement ( ) <EOL> diagnostic = ConeSimpleDiagnostic ( "<STR_LIT>" , DiagnosticKind . ExpressionExpected ) <EOL> nonExpressionElement = result <EOL> } , true , ) <EOL> } <EOL> }


private fun convertArrayAccessExpression ( arrayAccess : LighterASTNode ) : FirExpression

{ <EOL> var firExpression : FirExpression ? = null <EOL> val indices : MutableList < FirExpression > = mutableListOf ( ) <EOL> arrayAccess . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> INDICES -> indices += convertIndices ( it ) <EOL> else -> if ( it . isExpression ( ) ) firExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val getArgument = context . arraySetArgument . remove ( arrayAccess ) <EOL> return buildFunctionCall { <EOL> val isGet = getArgument == null <EOL> source = ( if ( isGet ) arrayAccess else arrayAccess . getParent ( ) ! ! ) . toFirSourceElement ( ) <EOL> calleeReference = buildSimpleNamedReference { <EOL> source = arrayAccess . toFirSourceElement ( ) . fakeElement ( KtFakeSourceElementKind . ArrayAccessNameReference ) <EOL> name = if ( isGet ) OperatorNameConventions . GET else OperatorNameConventions . SET <EOL> } <EOL> explicitReceiver = <EOL> firExpression ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> argumentList = buildArgumentList { <EOL> arguments += indices <EOL> getArgument ? . let { arguments += it } <EOL> } <EOL> origin = FirFunctionCallOrigin . Operator <EOL> } . pullUpSafeCallIfNecessary ( ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseArrayAccess
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitArrayAccessExpression
 */


private fun convertCollectionLiteralExpression ( expression : LighterASTNode ) : FirExpression

{ <EOL> val firExpressionList = mutableListOf < FirExpression > ( ) <EOL> expression . forEachChildren { <EOL> if ( it . isExpression ( ) ) firExpressionList += getAsFirExpression < FirExpression > ( it , "<STR_LIT>" ) <EOL> } <EOL> return buildArrayLiteral { <EOL> source = expression . toFirSourceElement ( ) <EOL> argumentList = buildArgumentList { <EOL> arguments += firExpressionList <EOL> } <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseCollectionLiteralExpression
 */


private fun convertIndices ( indices : LighterASTNode ) : List < FirExpression >

{ <EOL> val firExpressionList : MutableList < FirExpression > = mutableListOf ( ) <EOL> indices . forEachChildren { <EOL> if ( it . isExpression ( ) ) firExpressionList += getAsFirExpression < FirExpression > ( it , "<STR_LIT>" ) <EOL> } <EOL> return firExpressionList <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseAsCollectionLiteralExpression
 */


private fun convertSimpleNameExpression ( referenceExpression : LighterASTNode ) : FirQualifiedAccessExpression

{ <EOL> val nameSource = referenceExpression . toFirSourceElement ( ) <EOL> val referenceSourceElement = if ( nameSource . kind is KtFakeSourceElementKind ) { <EOL> nameSource <EOL> } else { <EOL> nameSource . fakeElement ( KtFakeSourceElementKind . ReferenceInAtomicQualifiedAccess ) <EOL> } <EOL> return buildPropertyAccessExpression { <EOL> val rawText = referenceExpression . asText <EOL> if ( rawText . isUnderscore ) { <EOL> nonFatalDiagnostics . add ( ConeUnderscoreUsageWithoutBackticks ( nameSource ) ) <EOL> } <EOL> source = nameSource <EOL> calleeReference = createSimpleNamedReference ( referenceSourceElement , referenceExpression ) <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseSimpleNameExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitSimpleNameExpression
 */


private fun createSimpleNamedReference ( sourceElement : KtSourceElement , referenceExpression : LighterASTNode ) : FirNamedReference

{ <EOL> return buildSimpleNamedReference { <EOL> source = sourceElement <EOL> name = referenceExpression . asText . nameAsSafeName ( ) <EOL> } <EOL> }


private fun convertDoWhile ( doWhileLoop : LighterASTNode ) : FirElement

{ <EOL> var block : LighterASTNode ? = null <EOL> var firCondition : FirExpression ? = null <EOL> val target : FirLoopTarget <EOL> return FirDoWhileLoopBuilder ( ) . apply { <EOL> source = doWhileLoop . toFirSourceElement ( ) <EOL> target = prepareTarget ( doWhileLoop ) <EOL> doWhileLoop . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> BODY -> block = it <EOL> CONDITION -> firCondition = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> condition = <EOL> firCondition ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> } . configure ( target ) { convertLoopBody ( block ) } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseDoWhile
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitDoWhileExpression
 */


private fun convertWhile ( whileLoop : LighterASTNode ) : FirElement

{ <EOL> var block : LighterASTNode ? = null <EOL> var firCondition : FirExpression ? = null <EOL> whileLoop . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> BODY -> block = it <EOL> CONDITION -> firCondition = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val target : FirLoopTarget <EOL> return FirWhileLoopBuilder ( ) . apply { <EOL> source = whileLoop . toFirSourceElement ( ) <EOL> condition = <EOL> firCondition ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> target = prepareTarget ( whileLoop ) <EOL> } . configure ( target ) { convertLoopBody ( block ) } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseWhile
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitWhileExpression
 */


private fun convertFor ( forLoop : LighterASTNode ) : FirElement

{ <EOL> var parameter : ValueParameter ? = null <EOL> var rangeExpression : FirExpression ? = null <EOL> var blockNode : LighterASTNode ? = null <EOL> forLoop . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> VALUE_PARAMETER -> parameter = declarationBuilder . convertValueParameter ( it , null , ValueParameterDeclaration . FOR_LOOP ) <EOL> LOOP_RANGE -> rangeExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> BODY -> blockNode = it <EOL> } <EOL> } <EOL> val calculatedRangeExpression = <EOL> rangeExpression ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> val fakeSource = forLoop . toFirSourceElement ( KtFakeSourceElementKind . DesugaredForLoop ) <EOL> val rangeSource = calculatedRangeExpression . source ? . fakeElement ( KtFakeSourceElementKind . DesugaredForLoop ) ? : fakeSource <EOL> val target : FirLoopTarget <EOL> return buildBlock { <EOL> source = fakeSource <EOL> val iteratorVal = generateTemporaryVariable ( baseModuleData , rangeSource , SpecialNames . ITERATOR , buildFunctionCall { <EOL> source = rangeSource <EOL> calleeReference = buildSimpleNamedReference { <EOL> source = rangeSource <EOL> name = OperatorNameConventions . ITERATOR <EOL> } <EOL> explicitReceiver = calculatedRangeExpression <EOL> origin = FirFunctionCallOrigin . Operator <EOL> } ) <EOL> statements += iteratorVal <EOL> statements += FirWhileLoopBuilder ( ) . apply { <EOL> source = fakeSource <EOL> condition = buildFunctionCall { <EOL> source = rangeSource <EOL> calleeReference = buildSimpleNamedReference { <EOL> source = rangeSource <EOL> name = OperatorNameConventions . HAS_NEXT <EOL> } <EOL> explicitReceiver = generateResolvedAccessExpression ( rangeSource , iteratorVal ) <EOL> origin = FirFunctionCallOrigin . Operator <EOL> } <EOL> target = prepareTarget ( forLoop ) <EOL> } . configure ( target ) { <EOL> buildBlock block @ { <EOL> source = blockNode ? . toFirSourceElement ( ) <EOL> val valueParameter = parameter ? : return@block <EOL> val multiDeclaration = valueParameter . destructuringDeclaration <EOL> val firLoopParameter = generateTemporaryVariable ( baseModuleData , valueParameter . source , if ( multiDeclaration != null ) SpecialNames . DESTRUCT else valueParameter . name , buildFunctionCall { <EOL> source = rangeSource <EOL> calleeReference = buildSimpleNamedReference { <EOL> source = rangeSource <EOL> name = OperatorNameConventions . NEXT <EOL> } <EOL> explicitReceiver = generateResolvedAccessExpression ( rangeSource , iteratorVal ) <EOL> origin = FirFunctionCallOrigin . Operator <EOL> } , valueParameter . returnTypeRef , extractedAnnotations = valueParameter . annotations ) <EOL> if ( multiDeclaration != null ) { <EOL> addDestructuringStatements ( statements , baseModuleData , multiDeclaration , firLoopParameter , tmpVariable = true , forceLocal = true , ) <EOL> } else { <EOL> statements . add ( firLoopParameter ) <EOL> } <EOL> statements += convertLoopBody ( blockNode ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseFor
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitForExpression
 */


private fun convertLoopBody ( body : LighterASTNode ? ) : FirBlock

{ <EOL> return convertLoopOrIfBody ( body ) ? : buildEmptyExpressionBlock ( ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseLoopBody
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.toFirBlock
 */


private fun convertLoopOrIfBody ( body : LighterASTNode ? ) : FirBlock ?

{ <EOL> var firBlock : FirBlock ? = null <EOL> var firStatement : FirStatement ? = null <EOL> body ? . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> BLOCK -> firBlock = declarationBuilder . convertBlockExpression ( it ) <EOL> ANNOTATED_EXPRESSION -> { <EOL> if ( it . getChildNodeByType ( BLOCK ) != null ) { <EOL> firBlock = getAsFirExpression ( it ) <EOL> } else { <EOL> firStatement = getAsFirStatement ( it ) <EOL> } <EOL> } <EOL> else -> if ( it . isExpression ( ) ) firStatement = getAsFirStatement ( it ) <EOL> } <EOL> } <EOL> return firStatement ? . let { FirSingleExpressionBlock ( it ) } ? : firBlock <EOL> }


private fun convertTryExpression ( tryExpression : LighterASTNode ) : FirExpression

{ <EOL> lateinit var tryBlock : FirBlock <EOL> val catchClauses = mutableListOf < Triple < ValueParameter ? , FirBlock , KtLightSourceElement > > ( ) <EOL> var finallyBlock : FirBlock ? = null <EOL> tryExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> BLOCK -> tryBlock = declarationBuilder . convertBlock ( it ) <EOL> CATCH -> convertCatchClause ( it ) ? . also { oneClause -> catchClauses += oneClause } <EOL> FINALLY -> finallyBlock = convertFinally ( it ) <EOL> } <EOL> } <EOL> return buildTryExpression { <EOL> source = tryExpression . toFirSourceElement ( ) <EOL> this . tryBlock = tryBlock <EOL> this . finallyBlock = finallyBlock <EOL> for ( ( parameter , block , clauseSource ) in catchClauses ) { <EOL> if ( parameter == null ) continue <EOL> catches += buildCatch { <EOL> this . parameter = buildProperty { <EOL> source = parameter . source <EOL> moduleData = baseModuleData <EOL> origin = FirDeclarationOrigin . Source <EOL> returnTypeRef = parameter . returnTypeRef <EOL> isVar = false <EOL> status = FirResolvedDeclarationStatusImpl ( Visibilities . Local , Modality . FINAL , EffectiveVisibility . Local ) <EOL> isLocal = true <EOL> this . name = parameter . name <EOL> symbol = FirPropertySymbol ( CallableId ( name ) ) <EOL> annotations += parameter . annotations <EOL> } . also { <EOL> it . isCatchParameter = true <EOL> } <EOL> this . block = block <EOL> this . source = clauseSource <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseTry
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitTryExpression
 */


private fun convertCatchClause ( catchClause : LighterASTNode ) : Triple < ValueParameter ? , FirBlock , KtLightSourceElement > ?

{ <EOL> var valueParameter : ValueParameter ? = null <EOL> var blockNode : LighterASTNode ? = null <EOL> catchClause . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> VALUE_PARAMETER_LIST -> valueParameter = declarationBuilder . convertValueParameters ( it , FirAnonymousFunctionSymbol ( ) , ValueParameterDeclaration . CATCH ) <EOL> . firstOrNull ( ) ? : return null <EOL> BLOCK -> blockNode = it <EOL> } <EOL> } <EOL> return Triple ( valueParameter , declarationBuilder . convertBlock ( blockNode ) , catchClause . toFirSourceElement ( ) ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseTry
 */


private fun convertFinally ( finallyExpression : LighterASTNode ) : FirBlock

{ <EOL> var blockNode : LighterASTNode ? = null <EOL> finallyExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> BLOCK -> blockNode = it <EOL> } <EOL> } <EOL> return declarationBuilder . convertBlock ( blockNode ) <EOL> }


private fun convertIfExpression ( ifExpression : LighterASTNode ) : FirExpression

{ <EOL> return buildWhenExpression { <EOL> source = ifExpression . toFirSourceElement ( ) <EOL> with ( parseIfExpression ( ifExpression ) ) { <EOL> val trueBranch = convertLoopBody ( thenBlock ) <EOL> branches += buildWhenBranch { <EOL> source = firCondition ? . source <EOL> condition = firCondition ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> result = trueBranch <EOL> } <EOL> if ( elseBlock != null ) { <EOL> val elseBranch = convertLoopOrIfBody ( elseBlock ) <EOL> if ( elseBranch != null ) { <EOL> branches += buildWhenBranch { <EOL> source = elseBlock . toFirSourceElement ( ) <EOL> condition = buildElseIfTrueCondition ( ) <EOL> result = elseBranch <EOL> } <EOL> } <EOL> } <EOL> } <EOL> usedAsExpression = ifExpression . usedAsExpression <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseIf
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitIfExpression
 */


private fun parseIfExpression ( ifExpression : LighterASTNode ) : IfNodeComponents

{ <EOL> var firCondition : FirExpression ? = null <EOL> var thenBlock : LighterASTNode ? = null <EOL> var elseBlock : LighterASTNode ? = null <EOL> ifExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> CONDITION -> firCondition = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> THEN -> thenBlock = it <EOL> ELSE -> elseBlock = it <EOL> } <EOL> } <EOL> return IfNodeComponents ( firCondition , thenBlock , elseBlock ) <EOL> }


private fun convertLoopJump ( jump : LighterASTNode ) : FirExpression

{ <EOL> var isBreak = true <EOL> jump . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> CONTINUE_KEYWORD -> isBreak = false <EOL> } <EOL> } <EOL> val jumpBuilder = if ( isBreak ) FirBreakExpressionBuilder ( ) else FirContinueExpressionBuilder ( ) <EOL> val sourceElement = jump . toFirSourceElement ( ) <EOL> return jumpBuilder . apply { <EOL> source = sourceElement <EOL> } . bindLabel ( jump ) . build ( ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseJump
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitBreakExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitContinueExpression
 */


private fun convertReturn ( returnExpression : LighterASTNode ) : FirExpression

{ <EOL> var labelName : String ? = null <EOL> var firExpression : FirExpression ? = null <EOL> returnExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> LABEL_QUALIFIER -> labelName = it . getAsStringWithoutBacktick ( ) . replace ( "<STR_LIT:@>" , "<STR_LIT>" ) <EOL> else -> if ( it . isExpression ( ) ) firExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val calculatedFirExpression = firExpression ? : buildUnitExpression { <EOL> source = returnExpression . toFirSourceElement ( KtFakeSourceElementKind . ImplicitUnit . Return ) <EOL> } <EOL> return calculatedFirExpression . toReturn ( baseSource = returnExpression . toFirSourceElement ( ) , labelName = labelName , fromKtReturnExpression = true ) <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseReturn
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitReturnExpression
 */