private fun foldSafeCall ( safeCallInfo : SafeCallInfo ) : IrExpression

{ <EOL> val safeCallBlock = safeCallInfo . block <EOL> val startOffset = safeCallBlock . startOffset <EOL> val endOffset = safeCallBlock . endOffset <EOL> val safeCallType = safeCallBlock . type <EOL> val safeCallTmpVal = safeCallInfo . tmpVal <EOL> val tmpValInitializer = safeCallTmpVal . initializer <EOL> if ( tmpValInitializer is IrBlock && tmpValInitializer . origin == JvmLoweredStatementOrigin . FOLDED_SAFE_CALL ) { <EOL> val foldedBlock : IrBlock = tmpValInitializer <EOL> val foldedWhen = foldedBlock . statements [ <NUM_LIT:0> ] as IrWhen <EOL> val safeReceiverCondition = foldedWhen . branches [ <NUM_LIT:0> ] . condition <EOL> val safeReceiverResult = foldedWhen . branches [ <NUM_LIT:0> ] . result <EOL> safeCallTmpVal . initializer = safeReceiverResult <EOL> safeCallTmpVal . type = safeReceiverResult . type <EOL> val foldedConditionPart = <EOL> IrCompositeImpl ( startOffset , endOffset , context . irBuiltIns . booleanType , null , listOf < IrStatement > ( safeCallTmpVal , irValNotNull ( startOffset , endOffset , safeCallTmpVal ) ) ) <EOL> foldedBlock . type = safeCallType <EOL> foldedWhen . type = safeCallType <EOL> foldedWhen . branches [ <NUM_LIT:0> ] . condition = irAndAnd ( safeReceiverCondition , foldedConditionPart ) <EOL> foldedWhen . branches [ <NUM_LIT:0> ] . result = safeCallInfo . ifNotNullBranch . result <EOL> return foldedBlock <EOL> } else { <EOL> val foldedCondition = <EOL> IrCompositeImpl ( startOffset , endOffset , context . irBuiltIns . booleanType , null , listOf < IrStatement > ( safeCallTmpVal , irValNotNull ( startOffset , endOffset , safeCallTmpVal ) ) ) <EOL> val safeCallResult = safeCallInfo . ifNotNullBranch . result <EOL> val nullResult = safeCallInfo . ifNullBranch . result <EOL> val foldedWhen = IrWhenImpl ( startOffset , endOffset , safeCallType , JvmLoweredStatementOrigin . FOLDED_SAFE_CALL , listOf ( IrBranchImpl ( startOffset , endOffset , foldedCondition , safeCallResult ) , IrBranchImpl ( startOffset , endOffset , irTrue ( startOffset , endOffset ) , nullResult ) ) ) <EOL> return foldedWhen . wrapWithBlock ( JvmLoweredStatementOrigin . FOLDED_SAFE_CALL ) <EOL> } <EOL> }


private fun foldElvis ( elvisInfo : ElvisInfo ) : IrExpression

{ <EOL> val elvisLhs = elvisInfo . elvisLhs <EOL> val elvisBlock = elvisInfo . block <EOL> val startOffset = elvisBlock . startOffset <EOL> val endOffset = elvisBlock . endOffset <EOL> val elvisType = elvisBlock . type <EOL> val elvisTmpVal = elvisInfo . tmpVal <EOL> when { <EOL> elvisLhs is IrBlock && elvisLhs . origin == JvmLoweredStatementOrigin . FOLDED_SAFE_CALL -> { <EOL> val safeCallWhen = elvisLhs . statements [ <NUM_LIT:0> ] as IrWhen <EOL> val safeCallCondition = safeCallWhen . branches [ <NUM_LIT:0> ] . condition <EOL> val safeCallResult = safeCallWhen . branches [ <NUM_LIT:0> ] . result <EOL> elvisTmpVal . initializer = safeCallResult <EOL> elvisTmpVal . type = safeCallResult . type <EOL> val foldedConditionPart = <EOL> IrCompositeImpl ( startOffset , endOffset , context . irBuiltIns . booleanType , null , listOf < IrStatement > ( elvisTmpVal , irValNotNull ( startOffset , endOffset , elvisTmpVal ) ) ) <EOL> val branches = ArrayList < IrBranch > ( ) <EOL> branches . add ( IrBranchImpl ( startOffset , endOffset , irAndAnd ( safeCallCondition , foldedConditionPart ) , IrGetValueImpl ( startOffset , endOffset , elvisTmpVal . symbol ) ) ) <EOL> val elvisRhs = elvisInfo . elvisRhs <EOL> if ( elvisRhs . isFoldedSafeCallWithNonNullResult ( ) ) { <EOL> val rhsInnerWhen = ( elvisRhs as IrBlock ) . statements [ <NUM_LIT:0> ] as IrWhen <EOL> branches . addAll ( rhsInnerWhen . branches ) <EOL> } else { <EOL> branches . add ( IrBranchImpl ( startOffset , endOffset , irTrue ( startOffset , endOffset ) , elvisInfo . elvisRhs ) ) <EOL> } <EOL> return IrWhenImpl ( startOffset , endOffset , elvisType , JvmLoweredStatementOrigin . FOLDED_ELVIS , branches ) <EOL> . wrapWithBlock ( JvmLoweredStatementOrigin . FOLDED_ELVIS ) <EOL> } <EOL> elvisLhs is IrBlock && elvisLhs . origin == JvmLoweredStatementOrigin . FOLDED_ELVIS -> { <EOL> val innerElvisWhen = elvisLhs . statements [ <NUM_LIT:0> ] as IrWhen <EOL> val innerElvisLastBranch = innerElvisWhen . branches . last ( ) <EOL> val innerElvisRhs = innerElvisLastBranch . result <EOL> elvisTmpVal . initializer = innerElvisRhs <EOL> elvisTmpVal . type = innerElvisRhs . type <EOL> val newCondition = IrCompositeImpl ( startOffset , endOffset , context . irBuiltIns . booleanType , null , listOf ( elvisTmpVal , irValNotNull ( startOffset , endOffset , elvisTmpVal ) ) ) <EOL> innerElvisLastBranch . condition = newCondition <EOL> innerElvisLastBranch . result = IrGetValueImpl ( startOffset , endOffset , elvisTmpVal . symbol ) <EOL> innerElvisWhen . branches . add ( IrBranchImpl ( startOffset , endOffset , irTrue ( startOffset , endOffset ) , elvisInfo . elvisRhs ) ) <EOL> innerElvisWhen . type = elvisType <EOL> return innerElvisWhen . wrapWithBlock ( JvmLoweredStatementOrigin . FOLDED_ELVIS ) <EOL> } <EOL> else -> { <EOL> val newCondition = IrCompositeImpl ( startOffset , endOffset , context . irBuiltIns . booleanType , null , listOf ( elvisTmpVal , irValNotNull ( startOffset , endOffset , elvisTmpVal ) ) ) <EOL> val foldedWhen = IrWhenImpl ( startOffset , endOffset , elvisType , JvmLoweredStatementOrigin . FOLDED_ELVIS , listOf ( IrBranchImpl ( startOffset , endOffset , newCondition , IrGetValueImpl ( startOffset , endOffset , elvisTmpVal . symbol ) ) , IrBranchImpl ( startOffset , endOffset , irTrue ( startOffset , endOffset ) , elvisInfo . elvisRhs ) ) ) <EOL> return foldedWhen . wrapWithBlock ( JvmLoweredStatementOrigin . FOLDED_ELVIS ) <EOL> } <EOL> } <EOL> }


private fun IrExpression . isFoldedSafeCallWithNonNullResult ( ) : Boolean

{ <EOL> if ( this !is IrBlock ) return false <EOL> if ( this . origin != JvmLoweredStatementOrigin . FOLDED_SAFE_CALL ) return false <EOL> val innerWhen = this . statements [ <NUM_LIT:0> ] as? IrWhen ? : return false <EOL> val safeCallResult = innerWhen . branches [ <NUM_LIT:0> ] . result <EOL> return ! safeCallResult . type . isJvmNullable ( ) <EOL> }


override fun visitCall ( expression : IrCall ) : IrExpression

{ <EOL> expression . transformChildrenVoid ( ) <EOL> if ( expression . symbol == context . irBuiltIns . eqeqSymbol ) { <EOL> val startOffset = expression . startOffset <EOL> val endOffset = expression . endOffset <EOL> val left = expression . getValueArgument ( <NUM_LIT:0> ) <EOL> ? : throw AssertionError ( "<STR_LIT>" ) <EOL> val right = expression . getValueArgument ( <NUM_LIT:1> ) <EOL> ? : throw AssertionError ( "<STR_LIT>" ) <EOL> if ( left is IrBlock && left . origin == JvmLoweredStatementOrigin . FOLDED_SAFE_CALL && right . type . isJvmPrimitive ( ) ) { <EOL> val safeCallWhen = left . statements [ <NUM_LIT:0> ] as IrWhen <EOL> val safeCallResult = safeCallWhen . branches [ <NUM_LIT:0> ] . result <EOL> expression . putValueArgument ( <NUM_LIT:0> , safeCallResult ) <EOL> safeCallWhen . branches [ <NUM_LIT:0> ] . result = expression <EOL> safeCallWhen . branches [ <NUM_LIT:1> ] . result = irFalse ( startOffset , endOffset ) <EOL> safeCallWhen . type = expression . type <EOL> return safeCallWhen . wrapWithBlock ( origin = null ) <EOL> } <EOL> if ( right is IrBlock && right . origin == JvmLoweredStatementOrigin . FOLDED_SAFE_CALL && left . type . isJvmPrimitive ( ) ) { <EOL> val safeCallWhen = right . statements [ <NUM_LIT:0> ] as IrWhen <EOL> val safeCallResult = safeCallWhen . branches [ <NUM_LIT:0> ] . result <EOL> expression . putValueArgument ( <NUM_LIT:1> , safeCallResult ) <EOL> safeCallWhen . branches [ <NUM_LIT:0> ] . result = expression <EOL> safeCallWhen . branches [ <NUM_LIT:1> ] . result = irFalse ( startOffset , endOffset ) <EOL> safeCallWhen . type = expression . type <EOL> return safeCallWhen . wrapWithBlock ( origin = null ) <EOL> } <EOL> } <EOL> return expression <EOL> }


