private fun JsIrProgramFragment . buildRenames ( nameMap : MutableMap < String , JsName > ) : Map < JsName , JsName >

{ <EOL> val result = mutableMapOf < JsName , JsName > ( ) <EOL> this . importedModules . forEach { module -> <EOL> val existingModule = importedModulesMap . getOrPut ( module . key ) { module } <EOL> if ( existingModule !== module ) { <EOL> result [ module . internalName ] = existingModule . internalName <EOL> } <EOL> } <EOL> this . nameBindings . entries . forEach { ( tag , name ) -> <EOL> val existingName = nameMap . getOrPut ( tag ) { name } <EOL> if ( existingName !== name ) { <EOL> result [ name ] = existingName <EOL> } <EOL> } <EOL> return result <EOL> }


private fun Map < JsName , JsName > . rename ( name : JsName ) : JsName

= getOrElse ( name ) { name }


private fun < T : JsNode > Map < JsName , JsName > . rename ( rootNode : T ) : T

{ <EOL> rootNode . accept ( object : RecursiveJsVisitor ( ) { <EOL> override fun visitElement ( node : JsNode ) { <EOL> super . visitElement ( node ) <EOL> if ( node is HasName ) { <EOL> node . name = node . name ? . let { rename ( it ) } <EOL> } <EOL> } <EOL> } ) <EOL> return rootNode <EOL> }