internal fun IrBlock . parseSafeCall ( irBuiltIns : IrBuiltIns ) : SafeCallInfo ?

{ <EOL> if ( this . statements . size != <NUM_LIT:2> ) return null <EOL> val tmpVal = this . statements [ <NUM_LIT:0> ] as? IrVariable ? : return null <EOL> val whenExpr = this . statements [ <NUM_LIT:1> ] as? IrWhen ? : return null <EOL> if ( whenExpr . branches . size != <NUM_LIT:2> ) return null <EOL> val ifNullBranch = whenExpr . branches [ <NUM_LIT:0> ] <EOL> val ifNullBranchCondition = ifNullBranch . condition <EOL> if ( ifNullBranchCondition !is IrCall ) return null <EOL> if ( ifNullBranchCondition . symbol != irBuiltIns . eqeqSymbol ) return null <EOL> val arg0 = ifNullBranchCondition . getValueArgument ( <NUM_LIT:0> ) <EOL> if ( arg0 !is IrGetValue || arg0 . symbol != tmpVal . symbol ) return null <EOL> val arg1 = ifNullBranchCondition . getValueArgument ( <NUM_LIT:1> ) <EOL> if ( arg1 !is IrConst < * > || arg1 . value != null ) return null <EOL> val ifNullBranchResult = ifNullBranch . result <EOL> if ( ifNullBranchResult !is IrConst < * > || ifNullBranchResult . value != null ) return null <EOL> val ifNotNullBranch = whenExpr . branches [ <NUM_LIT:1> ] <EOL> return SafeCallInfo ( this , tmpVal , ifNullBranch , ifNotNullBranch ) <EOL> }


internal fun IrBlock . parseElvis ( irBuiltIns : IrBuiltIns ) : ElvisInfo ?

{ <EOL> if ( this . statements . size != <NUM_LIT:2> ) return null <EOL> val tmpVal = this . statements [ <NUM_LIT:0> ] as? IrVariable ? : return null <EOL> val whenExpr = this . statements [ <NUM_LIT:1> ] as? IrWhen ? : return null <EOL> if ( whenExpr . branches . size != <NUM_LIT:2> ) return null <EOL> val elvisLhs = tmpVal . initializer ? : return null <EOL> val ifNullBranch = whenExpr . branches [ <NUM_LIT:0> ] <EOL> val ifNullBranchCondition = ifNullBranch . condition <EOL> if ( ifNullBranchCondition !is IrCall ) return null <EOL> if ( ifNullBranchCondition . symbol != irBuiltIns . eqeqSymbol ) return null <EOL> val arg0 = ifNullBranchCondition . getValueArgument ( <NUM_LIT:0> ) <EOL> if ( arg0 !is IrGetValue || arg0 . symbol != tmpVal . symbol ) return null <EOL> val arg1 = ifNullBranchCondition . getValueArgument ( <NUM_LIT:1> ) <EOL> if ( arg1 !is IrConst < * > || arg1 . value != null ) return null <EOL> val elvisRhs = ifNullBranch . result <EOL> val ifNonNullBranch = whenExpr . branches [ <NUM_LIT:1> ] <EOL> val ifNonNullBranchResult = ifNonNullBranch . result <EOL> if ( ifNonNullBranchResult !is IrGetValue || ifNonNullBranchResult . symbol != tmpVal . symbol ) return null <EOL> return ElvisInfo ( this , tmpVal , elvisLhs , elvisRhs ) <EOL> }


override fun resolveSymbolWithPrefix ( parts : List < FirQualifierPart > , prefix : ClassId ) : FirClassifierSymbol < * > ?

{ <EOL> val symbolProvider = session . symbolProvider <EOL> val fqName = ClassId ( prefix . packageFqName , parts . drop ( <NUM_LIT:1> ) . fold ( prefix . relativeClassName ) { result , suffix -> result . child ( suffix . name ) } , isLocal = false ) <EOL> return symbolProvider . getClassLikeSymbolByClassId ( fqName ) <EOL> }


override fun resolveSymbol ( parts : List < FirQualifierPart > ) : FirClassifierSymbol < * > ?

{ <EOL> if ( parts . firstOrNull ( ) ? . name ? . asString ( ) == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE ) { <EOL> return resolveSymbol ( parts . drop ( <NUM_LIT:1> ) ) <EOL> } <EOL> val firProvider = session . symbolProvider <EOL> if ( parts . isNotEmpty ( ) ) { <EOL> val lastPart = mutableListOf < FirQualifierPart > ( ) <EOL> val firstPart = parts . toMutableList ( ) <EOL> while ( firstPart . isNotEmpty ( ) ) { <EOL> lastPart . add ( <NUM_LIT:0> , firstPart . last ( ) ) <EOL> firstPart . removeAt ( firstPart . lastIndex ) <EOL> val fqName = ClassId ( firstPart . toFqName ( ) , lastPart . toFqName ( ) , isLocal = false ) <EOL> val foundSymbol = firProvider . getClassLikeSymbolByClassId ( fqName ) <EOL> if ( foundSymbol != null ) { <EOL> return foundSymbol <EOL> } <EOL> } <EOL> } <EOL> return null <EOL> }


private fun List < FirQualifierPart > . toFqName ( )

= fold ( FqName . ROOT ) { a , b -> a . child ( b . name ) }


{ <EOL> tempDir = createTempDirectory ( ClassPathTest :: class . simpleName ! ! ) <EOL> super . setUp ( ) <EOL> }


{ <EOL> super . tearDown ( ) <EOL> tempDir . toFile ( ) . deleteRecursively ( ) <EOL> }


{ <EOL> val collection = createTempFile ( directory = tempDir , "<STR_LIT>" , "<STR_LIT>" ) . apply { createCollectionJar ( emulatedCollectionFiles , "<STR_LIT>" ) } <EOL> val cl = URLClassLoader ( arrayOf ( collection . toUri ( ) . toURL ( ) ) , null ) <EOL> val cp = classpathFromClassloader ( cl , true ) <EOL> Assert . assertTrue ( cp != null && cp . isNotEmpty ( ) ) <EOL> testUnpackedCollection ( cp ! ! , emulatedCollectionFiles ) <EOL> }


@ Test <EOL> fun testDetectClasspathFromResources ( )

{ <EOL> val root1 = createTempDirectory ( directory = tempDir , "<STR_LIT>" ) <EOL> val jar = createTempFile ( directory = tempDir , "<STR_LIT>" , "<STR_LIT>" ) . apply { createJarWithManifest ( ) } <EOL> val cl = URLClassLoader ( ( emulatedClasspath . map { ( root1 / it ) . apply { createDirectories ( ) } . toUri ( ) . toURL ( ) } + jar . toUri ( ) . toURL ( ) ) . toTypedArray ( ) , null ) <EOL> val cp = cl . classPathFromTypicalResourceUrls ( ) . toList ( ) . map { it . canonicalFile } <EOL> Assert . assertTrue ( cp . contains ( jar . toFile ( ) . canonicalFile ) ) <EOL> for ( el in emulatedClasspath ) { <EOL> Assert . assertTrue ( cp . contains ( ( root1 / el ) . toFile ( ) . canonicalFile ) ) <EOL> } <EOL> }


@ Test <EOL> fun testFilterClasspath ( )

{ <EOL> val tempDir = createTempDirectory ( ) . toRealPath ( ) <EOL> try { <EOL> val files = listOf ( ( tempDir / "<STR_LIT>" ) , ( tempDir / "<STR_LIT>" ) , ( tempDir / "<STR_LIT>" ) ) <EOL> files . forEach { it . createDirectories ( ) } <EOL> val classloader = URLClassLoader ( files . map { it . toUri ( ) . toURL ( ) } . toTypedArray ( ) , null ) <EOL> val classpath = <EOL> scriptCompilationClasspathFromContextOrNull ( "<STR_LIT>" , classLoader = classloader ) ! ! . map { it . toPath ( ) . relativeTo ( tempDir ) } <EOL> Assert . assertEquals ( files . dropLast ( <NUM_LIT:1> ) . map { it . relativeTo ( tempDir ) } , classpath ) <EOL> } finally { <EOL> tempDir . toFile ( ) . deleteRecursively ( ) <EOL> } <EOL> }


@ Test <EOL> fun testClasspathFromClass ( )

{ <EOL> val cpFromThis = classpathFromClass ( this :: class ) <EOL> val expectedSuffix = File ( "<STR_LIT>" ) . path <EOL> assertTrue ( "<STR_LIT>" , cpFromThis ! ! . first ( ) . absoluteFile . path . endsWith ( expectedSuffix ) ) <EOL> }


fun Path . createCollectionJar ( fileNames : Array < String > , infDirName : String )

{ <EOL> this . outputStream ( ) . use { fileStream -> <EOL> val jarStream = JarOutputStream ( fileStream ) <EOL> jarStream . putNextEntry ( JarEntry ( "<STR_LIT>" ) ) <EOL> jarStream . putNextEntry ( JarEntry ( "<STR_LIT>" ) ) <EOL> for ( name in fileNames ) { <EOL> jarStream . putNextEntry ( JarEntry ( "<STR_LIT>" ) ) <EOL> jarStream . write ( name . toByteArray ( ) ) <EOL> } <EOL> jarStream . finish ( ) <EOL> } <EOL> }


fun testUnpackedCollection ( classpath : List < File > , fileNames : Array < String > )

{ <EOL> fun List < String > . checkFiles ( root : File ) = forEach { <EOL> val file = File ( root , it ) <EOL> Assert . assertTrue ( file . exists ( ) ) <EOL> Assert . assertEquals ( it , file . readText ( ) ) <EOL> } <EOL> val ( classes , jars ) = fileNames . partition { it . startsWith ( "<STR_LIT>" ) } <EOL> val ( cpClasses , cpJars ) = classpath . partition { it . isDirectory && it . name == "<STR_LIT>" } <EOL> Assert . assertTrue ( cpClasses . size == <NUM_LIT:1> ) <EOL> classes . checkFiles ( cpClasses . first ( ) . parentFile ) <EOL> jars . checkFiles ( cpJars . first ( ) . parentFile . parentFile ) <EOL> }


{ <EOL> this . outputStream ( ) . use { fileStream -> <EOL> val jarStream = JarOutputStream ( fileStream , Manifest ( ) ) <EOL> jarStream . finish ( ) <EOL> } <EOL> }


abstract fun getExportChecker ( compatibleMode : Boolean ) : KotlinExportChecker < D >


abstract fun getMangleComputer ( mode : MangleMode , compatibleMode : Boolean ) : KotlinMangleComputer < D >


inline fun < T > mrun ( block : ( ) -> T )

= block ( )


{ <EOL> val callable = mrun { <EOL> fun localAnonymousFun ( k : String ) : String { <EOL> val obj = object { <EOL> fun foo ( ) = o + k <EOL> } <EOL> return obj . foo ( ) <EOL> } <EOL> :: localAnonymousFun <EOL> } <EOL> return callable ( "<STR_LIT:K>" ) <EOL> }


= bar ( "<STR_LIT:O>" )


= <NUM_LIT:5>


= It ( )


= if ( hasNext ) { hasNext = false ; true } else false


{ <EOL> for ( i in C ( ) ) { <EOL> foo ( i ) <EOL> } <EOL> }


{ <EOL> X ( ) . test ( ) <EOL> return "<STR_LIT:OK>" <EOL> }


public fun encodeJsonElement ( element : JsonElement )

/**
 * Appends the given JSON [element] to the current output.
 * This method is allowed to invoke only as the part of the whole serialization process of the class,
 * calling this method after invoking [beginStructure] or any `encode*` method will lead to unspecified behaviour
 * and may produce an invalid JSON result.
 * For example:
 * ```
 * class Holder(val value: Int, val list: List<Int>())
 *
 * // Holder serialize method
 * fun serialize(encoder: Encoder, value: Holder) {
 * // Completely okay, the whole Holder object is read
 * val jsonObject = JsonObject(...) // build a JsonObject from Holder
 * (encoder as JsonEncoder).encodeJsonElement(jsonObject) // Write it
 * }
 *
 * // Incorrect Holder serialize method
 * fun serialize(encoder: Encoder, value: Holder) {
 * val composite = encoder.beginStructure(descriptor)
 * composite.encodeSerializableElement(descriptor, 0, Int.serializer(), value.value)
 * val array = JsonArray(value.list)
 * // Incorrect, encoder is already in an intermediate state after encodeSerializableElement
 * (composite as JsonEncoder).encodeJsonElement(array)
 * composite.endStructure(descriptor)
 * // ...
 * }
 * ```
 */


fun mentionedTypes ( ) : List < TypeRef >

= <EOL> if ( typeArguments . isEmpty ( ) ) listOf ( this ) else typeArguments . flatMap { it . type . mentionedTypes ( ) }


fun mentionedTypeRefs ( ) : List < TypeRef >

= constraint ? . mentionedTypes ( ) . orEmpty ( )


fun parseTypeParameter ( typeString : String ) : TypeParameter

= <EOL> removeAnnotations ( typeString . trim ( ) . removePrefix ( "<STR_LIT>" ) ) . let { trimmed -> <EOL> if ( '<CHAR_LIT::>' in trimmed ) { <EOL> val ( name , constraint ) = trimmed . split ( '<CHAR_LIT::>' ) <EOL> TypeParameter ( typeString , name . trim ( ) , parseTypeRef ( removeAnnotations ( constraint . trim ( ) ) ) ) <EOL> } else { <EOL> TypeParameter ( typeString , trimmed ) <EOL> } <EOL> }


fun parseTypeRef ( typeRef : String ) : TypeRef

= <EOL> typeRef . trim ( ) . run { <EOL> if ( contains ( '<CHAR_LIT>' ) && ( endsWith ( '<CHAR_LIT>' ) || endsWith ( "<STR_LIT>" ) ) ) { <EOL> val name = substringBefore ( '<CHAR_LIT>' ) + if ( endsWith ( "<STR_LIT>" ) ) "<STR_LIT:?>" else "<STR_LIT>" <EOL> val params = substringAfter ( '<CHAR_LIT>' ) . substringBeforeLast ( '<CHAR_LIT>' ) <EOL> TypeRef ( name , parseArguments ( params ) ) <EOL> } <EOL> else <EOL> TypeRef ( this ) <EOL> }


private fun parseTypeArgument ( typeParam : String ) : TypeArgument <EOL>

= typeParam . trim ( ) . removePrefix ( "<STR_LIT>" ) . removePrefix ( "<STR_LIT>" ) . let { TypeArgument ( parseTypeRef ( it ) ) }


private fun parseArguments ( typeParams : String ) : List < TypeArgument >

{ <EOL> var restParams : String = typeParams <EOL> val params = mutableListOf < TypeArgument > ( ) <EOL> while ( true ) { <EOL> val comma = restParams . indexOf ( '<CHAR_LIT:U+002C>' ) <EOL> if ( comma < <NUM_LIT:0> ) { <EOL> params += parseTypeArgument ( restParams ) <EOL> break <EOL> } else { <EOL> val open = restParams . indexOf ( '<CHAR_LIT>' ) <EOL> val close = restParams . indexOf ( '<CHAR_LIT>' ) <EOL> if ( comma !in open .. close ) { <EOL> params += parseTypeArgument ( restParams . take ( comma ) ) <EOL> restParams = restParams . drop ( comma + <NUM_LIT:1> ) <EOL> } <EOL> else { <EOL> params += parseTypeArgument ( restParams . take ( close + <NUM_LIT:1> ) ) <EOL> val nextComma = restParams . indexOf ( '<CHAR_LIT:U+002C>' , startIndex = close ) <EOL> if ( nextComma < <NUM_LIT:0> ) break <EOL> restParams = restParams . drop ( nextComma + <NUM_LIT:1> ) <EOL> } <EOL> } <EOL> } <EOL> return params <EOL> }


private fun removeAnnotations ( typeParam : String )

= <EOL> typeParam . replace ( """<STR_LIT>""" . toRegex ( ) , "<STR_LIT>" )


= "<STR_LIT:OK>"


tailrec fun foo ( i : Int = <NUM_LIT:1> , c : Char = '<CHAR_LIT:2>' , s : String = "<STR_LIT>" , b : Boolean = true , d : Double = <NUM_LIT:1.0> , l : Long = <NUM_LIT:1L> , y : String = withEffects ( ) )

{ <EOL> foo ( i , c , s , b , d , l , y ) <EOL> }


tailrec fun foo2 ( x : Int = <NUM_LIT:1> , y : String = withEffects ( ) , z : String = Z )

{ <EOL> foo2 ( x , y , z ) <EOL> }


tailrec fun foo3 ( y : String = withEffects ( ) )

{ <EOL> foo3 ( y ) <EOL> }


tailrec fun foo4 ( x : String = withEffects ( ) , y : String = withEffects ( ) )

{ <EOL> foo4 ( x , y ) <EOL> }


tailrec fun foo5 ( x : String = withEffects ( ) , y : String = withEffects ( ) , z : String = withEffects ( ) )

{ <EOL> foo5 ( x , y , z ) <EOL> }


tailrec fun foo6 ( x : String = withEffects ( ) , y : EnumA = EnumA . A )

{ <EOL> foo6 ( x , y ) <EOL> }


tailrec fun foo7 ( x : String = withEffects ( ) , y : KClass < out EnumA > = EnumA . A :: class )