{ <EOL> val definitions = mutableSetOf < String > ( ) <EOL> fragments . forEach { <EOL> it . definitions . forEach { <EOL> if ( ! definitions . add ( it ) ) { <EOL> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> }


private fun declareAndCallJsExporter ( ) : List < JsStatement >

{ <EOL> if ( isEsModules ) { <EOL> val allExportRelatedStatements = fragments . flatMap { it . exports . statements } <EOL> val ( allExportStatements , restStatements ) = allExportRelatedStatements . partitionIsInstance < JsStatement , JsExport > ( ) <EOL> val ( currentModuleExportStatements , restExportStatements ) = allExportStatements . partition { it . fromModule == null } <EOL> val exportedElements = currentModuleExportStatements . takeIf { it . isNotEmpty ( ) } <EOL> ? . asSequence ( ) <EOL> ? . flatMap { ( it . subject as JsExport . Subject . Elements ) . elements } <EOL> ? . distinctBy { it . alias ? . ident ? : it . name . ident } <EOL> ? . toList ( ) <EOL> val oneLargeExportStatement = exportedElements ? . let { JsExport ( JsExport . Subject . Elements ( it ) ) } <EOL> return restStatements + listOfNotNull ( oneLargeExportStatement ) + restExportStatements <EOL> } else { <EOL> val exportBody = JsBlock ( fragments . flatMap { it . exports . statements } ) <EOL> if ( exportBody . isEmpty ) { <EOL> return emptyList ( ) <EOL> } <EOL> val internalModuleName = ReservedJsNames . makeInternalModuleName ( ) <EOL> val exporterName = ReservedJsNames . makeJsExporterName ( ) <EOL> val jsExporterFunction = JsFunction ( emptyScope , "<STR_LIT>" ) . apply { <EOL> body = exportBody <EOL> name = exporterName <EOL> parameters . add ( JsParameter ( internalModuleName ) ) <EOL> } <EOL> val jsExporterCall = JsInvocation ( exporterName . makeRef ( ) , internalModuleName . makeRef ( ) ) <EOL> val result = mutableListOf ( jsExporterFunction . makeStmt ( ) , jsExporterCall . makeStmt ( ) ) <EOL> if ( ! generateCallToMain ) { <EOL> val exportExporter = jsAssignment ( JsNameRef ( exporterName , internalModuleName . makeRef ( ) ) , exporterName . makeRef ( ) ) <EOL> result += exportExporter . makeStmt ( ) <EOL> } <EOL> return result <EOL> } <EOL> }


private fun transitiveJsExport ( ) : List < JsStatement >

{ <EOL> return if ( isEsModules ) { <EOL> crossModuleReferences . transitiveExportFrom . map { <EOL> JsExport ( JsExport . Subject . All , it . getRequireEsmName ( ) ) <EOL> } <EOL> } else { <EOL> val internalModuleName = ReservedJsNames . makeInternalModuleName ( ) <EOL> val exporterName = ReservedJsNames . makeJsExporterName ( ) <EOL> crossModuleReferences . transitiveExportFrom . map { <EOL> JsInvocation ( JsNameRef ( exporterName , it . internalName . makeRef ( ) ) , internalModuleName . makeRef ( ) ) . makeStmt ( ) <EOL> } <EOL> } <EOL> }


{ <EOL> assertSingleDefinition ( ) <EOL> linkJsNames ( ) <EOL> val moduleBody = mutableListOf < JsStatement > ( ) <EOL> val preDeclarationBlock = JsCompositeBlock ( ) <EOL> val postDeclarationBlock = JsCompositeBlock ( ) <EOL> val polyfillDeclarationBlock = JsCompositeBlock ( ) <EOL> moduleBody . addWithComment ( "<STR_LIT>" , preDeclarationBlock ) <EOL> val classModels = mutableMapOf < JsName , JsIrIcClassModel > ( ) <EOL> val initializerBlock = JsCompositeBlock ( ) <EOL> fragments . forEach { <EOL> moduleBody += it . declarations . statements <EOL> classModels += it . classes <EOL> initializerBlock . statements += it . initializers . statements + it . eagerInitializers . statements <EOL> polyfillDeclarationBlock . statements += it . polyfills . statements <EOL> } <EOL> processClassModels ( classModels , preDeclarationBlock , postDeclarationBlock ) <EOL> moduleBody . addWithComment ( "<STR_LIT>" , postDeclarationBlock . statements ) <EOL> moduleBody . addWithComment ( "<STR_LIT>" , initializerBlock . statements ) <EOL> JsTestFunctionTransformer . generateTestFunctionCall ( fragments . asTestFunctionContainers ( ) ) ? . let { <EOL> moduleBody . startRegion ( "<STR_LIT>" ) <EOL> moduleBody += it . makeStmt ( ) <EOL> moduleBody . endRegion ( ) <EOL> } <EOL> val fragmentWithMainFunction = JsMainFunctionDetector . pickMainFunctionFromCandidates ( fragments ) { <EOL> JsMainFunctionDetector . MainFunctionCandidate ( it . packageFqn , it . mainFunctionTag ) <EOL> } <EOL> val exportStatements = declareAndCallJsExporter ( ) + additionalExports + transitiveJsExport ( ) <EOL> val importedJsModules = this . importedModulesMap . values . toList ( ) + this . crossModuleReferences . importedModules <EOL> val importStatements = this . importStatements . values . toList ( ) + this . importStatementsWithEffect . toList ( ) <EOL> val program = JsProgram ( ) <EOL> val internalModuleName = ReservedJsNames . makeInternalModuleName ( ) <EOL> val rootFunction = JsFunction ( program . rootScope , JsBlock ( ) , "<STR_LIT>" ) . apply { <EOL> parameters += JsParameter ( internalModuleName ) <EOL> parameters += ( importedJsModules ) . map { JsParameter ( it . internalName ) } <EOL> with ( body ) { <EOL> if ( ! isEsModules ) { <EOL> statements += JsStringLiteral ( "<STR_LIT>" ) . makeStmt ( ) <EOL> } <EOL> statements . addWithComment ( "<STR_LIT>" , importStatements ) <EOL> statements += moduleBody <EOL> statements . addWithComment ( "<STR_LIT>" , exportStatements ) <EOL> if ( generateCallToMain && fragmentWithMainFunction != null ) { <EOL> val mainFunctionTag = fragmentWithMainFunction . mainFunctionTag ? : error ( "<STR_LIT>" ) <EOL> val mainFunctionName = fragmentWithMainFunction . nameBindings [ mainFunctionTag ] ? : error ( "<STR_LIT>" ) <EOL> statements += JsInvocation ( mainFunctionName . makeRef ( ) ) . makeStmt ( ) <EOL> } <EOL> this . statements += JsReturn ( internalModuleName . makeRef ( ) ) <EOL> } <EOL> } <EOL> polyfillDeclarationBlock . statements <EOL> . takeIf { it . isNotEmpty ( ) } <EOL> ? . let { program . globalBlock . statements . addWithComment ( "<STR_LIT>" , it ) } <EOL> program . globalBlock . statements += ModuleWrapperTranslation . wrap ( moduleName , rootFunction , importedJsModules , program , kind = moduleKind ) <EOL> return program <EOL> }


private fun processClassModels ( classModelMap : Map < JsName , JsIrIcClassModel > , preDeclarationBlock : JsBlock , postDeclarationBlock : JsBlock )

{ <EOL> val declarationHandler = object : DFS . AbstractNodeHandler < JsName , Unit > ( ) { <EOL> override fun result ( ) { } <EOL> override fun afterChildren ( current : JsName ) { <EOL> classModelMap [ current ] ? . let { <EOL> preDeclarationBlock . statements += it . preDeclarationBlock . statements <EOL> postDeclarationBlock . statements += it . postDeclarationBlock . statements <EOL> } <EOL> } <EOL> } <EOL> DFS . dfs ( classModelMap . keys , { classModelMap [ it ] ? . superClasses ? : emptyList ( ) } , declarationHandler ) <EOL> }


private fun MutableList < JsStatement > . startRegion ( description : String = "<STR_LIT>" )

{ <EOL> if ( generateRegionComments ) { <EOL> this += JsSingleLineComment ( "<STR_LIT>" ) <EOL> } <EOL> }


private fun MutableList < JsStatement > . endRegion ( )


private fun MutableList < JsStatement > . addWithComment ( regionDescription : String = "<STR_LIT>" , block : JsBlock )

{ <EOL> startRegion ( regionDescription ) <EOL> this += block <EOL> endRegion ( ) <EOL> }


private fun MutableList < JsStatement > . addWithComment ( regionDescription : String = "<STR_LIT>" , statements : List < JsStatement > )

{ <EOL> if ( statements . isEmpty ( ) ) return <EOL> startRegion ( regionDescription ) <EOL> this += statements <EOL> endRegion ( ) <EOL> }


private fun JsStatement . importStatementWithName ( name : JsName ? ) : JsStatement

{ <EOL> if ( name == null ) return this <EOL> return when ( this ) { <EOL> is JsVars -> JsVars ( JsVars . JsVar ( name , vars . single ( ) . initExpression ) ) <EOL> is JsImport -> JsImport ( module , when ( target ) { <EOL> is JsImport . Target . Effect -> JsImport . Target . Effect <EOL> is JsImport . Target . All -> JsImport . Target . All ( alias = name . makeRef ( ) ) <EOL> is JsImport . Target . Default -> JsImport . Target . Default ( name = name . makeRef ( ) ) <EOL> is JsImport . Target . Elements -> JsImport . Target . Elements ( mutableListOf ( JsImport . Element ( elements . single ( ) . name , name . makeRef ( ) ) ) ) <EOL> } ) <EOL> is JsCompositeBlock -> JsCompositeBlock ( statements . dropLast ( <NUM_LIT:1> ) + statements . last ( ) . importStatementWithName ( name ) ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> }


fun List < JsIrModule > . merge ( ) : JsIrModule

{ <EOL> assert ( isNotEmpty ( ) ) { "<STR_LIT>" } <EOL> val firstModule = first ( ) <EOL> return if ( size == <NUM_LIT:1> ) { <EOL> firstModule <EOL> } else { <EOL> val fragments = mutableListOf < JsIrProgramFragment > ( ) <EOL> var reexportedInModuleWithName : String ? = null <EOL> for ( module in this ) { <EOL> fragments . addAll ( module . fragments ) <EOL> module . reexportedInModuleWithName ? . let { reexportedInModuleWithName = it } <EOL> } <EOL> JsIrModule ( firstModule . moduleName , firstModule . externalModuleName , fragments , reexportedInModuleWithName ) <EOL> } <EOL> }


fun List < JsIrModuleHeader > . merge ( ) : JsIrModuleHeader

{ <EOL> assert ( isNotEmpty ( ) ) { "<STR_LIT>" } <EOL> val firstModule = first ( ) <EOL> return if ( size == <NUM_LIT:1> ) { <EOL> firstModule <EOL> } else { <EOL> val definitions = mutableSetOf < String > ( ) <EOL> val nameBindings = mutableMapOf < String , String > ( ) <EOL> val optionalCrossModuleImports = mutableSetOf < String > ( ) <EOL> var reexportedInModuleWithName : String ? = null <EOL> var importedWithEffectInModuleWithName : String ? = null <EOL> for ( header in this ) { <EOL> definitions . addAll ( header . definitions ) <EOL> nameBindings . putAll ( header . nameBindings ) <EOL> optionalCrossModuleImports . addAll ( header . optionalCrossModuleImports ) <EOL> header . reexportedInModuleWithName ? . let { reexportedInModuleWithName = it } <EOL> header . importedWithEffectInModuleWithName ? . let { importedWithEffectInModuleWithName = it } <EOL> } <EOL> JsIrModuleHeader ( firstModule . moduleName , firstModule . externalModuleName , definitions , nameBindings , optionalCrossModuleImports , reexportedInModuleWithName , importedWithEffectInModuleWithName , null ) <EOL> } <EOL> }


@ GCUnsafeCall ( "<STR_LIT>" ) <EOL> private external fun kotlin_ObjCExport_ExceptionDetails ( nativeException : Any ) : String ?


@ ExportForCppRuntime <EOL> @ BetaInteropApi <EOL> @ ExperimentalForeignApi <EOL> internal fun CreateForeignException ( payload : NativePtr ) : Throwable <EOL>

= ForeignException ( interpretObjCPointerOrNull < Any ? > ( payload ) )


{ <EOL> val plusK = Class . forName ( "<STR_LIT>" ) . kotlinPackage . <EOL> getMemberByName ( "<STR_LIT>" ) as KProperty1 < String , String > <EOL> return plusK . getter . callBy ( mapOf ( plusK . parameters [ <NUM_LIT:0> ] to "<STR_LIT:O>" ) ) <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:2> , arrayOf ( <NUM_LIT:1> , <NUM_LIT:2> ) [ fizz ( <NUM_LIT:0> ) + buzz ( <NUM_LIT:1> ) ] ) <EOL> assertEquals ( "<STR_LIT>" , pullLog ( ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


override fun decodeElementIndex ( descriptor : SerialDescriptor ) : Int

= <NUM_LIT:42>


@ Test <EOL> fun testJsonDecodingException ( )

= checkRecovered ( "<STR_LIT:JsonDecodingException>" ) { <EOL> Json . decodeFromString < String > ( "<STR_LIT:42>" ) <EOL> }


@ Test <EOL> fun testJsonEncodingException ( )

= checkRecovered ( "<STR_LIT>" ) { <EOL> Json . encodeToString ( Double . NaN ) <EOL> }


@ Test <EOL> fun testUnknownFieldException ( )

= checkRecovered ( "<STR_LIT>" ) { <EOL> val serializer = Data . serializer ( ) <EOL> serializer . deserialize ( BadDecoder ( ) ) <EOL> }


private fun checkRecovered ( exceptionClassSimpleName : String , block : ( ) -> Unit )

= runBlocking { <EOL> val result = runCatching { <EOL> callBlockWithRecovery ( block ) <EOL> } <EOL> assertTrue ( result . isFailure , "<STR_LIT>" ) <EOL> val e = result . exceptionOrNull ( ) ! ! <EOL> assertEquals ( exceptionClassSimpleName , e :: class . simpleName ! ! ) <EOL> val cause = e . cause <EOL> assertNotNull ( cause , "<STR_LIT>" ) <EOL> assertEquals ( e . message , cause . message ) <EOL> assertEquals ( exceptionClassSimpleName , e :: class . simpleName ! ! ) <EOL> }


private suspend fun callBlockWithRecovery ( block : ( ) -> Unit )

{ <EOL> yield ( ) <EOL> withContext ( NonCancellable ) { <EOL> block ( ) <EOL> } <EOL> }


{ <EOL> assertEquals ( "<STR_LIT>" , C :: arrayOfInt . annotations . filterIsInstance < ArrayOfInt > ( ) . map { it . ints . single ( ) } . toString ( ) ) <EOL> assertEquals ( "<STR_LIT>" , C :: arrayOfString . annotations . filterIsInstance < ArrayOfString > ( ) . map { it . strings . single ( ) } . toString ( ) ) <EOL> assertEquals ( "<STR_LIT>" , C :: arrayOfEnum . annotations . filterIsInstance < ArrayOfEnum > ( ) . map { it . enums . single ( ) } . toString ( ) ) <EOL> assertEquals ( "<STR_LIT>" , C :: arrayOfAnnotation . annotations . filterIsInstance < ArrayOfAnnotation > ( ) . map { <EOL> it . annotations . single ( ) . strings . single ( ) <EOL> } . toString ( ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


= suspendCoroutineUninterceptedOrReturn { x -> <EOL> x . resume ( ( i ++ ) . toString ( ) ) <EOL> COROUTINE_SUSPENDED <EOL> }


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

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


{ <EOL> var result = "<STR_LIT>" <EOL> builder { <EOL> result += "<STR_LIT:->" <EOL> result += suspendHere ( ) <EOL> if ( result == "<STR_LIT>" ) { <EOL> builder { <EOL> result += "<STR_LIT:+>" <EOL> result += suspendHere ( ) <EOL> result += suspendHere ( ) <EOL> result += "<STR_LIT:#>" <EOL> } <EOL> result += suspendHere ( ) <EOL> result += "<STR_LIT>" <EOL> } <EOL> } <EOL> if ( result != "<STR_LIT>" ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


override fun getForeignValues ( codeFragment : KtCodeFragment ) : Map < String , String >

{ <EOL> return codeFragment . getUserData ( FOREIGN_VALUES_KEY ) ? : emptyMap ( ) <EOL> }


fun submitForeignValues ( codeFragment : KtCodeFragment , values : List < TestForeignValue > )

{ <EOL> require ( codeFragment . getUserData ( FOREIGN_VALUES_KEY ) == null ) <EOL> val map = values . map { Pair ( it . name , it . internalType ) } . toMap ( ) <EOL> codeFragment . putUserData ( FOREIGN_VALUES_KEY , map ) <EOL> }


override fun check ( rttiInformation : RttiExpressionInformation , reportOn : PsiElement , trace : BindingTrace )

{ <EOL> val sourceType = rttiInformation . sourceType <EOL> val targetType = rttiInformation . targetType <EOL> val targetDescriptor = targetType ? . constructor ? . declarationDescriptor <EOL> if ( sourceType != null && targetDescriptor is ClassDescriptor ) { <EOL> val kind = targetDescriptor . getForwardDeclarationKindOrNull ( ) ? : return <EOL> when ( rttiInformation . operation ) { <EOL> RttiOperation . IS , <EOL> RttiOperation . NOT_IS -> trace . report ( ErrorsNative . CANNOT_CHECK_FOR_FORWARD_DECLARATION . on ( reportOn , targetType ) ) <EOL> RttiOperation . AS , <EOL> RttiOperation . SAFE_AS -> { <EOL> val sourceDescriptor = sourceType . constructor . declarationDescriptor as? ClassDescriptor <EOL> val isAllowedCast = sourceDescriptor != null && <EOL> sourceDescriptor . name == targetDescriptor . name && <EOL> sourceDescriptor . kind == kind . classKind && <EOL> sourceDescriptor . getAllSuperClassifiers ( ) . any { it . fqNameSafe == kind . matchSuperClassFqName } <EOL> if ( ! isAllowedCast ) { <EOL> trace . report ( ErrorsNative . UNCHECKED_CAST_TO_FORWARD_DECLARATION . on ( reportOn , sourceType , targetType ) ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> }


override fun check ( expression : KtClassLiteralExpression , type : KotlinType , context : ResolutionContext < * > )

{ <EOL> val descriptor = type . constructor . declarationDescriptor as? ClassDescriptor <EOL> if ( descriptor ? . getForwardDeclarationKindOrNull ( ) != null ) { <EOL> context . trace . report ( ErrorsNative . FORWARD_DECLARATION_AS_CLASS_LITERAL . on ( expression , type ) ) <EOL> } <EOL> }


= TODO ( )


override fun contains ( element : E ) : Boolean

= TODO ( )


override fun containsAll ( elements : Collection < E > ) : Boolean

= TODO ( )


= MyIterator < E > ( )


fun generate ( )


fun generateClassOrObject ( classOrObject : KtClassOrObject , packagePartContext : FieldOwnerContext < PackageFragmentDescriptor > )


private fun getDeserializedCallables ( compiledPackageFragment : PackageFragmentDescriptor )

= <EOL> compiledPackageFragment . getMemberScope ( ) <EOL> . getContributedDescriptors ( DescriptorKindFilter . CALLABLES , MemberScope . ALL_NAME_FILTER ) <EOL> . filterIsInstance < DeserializedCallableMemberDescriptor > ( )


private fun getSuperClassForPart ( partInternalName : String )

= <EOL> if ( shouldGeneratePartHierarchy ) <EOL> superClassForInheritedPart [ partInternalName ] ? : J_L_OBJECT <EOL> else <EOL> J_L_OBJECT


private fun KtFile . isJvmSynthetic ( ) : Boolean

{ <EOL> return annotationEntries . any { entry -> <EOL> val descriptor = state . bindingContext [ BindingContext . ANNOTATION , entry ] <EOL> descriptor ? . annotationClass ? . let ( DescriptorUtils :: getFqNameSafe ) == JVM_SYNTHETIC_ANNOTATION_FQ_NAME <EOL> } <EOL> }


{ <EOL> assert ( delegateGenerationTasks . isEmpty ( ) ) { "<STR_LIT>" } <EOL> generateCodeForSourceFiles ( ) <EOL> generateDelegatesToPreviouslyCompiledParts ( ) <EOL> if ( partInternalNamesSorted . isNotEmpty ( ) ) { <EOL> generateMultifileFacadeClass ( ) <EOL> } <EOL> done ( ) <EOL> }


private fun generateCodeForSourceFiles ( )

{ <EOL> for ( file in files ) { <EOL> ProgressIndicatorAndCompilationCanceledStatus . checkCanceled ( ) <EOL> try { <EOL> generatePart ( file ) <EOL> state . afterIndependentPart ( ) <EOL> } catch ( e : ProcessCanceledException ) { <EOL> throw e <EOL> } catch ( e : Throwable ) { <EOL> CodegenUtil . reportBackendException ( e , "<STR_LIT>" , file . virtualFile ? . url ) <EOL> } <EOL> } <EOL> }


private fun generateMultifileFacadeClass ( )

{ <EOL> for ( member in delegateGenerationTasks . keys . sortedWith ( MemberComparator . INSTANCE ) ) { <EOL> delegateGenerationTasks [ member ] ! ! ( ) <EOL> } <EOL> writeKotlinMultifileFacadeAnnotationIfNeeded ( ) <EOL> }


override fun generateClassOrObject ( classOrObject : KtClassOrObject , packagePartContext : FieldOwnerContext < PackageFragmentDescriptor > )

{ <EOL> MemberCodegen . genClassOrObject ( packagePartContext , classOrObject , state , null ) <EOL> }


private fun generatePart ( file : KtFile )

{ <EOL> val packageFragment = this . packageFragment <EOL> ? : throw AssertionError ( "<STR_LIT>" ) <EOL> val partType = Type . getObjectType ( JvmFileClassUtil . getFileClassInternalName ( file ) ) <EOL> val partContext = state . rootContext . intoMultifileClassPart ( packageFragment , facadeClassType , partType , file ) <EOL> PackageCodegenImpl . generateClassesAndObjectsInFile ( file , partContext , state ) <EOL> if ( ! state . generateDeclaredClassFilter . shouldGeneratePackagePart ( file ) || ! file . hasDeclarationsForPartClass ( ) ) return <EOL> state . factory . packagePartRegistry . addPart ( packageFragment . fqName , partType . internalName , facadeClassType . internalName ) <EOL> val builder = state . factory . newVisitor ( MultifileClassPart ( file , packageFragment ) , partType , file ) <EOL> MultifileClassPartCodegen ( builder , file , packageFragment , getSuperClassForPart ( partType . internalName ) , shouldGeneratePartHierarchy , partContext , state ) . generate ( ) <EOL> addDelegateGenerationTasksForDeclarationsInFile ( file , packageFragment , partType ) <EOL> }


private fun addDelegateGenerationTasksForDeclarationsInFile ( file : KtFile , packageFragment : PackageFragmentDescriptor , partType : Type )

{ <EOL> val facadeContext = state . rootContext . intoMultifileClass ( packageFragment , facadeClassType , partType ) <EOL> val memberCodegen = createCodegenForDelegatesInMultifileFacade ( facadeContext ) <EOL> for ( declaration in CodegenUtil . getMemberDeclarationsToGenerate ( file ) ) { <EOL> if ( declaration is KtTypeAlias && ! state . classBuilderMode . generateMetadata ) continue <EOL> val descriptor = state . bindingContext . get ( BindingContext . DECLARATION_TO_DESCRIPTOR , declaration ) <EOL> if ( descriptor !is MemberDescriptor ) { <EOL> throw AssertionError ( "<STR_LIT>" + descriptor + "<STR_LIT>" + declaration . text ) <EOL> } <EOL> addDelegateGenerationTaskIfNeeded ( descriptor ) { memberCodegen . genSimpleMember ( declaration ) } <EOL> } <EOL> }


private fun shouldGenerateInFacade ( descriptor : MemberDescriptor ) : Boolean

{ <EOL> if ( DescriptorVisibilities . isPrivate ( descriptor . visibility ) ) return false <EOL> if ( DescriptorAsmUtil . getVisibilityAccessFlag ( descriptor ) == Opcodes . ACC_PRIVATE ) return false <EOL> if ( ! state . classBuilderMode . generateBodies ) return true <EOL> if ( shouldGeneratePartHierarchy ) { <EOL> if ( descriptor !is PropertyDescriptor || ! descriptor . isConst ) return false <EOL> } <EOL> return true <EOL> }


private fun addDelegateGenerationTaskIfNeeded ( callable : MemberDescriptor , task : ( ) -> Unit )

{ <EOL> if ( shouldGenerateInFacade ( callable ) ) { <EOL> delegateGenerationTasks [ callable ] = task <EOL> } <EOL> }


private fun generateDelegatesToPreviouslyCompiledParts ( )

{ <EOL> if ( compiledPackageFragment == null ) return <EOL> for ( callable in previouslyCompiledCallables ) { <EOL> val partFqName = JvmFileClassUtil . getPartFqNameForDeserialized ( callable ) <EOL> val partType = AsmUtil . asmTypeByFqNameWithoutInnerClasses ( partFqName ) <EOL> addDelegateGenerationTaskIfNeeded ( callable ) { generateDelegateToCompiledMember ( callable , compiledPackageFragment , partType ) } <EOL> } <EOL> }


private fun generateDelegateToCompiledMember ( member : CallableMemberDescriptor , compiledPackageFragment : PackageFragmentDescriptor , partType : Type )

{ <EOL> val context = state . rootContext . intoMultifileClass ( compiledPackageFragment , facadeClassType , partType ) <EOL> val memberCodegen = createCodegenForDelegatesInMultifileFacade ( context ) <EOL> when ( member ) { <EOL> is DeserializedSimpleFunctionDescriptor -> { <EOL> memberCodegen . functionCodegen . generateMethod ( OtherOrigin ( member ) , member , DelegateToCompiledMemberGenerationStrategy ) <EOL> memberCodegen . functionCodegen . generateDefaultIfNeeded ( context . intoFunction ( member ) , member , OwnerKind . PACKAGE , DefaultParameterValueLoader . DEFAULT , null ) <EOL> memberCodegen . functionCodegen . generateOverloadsWithDefaultValues ( null , member , member ) <EOL> } <EOL> is DeserializedPropertyDescriptor -> { <EOL> memberCodegen . propertyCodegen . generateInPackageFacade ( member ) <EOL> } <EOL> else -> { <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }


override fun skipNotNullAssertionsForParameters ( ) : Boolean

{ <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> }


override fun generateBody ( mv : MethodVisitor , frameMap : FrameMap , signature : JvmMethodSignature , context : MethodContext , parentCodegen : MemberCodegen < * > )


private fun writeKotlinMultifileFacadeAnnotationIfNeeded ( )

{ <EOL> if ( ! state . classBuilderMode . generateMetadata ) { <EOL> classBuilder . ensureGenerated ( ) <EOL> return <EOL> } <EOL> if ( files . any { it . isScript ( ) } ) return <EOL> val extraFlags = if ( shouldGeneratePartHierarchy ) JvmAnnotationNames . METADATA_MULTIFILE_PARTS_INHERIT_FLAG else <NUM_LIT:0> <EOL> val kotlinPackageFqName = <EOL> packageFragment ? . fqName ? : compiledPackageFragment ? . fqName <EOL> ? : error ( "<STR_LIT>" ) <EOL> if ( files . any { it . packageFqName != kotlinPackageFqName } ) <EOL> throw UnsupportedOperationException ( "<STR_LIT>" + files . joinToString ( "<STR_LIT>" ) { file -> "<STR_LIT>" } ) <EOL> writeMetadata ( classBuilder , state , extraFlags , partInternalNamesSorted , facadeClassType , kotlinPackageFqName ) <EOL> }


private fun createCodegenForDelegatesInMultifileFacade ( facadeContext : FieldOwnerContext < * > ) : MemberCodegen < KtFile >

= <EOL> object : MemberCodegen < KtFile > ( state , null , facadeContext , null , classBuilder ) { <EOL> override fun generateDeclaration ( ) = throw UnsupportedOperationException ( ) <EOL> override fun generateBody ( ) = throw UnsupportedOperationException ( ) <EOL> override fun generateKotlinMetadataAnnotation ( ) = throw UnsupportedOperationException ( ) <EOL> }


{ <EOL> classBuilder . done ( state . config . generateSmapCopyToAnnotation ) <EOL> if ( classBuilder . isComputed ) { <EOL> state . afterIndependentPart ( ) <EOL> } <EOL> }


private fun getOnlyPackageFragment ( files : Collection < KtFile > , moduleDescriptor : ModuleDescriptor ) : PackageFragmentDescriptor ?

{ <EOL> val fragments = files . mapTo ( linkedSetOf ( ) ) { file -> <EOL> moduleDescriptor . findPackageFragmentForFile ( file ) <EOL> ? : throw AssertionError ( "<STR_LIT>" + file + "<STR_LIT:\n>" + file . text ) <EOL> } <EOL> if ( fragments . size > <NUM_LIT:1> ) { <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> return fragments . firstOrNull ( ) <EOL> }


private fun KtFile . hasDeclarationsForPartClass ( )

= <EOL> CodegenUtil . getMemberDeclarationsToGenerate ( this ) . isNotEmpty ( )


private fun getCompiledPackageFragment ( facadeFqName : FqName , state : GenerationState ) : IncrementalPackageFragmentProvider . IncrementalMultifileClassPackageFragment ?

{ <EOL> if ( ! state . isIncrementalCompilation ) return null <EOL> val packageFqName = facadeFqName . parent ( ) <EOL> val incrementalPackageFragment = state . module . getPackage ( packageFqName ) . fragments . firstOrNull { fragment -> <EOL> fragment is IncrementalPackageFragmentProvider . IncrementalPackageFragment && fragment . target == state . targetId <EOL> } as IncrementalPackageFragmentProvider . IncrementalPackageFragment ? <EOL> return incrementalPackageFragment ? . getPackageFragmentForMultifileClass ( facadeFqName ) <EOL> }


fun writeMetadata ( classBuilder : ClassBuilder , state : GenerationState , flags : Int , partInternalNames : List < String > , facadeClassType : Type , kotlinPackageFqName : FqName )

{ <EOL> writeKotlinMetadata ( classBuilder , state . config , KotlinClassHeader . Kind . MULTIFILE_CLASS , false , flags ) { av -> <EOL> val arv = av . visitArray ( JvmAnnotationNames . METADATA_DATA_FIELD_NAME ) <EOL> for ( internalName in partInternalNames ) { <EOL> arv . visit ( null , internalName ) <EOL> } <EOL> arv . visitEnd ( ) <EOL> if ( kotlinPackageFqName != JvmClassName . byInternalName ( facadeClassType . internalName ) . packageFqName ) { <EOL> av . visit ( JvmAnnotationNames . METADATA_PACKAGE_NAME_FIELD_NAME , kotlinPackageFqName . asString ( ) ) <EOL> } <EOL> } <EOL> }


override fun lowerTypeValueModel ( ownerContext : NodeOwner < TypeValueModel > ) : TypeValueModel

{ <EOL> val type = super . lowerTypeValueModel ( ownerContext ) <EOL> if ( type . value . isGenerated ( ) ) { <EOL> usedTypes += type . value <EOL> } <EOL> return type <EOL> }


fun isUnused ( name : NameEntity ) : Boolean

{ <EOL> return ! usedTypes . contains ( name ) <EOL> }


override fun lowerRoot ( moduleModel : ModuleModel , ownerContext : NodeOwner < ModuleModel > ) : ModuleModel

{ <EOL> return moduleModel . copy ( declarations = moduleModel . declarations . filterNot { <EOL> it is InterfaceModel && it . name . isGenerated ( ) && collector . isUnused ( it . name ) <EOL> } ) <EOL> }


override fun lower ( source : SourceSetModel ) : SourceSetModel

{ <EOL> collector = GeneratedInterfaceReferenceCollector ( ) <EOL> collector . lower ( source ) <EOL> return super . lower ( source ) <EOL> }


{ <EOL> bar = "<STR_LIT>" <EOL> return bar <EOL> }


override fun equals ( other : Any ? ) : Boolean

{ <EOL> if ( this === other ) return true <EOL> if ( other == null || this :: class . java != other :: class . java ) return false <EOL> val bound = other as Bound <EOL> if ( typeVariable != bound . typeVariable ) return false <EOL> if ( constrainingType != bound . constrainingType ) return false <EOL> if ( kind != bound . kind ) return false <EOL> if ( position . isStrong ( ) != bound . position . isStrong ( ) ) return false <EOL> return true <EOL> }


{ <EOL> var result = typeVariable . hashCode ( ) <EOL> result = <NUM_LIT:31> * result + constrainingType . hashCode ( ) <EOL> result = <NUM_LIT:31> * result + kind . hashCode ( ) <EOL> result = <NUM_LIT:31> * result + if ( position . isStrong ( ) ) <NUM_LIT:1> else <NUM_LIT:0> <EOL> return result <EOL> }


= "<STR_LIT>"


= when ( this ) { <EOL> LOWER_BOUND -> UPPER_BOUND <EOL> UPPER_BOUND -> LOWER_BOUND <EOL> EXACT_BOUND -> EXACT_BOUND <EOL> }


override fun isAcceptable ( element : Any ? , context : PsiElement ? ) : Boolean

{ <EOL> if ( element == null ) return false <EOL> return getTextByElement ( element ) == value <EOL> }


override fun isClassAcceptable ( hintClass : Class < * > ) : Boolean

= true


private fun getTextByElement ( element : Any ) : String ?

{ <EOL> return when ( element ) { <EOL> is PsiType -> element . presentableText <EOL> is PsiNamedElement -> element . name <EOL> is PsiElement -> element . text <EOL> else -> null <EOL> } <EOL> }


{ <EOL> if ( element !is PsiElement ) return false <EOL> val previous = FilterPositionUtil . searchNonSpaceNonCommentBack ( element ) <EOL> return if ( previous != null ) getFilter ( ) . isAcceptable ( previous , context ) else false <EOL> }


internal fun Color . toEchartsColor ( ) : EchartsColor

= when ( this ) { <EOL> is StandardColor -> BaseColor ( this . description ) <EOL> is LinearGradient -> LinearGradientColor ( x , y , x2 , y2 , colorStops ) <EOL> is RadialGradient -> RadialGradientColor ( x , y , r , colorStops ) <EOL> else -> BaseColor ( this . toString ( ) ) <EOL> }


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


private fun FirExpression . canBeConsideredProperExpression ( ) : Boolean

{ <EOL> return when { <EOL> this is FirQualifiedAccessExpression && explicitReceiver ? . canBeConsideredProperExpression ( ) != true -> false <EOL> else -> true <EOL> } <EOL> }


private fun FirExpression . canBeConsideredProperType ( ) : Boolean

{ <EOL> return when { <EOL> this is FirFunctionCall && <EOL> explicitReceiver ? . canBeConsideredProperType ( ) != false -> false <EOL> this is FirQualifiedAccessExpression && <EOL> explicitReceiver ? . canBeConsideredProperType ( ) != false && <EOL> calleeReference is FirNamedReference -> true <EOL> this is FirResolvedQualifier -> true <EOL> else -> false <EOL> } <EOL> }


private fun shouldTryResolveLHSAsExpression ( expression : FirCallableReferenceAccess ) : Boolean

{ <EOL> val lhs = expression . explicitReceiver ? : return false <EOL> return lhs . canBeConsideredProperExpression ( ) && ! expression . hasQuestionMarkAtLHS <EOL> }


private fun shouldTryResolveLHSAsType ( expression : FirCallableReferenceAccess ) : Boolean

{ <EOL> val lhs = expression . explicitReceiver <EOL> return lhs != null && lhs . canBeConsideredProperType ( ) <EOL> }


internal fun resolveDoubleColonLHS ( doubleColonExpression : FirCallableReferenceAccess ) : DoubleColonLHS ?

{ <EOL> val resultForExpr = tryResolveLHS ( doubleColonExpression , this :: shouldTryResolveLHSAsExpression , this :: resolveExpressionOnLHS ) <EOL> if ( resultForExpr != null && ! resultForExpr . isObjectQualifier ) { <EOL> return resultForExpr <EOL> } <EOL> val resultForType = tryResolveLHS ( doubleColonExpression , this :: shouldTryResolveLHSAsType ) { expression -> <EOL> resolveTypeOnLHS ( expression ) <EOL> } <EOL> if ( resultForType != null ) { <EOL> if ( resultForExpr != null && resultForType . type == resultForExpr . type ) { <EOL> return resultForExpr <EOL> } <EOL> return resultForType <EOL> } <EOL> return resultForExpr <EOL> }


private fun < T : DoubleColonLHS > tryResolveLHS ( doubleColonExpression : FirCallableReferenceAccess , criterion : ( FirCallableReferenceAccess ) -> Boolean , resolve : ( FirExpression ) -> T ? <EOL> ) : T ?

{ <EOL> val expression = doubleColonExpression . explicitReceiver ? : return null <EOL> if ( ! criterion ( doubleColonExpression ) ) return null <EOL> return resolve ( expression ) <EOL> }

/**
 * Returns null if the LHS is definitely not an expression. Returns a non-null result if a resolution was attempted and led to
 * either a successful result or not.
 */


private fun FirResolvedQualifier . expandedRegularClassIfAny ( ) : FirRegularClass ?

{ <EOL> var fir = symbol ? . fir ? : return null <EOL> while ( fir is FirTypeAlias ) { <EOL> fir = fir . expandedConeType ? . lookupTag ? . toSymbol ( session ) ? . fir ? : return null <EOL> } <EOL> return fir as? FirRegularClass <EOL> }


private fun resolveExpressionOnLHS ( expression : FirExpression ) : DoubleColonLHS . Expression ?

{ <EOL> val type = expression . resolvedType <EOL> if ( expression is FirResolvedQualifier ) { <EOL> val firClass = expression . expandedRegularClassIfAny ( ) ? : return null <EOL> if ( firClass . classKind == ClassKind . OBJECT ) { <EOL> return DoubleColonLHS . Expression ( type , isObjectQualifier = true ) <EOL> } <EOL> return null <EOL> } <EOL> return DoubleColonLHS . Expression ( type , isObjectQualifier = false ) <EOL> }


private fun resolveTypeOnLHS ( expression : FirExpression ) : DoubleColonLHS . Type ?

{ <EOL> val resolvedExpression = expression as? FirResolvedQualifier <EOL> ? : return null <EOL> val firClassLikeDeclaration = resolvedExpression . symbol ? . fir <EOL> ? : return null <EOL> val type = ConeClassLikeTypeImpl ( firClassLikeDeclaration . symbol . toLookupTag ( ) , Array ( firClassLikeDeclaration . typeParameters . size ) { index -> <EOL> val typeArgument = expression . typeArguments . getOrNull ( index ) <EOL> if ( typeArgument == null ) { <EOL> val typeParameter = firClassLikeDeclaration . typeParameters [ <NUM_LIT:0> ] <EOL> if ( firClassLikeDeclaration . isLocal && typeParameter is FirOuterClassTypeParameterRef && typeParameter . symbol . containingDeclarationSymbol !is FirClassSymbol ) { <EOL> typeParameter . symbol . defaultType <EOL> } else { <EOL> ConeStarProjection <EOL> } <EOL> } else { <EOL> when ( typeArgument ) { <EOL> is FirTypeProjectionWithVariance -> { <EOL> val coneType = typeArgument . typeRef . coneType <EOL> when ( typeArgument . variance ) { <EOL> Variance . INVARIANT -> coneType <EOL> Variance . IN_VARIANCE -> ConeKotlinTypeProjectionIn ( coneType ) <EOL> Variance . OUT_VARIANCE -> ConeKotlinTypeProjectionOut ( coneType ) <EOL> } <EOL> } <EOL> else -> ConeStarProjection <EOL> } <EOL> } <EOL> } , isNullable = resolvedExpression . isNullableLHSForCallableReference ) <EOL> return DoubleColonLHS . Type ( type ) <EOL> }


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

{ <EOL> val containingClass = context . containingDeclarations . lastOrNull ( ) as? FirClass ? : return <EOL> val source = declaration . source <EOL> val elementType = source ? . elementType <EOL> if ( elementType != KtNodeTypes . PRIMARY_CONSTRUCTOR && elementType != KtNodeTypes . SECONDARY_CONSTRUCTOR ) { <EOL> return <EOL> } <EOL> when ( containingClass . classKind ) { <EOL> ClassKind . OBJECT -> reporter . reportOn ( source , FirErrors . CONSTRUCTOR_IN_OBJECT , context ) <EOL> ClassKind . INTERFACE -> reporter . reportOn ( source , FirErrors . CONSTRUCTOR_IN_INTERFACE , context ) <EOL> ClassKind . ENUM_ENTRY -> reporter . reportOn ( source , FirErrors . CONSTRUCTOR_IN_OBJECT , context ) <EOL> ClassKind . ENUM_CLASS -> if ( declaration . visibility != Visibilities . Private ) { <EOL> reporter . reportOn ( source , FirErrors . NON_PRIVATE_CONSTRUCTOR_IN_ENUM , context ) <EOL> } <EOL> ClassKind . CLASS -> when ( containingClass ) { <EOL> is FirAnonymousObject -> reporter . reportOn ( source , FirErrors . CONSTRUCTOR_IN_OBJECT , context ) <EOL> is FirRegularClass -> if ( containingClass . modality == Modality . SEALED ) { <EOL> val modifierList = source . getModifierList ( ) ? : return <EOL> val hasIllegalModifier = modifierList . modifiers . any { <EOL> val token = it . token <EOL> token in KtTokens . VISIBILITY_MODIFIERS && token != KtTokens . PROTECTED_KEYWORD && token != KtTokens . PRIVATE_KEYWORD <EOL> } <EOL> if ( hasIllegalModifier ) { <EOL> reporter . reportOn ( source , FirErrors . NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED , context ) <EOL> } <EOL> } <EOL> } <EOL> ClassKind . ANNOTATION_CLASS -> { <EOL> } <EOL> } <EOL> }


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

{ <EOL> val descriptor = resolvedCall . candidateDescriptor <EOL> if ( descriptor !is FunctionDescriptor || ! descriptor . isSuspend ) return <EOL> val enclosingSuspendFunctionSource = <EOL> findEnclosingSuspendFunction ( context ) ? . source ? . getPsi ( ) ? : return <EOL> var parent = reportOn <EOL> var child = reportOn <EOL> var insideLambda = false <EOL> while ( parent != enclosingSuspendFunctionSource ) { <EOL> if ( parent is KtCallExpression ) { <EOL> if ( checkCall ( context , parent , child , insideLambda , reportOn , resolvedCall ) ) break <EOL> } <EOL> if ( parent is KtLambdaExpression ) { <EOL> insideLambda = true <EOL> } <EOL> if ( parent !is KtValueArgumentList ) { <EOL> child = parent <EOL> } <EOL> parent = parent . parent ? : return <EOL> } <EOL> }


private fun checkCall ( context : CallCheckerContext , parent : KtCallExpression , child : PsiElement , insideLambda : Boolean , reportOn : PsiElement , resolvedCall : ResolvedCall < * > ) : Boolean

{ <EOL> val call = context . trace [ BindingContext . CALL , parent . calleeExpression ] ? : return false <EOL> val resolved = context . trace [ BindingContext . RESOLVED_CALL , call ] ? : return false <EOL> val isSynchronized = resolved . resultingDescriptor . isTopLevelInPackage ( "<STR_LIT>" , "<STR_LIT:kotlin>" ) <EOL> if ( isSynchronized ) { <EOL> val isSecondArgument = ( resolved . valueArgumentsByIndex ? . get ( <NUM_LIT:1> ) as? ExpressionValueArgument ) ? . valueArgument == child <EOL> if ( insideLambda && isSecondArgument ) { <EOL> reportProblem ( context , reportOn , resolvedCall ) <EOL> } <EOL> return true <EOL> } <EOL> val isWithLock = resolved . resultingDescriptor . isTopLevelInPackage ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> if ( isWithLock ) { <EOL> reportProblem ( context , reportOn , resolvedCall ) <EOL> return true <EOL> } <EOL> return false <EOL> }


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

{ <EOL> context . trace . report ( ErrorsJvm . SUSPENSION_POINT_INSIDE_CRITICAL_SECTION . on ( reportOn , resolvedCall . resultingDescriptor ) ) <EOL> }


public open operator fun equals ( other : Any ? ) : Boolean

= TODO ( )


= TODO ( )


fun getElement ( element : @ UnsafeVariance E ) : E ?

/**
 * Searches for the specified element in this set.
 *
 * @return the element from the set equal to [element], or `null` if no such element found.
 */


fun second ( ) : Int


= <NUM_LIT:1>


= <NUM_LIT:2>


{ <EOL> val b = B ( ) <EOL> val a : A = b <EOL> val c = C ( ) <EOL> a . second ( ) <EOL> b . second ( ) <EOL> c . second ( ) <EOL> }


protected abstract fun applyImpl ( data : FloatArray , shape : TensorShape ) : FloatArray

/**
 * Actual implementation of the [Operation] that should be applied to the [data].
 */


override fun apply ( input : FloatData ) : FloatData

{ <EOL> val ( data , shape ) = input <EOL> return applyImpl ( data , shape ) to getOutputShape ( shape ) <EOL> }


override fun getOutputShape ( inputShape : TensorShape ) : TensorShape

= inputShape


internal fun KType . shouldBeConvertedToFrameColumn ( ) : Boolean

= when ( jvmErasure ) { <EOL> DataFrame :: class -> true <EOL> List :: class -> arguments [ <NUM_LIT:0> ] . type ? . jvmErasure ? . hasAnnotation < DataSchema > ( ) == true <EOL> else -> false <EOL> }


internal fun KType . shouldBeConvertedToColumnGroup ( ) : Boolean

= jvmErasure . let { <EOL> it == DataRow :: class || it . hasAnnotation < DataSchema > ( ) <EOL> }


private fun String . toNullable ( ) : String

= if ( endsWith ( "<STR_LIT:?>" ) ) this else "<STR_LIT>"


= get ( T :: class )


fun get ( markerClass : KClass < * > , nullableProperties : Boolean = false ) : Marker

= <EOL> cache . getOrPut ( Pair ( markerClass , nullableProperties ) ) { <EOL> val fields = getFields ( markerClass , nullableProperties ) <EOL> val isOpen = ! markerClass . isSealed && <EOL> markerClass . java . isInterface && <EOL> markerClass . findAnnotation < DataSchema > ( ) ? . isOpen == true <EOL> val baseSchemas = markerClass . superclasses . filter { it != Any :: class } . map { get ( it , nullableProperties ) } <EOL> Marker ( name = markerClass . qualifiedName ? : markerClass . simpleName ! ! , isOpen = isOpen , fields = fields , superMarkers = baseSchemas , visibility = MarkerVisibility . IMPLICIT_PUBLIC , klass = markerClass , ) <EOL> }


private fun getFields ( markerClass : KClass < * > , nullableProperties : Boolean ) : List < GeneratedField >

{ <EOL> val order = getPropertiesOrder ( markerClass ) <EOL> return markerClass . memberProperties . sortedBy { order [ it . name ] ? : Int . MAX_VALUE } . mapIndexed { _ , it -> <EOL> val fieldName = ValidFieldName . of ( it . name ) <EOL> val columnName = it . findAnnotation < ColumnName > ( ) ? . name ? : fieldName . unquoted <EOL> val type = it . returnType <EOL> val fieldType : FieldType <EOL> val clazz = type . jvmErasure <EOL> val columnSchema = when { <EOL> type . shouldBeConvertedToColumnGroup ( ) -> { <EOL> val nestedType = if ( clazz == DataRow :: class ) type . arguments [ <NUM_LIT:0> ] . type ? : typeOf < Any ? > ( ) else type <EOL> val marker = get ( nestedType . jvmErasure , nullableProperties || type . isMarkedNullable ) <EOL> fieldType = FieldType . GroupFieldType ( marker . name ) <EOL> ColumnSchema . Group ( marker . schema , nestedType ) <EOL> } <EOL> type . shouldBeConvertedToFrameColumn ( ) -> { <EOL> val frameType = type . arguments [ <NUM_LIT:0> ] . type ? : typeOf < Any ? > ( ) <EOL> val marker = get ( frameType . jvmErasure , nullableProperties || type . isMarkedNullable ) <EOL> fieldType = FieldType . FrameFieldType ( marker . name , type . isMarkedNullable || nullableProperties ) <EOL> ColumnSchema . Frame ( marker . schema , type . isMarkedNullable , frameType ) <EOL> } <EOL> else -> { <EOL> fieldType = FieldType . ValueFieldType ( if ( nullableProperties ) type . toString ( ) . toNullable ( ) else type . toString ( ) ) <EOL> ColumnSchema . Value ( if ( nullableProperties ) type . withNullability ( true ) else type ) <EOL> } <EOL> } <EOL> GeneratedField ( fieldName , columnName , false , columnSchema , fieldType ) <EOL> } <EOL> }


@ Test <EOL> fun testParseDataString ( )

= parametrizedTest { streaming -> <EOL> val ev = default . decodeFromString ( Event . serializer ( ) , inputDataString , streaming ) <EOL> with ( ev ) { <EOL> assertEquals ( <NUM_LIT:0> , id ) <EOL> assertEquals ( Either . Right ( Payload ( <NUM_LIT:42> , <NUM_LIT> , "<STR_LIT>" ) ) , payload ) <EOL> assertEquals ( <NUM_LIT> , timestamp ) <EOL> } <EOL> }


@ Test <EOL> fun testParseErrorString ( )

= parametrizedTest { jsonTestingMode -> <EOL> val ev = default . decodeFromString ( Event . serializer ( ) , inputErrorString , jsonTestingMode ) <EOL> with ( ev ) { <EOL> assertEquals ( <NUM_LIT:1> , id ) <EOL> assertEquals ( Either . Left ( "<STR_LIT>" ) , payload ) <EOL> assertEquals ( <NUM_LIT> , timestamp ) <EOL> } <EOL> }


@ Test <EOL> fun testWriteDataString ( )

= parametrizedTest { jsonTestingMode -> <EOL> val outputData = Event ( <NUM_LIT:0> , Either . Right ( Payload ( <NUM_LIT:42> , <NUM_LIT> , "<STR_LIT>" ) ) , <NUM_LIT> ) <EOL> val ev = default . encodeToString ( Event . serializer ( ) , outputData , jsonTestingMode ) <EOL> assertEquals ( inputDataString , ev ) <EOL> }


@ Test <EOL> fun testWriteDataStringIndented ( )

= parametrizedTest { jsonTestingMode -> <EOL> val outputData = Event ( <NUM_LIT:0> , Either . Right ( Payload ( <NUM_LIT:42> , <NUM_LIT> , "<STR_LIT>" ) ) , <NUM_LIT> ) <EOL> val ev = Json { prettyPrint = true } . encodeToString ( Event . serializer ( ) , outputData , jsonTestingMode ) <EOL> assertEquals ( """<STR_LIT>""" . trimMargin ( ) , ev ) <EOL> }


@ Test <EOL> fun testWriteErrorString ( )

= parametrizedTest { jsonTestingMode -> <EOL> val outputError = Event ( <NUM_LIT:1> , Either . Left ( "<STR_LIT>" ) , <NUM_LIT> ) <EOL> val ev = default . encodeToString ( Event . serializer ( ) , outputError , jsonTestingMode ) <EOL> assertEquals ( inputErrorString , ev ) <EOL> }


{ <EOL> val ev = default . decodeFromJsonElement ( Event . serializer ( ) , inputDataJson ) <EOL> with ( ev ) { <EOL> assertEquals ( <NUM_LIT:0> , id ) <EOL> assertEquals ( Either . Right ( Payload ( <NUM_LIT:42> , <NUM_LIT> , "<STR_LIT>" ) ) , payload ) <EOL> assertEquals ( <NUM_LIT> , timestamp ) <EOL> } <EOL> }


{ <EOL> val ev = default . decodeFromJsonElement ( Event . serializer ( ) , inputErrorJson ) <EOL> with ( ev ) { <EOL> assertEquals ( <NUM_LIT:1> , id ) <EOL> assertEquals ( Either . Left ( "<STR_LIT>" ) , payload ) <EOL> assertEquals ( <NUM_LIT> , timestamp ) <EOL> } <EOL> }


{ <EOL> val outputData = Event ( <NUM_LIT:0> , Either . Right ( Payload ( <NUM_LIT:42> , <NUM_LIT> , "<STR_LIT>" ) ) , <NUM_LIT> ) <EOL> val ev = default . encodeToJsonElement ( Event . serializer ( ) , outputData ) <EOL> assertEquals ( inputDataJson , ev ) <EOL> }


{ <EOL> val outputError = Event ( <NUM_LIT:1> , Either . Left ( "<STR_LIT>" ) , <NUM_LIT> ) <EOL> val ev = default . encodeToJsonElement ( Event . serializer ( ) , outputError ) <EOL> assertEquals ( inputErrorJson , ev ) <EOL> }


= parametrizedTest { jsonTestingMode -> <EOL> val ev = default . decodeFromString ( RecursiveSerializer , inputRecursive , jsonTestingMode ) <EOL> assertEquals ( outputRecursive , ev ) <EOL> }


= parametrizedTest { jsonTestingMode -> <EOL> val ev = default . encodeToString ( RecursiveSerializer , outputRecursive , jsonTestingMode ) <EOL> assertEquals ( inputRecursive , ev ) <EOL> }


override fun deserialize ( decoder : Decoder ) : Either

{ <EOL> val jsonReader = decoder as? JsonDecoder <EOL> ? : throw SerializationException ( "<STR_LIT>" ) <EOL> val tree = jsonReader . decodeJsonElement ( ) as? JsonObject <EOL> ? : throw SerializationException ( "<STR_LIT>" ) <EOL> if ( "<STR_LIT:error>" in tree ) return Either . Left ( tree . getValue ( "<STR_LIT:error>" ) . jsonPrimitive . content ) <EOL> return Either . Right ( decoder . json . decodeFromJsonElement ( Payload . serializer ( ) , tree ) ) <EOL> }


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

{ <EOL> val jsonWriter = encoder as? JsonEncoder <EOL> ? : throw SerializationException ( "<STR_LIT>" ) <EOL> val tree = when ( value ) { <EOL> is Either . Left -> JsonObject ( mapOf ( "<STR_LIT:error>" to JsonPrimitive ( value . errorMsg ) ) ) <EOL> is Either . Right -> encoder . json . encodeToJsonElement ( Payload . serializer ( ) , value . data ) <EOL> } <EOL> jsonWriter . encodeJsonElement ( tree ) <EOL> }


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

{ <EOL> if ( encoder !is JsonEncoder ) throw SerializationException ( "<STR_LIT>" ) <EOL> val ( tree , typeName ) = when ( value ) { <EOL> is SealedRecursive . A -> encoder . json . encodeToJsonElement ( SealedRecursive . A . serializer ( ) , value ) to typeNameA <EOL> is SealedRecursive . B -> encoder . json . encodeToJsonElement ( SealedRecursive . B . serializer ( ) , value ) to typeNameB <EOL> } <EOL> val contents : MutableMap < String , JsonElement > = mutableMapOf ( typeAttribute to JsonPrimitive ( typeName ) ) <EOL> contents . putAll ( tree . jsonObject ) <EOL> val element = JsonObject ( contents ) <EOL> encoder . encodeJsonElement ( element ) <EOL> }


override fun deserialize ( decoder : Decoder ) : SealedRecursive

{ <EOL> val jsonReader = decoder as? JsonDecoder <EOL> ? : throw SerializationException ( "<STR_LIT>" ) <EOL> val tree = jsonReader . decodeJsonElement ( ) as? JsonObject <EOL> ? : throw SerializationException ( "<STR_LIT>" ) <EOL> val typeName = tree . getValue ( typeAttribute ) . jsonPrimitive . content <EOL> val objTree = JsonObject ( tree - typeAttribute ) <EOL> return when ( typeName ) { <EOL> typeNameA -> decoder . json . decodeFromJsonElement ( SealedRecursive . A . serializer ( ) , objTree ) <EOL> typeNameB -> decoder . json . decodeFromJsonElement ( SealedRecursive . B . serializer ( ) , objTree ) <EOL> else -> throw SerializationException ( "<STR_LIT>" ) <EOL> } <EOL> }


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( KOTLIN_OPTIONS_AS_TOOLS_DEPRECATION_MESSAGE ) <EOL> fun kotlinOptions ( fn : KotlinCommonToolOptions . ( ) -> Unit )

{ <EOL> kotlinOptions . fn ( ) <EOL> }


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( KOTLIN_OPTIONS_AS_TOOLS_DEPRECATION_MESSAGE ) <EOL> fun kotlinOptions ( fn : Action < KotlinCommonToolOptions > )

{ <EOL> fn . execute ( kotlinOptions ) <EOL> }


{ <EOL> val metricReporter = metrics . get ( ) <EOL> addBuildMetricsForTaskAction ( metricsReporter = metricReporter , languageVersion = null ) { <EOL> val outFile = outputFile . get ( ) <EOL> outFile . ensureParentDirsCreated ( ) <EOL> fun FileCollection . klibs ( ) = files . filter { it . extension == "<STR_LIT>" } <EOL> val buildArgs = buildKotlinNativeBinaryLinkerArgs ( outFile = outFile , optimized = optimized . get ( ) , debuggable = debuggable . get ( ) , target = konanTarget , outputKind = outputKind , libraries = libraries . klibs ( ) , friendModules = emptyList ( ) , toolOptions = toolOptions , compilerPlugins = emptyList ( ) , processTests = processTests . get ( ) , entryPoint = entryPoint . getOrNull ( ) , embedBitcode = bitcodeEmbeddingMode ( ) , linkerOpts = linkerOptions . get ( ) , binaryOptions = allBinaryOptions . get ( ) , isStaticFramework = staticFramework . get ( ) , exportLibraries = exportLibraries . klibs ( ) , includeLibraries = includeLibraries . klibs ( ) , additionalOptions = emptyList ( ) ) <EOL> KotlinNativeCompilerRunner ( settings = runnerSettings , executionContext = KotlinToolRunner . GradleExecutionContext . fromTaskContext ( objectFactory , execOperations , logger ) , metricReporter , ) . run ( buildArgs ) <EOL> } <EOL> }


private fun bitcodeEmbeddingMode ( ) : BitcodeEmbeddingMode

{ <EOL> return XcodeUtils . bitcodeEmbeddingMode ( outputKind , embedBitcode . orNull , xcodeVersion , konanTarget , debuggable . get ( ) ) <EOL> }


= x . foo


fun setFooValue ( x : Int , value : String )

{ <EOL> x . foo = value <EOL> }


{ <EOL> var d = Derived ( ) <EOL> assertEquals ( "<STR_LIT>" , d . getFooValue ( <NUM_LIT:5> ) ) <EOL> d . setFooValue ( <NUM_LIT:10> , "<STR_LIT:A>" ) <EOL> assertEquals ( "<STR_LIT>" , d . prop ) <EOL> return "<STR_LIT:OK>" <EOL> }


override fun doTestByMainFile ( mainFile : KtFile , mainModule : KtTestModule , testServices : TestServices )

{ <EOL> val targetElement = testServices . expressionMarkerProvider <EOL> . getBottommostSelectedElementOfType ( mainFile , KtElement :: class . java ) <EOL> assertNull ( targetElement . getNonLocalReanalyzableContainingDeclaration ( ) ) <EOL> val actualText = testInBlockModification ( mainFile , mainFile , testServices , dumpFirFile = false ) <EOL> testServices . assertions . assertEqualsToTestDataFileSibling ( actualText ) <EOL> }


fun < T : Any > bar ( a : Array < T > ) : Array < T ? >

= null ! !


{ <EOL> val r : Array < out Int ? > = bar ( a ) <EOL> val t = bar ( a ) <EOL> t checkType { _ < Array < out Int ? > > ( ) } <EOL> }


fun < T : Any > foo ( l : Array < T > ) : Array < Array < T ? > >

= null ! !


{ <EOL> val r : Array < out Array < out Int ? > > = foo ( a ) <EOL> val t = foo ( a ) <EOL> t checkType { _ < Array < out Array < out Int ? > > > ( ) } <EOL> }


@ ExperimentalSerializationApi <EOL> public fun decodeStringChunked ( consumeChunk : ( chunk : String ) -> Unit )

/**
 * Method allows decoding a string value by fixed-size chunks.
 * Usable for handling very large strings that may not fit in memory.
 * Chunk size is guaranteed to not exceed 16384 chars (but it may be smaller than that).
 * Feeds string chunks to the provided consumer.
 *
 * @param consumeChunk - lambda function to handle string chunks
 *
 * Example usage:
 * ```
 * @Serializable(with = LargeStringSerializer::class)
 * data class LargeStringData(val largeString: String)
 *
 * @Serializable
 * data class ClassWithLargeStringDataField(val largeStringField: LargeStringData)
 *
 * object LargeStringSerializer : KSerializer<LargeStringData> {
 * override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("LargeStringContent", PrimitiveKind.STRING)
 *
 * override fun deserialize(decoder: Decoder): LargeStringData {
 * require(decoder is ChunkedDecoder) { "Only chunked decoder supported" }
 *
 * val tmpFile = createTempFile()
 * val writer = FileWriter(tmpFile.toFile()).use {
 * decoder.decodeStringChunked { chunk ->
 * writer.append(chunk)
 * }
 * }
 * return LargeStringData("file://${tmpFile.absolutePathString()}")
 * }
 * }
 * ```
 *
 * In this sample, we need to be able to handle a huge string coming from json. Instead of storing it in memory,
 * we offload it into a file and return the file name instead
 */


= fs ( Z ( "<STR_LIT:O>" ) )


{ <EOL> val t = foo1 { Z ( it . value + "<STR_LIT:K>" ) } <EOL> if ( t . value != "<STR_LIT:OK>" ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


@ Test <EOL> fun `should substitute AddToNavigationCommand in root directory` ( @ TempDir outputDirectory : File )

{ <EOL> addToNavigationTest ( outputDirectory ) { <EOL> val output = outputDirectory . resolve ( "<STR_LIT>" ) . readText ( ) <EOL> val expected = expectedOutput ( ModuleWithPrefix ( "<STR_LIT>" ) , ModuleWithPrefix ( "<STR_LIT>" ) ) <EOL> assertHtmlEqualsIgnoringWhitespace ( expected , output ) <EOL> } <EOL> }


@ ParameterizedTest <EOL> @ ValueSource ( strings = [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> fun `should substitute AddToNavigationCommand in modules directory` ( moduleName : String , @ TempDir outputDirectory : File )

{ <EOL> addToNavigationTest ( outputDirectory ) { <EOL> val output = outputDirectory . resolve ( moduleName ) . resolve ( "<STR_LIT>" ) . readText ( ) <EOL> val expected = expectedOutput ( ModuleWithPrefix ( "<STR_LIT>" , "<STR_LIT>" ) , ModuleWithPrefix ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> assertHtmlEqualsIgnoringWhitespace ( expected , output ) <EOL> } <EOL> }


private fun expectedOutput ( vararg modulesWithPrefix : ModuleWithPrefix )

= createHTML ( prettyPrint = true ) <EOL> . div ( "<STR_LIT>" ) { <EOL> modulesWithPrefix . forEach { ( moduleName , prefix ) -> <EOL> val relativePrefix = prefix ? . let { "<STR_LIT>" } ? : "<STR_LIT>" <EOL> div ( "<STR_LIT>" ) { <EOL> id = "<STR_LIT>" <EOL> div ( "<STR_LIT>" ) { <EOL> a { <EOL> href = "<STR_LIT>" <EOL> span { <EOL> + "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> div ( "<STR_LIT>" ) { <EOL> id = "<STR_LIT>" <EOL> div ( "<STR_LIT>" ) { <EOL> a { <EOL> href = "<STR_LIT>" <EOL> span { <EOL> + "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> }


private fun inputForModule ( moduleName : String )

= createHTML ( ) <EOL> . templateCommand ( AddToNavigationCommand ( moduleName ) ) { <EOL> div ( "<STR_LIT>" ) { <EOL> id = "<STR_LIT>" <EOL> div ( "<STR_LIT>" ) { <EOL> a { <EOL> href = "<STR_LIT>" <EOL> span { <EOL> + "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> div ( "<STR_LIT>" ) { <EOL> id = "<STR_LIT>" <EOL> div ( "<STR_LIT>" ) { <EOL> a { <EOL> href = "<STR_LIT>" <EOL> span { <EOL> + "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> }


private fun addToNavigationTest ( outputDirectory : File , test : ( DokkaContext ) -> Unit )

{ <EOL> val module1 = outputDirectory . resolve ( "<STR_LIT>" ) . also { it . mkdirs ( ) } <EOL> val module2 = outputDirectory . resolve ( "<STR_LIT>" ) . also { it . mkdirs ( ) } <EOL> val configuration = dokkaConfiguration { <EOL> modules = listOf ( DokkaModuleDescriptionImpl ( name = "<STR_LIT>" , relativePathToOutputDirectory = module1 , includes = emptySet ( ) , sourceOutputDirectory = module1 , ) , DokkaModuleDescriptionImpl ( name = "<STR_LIT>" , relativePathToOutputDirectory = module2 , includes = emptySet ( ) , sourceOutputDirectory = module2 , ) , ) <EOL> this . outputDir = outputDirectory <EOL> } <EOL> val module1Navigation = module1 . resolve ( "<STR_LIT>" ) <EOL> module1Navigation . writeText ( inputForModule ( "<STR_LIT>" ) ) <EOL> val module2Navigation = module2 . resolve ( "<STR_LIT>" ) <EOL> module2Navigation . writeText ( inputForModule ( "<STR_LIT>" ) ) <EOL> testFromData ( configuration , useOutputLocationFromConfig = true ) { <EOL> finishProcessingSubmodules = { ctx -> <EOL> test ( ctx ) <EOL> } <EOL> } <EOL> }


inline fun < reified T : Any > getSer ( module : SerializersModule ) : KSerializer < T >

{ <EOL> return module . serializer ( ) <EOL> }


{ <EOL> module . serializer < Simple > ( ) <EOL> module . serializer < NoSer > ( ) <EOL> module . serializer < List < Simple > > ( ) <EOL> module . serializer < List < NoSer > > ( ) <EOL> getSer < Simple > ( module ) <EOL> getSer < NoSer > ( module ) <EOL> getSer < NoSerGeneric < Simple > > ( module ) <EOL> getSer < NoSerGeneric < NoSer > > ( module ) <EOL> }


= combine ( flow , flow2 , flow3 , flow4 , flow5 , flow6 , flow7 , flow8 , flow9 , flow10 , flow11 , flow12 , flow13 , flow14 , flow15 , flow16 , flow17 , flow18 , flow19 , flow20 , flow21 , flow22 , flow23 ) { args : Array < * > -> <EOL> transform ( args [ <NUM_LIT:0> ] as T1 , args [ <NUM_LIT:1> ] as T2 , args [ <NUM_LIT:2> ] as T3 , args [ <NUM_LIT:3> ] as T4 , args [ <NUM_LIT:4> ] as T5 , args [ <NUM_LIT:5> ] as T6 , args [ <NUM_LIT:6> ] as T7 , args [ <NUM_LIT:7> ] as T8 , args [ <NUM_LIT:8> ] as T9 , args [ <NUM_LIT:9> ] as T10 , args [ <NUM_LIT:10> ] as T11 , args [ <NUM_LIT:11> ] as T12 , args [ <NUM_LIT:12> ] as T13 , args [ <NUM_LIT> ] as T14 , args [ <NUM_LIT> ] as T15 , args [ <NUM_LIT> ] as T16 , args [ <NUM_LIT:16> ] as T17 , args [ <NUM_LIT> ] as T18 , args [ <NUM_LIT> ] as T19 , args [ <NUM_LIT> ] as T20 , args [ <NUM_LIT:20> ] as T21 , args [ <NUM_LIT> ] as T22 , args [ <NUM_LIT> ] as T23 , ) <EOL> }


fun bar ( a : A , extLambda : A . ( Int , String ) -> String ) : String

= a . extLambda ( <NUM_LIT:7> , "<STR_LIT>" )


internal external fun nativeBox ( b : B ) : String

= definedExternally


{ <EOL> val r = nativeBox ( B ( ) ) <EOL> if ( r != "<STR_LIT>" ) return r <EOL> return "<STR_LIT:OK>" <EOL> }


override fun check ( expression : FirLoop , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> val parent = if ( context . containingElements . size >= <NUM_LIT:2> ) context . containingElements [ context . containingElements . size - <NUM_LIT:2> ] else return <EOL> if ( parent . source ? . kind != KtFakeSourceElementKind . DesugaredForLoop ) return <EOL> val grandParent = if ( context . containingElements . size >= <NUM_LIT:3> ) <EOL> context . containingElements [ context . containingElements . size - <NUM_LIT:3> ] <EOL> else <EOL> return <EOL> if ( grandParent is FirBlock || ( grandParent is FirReturnExpression && grandParent . source ? . kind == KtFakeSourceElementKind . ImplicitReturn . FromLastStatement ) || ( grandParent is FirProperty && ( grandParent . origin as? FirDeclarationOrigin . ScriptCustomization ) ? . kind == FirScriptCustomizationKind . RESULT_PROPERTY ) || ( grandParent is FirErrorExpression ) ) <EOL> return <EOL> reporter . reportOn ( expression . source , FirErrors . EXPRESSION_EXPECTED , context ) <EOL> }


operator fun IntArray . set ( index : Long , elem : Int )

{ this [ index . toInt ( ) ] = elem }


operator fun IntArray . get ( index : Long )

= this [ index . toInt ( ) ]


{ <EOL> var l = IntArray ( <NUM_LIT:1> ) <EOL> l [ <NUM_LIT:0> . toLong ( ) ] = <NUM_LIT:4> <EOL> l [ <NUM_LIT:0> . toLong ( ) ] += <NUM_LIT:6> <EOL> return if ( l [ <NUM_LIT:0> . toLong ( ) ] == <NUM_LIT:10> ) "<STR_LIT:OK>" else "<STR_LIT:Fail>" <EOL> }


@ Test <EOL> fun testCborDecodingException ( )

= checkRecovered < CborDecodingException > { <EOL> Cbor . decodeFromByteArray < String > ( byteArrayOf ( <NUM_LIT> . toByte ( ) ) ) <EOL> }


private inline fun < reified E : Exception > checkRecovered ( noinline block : ( ) -> Unit )

= runBlocking { <EOL> val result = runCatching { <EOL> callBlockWithRecovery ( block ) <EOL> } <EOL> assertTrue ( result . isFailure , "<STR_LIT>" ) <EOL> val e = result . exceptionOrNull ( ) ! ! <EOL> assertEquals ( E :: class , e :: class ) <EOL> val cause = e . cause <EOL> assertNotNull ( cause , "<STR_LIT>" ) <EOL> assertEquals ( e . message , cause . message ) <EOL> assertEquals ( E :: class , cause :: class ) <EOL> }


private suspend fun callBlockWithRecovery ( block : ( ) -> Unit )

{ <EOL> yield ( ) <EOL> withContext ( NonCancellable ) { <EOL> block ( ) <EOL> } <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:5> , fibi . take ( <NUM_LIT:3> ) . last ( ) ) <EOL> }


= this == Equals || this == IsSuper


= this == Equals


public fun combine ( other : CompareResult ) : CompareResult

= <EOL> when ( this ) { <EOL> Equals -> other <EOL> None -> None <EOL> IsDerived -> if ( other == Equals || other == IsDerived ) this else None <EOL> IsSuper -> if ( other == Equals || other == IsSuper ) this else None <EOL> }


public fun compareNullability ( thisIsNullable : Boolean , otherIsNullable : Boolean ) : CompareResult

= when { <EOL> thisIsNullable == otherIsNullable -> Equals <EOL> thisIsNullable -> IsSuper <EOL> else -> IsDerived <EOL> }


= { <NUM_LIT:42> }


private fun DProperty . hasModifier ( modifier : ExtraModifiers . KotlinOnlyModifiers ) : Boolean

= <EOL> extra [ AdditionalModifiers ] <EOL> ? . content <EOL> ? . any { ( _ , modifiers ) -> modifier in modifiers } == true


internal fun DPackage . asJava ( ) : DPackage

{ <EOL> val syntheticClasses = <EOL> ( properties . map { jvmNameProvider . nameForSyntheticClass ( it ) to it } + functions . map { jvmNameProvider . nameForSyntheticClass ( it ) to it } ) <EOL> . groupBy ( { it . first } ) { it . second } <EOL> . map { ( syntheticClassName , nodes ) -> <EOL> DClass ( dri = dri . withClass ( syntheticClassName . name ) , name = syntheticClassName . name , properties = nodes . filterIsInstance < DProperty > ( ) . filterNot { it . hasJvmSynthetic ( ) } . map { it . asJava ( true ) } , constructors = emptyList ( ) , functions = ( nodes . filterIsInstance < DProperty > ( ) . filterNot { it . isConst || it . isJvmField || it . hasJvmSynthetic ( ) } . flatMap { it . javaAccessors ( relocateToClass = syntheticClassName . name ) } + nodes . filterIsInstance < DFunction > ( ) . flatMap { it . asJava ( syntheticClassName . name , true ) } ) . filterNot { it . hasJvmSynthetic ( ) } , classlikes = emptyList ( ) , sources = emptyMap ( ) , expectPresentInSet = null , visibility = sourceSets . associateWith { <EOL> JavaVisibility . Public <EOL> } , companion = null , generics = emptyList ( ) , supertypes = emptyMap ( ) , documentation = emptyMap ( ) , modifier = sourceSets . associateWith { JavaModifier . Final } , sourceSets = sourceSets , isExpectActual = false , extra = PropertyContainer . empty ( ) ) <EOL> } <EOL> return copy ( functions = emptyList ( ) , properties = emptyList ( ) , classlikes = classlikes . map { it . asJava ( ) } + syntheticClasses , typealiases = emptyList ( ) ) <EOL> }


internal fun DProperty . asJava ( isTopLevel : Boolean = false , relocateToClass : String ? = null , isFromObjectOrCompanion : Boolean = false )

= <EOL> copy ( dri = if ( relocateToClass . isNullOrBlank ( ) ) { <EOL> dri <EOL> } else { <EOL> dri . withClass ( relocateToClass ) <EOL> } , modifier = javaModifierFromSetter ( ) , visibility = visibility . mapValues { <EOL> if ( isConst || isJvmField || ( getter == null && setter == null ) || ( isFromObjectOrCompanion && isLateInit ) ) { <EOL> it . value . asJava ( ) <EOL> } else { <EOL> it . value . propertyVisibilityAsJava ( ) <EOL> } <EOL> } , type = type . asJava ( ) , setter = null , getter = null , extra = if ( isTopLevel || isConst || ( isFromObjectOrCompanion && isJvmField ) || ( isFromObjectOrCompanion && isLateInit ) ) extra + extra . mergeAdditionalModifiers ( sourceSets . associateWith { <EOL> setOf ( ExtraModifiers . JavaOnlyModifiers . Static ) <EOL> } ) else extra )


= <EOL> when ( this ) { <EOL> is JavaVisibility -> this <EOL> is KotlinVisibility . Public , KotlinVisibility . Internal -> JavaVisibility . Public <EOL> is KotlinVisibility . Private -> JavaVisibility . Private <EOL> is KotlinVisibility . Protected -> JavaVisibility . Protected <EOL> }


internal fun DProperty . javaModifierFromSetter ( )

= <EOL> modifier . mapValues { <EOL> when { <EOL> it . value is JavaModifier -> it . value <EOL> setter == null -> JavaModifier . Final <EOL> else -> JavaModifier . Empty <EOL> } <EOL> }


internal fun DProperty . javaAccessors ( isTopLevel : Boolean = false , relocateToClass : String ? = null ) : List < DFunction >

= <EOL> listOfNotNull ( getter ? . let { getter -> <EOL> val name = "<STR_LIT:get>" + name . capitalize ( ) <EOL> getter . copy ( dri = if ( relocateToClass . isNullOrBlank ( ) ) { <EOL> getter . dri <EOL> } else { <EOL> getter . dri . withClass ( relocateToClass ) <EOL> } . withCallableName ( name ) , name = name , modifier = javaModifierFromSetter ( ) , visibility = visibility . mapValues { JavaVisibility . Public } , type = getter . type . asJava ( ) , extra = if ( isTopLevel ) getter . extra + getter . extra . mergeAdditionalModifiers ( sourceSets . associateWith { <EOL> setOf ( ExtraModifiers . JavaOnlyModifiers . Static ) <EOL> } ) else getter . extra ) <EOL> } , setter ? . let { setter -> <EOL> val name = "<STR_LIT:set>" + name . capitalize ( ) <EOL> val baseDRI = ( if ( relocateToClass . isNullOrBlank ( ) ) { <EOL> setter . dri <EOL> } else { <EOL> setter . dri . withClass ( relocateToClass ) <EOL> } ) . withCallableName ( name ) <EOL> setter . copy ( dri = baseDRI , name = name , parameters = setter . parameters . map { <EOL> it . copy ( dri = baseDRI . copy ( target = it . dri . target , extra = it . dri . extra ) , type = it . type . asJava ( ) ) <EOL> } , modifier = javaModifierFromSetter ( ) , visibility = visibility . mapValues { JavaVisibility . Public } , type = Void , extra = if ( isTopLevel ) setter . extra + setter . extra . mergeAdditionalModifiers ( sourceSets . associateWith { <EOL> setOf ( ExtraModifiers . JavaOnlyModifiers . Static ) <EOL> } ) else setter . extra ) <EOL> } )


private fun DFunction . asJava ( containingClassName : String , newName : String , parameters : List < DParameter > , isTopLevel : Boolean = false ) : DFunction

{ <EOL> return copy ( dri = dri . copy ( classNames = containingClassName , callable = dri . callable ? . copy ( name = newName ) ) , name = newName , type = type . asJava ( ) , modifier = if ( modifier . all { ( _ , v ) -> v is KotlinModifier . Final } && isConstructor ) sourceSets . associateWith { JavaModifier . Empty } else sourceSets . associateWith { modifier . values . first ( ) } , parameters = listOfNotNull ( receiver ? . asJava ( ) ) + parameters . map { it . asJava ( ) } , visibility = visibility . map { ( sourceSet , visibility ) -> Pair ( sourceSet , visibility . asJava ( ) ) } . toMap ( ) , receiver = null , extra = if ( isTopLevel || isJvmStatic ) { <EOL> extra + extra . mergeAdditionalModifiers ( sourceSets . associateWith { <EOL> setOf ( ExtraModifiers . JavaOnlyModifiers . Static ) <EOL> } ) <EOL> } else { <EOL> extra <EOL> } ) <EOL> }


private fun DFunction . withJvmOverloads ( containingClassName : String , newName : String , isTopLevel : Boolean = false ) : List < DFunction > ?

{ <EOL> val ( paramsWithDefaults , paramsWithoutDefaults ) = parameters <EOL> . withIndex ( ) <EOL> . partition { ( _ , p ) -> p . extra [ DefaultValue ] != null } <EOL> return paramsWithDefaults <EOL> . runningFold ( paramsWithoutDefaults ) { acc , param -> ( acc + param ) } <EOL> . map { params -> <EOL> asJava ( containingClassName , newName , params . sortedBy ( IndexedValue < DParameter > :: index ) . map { it . value } , isTopLevel ) <EOL> } <EOL> . reversed ( ) <EOL> . takeIf { it . isNotEmpty ( ) } <EOL> }


internal fun DFunction . asJava ( containingClassName : String , isTopLevel : Boolean = false ) : List < DFunction >

{ <EOL> val newName = when { <EOL> isConstructor -> containingClassName <EOL> else -> name <EOL> } <EOL> val baseFunction = asJava ( containingClassName , newName , parameters , isTopLevel ) <EOL> return if ( hasJvmOverloads ( ) ) { <EOL> withJvmOverloads ( containingClassName , newName , isTopLevel ) ? : listOf ( baseFunction ) <EOL> } else { <EOL> listOf ( baseFunction ) <EOL> } <EOL> }


internal fun DClasslike . asJava ( ) : DClasslike

= when ( this ) { <EOL> is DClass -> asJava ( ) <EOL> is DEnum -> asJava ( ) <EOL> is DAnnotation -> asJava ( ) <EOL> is DObject -> asJava ( ) <EOL> is DInterface -> asJava ( ) <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> }


internal fun DClass . asJava ( ) : DClass

= copy ( constructors = constructors . filterNot { it . hasJvmSynthetic ( ) } . flatMap { <EOL> it . asJava ( dri . classNames ? : name ) <EOL> } , functions = functionsInJava ( ) , properties = propertiesInJava ( ) , classlikes = classlikesInJava ( ) , generics = generics . map { it . asJava ( ) } , companion = companion ? . companionAsJava ( ) , supertypes = supertypes . mapValues { it . value . map { it . asJava ( ) } } , modifier = if ( modifier . all { ( _ , v ) -> v is KotlinModifier . Empty } ) sourceSets . associateWith { JavaModifier . Final } else sourceSets . associateWith { modifier . values . first ( ) } )


internal fun DClass . classlikesInJava ( ) : List < DClasslike >

{ <EOL> val classlikes = classlikes <EOL> . filter { it . name != companion ? . name } <EOL> . map { it . asJava ( ) } <EOL> val companionAsJava = companion ? . companionAsJava ( ) <EOL> return if ( companionAsJava != null ) classlikes . plus ( companionAsJava ) else classlikes <EOL> }

/**
 * Companion objects requires some custom logic for rendering as Java.
 * They are excluded from usual classlikes rendering and added after.
 */


internal fun DClass . functionsInJava ( ) : List < DFunction >

= <EOL> properties <EOL> . filter { ! it . isJvmField && ! it . hasJvmSynthetic ( ) } <EOL> . flatMap { property -> listOfNotNull ( property . getter , property . setter ) } <EOL> . plus ( functions ) <EOL> . plus ( companion . staticFunctionsForJava ( ) ) <EOL> . filterNot { it . hasJvmSynthetic ( ) } <EOL> . flatMap { it . asJava ( it . dri . classNames ? : it . name ) }


internal fun DClass . propertiesInJava ( ) : List < DProperty >

{ <EOL> val propertiesFromCompanion = companion <EOL> . staticPropertiesForJava ( ) <EOL> . filterNot { it . hasJvmSynthetic ( ) } <EOL> . map { it . asJava ( isFromObjectOrCompanion = true ) } <EOL> val companionInstanceProperty = companion ? . companionInstancePropertyForJava ( ) <EOL> val ownProperties = properties <EOL> . filterNot { it . hasJvmSynthetic ( ) } <EOL> . map { it . asJava ( ) } <EOL> return propertiesFromCompanion + ownProperties + listOfNotNull ( companionInstanceProperty ) <EOL> }


private fun DTypeParameter . asJava ( ) : DTypeParameter

= copy ( variantTypeParameter = variantTypeParameter . withDri ( dri . possiblyAsJava ( ) ) , bounds = bounds . map { it . asJava ( ) } )


private fun Projection . asJava ( ) : Projection

= when ( this ) { <EOL> is Star -> Star <EOL> is Covariance < * > -> copy ( inner . asJava ( ) ) <EOL> is Contravariance < * > -> copy ( inner . asJava ( ) ) <EOL> is Invariance < * > -> copy ( inner . asJava ( ) ) <EOL> is Bound -> asJava ( ) <EOL> }


= when ( this ) { <EOL> is TypeParameter -> copy ( dri . possiblyAsJava ( ) ) <EOL> is GenericTypeConstructor -> copy ( dri = dri . possiblyAsJava ( ) , projections = projections . map { it . asJava ( ) } ) <EOL> is FunctionalTypeConstructor -> copy ( dri = dri . possiblyAsJava ( ) , projections = projections . map { it . asJava ( ) } ) <EOL> is TypeAliased -> copy ( typeAlias = typeAlias . asJava ( ) , inner = inner . asJava ( ) ) <EOL> is Nullable -> copy ( inner . asJava ( ) ) <EOL> is DefinitelyNonNullable -> copy ( inner . asJava ( ) ) <EOL> is PrimitiveJavaType -> this <EOL> is Void -> this <EOL> is JavaObject -> this <EOL> is Dynamic -> this <EOL> is UnresolvedBound -> this <EOL> }


= copy ( constructors = constructors . flatMap { it . asJava ( dri . classNames ? : name ) } , functions = functions . plus ( properties . filter { ! it . isJvmField && ! it . hasJvmSynthetic ( ) } . flatMap { listOf ( it . getter , it . setter ) } ) . filterNotNull ( ) . filterNot { it . hasJvmSynthetic ( ) } . flatMap { it . asJava ( dri . classNames ? : name ) } , properties = properties . filterNot { it . hasJvmSynthetic ( ) } . map { it . asJava ( ) } , classlikes = classlikes . map { it . asJava ( ) } , supertypes = supertypes . mapValues { it . value . map { it . asJava ( ) } } )


internal fun DObject . asJava ( excludedProps : List < DProperty > = emptyList ( ) , excludedFunctions : List < DFunction > = emptyList ( ) ) : DObject

= copy ( functions = functions . plus ( properties . filterNot { it in excludedProps } . filter { ! it . isJvmField && ! it . isConst && ! it . isLateInit && ! it . hasJvmSynthetic ( ) } . flatMap { listOf ( it . getter , it . setter ) } ) . filterNotNull ( ) . filterNot { it in excludedFunctions } . filterNot { it . hasJvmSynthetic ( ) } . flatMap { it . asJava ( dri . classNames ? : name . orEmpty ( ) ) } , properties = properties . filterNot { it . hasJvmSynthetic ( ) } . filterNot { it in excludedProps } . map { it . asJava ( isFromObjectOrCompanion = true ) } + DProperty ( name = OBJECT_INSTANCE_NAME , modifier = sourceSets . associateWith { JavaModifier . Final } , dri = dri . copy ( callable = Callable ( OBJECT_INSTANCE_NAME , null , emptyList ( ) ) ) , documentation = emptyMap ( ) , sources = emptyMap ( ) , visibility = sourceSets . associateWith { <EOL> JavaVisibility . Public <EOL> } , type = GenericTypeConstructor ( dri , emptyList ( ) ) , setter = null , getter = null , sourceSets = sourceSets , receiver = null , generics = emptyList ( ) , expectPresentInSet = expectPresentInSet , isExpectActual = false , extra = PropertyContainer . withAll ( sourceSets . map { <EOL> mapOf ( it to setOf ( ExtraModifiers . JavaOnlyModifiers . Static ) ) . toAdditionalModifiers ( ) <EOL> } ) ) , classlikes = classlikes . map { it . asJava ( ) } , supertypes = supertypes . mapValues { it . value . map { it . asJava ( ) } } )

/**
 * Parameters [excludedProps] and [excludedFunctions] used for rendering companion objects
 * where some members (that lifted to outer class) are not rendered
 */


internal fun DInterface . asJava ( ) : DInterface

= copy ( functions = functions . plus ( properties . filter { it . jvmField ( ) == null && ! it . hasJvmSynthetic ( ) } . flatMap { listOf ( it . getter , it . setter ) } ) . filterNotNull ( ) . filterNot { it . hasJvmSynthetic ( ) } . flatMap { it . asJava ( dri . classNames ? : name ) } , properties = emptyList ( ) , classlikes = classlikes . map { it . asJava ( ) } , generics = generics . map { it . asJava ( ) } , supertypes = supertypes . mapValues { it . value . map { it . asJava ( ) } } )


internal fun DAnnotation . asJava ( ) : DAnnotation

= copy ( properties = properties . map { it . asJava ( ) } , constructors = emptyList ( ) , classlikes = classlikes . map { it . asJava ( ) } )


internal fun DParameter . asJava ( ) : DParameter

= copy ( type = type . asJava ( ) , name = if ( name . isNullOrBlank ( ) ) "<STR_LIT>" else name )


internal fun Visibility . propertyVisibilityAsJava ( ) : Visibility

= <EOL> if ( this is JavaVisibility ) this <EOL> else JavaVisibility . Private


private fun TypeConstructor . possiblyAsJava ( ) : TypeConstructor

= when ( this ) { <EOL> is GenericTypeConstructor -> copy ( dri = this . dri . possiblyAsJava ( ) ) <EOL> is FunctionalTypeConstructor -> copy ( dri = this . dri . possiblyAsJava ( ) ) <EOL> }


internal fun TypeConstructorWithKind . asJava ( ) : TypeConstructorWithKind

= <EOL> TypeConstructorWithKind ( typeConstructor = typeConstructor . possiblyAsJava ( ) , kind = kind . asJava ( ) )


internal fun ClassKind . asJava ( ) : ClassKind

{ <EOL> return when ( this ) { <EOL> is JavaClassKindTypes -> this <EOL> KotlinClassKindTypes . CLASS -> JavaClassKindTypes . CLASS <EOL> KotlinClassKindTypes . INTERFACE -> JavaClassKindTypes . INTERFACE <EOL> KotlinClassKindTypes . ENUM_CLASS -> JavaClassKindTypes . ENUM_CLASS <EOL> KotlinClassKindTypes . ENUM_ENTRY -> JavaClassKindTypes . ENUM_ENTRY <EOL> KotlinClassKindTypes . ANNOTATION_CLASS -> JavaClassKindTypes . ANNOTATION_CLASS <EOL> KotlinClassKindTypes . OBJECT -> JavaClassKindTypes . CLASS <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> }


private fun < T : Documentable > PropertyContainer < T > . mergeAdditionalModifiers ( second : SourceSetDependent < Set < ExtraModifiers > > )

= <EOL> this [ AdditionalModifiers ] ? . squash ( AdditionalModifiers ( second ) ) ? : AdditionalModifiers ( second )


private fun AdditionalModifiers . squash ( second : AdditionalModifiers )

= <EOL> AdditionalModifiers ( content + second . content )


internal fun DObject . companionAsJava ( ) : DObject ?

{ <EOL> if ( hasNothingToRender ( ) ) return null <EOL> return asJava ( excludedProps = staticPropertiesForJava ( ) , excludedFunctions = staticFunctionsForJava ( ) ) <EOL> }


private fun DRI . possiblyAsJava ( ) : DRI

{ <EOL> return kotlinToJavaMapper . findAsJava ( this ) ? : this <EOL> }


operator fun invoke ( classType : KotlinType , contextClassLoader : ClassLoader ? , hostConfiguration : ScriptingHostConfiguration ) : KClass < * >


override fun invoke ( classType : KotlinType , contextClass : KClass < * > , hostConfiguration : ScriptingHostConfiguration ) : KClass < * >

= <EOL> invoke ( classType , contextClass . java . classLoader , hostConfiguration )


@ Synchronized <EOL> override operator fun invoke ( classType : KotlinType , contextClassLoader : ClassLoader ? , hostConfiguration : ScriptingHostConfiguration ) : KClass < * >

{ <EOL> val fromClass = classType . fromClass <EOL> if ( fromClass != null ) { <EOL> if ( fromClass . java . classLoader == null ) return fromClass <EOL> val actualClassLoadersChain = generateSequence ( contextClassLoader ) { it . parent } <EOL> if ( actualClassLoadersChain . any { it == fromClass . java . classLoader } ) return fromClass <EOL> } <EOL> val newDeps = hostConfiguration [ ScriptingHostConfiguration . configurationDependencies ] <EOL> if ( dependencies == null ) { <EOL> dependencies = newDeps <EOL> } else { <EOL> if ( newDeps != dependencies ) throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> if ( baseClassLoaderIsInitialized != true ) { <EOL> baseClassLoader = contextClassLoader <EOL> baseClassLoaderIsInitialized = true <EOL> } <EOL> if ( classLoader == null ) { <EOL> val classpath = dependencies ? . flatMap { dependency -> <EOL> when ( dependency ) { <EOL> is JvmDependency -> dependency . classpath . map { it . toURI ( ) . toURL ( ) } <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> classLoader = <EOL> if ( classpath == null || classpath . isEmpty ( ) ) baseClassLoader <EOL> else URLClassLoader ( classpath . toTypedArray ( ) , baseClassLoader ) <EOL> } <EOL> return try { <EOL> ( classLoader ? : ClassLoader . getSystemClassLoader ( ) ) . loadClass ( classType . typeName ) . kotlin <EOL> } catch ( e : Throwable ) { <EOL> throw IllegalArgumentException ( "<STR_LIT>" , e ) <EOL> } <EOL> }


override fun equals ( other : Any ? ) : Boolean

= <EOL> when { <EOL> other === this -> true <EOL> other !is JvmGetScriptingClass -> false <EOL> else -> { <EOL> other . dependencies == dependencies && <EOL> ( other . classLoader == null || classLoader == null || other . classLoader == classLoader ) && <EOL> ( other . baseClassLoader == null || baseClassLoader == null || other . baseClassLoader == baseClassLoader ) <EOL> } <EOL> }


{ <EOL> return dependencies . hashCode ( ) + <NUM_LIT:23> * classLoader . hashCode ( ) + <NUM_LIT> * baseClassLoader . hashCode ( ) <EOL> }


= values ( ) . firstOrNull { it . alias == alias }


fun getInstance ( project : Project ) : JavaSourceSetsAccessor


override fun getInstance ( project : Project ) : JavaSourceSetsAccessor

= DefaultJavaSourceSetsAccessor ( project . extensions )


public fun < T > foo ( ) : T


public fun dummy ( )


override fun < E > foo ( ) : E


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

{ <EOL> val ce = encoder . beginStructure ( descriptor ) <EOL> ce . encodeInlineElement ( descriptor , <NUM_LIT:0> ) . encodeInt ( value . u . toInt ( ) ) <EOL> ce . endStructure ( descriptor ) <EOL> }


override fun deserialize ( decoder : Decoder ) : WithUnsigned

{ <EOL> val cd = decoder . beginStructure ( descriptor ) <EOL> var u : UInt = <NUM_LIT:0> . toUInt ( ) <EOL> loop @ while ( true ) { <EOL> u = when ( val i = cd . decodeElementIndex ( descriptor ) ) { <EOL> <NUM_LIT:0> -> cd . decodeInlineElement ( descriptor , i ) . decodeInt ( ) . toUInt ( ) <EOL> else -> break@loop <EOL> } <EOL> } <EOL> cd . endStructure ( descriptor ) <EOL> return WithUnsigned ( u ) <EOL> }


{ <EOL> val w = WithUnsigned ( Int . MAX_VALUE . toUInt ( ) + <NUM_LIT:1> . toUInt ( ) ) <EOL> assertStringFormAndRestored < WithUnsigned > ( """<STR_LIT>""" , w , WithUnsignedSerializer , printResult = true ) <EOL> }


= "<STR_LIT>"


override fun doTestByMainFile ( mainFile : KtFile , mainModule : KtTestModule , testServices : TestServices )

{ <EOL> val context = testServices . expressionMarkerProvider . getElementOfTypeAtCaret < KtProperty > ( mainFile ) <EOL> analyseForTest ( context ) { declaration -> <EOL> val propertySymbol = ( declaration as KtProperty ) . getVariableSymbol ( ) as KtPropertySymbol <EOL> val setterSymbol = propertySymbol . setter ! ! <EOL> val setterParameterSymbol = setterSymbol . valueParameters . single ( ) <EOL> testServices . assertions . assertEquals ( propertySymbol , setterSymbol . getContainingSymbol ( ) ) <EOL> testServices . assertions . assertEquals ( setterSymbol , setterParameterSymbol . getContainingSymbol ( ) ) <EOL> } <EOL> }


{ <EOL> val z = kotlin . tex < caret > t . charset ( "<STR_LIT>" ) <EOL> }


{ <EOL> val z1 = S ( "<STR_LIT:1>" ) <EOL> val z2 = S ( "<STR_LIT:2>" ) <EOL> val z3 = S ( "<STR_LIT:3>" ) <EOL> val z4 = S ( "<STR_LIT:4>" ) <EOL> val outer = :: Outer . call ( z1 , z2 ) <EOL> assertEquals ( z1 , outer . z1 ) <EOL> assertEquals ( z2 , outer . z2 ) <EOL> assertEquals ( "<STR_LIT>" , Outer :: Inner . call ( outer , z3 , z4 ) . test ) <EOL> assertEquals ( "<STR_LIT>" , outer :: Inner . call ( z2 , z4 ) . test ) <EOL> val inlineNonNullOuter = InlineNonNullOuter ( z1 ) <EOL> assertEquals ( "<STR_LIT>" , InlineNonNullOuter :: Inner . call ( inlineNonNullOuter , z2 , z3 ) . test ) <EOL> assertEquals ( "<STR_LIT>" , inlineNonNullOuter :: Inner . call ( z2 , z2 ) . test ) <EOL> val inlineNullableOuter = InlineNullableOuter ( z1 ) <EOL> assertEquals ( "<STR_LIT>" , InlineNullableOuter :: Inner . call ( inlineNullableOuter , z2 , z3 ) . test ) <EOL> assertEquals ( "<STR_LIT>" , inlineNullableOuter :: Inner . call ( z2 , z2 ) . test ) <EOL> return "<STR_LIT:OK>" <EOL> }


override fun handleCommandAsTag ( command : Command , body : Element , input : File , output : File )

{ <EOL> command as ResolveLinkCommand <EOL> val link = externalModuleLinkResolver . resolve ( command . dri , output ) <EOL> if ( link == null ) { <EOL> val children = body . childNodes ( ) . toList ( ) <EOL> val attributes = Attributes ( ) . apply { <EOL> put ( "<STR_LIT>" , command . dri . toString ( ) ) <EOL> } <EOL> val el = Element ( Tag . valueOf ( "<STR_LIT>" ) , "<STR_LIT>" , attributes ) . apply { <EOL> children . forEach { ch -> appendChild ( ch ) } <EOL> } <EOL> body . replaceWith ( el ) <EOL> return <EOL> } <EOL> val attributes = Attributes ( ) . apply { <EOL> put ( "<STR_LIT>" , link ) <EOL> } <EOL> val children = body . childNodes ( ) . toList ( ) <EOL> val el = Element ( Tag . valueOf ( "<STR_LIT:a>" ) , "<STR_LIT>" , attributes ) . apply { <EOL> children . forEach { ch -> appendChild ( ch ) } <EOL> } <EOL> body . replaceWith ( el ) <EOL> }


override fun canHandle ( command : Command ) : Boolean

= command is ResolveLinkCommand


override fun asStringForDebugging ( ) : String

= withValidityAssertion { coneType . renderForDebugging ( ) }


= typeEquals ( other )


= typeHashcode ( )


public operator fun invoke ( input : RootPageNode ) : RootPageNode


{ <EOL> val local = ShortWrapper ( <NUM_LIT:2> ) <EOL> if ( global . x + local . x != <NUM_LIT:3> ) return "<STR_LIT:FAIL>" <EOL> global . x = <NUM_LIT:5> <EOL> local . x = <NUM_LIT:6> <EOL> return if ( global . x + local . x != <NUM_LIT:11> ) return "<STR_LIT:FAIL>" else "<STR_LIT:OK>" <EOL> }


fun shouldReportNoBody ( declaration : FirCallableDeclaration , context : CheckerContext ) : Boolean


private fun genInvoke ( type : Type ? , v : InstructionAdapter )

{ <EOL> when ( type ) { <EOL> Type . INT_TYPE , Type . CHAR_TYPE -> v . invokestatic ( IntrinsicMethods . INTRINSICS_CLASS_NAME , "<STR_LIT>" , "<STR_LIT>" , false ) <EOL> Type . LONG_TYPE -> v . lcmp ( ) <EOL> Type . FLOAT_TYPE -> v . invokestatic ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , false ) <EOL> Type . DOUBLE_TYPE -> v . invokestatic ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , false ) <EOL> Type . BOOLEAN_TYPE -> v . invokestatic ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , false ) <EOL> else -> throw UnsupportedOperationException ( ) <EOL> } <EOL> }


override fun toCallable ( method : CallableMethod ) : Callable

{ <EOL> val parameterType = comparisonOperandType ( method . dispatchReceiverType ? : method . extensionReceiverType , method . parameterTypes . single ( ) ) <EOL> return createBinaryIntrinsicCallable ( method . returnType , parameterType , parameterType , null ) { <EOL> genInvoke ( parameterType , it ) <EOL> } <EOL> }


= <NUM_LIT:1>


= <NUM_LIT:3>


= <NUM_LIT:2>


= <NUM_LIT:4>


{ <EOL> with ( b ) { <EOL> with ( a ) { <EOL> foo ( ) <EOL> bar ( ) <EOL> } <EOL> } <EOL> with ( a ) { <EOL> with ( b ) { <EOL> foo ( ) <EOL> bar ( ) <EOL> } <EOL> } <EOL> }


{ return "<STR_LIT>" }


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

= block ( )


{ <EOL> val x : String = foo { <EOL> val task : String ? = null <EOL> if ( task == null ) { <EOL> return <EOL> } else task <EOL> } <EOL> }


@ Parameterized . Parameters ( name = "<STR_LIT>" ) <EOL> @ JvmStatic <EOL> fun params ( ) : Collection < Array < Any > >

= listOf ( <NUM_LIT:0> , <NUM_LIT:1> , Channel . UNLIMITED , Channel . CONFLATED ) . map { arrayOf < Any > ( it ) }


= runBlocking { <EOL> expect ( <NUM_LIT:1> ) <EOL> val actor = actor < String > ( capacity = capacity ) { <EOL> expect ( <NUM_LIT:3> ) <EOL> } <EOL> actor as Job <EOL> assertTrue ( actor . isActive ) <EOL> assertFalse ( actor . isCompleted ) <EOL> assertFalse ( actor . isClosedForSend ) <EOL> expect ( <NUM_LIT:2> ) <EOL> yield ( ) <EOL> assertFalse ( actor . isActive ) <EOL> assertTrue ( actor . isCompleted ) <EOL> assertTrue ( actor . isClosedForSend ) <EOL> finish ( <NUM_LIT:4> ) <EOL> }


= runBlocking { <EOL> expect ( <NUM_LIT:1> ) <EOL> val actor = actor < String > ( capacity = capacity ) { <EOL> expect ( <NUM_LIT:3> ) <EOL> assertEquals ( "<STR_LIT:OK>" , receive ( ) ) <EOL> expect ( <NUM_LIT:6> ) <EOL> } <EOL> actor as Job <EOL> assertTrue ( actor . isActive ) <EOL> assertFalse ( actor . isCompleted ) <EOL> assertFalse ( actor . isClosedForSend ) <EOL> expect ( <NUM_LIT:2> ) <EOL> yield ( ) <EOL> assertTrue ( actor . isActive ) <EOL> assertFalse ( actor . isCompleted ) <EOL> assertFalse ( actor . isClosedForSend ) <EOL> expect ( <NUM_LIT:4> ) <EOL> actor . send ( "<STR_LIT:OK>" ) <EOL> expect ( <NUM_LIT:5> ) <EOL> yield ( ) <EOL> assertFalse ( actor . isActive ) <EOL> assertTrue ( actor . isCompleted ) <EOL> assertTrue ( actor . isClosedForSend ) <EOL> finish ( <NUM_LIT:7> ) <EOL> }


@ Test <EOL> fun testCloseWithoutCause ( )

= runTest { <EOL> val actor = actor < Int > ( capacity = capacity ) { <EOL> val element = channel . receive ( ) <EOL> expect ( <NUM_LIT:2> ) <EOL> assertEquals ( <NUM_LIT:42> , element ) <EOL> val next = channel . receiveCatching ( ) <EOL> assertNull ( next . exceptionOrNull ( ) ) <EOL> expect ( <NUM_LIT:3> ) <EOL> } <EOL> expect ( <NUM_LIT:1> ) <EOL> actor . send ( <NUM_LIT:42> ) <EOL> yield ( ) <EOL> actor . close ( ) <EOL> yield ( ) <EOL> finish ( <NUM_LIT:4> ) <EOL> }


= runTest { <EOL> val actor = actor < Int > ( capacity = capacity ) { <EOL> val element = channel . receive ( ) <EOL> expect ( <NUM_LIT:2> ) <EOL> require ( element == <NUM_LIT:42> ) <EOL> try { <EOL> channel . receive ( ) <EOL> } catch ( e : IOException ) { <EOL> expect ( <NUM_LIT:3> ) <EOL> } <EOL> } <EOL> expect ( <NUM_LIT:1> ) <EOL> actor . send ( <NUM_LIT:42> ) <EOL> yield ( ) <EOL> actor . close ( IOException ( ) ) <EOL> yield ( ) <EOL> finish ( <NUM_LIT:4> ) <EOL> }


@ Test <EOL> fun testCancelEnclosingJob ( )

= runTest { <EOL> val job = async { <EOL> actor < Int > ( capacity = capacity ) { <EOL> expect ( <NUM_LIT:1> ) <EOL> channel . receive ( ) <EOL> expectUnreached ( ) <EOL> } <EOL> } <EOL> yield ( ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:2> ) <EOL> yield ( ) <EOL> job . cancel ( ) <EOL> try { <EOL> job . await ( ) <EOL> expectUnreached ( ) <EOL> } catch ( e : CancellationException ) { <EOL> assertTrue ( e . message ? . contains ( "<STR_LIT>" ) ? : false ) <EOL> } <EOL> finish ( <NUM_LIT:3> ) <EOL> }


= runTest ( unhandled = listOf ( { e -> e is IllegalArgumentException } ) ) { <EOL> val parent = Job ( ) <EOL> val actor = actor < Int > ( parent ) { <EOL> channel . consumeEach { <EOL> expect ( <NUM_LIT:1> ) <EOL> throw IllegalArgumentException ( ) <EOL> } <EOL> } <EOL> actor . send ( <NUM_LIT:1> ) <EOL> parent . cancel ( ) <EOL> parent . join ( ) <EOL> finish ( <NUM_LIT:2> ) <EOL> }


= runTest { <EOL> val parent = Job ( ) <EOL> actor < Int > ( parent ) { <EOL> launch { <EOL> try { <EOL> delay ( Long . MAX_VALUE ) <EOL> } finally { <EOL> expect ( <NUM_LIT:1> ) <EOL> } <EOL> } <EOL> } <EOL> yield ( ) <EOL> yield ( ) <EOL> parent . cancel ( ) <EOL> parent . join ( ) <EOL> finish ( <NUM_LIT:2> ) <EOL> }


@ Test <EOL> fun testCloseFreshActor ( )

= runTest { <EOL> for ( start in CoroutineStart . values ( ) ) { <EOL> val job = launch { <EOL> val actor = actor < Int > ( start = start ) { <EOL> for ( i in channel ) { <EOL> } <EOL> } <EOL> actor . close ( ) <EOL> } <EOL> job . join ( ) <EOL> } <EOL> }


@ Test <EOL> fun testCancelledParent ( )

= runTest ( { it is CancellationException } ) { <EOL> cancel ( ) <EOL> expect ( <NUM_LIT:1> ) <EOL> actor < Int > { <EOL> expectUnreached ( ) <EOL> } <EOL> finish ( <NUM_LIT:2> ) <EOL> }


= "<STR_LIT>"


{ <EOL> ( this as C ) . foo ( ) <EOL> }


public fun recursivePrintGroupInHDF5File ( hdfFile : HdfFile , group : Group )

{ <EOL> for ( node in group ) { <EOL> println ( "<STR_LIT>" + node . name ) <EOL> for ( ( key , value ) in node . attributes ) { <EOL> println ( "<STR_LIT>" ) <EOL> if ( value . isScalar ) { <EOL> println ( "<STR_LIT>" + value . data . toString ( ) ) <EOL> } else if ( value . data is Array < * > ) { <EOL> for ( i in <NUM_LIT:0> until value . size . toInt ( ) ) <EOL> println ( "<STR_LIT>" + ( value . data as Array < * > ) [ i ] . toString ( ) ) <EOL> } <EOL> } <EOL> if ( node is Group ) { <EOL> recursivePrintGroupInHDF5File ( hdfFile , node ) <EOL> } else { <EOL> println ( "<STR_LIT>" + node . path ) <EOL> val dataset = hdfFile . getDatasetByPath ( node . path ) <EOL> val dims = arrayOf ( dataset . dimensions ) <EOL> println ( "<STR_LIT>" + dims . contentDeepToString ( ) ) <EOL> } <EOL> } <EOL> }

/**
 * Helper function to print out file in hdf5 format for debugging purposes.
 */


fun fooInt ( b : ( Int , Int ) -> String ) : String

{ <EOL> return b ( <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> }


fun fooULong ( b : ( ULong , ULong ) -> String ) : String

{ <EOL> return b ( <NUM_LIT> , <NUM_LIT> ) <EOL> }


{ <EOL> return "<STR_LIT>" . get ( i ) . toString ( ) <EOL> }


{ <EOL> return "<STR_LIT>" . get ( l . toInt ( ) ) . toString ( ) <EOL> }


{ <EOL> return fooInt { from , to -> <EOL> var r = "<STR_LIT>" <EOL> for ( index in from .. to ) { <EOL> r += barInt ( index ) <EOL> } <EOL> r <EOL> } <EOL> }


{ <EOL> return fooULong { from , to -> <EOL> var r = "<STR_LIT>" <EOL> for ( index in from .. to ) { <EOL> r += barULong ( index ) <EOL> } <EOL> r <EOL> } <EOL> }


{ <EOL> val r1 = testInt ( ) <EOL> if ( r1 != "<STR_LIT>" ) return "<STR_LIT>" <EOL> val r2 = testULong ( ) <EOL> if ( r2 != "<STR_LIT>" ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


@ SlicedGeneratedTest ( allTools = true ) <EOL> fun BuildConfigurator . testDefaultXmlTitle ( )

{ <EOL> addProjectWithKover { <EOL> } <EOL> addProjectWithKover ( "<STR_LIT>" ) { <EOL> sourcesFrom ( "<STR_LIT:simple>" ) <EOL> } <EOL> run ( "<STR_LIT>" ) { <EOL> subproject ( "<STR_LIT>" ) { <EOL> file ( "<STR_LIT>" ) { <EOL> assertContains ( readText ( ) , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> }


@ SlicedGeneratedTest ( allTools = true ) <EOL> fun BuildConfigurator . testCustomXmlTitle ( )

{ <EOL> val title = "<STR_LIT>" <EOL> addProjectWithKover { <EOL> } <EOL> addProjectWithKover ( "<STR_LIT>" ) { <EOL> sourcesFrom ( "<STR_LIT:simple>" ) <EOL> kover { <EOL> reports { <EOL> total { <EOL> xml { <EOL> this . title . set ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> run ( "<STR_LIT>" ) { <EOL> subproject ( "<STR_LIT>" ) { <EOL> file ( "<STR_LIT>" ) { <EOL> assertContains ( readText ( ) , title ) <EOL> } <EOL> } <EOL> } <EOL> }


fun valueOfOrNull ( string : String ) : ReplEscapeType ?

{ <EOL> return try { <EOL> valueOf ( string ) <EOL> } <EOL> catch ( e : IllegalArgumentException ) { <EOL> null <EOL> } <EOL> }


{ <EOL> irFile . transformChildrenVoid ( Transformer ( ) ) <EOL> }


= <EOL> IrCallImpl . fromSymbolOwner ( startOffset , endOffset , booleanNot ) . apply { <EOL> dispatchReceiver = this@irNot <EOL> }


private fun irAndAnd ( left : IrExpression , right : IrExpression ) : IrExpression

= <EOL> IrCallImpl . fromSymbolOwner ( right . startOffset , right . endOffset , context . irBuiltIns . andandSymbol ) . apply { <EOL> putValueArgument ( <NUM_LIT:0> , left ) <EOL> putValueArgument ( <NUM_LIT:1> , right ) <EOL> }


private fun IrExpression . irEqEqNull ( ) : IrExpression

= <EOL> IrCallImpl . fromSymbolOwner ( this . startOffset , this . endOffset , context . irBuiltIns . eqeqSymbol ) . apply { <EOL> putValueArgument ( <NUM_LIT:0> , this @ irEqEqNull ) <EOL> putValueArgument ( <NUM_LIT:1> , IrConstImpl . constNull ( startOffset , endOffset , context . irBuiltIns . nothingNType ) ) <EOL> }


private fun IrExpression . wrapWithBlock ( origin : IrStatementOrigin ? ) : IrBlock

= <EOL> IrBlockImpl ( this . startOffset , this . endOffset , this . type , origin , listOf ( this ) )


private fun irTrue ( startOffset : Int , endOffset : Int )

= <EOL> IrConstImpl . boolean ( startOffset , endOffset , context . irBuiltIns . booleanType , true )


private fun irFalse ( startOffset : Int , endOffset : Int )

= <EOL> IrConstImpl . boolean ( startOffset , endOffset , context . irBuiltIns . booleanType , false )


private fun irValNotNull ( startOffset : Int , endOffset : Int , irVariable : IrVariable ) : IrExpression

= <EOL> if ( irVariable . type . isJvmNullable ( ) || irVariable . initializer ? . isConstantLike != true ) <EOL> IrGetValueImpl ( startOffset , endOffset , irVariable . symbol ) . irEqEqNull ( ) . irNot ( ) <EOL> else <EOL> irTrue ( startOffset , endOffset )


private fun IrType . isJvmNullable ( ) : Boolean

= <EOL> isNullable ( ) || hasAnnotation ( JvmAnnotationNames . ENHANCED_NULLABILITY_ANNOTATION )


private fun IrType . isJvmPrimitive ( ) : Boolean

= <EOL> ( isBoolean ( ) || isByte ( ) || isShort ( ) || isInt ( ) || isLong ( ) || isChar ( ) || isFloat ( ) || isDouble ( ) ) && <EOL> ! hasAnnotation ( JvmAnnotationNames . ENHANCED_NULLABILITY_ANNOTATION )


override fun visitBlock ( expression : IrBlock ) : IrExpression

{ <EOL> expression . transformChildrenVoid ( ) <EOL> val safeCallInfo = expression . parseSafeCall ( context . irBuiltIns ) <EOL> if ( safeCallInfo != null ) { <EOL> return foldSafeCall ( safeCallInfo ) <EOL> } <EOL> val elvisInfo = expression . parseElvis ( context . irBuiltIns ) <EOL> if ( elvisInfo != null ) { <EOL> return foldElvis ( elvisInfo ) <EOL> } <EOL> return expression <EOL> }