{ <EOL> foo7 ( x , y ) <EOL> }


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

{ <EOL> val variableResolvedCall = ( resolvedCall as? VariableAsFunctionResolvedCall ) ? . variableCall ? : resolvedCall <EOL> val variableDescriptor = variableResolvedCall . resultingDescriptor as? VariableDescriptor <EOL> if ( variableDescriptor != null ) { <EOL> checkCapturingInClosure ( variableDescriptor , context . trace , context . scope ) <EOL> checkFieldInExactlyOnceLambdaInitialization ( variableDescriptor , context . trace , context . scope . ownerDescriptor , reportOn ) <EOL> } <EOL> }


private fun checkCapturingInClosure ( variable : VariableDescriptor , trace : BindingTrace , scope : LexicalScope )

{ <EOL> val variableParent = variable . containingDeclaration <EOL> val scopeContainer = scope . ownerDescriptor <EOL> if ( isCapturedVariable ( variableParent , scopeContainer ) ) { <EOL> if ( trace . get ( CAPTURED_IN_CLOSURE , variable ) != CaptureKind . NOT_INLINE ) { <EOL> trace . record ( CAPTURED_IN_CLOSURE , variable , getCaptureKind ( trace . bindingContext , scopeContainer , variableParent , variable ) ) <EOL> return <EOL> } <EOL> } <EOL> }


private fun checkFieldInExactlyOnceLambdaInitialization ( variable : VariableDescriptor , trace : BindingTrace , scopeContainer : DeclarationDescriptor , nameElement : PsiElement )

{ <EOL> if ( variable !is PropertyDescriptor || scopeContainer !is AnonymousFunctionDescriptor || variable . isVar ) return <EOL> if ( ! isLhsOfAssignment ( nameElement as KtExpression ) ) return <EOL> val scopeDeclaration = DescriptorToSourceUtils . descriptorToDeclaration ( scopeContainer ) as? KtFunction ? : return <EOL> if ( scopeContainer . containingDeclaration !is ConstructorDescriptor && scopeContainer . containingDeclaration !is PropertyDescriptor ) return <EOL> if ( ! isExactlyOnceContract ( trace . bindingContext , scopeDeclaration ) ) return <EOL> if ( trace . bindingContext [ CAPTURED_IN_CLOSURE , variable ] == CaptureKind . NOT_INLINE ) return <EOL> val ( callee , param ) = getCalleeDescriptorAndParameter ( trace . bindingContext , scopeDeclaration ) ? : return <EOL> if ( callee !is FunctionDescriptor ) return <EOL> if ( ! callee . isInline || ( param . isCrossinline || ! InlineUtil . isInlineParameter ( param ) ) ) { <EOL> trace . report ( CAPTURED_VAL_INITIALIZATION . on ( nameElement , variable ) ) <EOL> } <EOL> }


private fun isLhsOfAssignment ( nameElement : KtExpression ) : Boolean

{ <EOL> val parent = nameElement . parent as? KtBinaryExpression ? : return false <EOL> return parent . operationToken == KtTokens . EQ && parent . left == nameElement <EOL> }


private fun isCapturedVariable ( variableParent : DeclarationDescriptor , scopeContainer : DeclarationDescriptor ) : Boolean

{ <EOL> if ( variableParent !is FunctionDescriptor || scopeContainer == variableParent ) return false <EOL> if ( variableParent is ConstructorDescriptor ) { <EOL> val classDescriptor = variableParent . containingDeclaration <EOL> if ( scopeContainer == classDescriptor ) return false <EOL> if ( scopeContainer is PropertyDescriptor && scopeContainer . containingDeclaration == classDescriptor ) return false <EOL> } <EOL> return true <EOL> }


private fun getCaptureKind ( context : BindingContext , scopeContainer : DeclarationDescriptor , variableParent : DeclarationDescriptor , variable : VariableDescriptor ) : CaptureKind

{ <EOL> val scopeDeclaration = DescriptorToSourceUtils . descriptorToDeclaration ( scopeContainer ) <EOL> if ( ! InlineUtil . canBeInlineArgument ( scopeDeclaration ) ) return CaptureKind . NOT_INLINE <EOL> if ( InlineUtil . isInlinedArgument ( scopeDeclaration as KtFunction , context , false ) && ! isCrossinlineParameter ( context , scopeDeclaration ) ) { <EOL> val scopeContainerParent = scopeContainer . containingDeclaration ? : error ( "<STR_LIT>" ) <EOL> return if ( ! isCapturedVariable ( variableParent , scopeContainerParent ) || getCaptureKind ( context , scopeContainerParent , variableParent , variable ) == CaptureKind . INLINE_ONLY ) CaptureKind . INLINE_ONLY else CaptureKind . NOT_INLINE <EOL> } <EOL> val exactlyOnceContract = isExactlyOnceContract ( context , scopeDeclaration ) <EOL> if ( ! exactlyOnceContract ) return CaptureKind . NOT_INLINE <EOL> return if ( isArgument ( variable , variableParent ) || findDestructuredVariable ( variable , variableParent ) != null || isForLoopParameter ( variable ) || isCatchBlockParameter ( variable ) || isValInWhen ( variable ) ) { <EOL> CaptureKind . NOT_INLINE <EOL> } else { <EOL> CaptureKind . EXACTLY_ONCE_EFFECT <EOL> } <EOL> }


private fun isArgument ( variable : VariableDescriptor , variableParent : DeclarationDescriptor ) : Boolean

= <EOL> variable is ValueParameterDescriptor && variableParent is CallableDescriptor <EOL> && variableParent . valueParameters . contains ( variable )


private fun isValInWhen ( variable : VariableDescriptor ) : Boolean

{ <EOL> val psi = ( ( variable as? LocalVariableDescriptor ) ? . source as? KotlinSourceElement ) ? . psi ? : return false <EOL> return ( psi . parent as? KtWhenExpression ) ? . let { it . subjectVariable == psi } == true <EOL> }


private fun isCatchBlockParameter ( variable : VariableDescriptor ) : Boolean

{ <EOL> val psi = ( ( variable as? LocalVariableDescriptor ) ? . source as? KotlinSourceElement ) ? . psi ? : return false <EOL> return psi . parent . parent . let { it is KtCatchClause && it . parameterList ? . parameters ? . contains ( psi ) == true } <EOL> }


private fun isForLoopParameter ( variable : VariableDescriptor ) : Boolean

{ <EOL> val psi = ( ( variable as? LocalVariableDescriptor ) ? . source as? KotlinSourceElement ) ? . psi ? : return false <EOL> if ( psi . parent is KtForExpression ) { <EOL> val forExpression = psi . parent as KtForExpression <EOL> return forExpression . loopParameter == psi <EOL> } else if ( psi . parent is KtDestructuringDeclaration ) { <EOL> val parameter = psi . parent . parent as? KtParameter ? : return false <EOL> val forExpression = parameter . parent as? KtForExpression ? : return false <EOL> return forExpression . loopParameter == parameter <EOL> } <EOL> return false <EOL> }


private fun isExactlyOnceParameter ( function : DeclarationDescriptor , parameter : VariableDescriptor ) : Boolean

{ <EOL> if ( function !is CallableDescriptor ) return false <EOL> if ( parameter !is ValueParameterDescriptor ) return false <EOL> val contractDescription = function . getUserData ( ContractProviderKey ) ? . getContractDescription ( ) ? : return false <EOL> val effect = contractDescription . effects . filterIsInstance < CallsEffectDeclaration > ( ) <EOL> . find { it . variableReference . descriptor == parameter . original } ? : return false <EOL> return effect . kind == EventOccurrencesRange . EXACTLY_ONCE <EOL> }


private fun isExactlyOnceContract ( bindingContext : BindingContext , argument : KtFunction ) : Boolean

{ <EOL> val ( descriptor , parameter ) = getCalleeDescriptorAndParameter ( bindingContext , argument ) ? : return false <EOL> return isExactlyOnceParameter ( descriptor , parameter ) <EOL> }


private fun getCalleeDescriptorAndParameter ( bindingContext : BindingContext , argument : KtFunction ) : Pair < CallableDescriptor , ValueParameterDescriptor > ?

{ <EOL> val call = KtPsiUtil . getParentCallIfPresent ( argument ) ? : return null <EOL> val resolvedCall = call . getResolvedCall ( bindingContext ) ? : return null <EOL> val descriptor = resolvedCall . resultingDescriptor <EOL> val valueArgument = resolvedCall . call . getValueArgumentForExpression ( argument ) ? : return null <EOL> val mapping = resolvedCall . getArgumentMapping ( valueArgument ) as? ArgumentMatch ? : return null <EOL> val parameter = mapping . valueParameter <EOL> return descriptor to parameter <EOL> }


private fun isCrossinlineParameter ( bindingContext : BindingContext , argument : KtFunction ) : Boolean

{ <EOL> return getCalleeDescriptorAndParameter ( bindingContext , argument ) ? . second ? . isCrossinline == true <EOL> }


fun findDestructuredVariable ( variable : VariableDescriptor , variableParent : DeclarationDescriptor ) : ValueParameterDescriptor ?

= <EOL> if ( variable is LocalVariableDescriptor && variableParent is AnonymousFunctionDescriptor ) { <EOL> variableParent . valueParameters . find { <EOL> it is ValueParameterDescriptorImpl . WithDestructuringDeclaration && it . destructuringVariables . contains ( variable ) <EOL> } <EOL> } else null


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

{ <EOL> declaration . packageDirective . source ? . forEachChildOfType ( setOf ( REFERENCE_EXPRESSION ) ) { <EOL> checkNameAndReport ( Name . identifier ( it . text . toString ( ) ) , it , context , reporter ) <EOL> } <EOL> }


@ Test <EOL> @ TodoAnalysisApi <EOL> fun `test - stringBuilder` ( )

{ <EOL> doTest ( dependenciesDir . resolve ( "<STR_LIT>" ) ) <EOL> }

/**
 * - Missing implementation of mangling
 */


@ Test <EOL> fun `test - implementIterator` ( )


@ Test <EOL> fun `test - notExportedDependency` ( )

{ <EOL> doTest ( dependenciesDir . resolve ( "<STR_LIT>" ) , configuration = HeaderGenerator . Configuration ( frameworkName = "<STR_LIT>" , withObjCBaseDeclarationStubs = true , dependencies = listOf ( testLibraryAKlibFile , testLibraryBKlibFile ) , ) ) <EOL> }


@ Test <EOL> fun `test - exportedAndNotExportedDependency` ( )

{ <EOL> doTest ( dependenciesDir . resolve ( "<STR_LIT>" ) , configuration = HeaderGenerator . Configuration ( frameworkName = "<STR_LIT>" , withObjCBaseDeclarationStubs = true , dependencies = listOf ( testLibraryAKlibFile , testLibraryBKlibFile ) , exportedDependencies = setOf ( testLibraryAKlibFile ) ) ) <EOL> }

/**
 * https://youtrack.jetbrains.com/issue/KT-65327/Support-reading-klib-contents-in-Analysis-API
 * Requires being able to use AA to iterate over symbols to 'export' the dependency
 */


private fun doTest ( root : File , configuration : HeaderGenerator . Configuration = HeaderGenerator . Configuration ( ) )

{ <EOL> if ( ! root . isDirectory ) fail ( "<STR_LIT>" ) <EOL> val generatedHeaders = generator . generateHeaders ( root , configuration ) . toString ( ) <EOL> KotlinTestUtils . assertEqualsToFile ( root . resolve ( "<STR_LIT>" ) , generatedHeaders ) <EOL> }


override fun < R , D > acceptChildren ( visitor : FirVisitor < R , D > , data : D )


override fun < D > transformChildren ( transformer : FirTransformer < D > , data : D ) : FirPlaceholderProjectionImpl

{ <EOL> return this <EOL> }


{ <EOL> if ( s != null ) { <EOL> s . length <EOL> var i = s . length <EOL> System . out . println ( s . length ) <EOL> } <EOL> }


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> fun getFrame ( insn : AbstractInsnNode ) : F ?

= frames [ insn . indexOf ( ) ] as? F


fun analyze ( ) : Array < Frame < V > ? >

{ <EOL> if ( nInsns == <NUM_LIT:0> ) return frames <EOL> checkAssertions ( ) <EOL> computeExceptionHandlers ( method ) <EOL> for ( tcb in method . tryCatchBlocks ) { <EOL> isTcbStart [ tcb . start . indexOf ( ) + <NUM_LIT:1> ] = true <EOL> } <EOL> beforeAnalyze ( ) <EOL> analyzeMainLoop ( ) <EOL> return frames <EOL> }


{ <EOL> val current = newFrame ( method . maxLocals , method . maxStack ) <EOL> val handler = newFrame ( method . maxLocals , method . maxStack ) <EOL> initLocals ( current ) <EOL> mergeControlFlowEdge ( <NUM_LIT:0> , current ) <EOL> while ( top > <NUM_LIT:0> ) { <EOL> val insn = queue [ -- top ] <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> val f = frames [ insn ] as F <EOL> queued [ insn ] = false <EOL> val insnNode = method . instructions [ insn ] <EOL> try { <EOL> analyzeInstruction ( insnNode , insn , f , current , handler ) <EOL> } catch ( e : AnalyzerException ) { <EOL> throw AnalyzerException ( e . node , "<STR_LIT>" , e ) <EOL> } catch ( e : Exception ) { <EOL> throw AnalyzerException ( insnNode , "<STR_LIT>" , e ) <EOL> } <EOL> } <EOL> }


private fun analyzeInstruction ( insnNode : AbstractInsnNode , insnIndex : Int , currentlyAnalyzing : F , current : F , handler : F )

{ <EOL> val insnOpcode = insnNode . opcode <EOL> val insnType = insnNode . nodeType <EOL> if ( insnType == AbstractInsnNode . LABEL || insnType == AbstractInsnNode . LINE || insnType == AbstractInsnNode . FRAME || insnOpcode == Opcodes . NOP ) { <EOL> visitNopInsn ( insnNode , currentlyAnalyzing , insnIndex ) <EOL> } else { <EOL> current . init ( currentlyAnalyzing ) <EOL> if ( insnOpcode != Opcodes . RETURN ) { <EOL> current . execute ( insnNode , interpreter ) <EOL> } <EOL> visitMeaningfulInstruction ( insnNode , insnType , insnOpcode , current , insnIndex ) <EOL> } <EOL> if ( ! pruneExceptionEdges || insnOpcode in Opcodes . ISTORE .. Opcodes . ASTORE || insnOpcode == Opcodes . IINC || isTcbStart [ insnIndex ] ) { <EOL> handlers [ insnIndex ] ? . forEach { tcb -> <EOL> val exnType = Type . getObjectType ( tcb . type ? : "<STR_LIT>" ) <EOL> val jump = tcb . handler . indexOf ( ) <EOL> handler . init ( currentlyAnalyzing ) <EOL> if ( handler . maxStackSize > <NUM_LIT:0> ) { <EOL> handler . clearStack ( ) <EOL> handler . push ( interpreter . newExceptionValue ( tcb , handler , exnType ) ) <EOL> } <EOL> mergeControlFlowEdge ( jump , handler ) <EOL> } <EOL> } <EOL> }


{ <EOL> if ( method . instructions . any { it . opcode == Opcodes . JSR || it . opcode == Opcodes . RET } ) <EOL> throw AssertionError ( "<STR_LIT>" ) <EOL> }


private fun computeExceptionHandlers ( m : MethodNode )

{ <EOL> for ( tcb in m . tryCatchBlocks ) { <EOL> if ( useFastComputeExceptionHandlers ) computeExceptionHandlerFast ( tcb ) else computeExceptionHandlersForEachInsn ( tcb ) <EOL> } <EOL> }


private fun computeExceptionHandlersForEachInsn ( tcb : TryCatchBlockNode )

{ <EOL> var current : AbstractInsnNode = tcb . start <EOL> val end = tcb . end <EOL> while ( current != end ) { <EOL> if ( current . isMeaningful ) { <EOL> val currentIndex = current . indexOf ( ) <EOL> var insnHandlers : MutableList < TryCatchBlockNode > ? = handlers [ currentIndex ] <EOL> if ( insnHandlers == null ) { <EOL> insnHandlers = SmartList ( ) <EOL> handlers [ currentIndex ] = insnHandlers <EOL> } <EOL> insnHandlers . add ( tcb ) <EOL> } <EOL> current = current . next <EOL> } <EOL> }


private fun computeExceptionHandlerFast ( tcb : TryCatchBlockNode )

{ <EOL> val start = tcb . start . indexOf ( ) <EOL> var insnHandlers : MutableList < TryCatchBlockNode > ? = handlers [ start ] <EOL> if ( insnHandlers == null ) { <EOL> insnHandlers = ArrayList ( ) <EOL> handlers [ start ] = insnHandlers <EOL> } <EOL> insnHandlers . add ( tcb ) <EOL> }


{ <EOL> current . setReturn ( interpreter . newReturnTypeValue ( Type . getReturnType ( method . desc ) ) ) <EOL> val args = Type . getArgumentTypes ( method . desc ) <EOL> var local = <NUM_LIT:0> <EOL> val isInstanceMethod = ( method . access and Opcodes . ACC_STATIC ) == <NUM_LIT:0> <EOL> if ( isInstanceMethod ) { <EOL> val ctype = Type . getObjectType ( owner ) <EOL> current . setLocal ( local , interpreter . newParameterValue ( true , local , ctype ) ) <EOL> local ++ <EOL> } <EOL> for ( arg in args ) { <EOL> current . setLocal ( local , interpreter . newParameterValue ( isInstanceMethod , local , arg ) ) <EOL> local ++ <EOL> if ( arg . size == <NUM_LIT:2> ) { <EOL> current . setLocal ( local , interpreter . newEmptyValue ( local ) ) <EOL> local ++ <EOL> } <EOL> } <EOL> while ( local < method . maxLocals ) { <EOL> current . setLocal ( local , interpreter . newEmptyValue ( local ) ) <EOL> local ++ <EOL> } <EOL> }


protected open fun visitControlFlowEdge ( insnNode : AbstractInsnNode , successor : Int ) : Boolean

= true


private fun processControlFlowEdge ( current : F , insnNode : AbstractInsnNode , jump : Int , canReuse : Boolean = false )

{ <EOL> if ( visitControlFlowEdge ( insnNode , jump ) ) { <EOL> mergeControlFlowEdge ( jump , current , canReuse ) <EOL> } <EOL> }


private fun mergeControlFlowEdge ( dest : Int , frame : F , canReuse : Boolean = false )

{ <EOL> if ( useFastMergeControlFlowEdge ) { <EOL> fastMergeControlFlowEdge ( dest , frame , canReuse ) <EOL> } else { <EOL> fullMergeControlFlowEdge ( dest , frame , canReuse ) <EOL> } <EOL> }


private fun fullMergeControlFlowEdge ( dest : Int , frame : F , canReuse : Boolean = false )

{ <EOL> val oldFrame = frames [ dest ] <EOL> val changes = when { <EOL> canReuse && ! isMergeNode [ dest ] -> { <EOL> frames [ dest ] = frame <EOL> true <EOL> } <EOL> oldFrame == null -> { <EOL> frames [ dest ] = newFrame ( frame . locals , frame . maxStackSize ) . apply { init ( frame ) } <EOL> true <EOL> } <EOL> ! isMergeNode [ dest ] -> { <EOL> oldFrame . init ( frame ) <EOL> true <EOL> } <EOL> else -> try { <EOL> oldFrame . merge ( frame , interpreter ) <EOL> } catch ( e : AnalyzerException ) { <EOL> throw AnalyzerException ( null , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> updateQueue ( changes , dest ) <EOL> }

/**
 * Updates frame at the index [dest] with its old value if provided and previous control flow node frame [frame].
 * Reuses old frame when possible and when [canReuse] is true.
 * If updated, adds the frame to the queue
 */


private fun fastMergeControlFlowEdge ( dest : Int , frame : F , canReuse : Boolean )

{ <EOL> val oldFrame = frames [ dest ] <EOL> val changes = when { <EOL> oldFrame == null -> { <EOL> frames [ dest ] = if ( canReuse && ! isMergeNode [ dest ] ) { <EOL> frame <EOL> } else { <EOL> newFrame ( frame . locals , frame . maxStackSize ) . apply { init ( frame ) } <EOL> } <EOL> true <EOL> } <EOL> else -> false <EOL> } <EOL> updateQueue ( changes , dest ) <EOL> }


private fun updateQueue ( changes : Boolean , dest : Int )

{ <EOL> if ( changes && ! queued [ dest ] ) { <EOL> queued [ dest ] = true <EOL> queue [ top ++ ] = dest <EOL> } <EOL> }


private fun visitMeaningfulInstruction ( insnNode : AbstractInsnNode , insnType : Int , insnOpcode : Int , current : F , insn : Int )

{ <EOL> when { <EOL> insnType == AbstractInsnNode . JUMP_INSN -> <EOL> visitJumpInsnNode ( insnNode as JumpInsnNode , current , insn , insnOpcode ) <EOL> insnType == AbstractInsnNode . LOOKUPSWITCH_INSN -> <EOL> visitLookupSwitchInsnNode ( insnNode as LookupSwitchInsnNode , current ) <EOL> insnType == AbstractInsnNode . TABLESWITCH_INSN -> <EOL> visitTableSwitchInsnNode ( insnNode as TableSwitchInsnNode , current ) <EOL> insnOpcode != Opcodes . ATHROW && ( insnOpcode < Opcodes . IRETURN || insnOpcode > Opcodes . RETURN ) -> <EOL> visitOpInsn ( insnNode , current , insn ) <EOL> else -> { <EOL> } <EOL> } <EOL> }


private fun visitNopInsn ( insnNode : AbstractInsnNode , current : F , insn : Int )

{ <EOL> processControlFlowEdge ( current , insnNode , insn + <NUM_LIT:1> , canReuse = true ) <EOL> }


private fun visitOpInsn ( insnNode : AbstractInsnNode , current : F , insn : Int )

{ <EOL> processControlFlowEdge ( current , insnNode , insn + <NUM_LIT:1> ) <EOL> }


private fun visitTableSwitchInsnNode ( insnNode : TableSwitchInsnNode , current : F )

{ <EOL> processControlFlowEdge ( current , insnNode , insnNode . dflt . indexOf ( ) ) <EOL> for ( label in insnNode . labels . asReversed ( ) ) { <EOL> processControlFlowEdge ( current , insnNode , label . indexOf ( ) ) <EOL> } <EOL> }


private fun visitLookupSwitchInsnNode ( insnNode : LookupSwitchInsnNode , current : F )

{ <EOL> processControlFlowEdge ( current , insnNode , insnNode . dflt . indexOf ( ) ) <EOL> for ( label in insnNode . labels ) { <EOL> processControlFlowEdge ( current , insnNode , label . indexOf ( ) ) <EOL> } <EOL> }


private fun visitJumpInsnNode ( insnNode : JumpInsnNode , current : F , insn : Int , insnOpcode : Int )

{ <EOL> if ( insnOpcode != Opcodes . GOTO ) { <EOL> processControlFlowEdge ( current , insnNode , insn + <NUM_LIT:1> ) <EOL> } <EOL> processControlFlowEdge ( current , insnNode , insnNode . label . indexOf ( ) ) <EOL> }


protected fun AbstractInsnNode . indexOf ( )

= <EOL> method . instructions . indexOf ( this )


private fun Frame < V > . dump ( ) : String

{ <EOL> return buildString { <EOL> append ( "<STR_LIT>" ) <EOL> append ( "<STR_LIT>" ) <EOL> for ( i in <NUM_LIT:0> until method . maxLocals ) { <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> val stackSize = this@dump . stackSize <EOL> append ( "<STR_LIT>" ) <EOL> append ( stackSize ) <EOL> if ( stackSize == <NUM_LIT:0> ) { <EOL> append ( "<STR_LIT>" ) <EOL> } else { <EOL> append ( "<STR_LIT>" ) <EOL> for ( i in <NUM_LIT:0> until stackSize ) { <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> }


fun findMergeNodes ( method : MethodNode ) : BooleanArray

{ <EOL> val isMergeNode = BooleanArray ( method . instructions . size ( ) ) <EOL> for ( insn in method . instructions ) { <EOL> when ( insn . nodeType ) { <EOL> AbstractInsnNode . JUMP_INSN -> { <EOL> val jumpInsn = insn as JumpInsnNode <EOL> isMergeNode [ method . instructions . indexOf ( jumpInsn . label ) ] = true <EOL> } <EOL> AbstractInsnNode . LOOKUPSWITCH_INSN -> { <EOL> val switchInsn = insn as LookupSwitchInsnNode <EOL> isMergeNode [ method . instructions . indexOf ( switchInsn . dflt ) ] = true <EOL> for ( label in switchInsn . labels ) { <EOL> isMergeNode [ method . instructions . indexOf ( label ) ] = true <EOL> } <EOL> } <EOL> AbstractInsnNode . TABLESWITCH_INSN -> { <EOL> val switchInsn = insn as TableSwitchInsnNode <EOL> isMergeNode [ method . instructions . indexOf ( switchInsn . dflt ) ] = true <EOL> for ( label in switchInsn . labels ) { <EOL> isMergeNode [ method . instructions . indexOf ( label ) ] = true <EOL> } <EOL> } <EOL> } <EOL> } <EOL> for ( tcb in method . tryCatchBlocks ) { <EOL> isMergeNode [ method . instructions . indexOf ( tcb . handler ) ] = true <EOL> } <EOL> return isMergeNode <EOL> }


fun type ( call : Call ? ) : KotlinType ?


operator fun plus ( smartCast : SingleSmartCast ) : ExplicitSmartCasts


= if ( call == this . call ) type else null


override fun plus ( smartCast : SingleSmartCast )

= <EOL> if ( this == smartCast ) this <EOL> else MultipleSmartCasts ( mapOf ( call to type , smartCast . call to smartCast . type ) )


= map [ call ]


= MultipleSmartCasts ( map + mapOf ( smartCast . call to smartCast . type ) )


override fun apply ( project : Project )

{ <EOL> val properties = KotlinTaskProperties ( providerFactory ) <EOL> project . configureKotlinVersions ( properties ) <EOL> }


private fun Project . configureKotlinVersions ( properties : KotlinTaskProperties )

{ <EOL> plugins . withType < KotlinBasePlugin > ( ) . configureEach { <EOL> configureExtension ( properties ) <EOL> if ( properties . kotlinOverrideUserValues . get ( ) ) { <EOL> forceConfigureTask ( properties ) <EOL> } else { <EOL> configureTask ( properties ) <EOL> } <EOL> } <EOL> }


private fun Project . configureExtension ( properties : KotlinTaskProperties )

{ <EOL> extensions . projectCompilerOptions ( ) ? . let { <EOL> configureKotlinOptions ( properties , it , ignoreExtensionValue = true ) <EOL> } <EOL> }


private fun Project . configureTask ( properties : KotlinTaskProperties )

{ <EOL> tasks . withType < KotlinCompilationTask < * > > ( ) . configureEach { <EOL> configureKotlinOptions ( properties , it . compilerOptions ) <EOL> } <EOL> }


private fun Project . forceConfigureTask ( properties : KotlinTaskProperties )

{ <EOL> afterEvaluate { <EOL> tasks . withType < KotlinCompilationTask < * > > ( ) . configureEach { <EOL> configureKotlinOptions ( properties , it . compilerOptions , true ) <EOL> } <EOL> } <EOL> }


@ OptIn ( ExperimentalKotlinGradlePluginApi :: class ) <EOL> private fun ExtensionContainer . projectCompilerOptions ( ) : KotlinCommonCompilerOptions ?

{ <EOL> val kotlinExtension = findByName ( "<STR_LIT:kotlin>" ) ? : return null <EOL> return when ( kotlinExtension ) { <EOL> is KotlinJvmProjectExtension -> kotlinExtension . compilerOptions <EOL> is KotlinAndroidProjectExtension -> kotlinExtension . compilerOptions <EOL> is KotlinMultiplatformExtension -> kotlinExtension . compilerOptions <EOL> else -> null <EOL> } <EOL> }


private fun Project . projectLevelLanguageVersion ( ) : Provider < KotlinVersion >

{ <EOL> return extensions . projectCompilerOptions ( ) ? . languageVersion ? : providers . provider { null } <EOL> }


private fun Project . projectLevelApiVersion ( ) : Provider < KotlinVersion >

{ <EOL> return extensions . projectCompilerOptions ( ) ? . apiVersion ? : providers . provider { null } <EOL> }


private fun Project . configureKotlinOptions ( properties : KotlinTaskProperties , taskOptions : KotlinCommonCompilerOptions , shouldSetValue : Boolean = false , ignoreExtensionValue : Boolean = false , )

{ <EOL> taskOptions . languageVersion . configureValue ( properties . kotlinLanguageVersion . run { <EOL> if ( ! ignoreExtensionValue ) orElse ( projectLevelLanguageVersion ( ) ) else this <EOL> } , shouldSetValue ) <EOL> taskOptions . apiVersion . configureValue ( properties . kotlinApiVersion . run { <EOL> if ( ! ignoreExtensionValue ) orElse ( projectLevelApiVersion ( ) ) else this <EOL> } , shouldSetValue ) <EOL> }


private fun < T : Any > Property < T > . configureValue ( source : Provider < T > , shouldSetValue : Boolean ) : Property < T >

= if ( shouldSetValue ) { <EOL> value ( source ) <EOL> } else { <EOL> convention ( source ) <EOL> }


fun primitives ( boolean : Boolean = true , character : Char = '<CHAR_LIT:z>' , byte : Byte = <NUM_LIT:5> . toByte ( ) , short : Short = ( - <NUM_LIT:5> ) . toShort ( ) , int : Int = <NUM_LIT> , float : Float = - <NUM_LIT> , long : Long = <NUM_LIT> , double : Double = <NUM_LIT> )

{ <EOL> assertEquals ( true , boolean ) <EOL> assertEquals ( '<CHAR_LIT:z>' , character ) <EOL> assertEquals ( <NUM_LIT:5> . toByte ( ) , byte ) <EOL> assertEquals ( ( - <NUM_LIT:5> ) . toShort ( ) , short ) <EOL> assertEquals ( <NUM_LIT> , int ) <EOL> assertEquals ( - <NUM_LIT> , float ) <EOL> assertEquals ( <NUM_LIT> , long ) <EOL> assertEquals ( <NUM_LIT> , double ) <EOL> }


{ <EOL> :: primitives . callBy ( emptyMap ( ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


override fun deserialize ( decoder : Decoder ) : Any ?

{ <EOL> if ( decoder !is JsonDecoder ) error ( "<STR_LIT>" ) <EOL> fun deserialize ( element : JsonElement ) : Any ? { <EOL> return when ( element ) { <EOL> is JsonArray -> buildList { <EOL> element . forEach { add ( deserialize ( it ) ) } <EOL> } <EOL> is JsonObject -> buildMap { <EOL> element . forEach { put ( it . key , deserialize ( it . value ) ) } <EOL> } <EOL> is JsonPrimitive -> when { <EOL> element . isString -> element . content <EOL> element is JsonNull -> null <EOL> element . booleanOrNull != null -> element . boolean <EOL> element . intOrNull != null -> element . int <EOL> element . longOrNull != null -> element . long <EOL> element . doubleOrNull != null -> element . double <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> return deserialize ( decoder . decodeJsonElement ( ) ) <EOL> }


override fun serialize ( encoder : Encoder , value : Any ? )

{ <EOL> when ( value ) { <EOL> is String -> encoder . encodeString ( value ) <EOL> is Double -> encoder . encodeDouble ( value ) <EOL> is Float -> encoder . encodeFloat ( value ) <EOL> is Number -> encoder . encodeLong ( value . toLong ( ) ) <EOL> is Boolean -> encoder . encodeBoolean ( value ) <EOL> is List < * > -> ListSerializer ( UntypedSerialization ) . serialize ( encoder , value ) <EOL> is Map < * , * > -> { <EOL> value . keys . forEach { <EOL> require ( it is String ) { "<STR_LIT>" } <EOL> } <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> MapSerializer ( serializer < String > ( ) , UntypedSerialization ) . serialize ( encoder , value as Map < String , * > ) <EOL> } <EOL> else -> { <EOL> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }


= error ( "<STR_LIT>" )


fun getWrappingStrategy ( ) : WrappingStrategy

{ <EOL> return wrap @ { childElement -> <EOL> Wrap ( "<STR_LIT:OK>" ) . let { <EOL> return@wrap it <EOL> } <EOL> } <EOL> }


fun getWrapAfterAnnotation ( childElement : ASTNode ) : Wrap ?

{ <EOL> return Wrap ( "<STR_LIT:OK>" ) <EOL> }


{ <EOL> return getWrappingStrategy ( ) . invoke ( ASTNode ( ) ) ? . message ? : "<STR_LIT:fail>" <EOL> }


public fun y ( parameters : AxisParameters . ( ) -> Unit = { } )

{ <EOL> y . apply ( parameters ) <EOL> }


override fun isOverriddenFunction ( overrideCandidate : FirSimpleFunction , baseDeclaration : FirSimpleFunction ) : Boolean

= <EOL> overrideCandidate . isPlatformOverriddenFunction ( session , baseDeclaration ) <EOL> ? : standardOverrideChecker . isOverriddenFunction ( overrideCandidate , baseDeclaration )


override fun isOverriddenProperty ( overrideCandidate : FirCallableDeclaration , baseDeclaration : FirProperty ) : Boolean

= <EOL> standardOverrideChecker . isOverriddenProperty ( overrideCandidate , baseDeclaration )


override fun chooseIntersectionVisibility ( overrides : Collection < FirCallableSymbol < * > > , dispatchClassSymbol : FirRegularClassSymbol ? , ) : Visibility

{ <EOL> return chooseIntersectionVisibilityOrNull ( overrides ) { it . isAbstractAccordingToRawStatus || it . isObjCClassPropertyOrAccessor ( session ) } <EOL> ? : Visibilities . Unknown <EOL> }


private fun FirCallableSymbol < * > . isObjCClassPropertyOrAccessor ( session : FirSession )

= <EOL> ( this is FirPropertySymbol || this is FirPropertyAccessorSymbol ) <EOL> && ( containingClassLookupTag ( ) ? . toSymbol ( session ) as? FirClassSymbol < * > ) ? . isObjCClass ( session ) ? : false


private fun FirSimpleFunction . isPlatformOverriddenFunction ( session : FirSession , baseDeclaration : FirSimpleFunction ) : Boolean ?

{ <EOL> if ( this . name != baseDeclaration . name ) { <EOL> return null <EOL> } <EOL> val superInfo = baseDeclaration . symbol . decodeObjCMethodAnnotation ( session ) ? : return null <EOL> val subInfo = symbol . decodeObjCMethodAnnotation ( session ) <EOL> return if ( subInfo != null ) { <EOL> superInfo . selector == subInfo . selector <EOL> } else { <EOL> if ( ! parameterNamesMatch ( this , baseDeclaration ) ) false else null <EOL> } <EOL> }

/**
 * mimics ObjCOverridabilityCondition.isOverridable
 */


private fun parameterNamesMatch ( first : FirSimpleFunction , second : FirSimpleFunction ) : Boolean

{ <EOL> if ( first . valueParameters . size != second . valueParameters . size ) { <EOL> return false <EOL> } <EOL> first . valueParameters . forEachIndexed { index , parameter -> <EOL> if ( index > <NUM_LIT:0> && parameter . name != second . valueParameters [ index ] . name ) { <EOL> return false <EOL> } <EOL> } <EOL> return true <EOL> }

/**
 * mimics ObjCInteropKt.parameterNamesMatch
 */


@ Test <EOL> fun `compare same version` ( )

{ <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) <= SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , "<STR_LIT>" ) <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) >= SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , "<STR_LIT>" ) <EOL> assertFalse ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) > SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun `compare higher version` ( )

{ <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) > SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) > SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) > SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> }


@ Test <EOL> fun `compare lower version` ( )

{ <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) < SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) < SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> ) ) <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) < SchemaVersion ( <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> }


{ <EOL> assertEquals ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT:100> ) , SchemaVersion . parseStringOrThrow ( "<STR_LIT>" ) ) <EOL> assertEquals ( SchemaVersion ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) , SchemaVersion . parseStringOrThrow ( "<STR_LIT>" ) ) <EOL> assertEquals ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , SchemaVersion . parseStringOrThrow ( "<STR_LIT>" ) ) <EOL> }


@ Test <EOL> fun `parseSchemaVersion failure` ( )

{ <EOL> assertFailsWith < IllegalArgumentException > { SchemaVersion . parseStringOrThrow ( "<STR_LIT:1.0>" ) } <EOL> assertFailsWith < IllegalArgumentException > { SchemaVersion . parseStringOrThrow ( "<STR_LIT>" ) } <EOL> assertFailsWith < IllegalArgumentException > { SchemaVersion . parseStringOrThrow ( "<STR_LIT>" ) } <EOL> }


@ Test <EOL> fun `toString and parse` ( )

{ <EOL> assertEquals ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , SchemaVersion . parseStringOrThrow ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) . toString ( ) ) ) <EOL> assertEquals ( SchemaVersion ( <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT> ) , SchemaVersion . parseStringOrThrow ( SchemaVersion ( <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT> ) . toString ( ) ) ) <EOL> }


{ <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> ) . isCompatible ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> assertTrue ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) . isCompatible ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> assertFalse ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) . isCompatible ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> ) ) ) <EOL> assertFalse ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) . isCompatible ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> assertFalse ( SchemaVersion ( <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> ) . isCompatible ( SchemaVersion ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> }


override fun getResolutionFacadeWithForcedPlatform ( elements : List < KtElement > , platform : TargetPlatform ) : ResolutionFacade

{ <EOL> return KotlinSimpleResolutionFacade ( ideaProject , elements ) <EOL> }


override fun getResolutionFacadeByFile ( file : PsiFile , platform : TargetPlatform ) : ResolutionFacade

{ <EOL> throw UnsupportedOperationException ( ) <EOL> }


override fun getResolutionFacadeByModuleInfo ( moduleInfo : ModuleInfo , settings : PlatformAnalysisSettings ) : ResolutionFacade ?


override fun getSuppressionCache ( ) : KotlinSuppressCache


override fun getResolutionFacade ( elements : List < KtElement > ) : ResolutionFacade


override fun getResolutionFacade ( element : KtElement ) : ResolutionFacade

= getResolutionFacade ( listOf ( element ) )


override fun getResolutionFacadeByModuleInfo ( moduleInfo : ModuleInfo , platform : TargetPlatform ) : ResolutionFacade ?

= <EOL> null


override fun < T : Any > tryGetFrontendService ( element : PsiElement , serviceClass : Class < T > ) : T ?

{ <EOL> return null <EOL> }


override fun resolveToDescriptor ( declaration : KtDeclaration , bodyResolveMode : BodyResolveMode ) : DeclarationDescriptor


override fun analyze ( element : KtElement , bodyResolveMode : BodyResolveMode ) : BindingContext

{ <EOL> val ktFile = element . containingKtFile <EOL> return KotlinAnalysisFileCache . getAnalysisResult ( ktFile ) . analysisResult . bindingContext <EOL> }


override fun analyzeWithAllCompilerChecks ( elements : Collection < KtElement > , callback : DiagnosticSink . DiagnosticsCallback ? <EOL> ) : AnalysisResult

{ <EOL> val ktFile = elements . first ( ) . containingKtFile <EOL> return KotlinAnalysisFileCache . getAnalysisResult ( ktFile ) . analysisResult <EOL> }


override fun analyze ( elements : Collection < KtElement > , bodyResolveMode : BodyResolveMode ) : BindingContext

{ <EOL> if ( elements . isEmpty ( ) ) { <EOL> return BindingContext . EMPTY <EOL> } <EOL> val ktFile = elements . first ( ) . containingKtFile <EOL> return KotlinAnalysisFileCache . getAnalysisResult ( ktFile ) . analysisResult . bindingContext <EOL> }


override fun < T : Any > getFrontendService ( element : PsiElement , serviceClass : Class < T > ) : T


override fun < T : Any > getFrontendService ( serviceClass : Class < T > ) : T

{ <EOL> val files = elements . map { it . containingKtFile } . toSet ( ) <EOL> if ( files . isEmpty ( ) ) throw IllegalStateException ( "<STR_LIT>" ) <EOL> val componentProvider = KotlinAnalyzer . analyzeFiles ( files ) . componentProvider <EOL> ? : throw IllegalStateException ( "<STR_LIT>" ) <EOL> return componentProvider . getService ( serviceClass ) <EOL> }


override fun < T : Any > getFrontendService ( moduleDescriptor : ModuleDescriptor , serviceClass : Class < T > ) : T


override fun < T : Any > getIdeService ( serviceClass : Class < T > ) : T


override fun getResolverForProject ( ) : ResolverForProject < out ModuleInfo >


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) fun < T : Any > ComponentProvider . getService ( request : Class < T > ) : T

{ <EOL> return resolve ( request ) ! ! . getValue ( ) as T <EOL> }


override fun invoke ( p1 : Int ) : String ?

{ <EOL> return if ( p1 and flag != <NUM_LIT:0> ) name else null <EOL> }


{ <EOL> return if ( p1 and flag == <NUM_LIT:0> ) name else null <EOL> }


= <EOL> this and Opcodes . ACC_PRIVATE != <NUM_LIT:0>


= <EOL> this and Opcodes . ACC_SYNTHETIC != <NUM_LIT:0>


= <EOL> this and Opcodes . ACC_BRIDGE != <NUM_LIT:0>


= <EOL> flagsList ( CLASS_FLAGS )


= <EOL> flagsList ( METHOD_FLAGS )


= <EOL> flagsList ( FIELD_FLAGS )


private fun Int . flagsList ( flags : List < ( Int ) -> String ? > )

= <EOL> flags . mapNotNull { flag -> <EOL> flag ( this ) <EOL> } . joinToString ( prefix = "<STR_LIT:[>" , postfix = "<STR_LIT:]>" ) { it }


= super . equals ( other )


{ <EOL> val a : A ? = null <EOL> testTrue { a == null } <EOL> testFalse { a != null } <EOL> testTrue { null == a } <EOL> testFalse { null != a } <EOL> return "<STR_LIT:OK>" <EOL> }


@ Test fun testUsingTempFolder ( @ TempDir folder : Path )

{ <EOL> val person = Person ( "<STR_LIT:Alice>" , <NUM_LIT> ) <EOL> val json = """<STR_LIT>""" <EOL> val jsonFile = ( folder . resolve ( "<STR_LIT>" ) ) . createFile ( ) <EOL> jsonFile . writeText ( serialize ( person ) ) <EOL> assertEquals ( json , jsonFile . readText ( ) ) <EOL> }


= expectThrowableMessage { <EOL> <NUM_LIT:2> mustEqual <NUM_LIT:6> <EOL> }


= a == b


fun equals2 ( a : Float ? , b : Float ? )

= a ! ! == b ! !


fun equals3 ( a : Float ? , b : Float ? )

= a != null && b != null && a == b


fun equals4 ( a : Float ? , b : Float ? )

= if ( a is Float && b is Float ) a == b else null ! !


{ <EOL> if ( - <NUM_LIT> != <NUM_LIT> ) return "<STR_LIT>" <EOL> if ( ! equals1 ( - <NUM_LIT> , <NUM_LIT> ) ) return "<STR_LIT:failU+00201>" <EOL> if ( ! equals2 ( - <NUM_LIT> , <NUM_LIT> ) ) return "<STR_LIT:failU+00202>" <EOL> if ( ! equals3 ( - <NUM_LIT> , <NUM_LIT> ) ) return "<STR_LIT:failU+00203>" <EOL> if ( ! equals4 ( - <NUM_LIT> , <NUM_LIT> ) ) return "<STR_LIT:failU+00204>" <EOL> if ( equals5 ( - <NUM_LIT> , <NUM_LIT> ) ) return "<STR_LIT:failU+00205>" <EOL> return "<STR_LIT:OK>" <EOL> }


@ JsModule ( "<STR_LIT>" ) <EOL> external fun func ( opts : String = definedExternally ) : Number


@ JvmOverloads <EOL> fun testTopLevelFunction ( x : Int = <NUM_LIT:0> ) : Z

= Z ( x )


fun < T : LineNumberReader > KnitContext . withLineNumberReader ( file : File , factory : ( Reader ) -> T , block : T . ( ) -> Unit ) : T ?

{ <EOL> val reader = factory ( file . reader ( ) ) <EOL> reader . use { <EOL> try { <EOL> it . block ( ) <EOL> } catch ( e : Exception ) { <EOL> log . error ( "<STR_LIT>" , e ) <EOL> return null <EOL> } <EOL> } <EOL> return reader <EOL> }


operator fun File . div ( path : String ) : File

= File ( this , path . replace ( "<STR_LIT:/>" , File . separator ) )


internal fun Reader . firstLineSeparator ( ) : String ?

{ <EOL> val n = '<CHAR_LIT:\n>' . toInt ( ) <EOL> val r = '<CHAR_LIT:\r>' . toInt ( ) <EOL> while ( true ) { <EOL> val current = read ( ) <EOL> if ( current == - <NUM_LIT:1> ) { <EOL> return null <EOL> } else if ( current == n || current == r ) { <EOL> var result = current . toChar ( ) . toString ( ) <EOL> val next = read ( ) <EOL> if ( current == r && next == n ) { <EOL> result += next . toChar ( ) . toString ( ) <EOL> } <EOL> return result <EOL> } <EOL> } <EOL> }