public fun < T > DataFrame < T > . min ( vararg columns : String ) : Comparable < Any >

= minOrNull ( * columns ) . suggestIfNull ( "<STR_LIT>" )


public fun < T , C : Comparable < C > > DataFrame < T > . min ( vararg columns : ColumnReference < C ? > ) : C

= <EOL> minOrNull ( * columns ) . suggestIfNull ( "<STR_LIT>" )


public fun < T , C : Comparable < C > > DataFrame < T > . min ( vararg columns : KProperty < C ? > ) : C


public fun < T , C : Comparable < C > > DataFrame < T > . minOrNull ( columns : ColumnsSelector < T , C ? > ) : C ?

= <EOL> Aggregators . min . aggregateAll ( this , columns ) as C ?


public fun < T > DataFrame < T > . minOrNull ( vararg columns : String ) : Comparable < Any ? > ?

= <EOL> minOrNull { columns . toComparableColumns ( ) }


public fun < T , C : Comparable < C > > DataFrame < T > . minOrNull ( vararg columns : ColumnReference < C ? > ) : C ?

= <EOL> minOrNull { columns . toColumnSet ( ) }


public fun < T , C : Comparable < C > > DataFrame < T > . minOrNull ( vararg columns : KProperty < C ? > ) : C ?


public fun < T , C : Comparable < C > > DataFrame < T > . minOf ( expression : RowExpression < T , C > ) : C

= <EOL> minOfOrNull ( expression ) . suggestIfNull ( "<STR_LIT>" )


public fun < T , C : Comparable < C > > DataFrame < T > . minOfOrNull ( expression : RowExpression < T , C > ) : C ?

= <EOL> rows ( ) . minOfOrNull { expression ( it , it ) }


public fun < T , C : Comparable < C > > DataFrame < T > . minBy ( expression : RowExpression < T , C ? > ) : DataRow < T >

= <EOL> minByOrNull ( expression ) . suggestIfNull ( "<STR_LIT>" )


public fun < T > DataFrame < T > . minBy ( column : String ) : DataRow < T >

= minByOrNull ( column ) . suggestIfNull ( "<STR_LIT>" )


public fun < T , C : Comparable < C > > DataFrame < T > . minBy ( column : ColumnReference < C ? > ) : DataRow < T >

= <EOL> minByOrNull ( column ) . suggestIfNull ( "<STR_LIT>" )


public fun < T , C : Comparable < C > > DataFrame < T > . minBy ( column : KProperty < C ? > ) : DataRow < T >


public fun < T , C : Comparable < C > > DataFrame < T > . minByOrNull ( expression : RowExpression < T , C ? > ) : DataRow < T > ?

= <EOL> getOrNull ( rows ( ) . asSequence ( ) . map { expression ( it , it ) } . indexOfMin ( ) )


public fun < T > DataFrame < T > . minByOrNull ( column : String ) : DataRow < T > ?

= <EOL> minByOrNull ( column . toColumnOf < Comparable < Any ? > ? > ( ) )


public fun < T , C : Comparable < C > > DataFrame < T > . minByOrNull ( column : ColumnReference < C ? > ) : DataRow < T > ?

= <EOL> getOrNull ( get ( column ) . asSequence ( ) . indexOfMin ( ) )


public fun < T , C : Comparable < C > > DataFrame < T > . minByOrNull ( column : KProperty < C ? > ) : DataRow < T > ?

= <EOL> minByOrNull ( column . toColumnAccessor ( ) )


public fun < T > Grouped < T > . min ( ) : DataFrame < T >

= minFor ( comparableColumns ( ) )


public fun < T , C : Comparable < C > > Grouped < T > . minFor ( columns : ColumnsForAggregateSelector < T , C ? > ) : DataFrame < T >

= <EOL> Aggregators . min . aggregateFor ( this , columns )


public fun < T > Grouped < T > . minFor ( vararg columns : String ) : DataFrame < T >

= minFor { columns . toComparableColumns ( ) }


public fun < T , C : Comparable < C > > Grouped < T > . minFor ( vararg columns : ColumnReference < C ? > ) : DataFrame < T >

= <EOL> minFor { columns . toColumnSet ( ) }


public fun < T , C : Comparable < C > > Grouped < T > . minFor ( vararg columns : KProperty < C ? > ) : DataFrame < T >


public fun < T , C : Comparable < C > > Grouped < T > . min ( name : String ? = null , columns : ColumnsSelector < T , C ? > , ) : DataFrame < T >

= <EOL> Aggregators . min . aggregateAll ( this , name , columns )


public fun < T > Grouped < T > . min ( vararg columns : String , name : String ? = null ) : DataFrame < T >

= <EOL> min ( name ) { columns . toComparableColumns ( ) }


public fun < T , C : Comparable < C > > Grouped < T > . min ( vararg columns : ColumnReference < C ? > , name : String ? = null , ) : DataFrame < T >

= min ( name ) { columns . toColumnSet ( ) }


public fun < T , C : Comparable < C > > Grouped < T > . min ( vararg columns : KProperty < C ? > , name : String ? = null ) : DataFrame < T >

= <EOL> min ( name ) { columns . toColumnSet ( ) }


public fun < T , C : Comparable < C > > Grouped < T > . minOf ( name : String ? = null , expression : RowExpression < T , C > , ) : DataFrame < T >

= <EOL> Aggregators . min . aggregateOfDelegated ( this , name ) { minOfOrNull ( expression ) }


public fun < T , G , R : Comparable < R > > GroupBy < T , G > . minBy ( rowExpression : RowExpression < G , R ? > ) : ReducedGroupBy < T , G >

= <EOL> reduce { minByOrNull ( rowExpression ) }


public fun < T , G , C : Comparable < C > > GroupBy < T , G > . minBy ( column : ColumnReference < C ? > ) : ReducedGroupBy < T , G >

= <EOL> reduce { minByOrNull ( column ) }


public fun < T , G > GroupBy < T , G > . minBy ( column : String ) : ReducedGroupBy < T , G >

= <EOL> minBy ( column . toColumnAccessor ( ) . cast < Comparable < Any ? > > ( ) )


public fun < T , G , C : Comparable < C > > GroupBy < T , G > . minBy ( column : KProperty < C ? > ) : ReducedGroupBy < T , G >

= <EOL> minBy ( column . toColumnAccessor ( ) )


public fun < T > Pivot < T > . min ( separate : Boolean = false ) : DataRow < T >

= delegate { min ( separate ) }


public fun < T , R : Comparable < R > > Pivot < T > . minFor ( separate : Boolean = false , columns : ColumnsForAggregateSelector < T , R ? > , ) : DataRow < T >

= delegate { minFor ( separate , columns ) }


public fun < T > Pivot < T > . minFor ( vararg columns : String , separate : Boolean = false ) : DataRow < T >

= <EOL> minFor ( separate ) { columns . toComparableColumns ( ) }


public fun < T , R : Comparable < R > > Pivot < T > . minFor ( vararg columns : ColumnReference < R ? > , separate : Boolean = false , ) : DataRow < T >

= minFor ( separate ) { columns . toColumnSet ( ) }


public fun < T , R : Comparable < R > > Pivot < T > . minFor ( vararg columns : KProperty < R ? > , separate : Boolean = false , ) : DataRow < T >


public fun < T , R : Comparable < R > > Pivot < T > . min ( columns : ColumnsSelector < T , R ? > ) : DataRow < T >

= delegate { min ( columns ) }


public fun < T , R : Comparable < R > > Pivot < T > . min ( vararg columns : String ) : DataRow < T >

= <EOL> min { columns . toComparableColumns ( ) }


public fun < T , R : Comparable < R > > Pivot < T > . min ( vararg columns : ColumnReference < R ? > ) : DataRow < T >

= <EOL> min { columns . toColumnSet ( ) }


public fun < T , R : Comparable < R > > Pivot < T > . min ( vararg columns : KProperty < R ? > ) : DataRow < T >


public fun < T , R : Comparable < R > > Pivot < T > . minOf ( rowExpression : RowExpression < T , R > ) : DataRow < T >

= <EOL> delegate { minOf ( rowExpression ) }


public fun < T , R : Comparable < R > > Pivot < T > . minBy ( rowExpression : RowExpression < T , R > ) : ReducedPivot < T >


public fun < T , C : Comparable < C > > Pivot < T > . minBy ( column : ColumnReference < C ? > ) : ReducedPivot < T >


public fun < T > Pivot < T > . minBy ( column : String ) : ReducedPivot < T >


public fun < T , C : Comparable < C > > Pivot < T > . minBy ( column : KProperty < C ? > ) : ReducedPivot < T >


public fun < T > PivotGroupBy < T > . min ( separate : Boolean = false ) : DataFrame < T >

= minFor ( separate , comparableColumns ( ) )


public fun < T , R : Comparable < R > > PivotGroupBy < T > . minFor ( separate : Boolean = false , columns : ColumnsForAggregateSelector < T , R ? > , ) : DataFrame < T >

= <EOL> Aggregators . min . aggregateFor ( this , separate , columns )


public fun < T > PivotGroupBy < T > . minFor ( vararg columns : String , separate : Boolean = false ) : DataFrame < T >


public fun < T , R : Comparable < R > > PivotGroupBy < T > . minFor ( vararg columns : ColumnReference < R ? > , separate : Boolean = false , ) : DataFrame < T >


public fun < T , R : Comparable < R > > PivotGroupBy < T > . minFor ( vararg columns : KProperty < R ? > , separate : Boolean = false , ) : DataFrame < T >


public fun < T , R : Comparable < R > > PivotGroupBy < T > . min ( columns : ColumnsSelector < T , R ? > ) : DataFrame < T >

= <EOL> Aggregators . min . aggregateAll ( this , columns )


public fun < T > PivotGroupBy < T > . min ( vararg columns : String ) : DataFrame < T >

= min { columns . toComparableColumns ( ) }


public fun < T , R : Comparable < R > > PivotGroupBy < T > . min ( vararg columns : ColumnReference < R ? > ) : DataFrame < T >


public fun < T , R : Comparable < R > > PivotGroupBy < T > . min ( vararg columns : KProperty < R ? > ) : DataFrame < T >


public fun < T , R : Comparable < R > > PivotGroupBy < T > . minOf ( rowExpression : RowExpression < T , R > ) : DataFrame < T >

= <EOL> aggregate { minOf ( rowExpression ) }


public fun < T , R : Comparable < R > > PivotGroupBy < T > . minBy ( rowExpression : RowExpression < T , R > ) : ReducedPivotGroupBy < T >


public fun < T , C : Comparable < C > > PivotGroupBy < T > . minBy ( column : ColumnReference < C ? > ) : ReducedPivotGroupBy < T >


public fun < T > PivotGroupBy < T > . minBy ( column : String ) : ReducedPivotGroupBy < T >


public fun < T , C : Comparable < C > > PivotGroupBy < T > . minBy ( column : KProperty < C ? > ) : ReducedPivotGroupBy < T >


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

{ <EOL> val selectedElement = testServices . expressionMarkerProvider . getSelectedElementOfTypeByDirective ( mainFile , mainModule ) as KtElement <EOL> val actual = resolveWithClearCaches ( mainFile ) { session -> <EOL> renderActualFir ( fir = selectedElement . getOrBuildFir ( session ) , ktElement = selectedElement , firFile = mainFile . getOrBuildFirFile ( session ) , ) <EOL> } <EOL> testServices . assertions . assertEqualsToTestDataFileSibling ( actual ) <EOL> }


fun renderActualFir ( fir : FirElement ? , ktElement : KtElement , renderKtText : Boolean = false , firFile : FirFile ? = null , ) : String

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


private fun render ( firElement : FirElement ? ) : String

= when ( firElement ) { <EOL> null -> "<STR_LIT:null>" <EOL> is FirImport -> "<STR_LIT>" <EOL> else -> FirRenderer ( packageDirectiveRenderer = FirPackageDirectiveRenderer ( ) , resolvePhaseRenderer = FirResolvePhaseRenderer ( ) , declarationRenderer = FirDeclarationRendererWithFilteredAttributes ( ) , ) . renderElementAsString ( firElement ) <EOL> }


= Unit


{ <EOL> INSTANCE <EOL> }


{ <EOL> try { <EOL> Test . foo ( ) <EOL> return "<STR_LIT>" <EOL> } catch ( e : Exception ) { <EOL> return "<STR_LIT:OK>" <EOL> } <EOL> }


fun generateTestGroupSuite ( args : Array < String > , mainClassName : String ? = TestGeneratorUtil . getMainClassName ( ) , init : TestGroupSuite . ( ) -> Unit )

{ <EOL> generateTestGroupSuite ( InconsistencyChecker . hasDryRunArg ( args ) , mainClassName , init ) <EOL> }


fun generateTestGroupSuite ( dryRun : Boolean = false , mainClassName : String ? = TestGeneratorUtil . getMainClassName ( ) , init : TestGroupSuite . ( ) -> Unit , )

{ <EOL> val suite = testGroupSuite ( init ) <EOL> suite . forEachTestClassParallel { testClass -> <EOL> val ( changed , testSourceFilePath ) = TestGeneratorImpl . generateAndSave ( testClass , dryRun , mainClassName ) <EOL> if ( changed ) { <EOL> inconsistencyChecker ( dryRun ) . add ( testSourceFilePath ) <EOL> } <EOL> } <EOL> }


= <EOL> if ( c == null ) TODO ( ) <EOL> else when ( c ) { <EOL> '<CHAR_LIT:a>' -> when ( c ) { <EOL> '<CHAR_LIT>' -> <NUM_LIT:1> <EOL> '<CHAR_LIT>' -> "<STR_LIT>" <EOL> else -> TODO ( ) <EOL> } <EOL> else -> TODO ( ) <EOL> }


override fun check ( expression : IrCall , context : JsKlibDiagnosticContext , reporter : IrDiagnosticReporter )

{ <EOL> if ( ! context . compilerConfiguration . languageVersionSettings . languageVersion . usesK2 ) { <EOL> return <EOL> } <EOL> if ( expression . symbol . owner . fqNameWhenAvailable != jsCodeFqName ) { <EOL> return <EOL> } <EOL> val jsCodeExpr = expression . getValueArgument ( <NUM_LIT:0> ) <EOL> if ( jsCodeExpr !is IrConst < * > || jsCodeExpr . kind != IrConstKind . String ) { <EOL> reporter . at ( jsCodeExpr ? : expression , context ) . report ( JsKlibErrors . JSCODE_CAN_NOT_VERIFY_JAVASCRIPT ) <EOL> return <EOL> } <EOL> val jsCodeStr = IrConstKind . String . valueOf ( jsCodeExpr ) <EOL> try { <EOL> val parserScope = JsFunctionScope ( JsRootScope ( JsProgram ( ) ) , "<STR_LIT>" ) <EOL> val fileName = context . containingFile ? . fileEntry ? . name ? : "<STR_LIT>" <EOL> val jsErrorReporter = JsErrorReporter ( jsCodeExpr , context , reporter ) <EOL> val statements = parseExpressionOrStatement ( jsCodeStr , jsErrorReporter , parserScope , CodePosition ( <NUM_LIT:0> , <NUM_LIT:0> ) , fileName ) <EOL> if ( statements . isNullOrEmpty ( ) ) { <EOL> reporter . at ( jsCodeExpr , context ) . report ( JsKlibErrors . JSCODE_NO_JAVASCRIPT_PRODUCED ) <EOL> } <EOL> } catch ( e : AbortParsingException ) { <EOL> } <EOL> }


override fun warning ( message : String , startPosition : CodePosition , endPosition : CodePosition )

{ <EOL> reporter . at ( codeExpression , context ) . report ( JsKlibErrors . JSCODE_WARNING , message ) <EOL> }


override fun error ( message : String , startPosition : CodePosition , endPosition : CodePosition )

{ <EOL> reporter . at ( codeExpression , context ) . report ( JsKlibErrors . JSCODE_ERROR , message ) <EOL> throw AbortParsingException ( ) <EOL> }


operator fun minus ( other : AbstractProjectFileSearchScope ) : AbstractProjectFileSearchScope


operator fun plus ( other : AbstractProjectFileSearchScope ) : AbstractProjectFileSearchScope


operator fun not ( ) : AbstractProjectFileSearchScope


override fun minus ( other : AbstractProjectFileSearchScope ) : AbstractProjectFileSearchScope

= this


override fun plus ( other : AbstractProjectFileSearchScope ) : AbstractProjectFileSearchScope

= other


override fun not ( ) : AbstractProjectFileSearchScope

= ANY


= error ( "<STR_LIT>" )


= this


= EMPTY


fun getKotlinClassFinder ( fileSearchScope : AbstractProjectFileSearchScope ) : KotlinClassFinder


fun getJavaModuleResolver ( ) : JavaModuleResolver


fun getPackagePartProvider ( fileSearchScope : AbstractProjectFileSearchScope ) : PackagePartProvider


fun registerAsJavaElementFinder ( firSession : FirSession )


fun getSearchScopeByIoFiles ( files : Iterable < File > , allowOutOfProjectRoots : Boolean = false ) : AbstractProjectFileSearchScope


fun getSearchScopeBySourceFiles ( files : Iterable < KtSourceFile > , allowOutOfProjectRoots : Boolean = false ) : AbstractProjectFileSearchScope


fun getSearchScopeByDirectories ( directories : Iterable < File > ) : AbstractProjectFileSearchScope


fun getSearchScopeForProjectLibraries ( ) : AbstractProjectFileSearchScope


fun getSearchScopeForProjectJavaSources ( ) : AbstractProjectFileSearchScope


fun getFirJavaFacade ( firSession : FirSession , baseModuleData : FirModuleData , fileSearchScope : AbstractProjectFileSearchScope ) : FirJavaFacade


fun foo ( param : Int )


@ Test <EOL> fun `test that outgoing configuration of binary frameworks should have user defined attributes` ( )

{ <EOL> val disambiguationAttribute1 = Attribute . of ( "<STR_LIT>" , String :: class . java ) <EOL> val disambiguationAttribute2 = Attribute . of ( "<STR_LIT>" , String :: class . java ) <EOL> val project = buildProjectWithMPP { <EOL> kotlin { <EOL> iosArm64 ( "<STR_LIT>" ) { <EOL> attributes . attributeProvider ( disambiguationAttribute1 , provider { "<STR_LIT>" } ) <EOL> binaries { <EOL> framework ( "<STR_LIT:main>" ) <EOL> framework ( "<STR_LIT>" ) { <EOL> embedBitcode ( "<STR_LIT>" ) <EOL> linkerOpts = mutableListOf ( "<STR_LIT>" ) <EOL> freeCompilerArgs = mutableListOf ( "<STR_LIT>" ) <EOL> isStatic = true <EOL> attributes . attributeProvider ( disambiguationAttribute2 , provider { "<STR_LIT>" } ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> project . evaluate ( ) <EOL> val customReleaseFrameworkIos = project . configurations . getByName ( "<STR_LIT>" ) <EOL> val attribute1Value = customReleaseFrameworkIos . attributes . getAttribute ( disambiguationAttribute1 ) <EOL> if ( attribute1Value != "<STR_LIT>" ) { <EOL> fail ( "<STR_LIT>" ) <EOL> } <EOL> val attribute2Value = customReleaseFrameworkIos . attributes . getAttribute ( disambiguationAttribute2 ) <EOL> if ( attribute2Value != "<STR_LIT>" ) { <EOL> fail ( "<STR_LIT>" ) <EOL> } <EOL> }


{ <EOL> val a1 = arrayOf < String > ( ) <EOL> val a2 = arrayOf ( "<STR_LIT:foo>" ) <EOL> val a3 = arrayOf ( "<STR_LIT:foo>" , "<STR_LIT:bar>" ) <EOL> return a1 . size + a2 . size + a3 . size <EOL> }


{ <EOL> val a1 = arrayOf < String > ( ) <EOL> val a2 = arrayOf ( "<STR_LIT:foo>" ) <EOL> val a3 = arrayOf ( "<STR_LIT:foo>" , "<STR_LIT:bar>" ) <EOL> return a1 . toList ( ) . toString ( ) + "<STR_LIT:->" + a2 . toList ( ) . toString ( ) + "<STR_LIT:->" + a3 . toList ( ) . toString ( ) <EOL> }


fun firstNotNullLen ( s1 : String ? , s2 : String ? , s3 : String ? ) : Int

{ <EOL> val len = ( s1 ? . length ? : s2 ? . length ) ? : <EOL> ( s2 ? . length ? : s3 ? . length ) ? : <EOL> return <NUM_LIT:0> <EOL> return len <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:1> , firstNotNullLen ( "<STR_LIT:a>" , null , null ) ) <EOL> assertEquals ( <NUM_LIT:2> , firstNotNullLen ( null , "<STR_LIT>" , null ) ) <EOL> assertEquals ( <NUM_LIT:3> , firstNotNullLen ( null , null , "<STR_LIT:abc>" ) ) <EOL> assertEquals ( <NUM_LIT:0> , firstNotNullLen ( null , null , null ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> v . defineClass ( element , state . config . classFileVersion , ACC_FINAL or ACC_SUPER or DescriptorAsmUtil . getVisibilityAccessFlagForClass ( classDescriptor ) or DescriptorAsmUtil . getSyntheticAccessFlagForLambdaClass ( classDescriptor ) , asmType . internalName , null , superAsmType . internalName , emptyArray ( ) ) <EOL> v . visitSource ( element . containingFile . name , null ) <EOL> }


{ <EOL> if ( JvmCodegenUtil . isConst ( closure ) ) { <EOL> generateConstInstance ( asmType , wrapperMethod . returnType ) <EOL> } else { <EOL> DescriptorAsmUtil . genClosureFields ( closure , v , typeMapper , state . languageVersionSettings ) <EOL> } <EOL> generateConstructor ( ) <EOL> if ( ! isOptimizedPropertyReferenceSupertype ( superAsmType ) ) { <EOL> generateMethod ( "<STR_LIT>" , ACC_PUBLIC , method ( "<STR_LIT>" , JAVA_STRING_TYPE ) ) { <EOL> aconst ( target . name . asString ( ) ) <EOL> } <EOL> generateMethod ( "<STR_LIT>" , ACC_PUBLIC , method ( "<STR_LIT>" , JAVA_STRING_TYPE ) ) { <EOL> generatePropertyReferenceSignature ( this , target , state ) <EOL> } <EOL> generateMethod ( "<STR_LIT>" , ACC_PUBLIC , method ( "<STR_LIT>" , K_DECLARATION_CONTAINER_TYPE ) ) { <EOL> generateCallableReferenceDeclarationContainer ( this , target , state ) <EOL> } <EOL> } <EOL> if ( ! isLocalDelegatedProperty ) { <EOL> generateAccessors ( ) <EOL> } <EOL> }


{ <EOL> generateMethod ( "<STR_LIT>" , <NUM_LIT:0> , constructor ) { <EOL> val shouldHaveBoundReferenceReceiver = closure . isForBoundCallableReference ( ) <EOL> val receiverIndexAndFieldInfo = generateClosureFieldsInitializationFromParameters ( closure , constructorArgs ) <EOL> load ( <NUM_LIT:0> , OBJECT_TYPE ) <EOL> val superCtorArgTypes = mutableListOf < Type > ( ) <EOL> if ( receiverIndexAndFieldInfo != null ) { <EOL> val ( receiverIndex , receiverFieldInfo ) = receiverIndexAndFieldInfo <EOL> loadBoundReferenceReceiverParameter ( receiverIndex , receiverFieldInfo . fieldType , receiverFieldInfo . fieldKotlinType ) <EOL> superCtorArgTypes . add ( OBJECT_TYPE ) <EOL> } else { <EOL> assert ( ! shouldHaveBoundReferenceReceiver ) { "<STR_LIT>" } <EOL> } <EOL> if ( isOptimizedPropertyReferenceSupertype ( superAsmType ) ) { <EOL> generateCallableReferenceDeclarationContainerClass ( this , target , state ) <EOL> aconst ( target . name . asString ( ) ) <EOL> generatePropertyReferenceSignature ( this , target , state ) <EOL> aconst ( getCallableReferenceTopLevelFlag ( target ) ) <EOL> superCtorArgTypes . add ( JAVA_CLASS_TYPE ) <EOL> superCtorArgTypes . add ( JAVA_STRING_TYPE ) <EOL> superCtorArgTypes . add ( JAVA_STRING_TYPE ) <EOL> superCtorArgTypes . add ( Type . INT_TYPE ) <EOL> } <EOL> invokespecial ( superAsmType . internalName , "<STR_LIT:<init>>" , Type . getMethodDescriptor ( Type . VOID_TYPE , * superCtorArgTypes . toTypedArray ( ) ) , false ) <EOL> } <EOL> }


{ <EOL> val getFunction = findGetFunction ( localVariableDescriptorForReference ) <EOL> val getImpl = createFakeOpenDescriptor ( getFunction , classDescriptor ) <EOL> functionCodegen . generateMethod ( JvmDeclarationOrigin . NO_ORIGIN , getImpl , PropertyReferenceGenerationStrategy ( true , getFunction , target , asmType , boundReceiverJvmKotlinType , element , state , false ) ) <EOL> if ( ! ReflectionTypes . isNumberedKMutablePropertyType ( localVariableDescriptorForReference . type ) ) return <EOL> val setFunction = localVariableDescriptorForReference . type . memberScope . getContributedFunctions ( OperatorNameConventions . SET , NoLookupLocation . FROM_BACKEND ) . single ( ) <EOL> val setImpl = createFakeOpenDescriptor ( setFunction , classDescriptor ) <EOL> functionCodegen . generateMethod ( JvmDeclarationOrigin . NO_ORIGIN , setImpl , PropertyReferenceGenerationStrategy ( false , setFunction , target , asmType , boundReceiverJvmKotlinType , element , state , false ) ) <EOL> }


private fun generateMethod ( debugString : String , access : Int , method : Method , generate : InstructionAdapter . ( ) -> Unit )

{ <EOL> v . generateMethod ( debugString , access , method , element , JvmDeclarationOrigin . NO_ORIGIN , state , generate ) <EOL> }


override fun generateKotlinMetadataAnnotation ( )

{ <EOL> writeSyntheticClassMetadata ( v , state . config , InlineUtil . isInPublicInlineScope ( classDescriptor ) ) <EOL> }


fun putInstanceOnStack ( receiverValue : StackValue ? ) : StackValue

{ <EOL> return StackValue . operation ( wrapperMethod . returnType ) { iv -> <EOL> if ( JvmCodegenUtil . isConst ( closure ) ) { <EOL> assert ( receiverValue == null ) { "<STR_LIT>" } <EOL> iv . getstatic ( asmType . internalName , JvmAbi . INSTANCE_FIELD , wrapperMethod . returnType . descriptor ) <EOL> } else { <EOL> assert ( receiverValue != null ) { "<STR_LIT>" } <EOL> iv . anew ( asmType ) <EOL> iv . dup ( ) <EOL> receiverValue ! ! . put ( receiverValue . type , receiverValue . kotlinType , iv ) <EOL> iv . invokespecial ( asmType . internalName , "<STR_LIT:<init>>" , constructor . descriptor , false ) <EOL> } <EOL> } <EOL> }


override fun get ( key : KotlinType ) : TypeProjection ?

{ <EOL> if ( KotlinBuiltIns . isUnit ( key ) ) { <EOL> return TypeProjectionImpl ( key ) <EOL> } <EOL> return TypeProjectionImpl ( key . builtIns . nullableAnyType ) <EOL> }


@ JvmStatic <EOL> fun getWrapperMethodForPropertyReference ( property : VariableDescriptor , receiverCount : Int ) : Method

{ <EOL> return when ( receiverCount ) { <EOL> <NUM_LIT:2> -> when { <EOL> property . isVar -> method ( "<STR_LIT>" , K_MUTABLE_PROPERTY2_TYPE , MUTABLE_PROPERTY_REFERENCE2 ) <EOL> else -> method ( "<STR_LIT>" , K_PROPERTY2_TYPE , PROPERTY_REFERENCE2 ) <EOL> } <EOL> <NUM_LIT:1> -> when { <EOL> property . isVar -> method ( "<STR_LIT>" , K_MUTABLE_PROPERTY1_TYPE , MUTABLE_PROPERTY_REFERENCE1 ) <EOL> else -> method ( "<STR_LIT>" , K_PROPERTY1_TYPE , PROPERTY_REFERENCE1 ) <EOL> } <EOL> else -> when { <EOL> property . isVar -> method ( "<STR_LIT>" , K_MUTABLE_PROPERTY0_TYPE , MUTABLE_PROPERTY_REFERENCE0 ) <EOL> else -> method ( "<STR_LIT>" , K_PROPERTY0_TYPE , PROPERTY_REFERENCE0 ) <EOL> } <EOL> } <EOL> }


@ JvmStatic <EOL> fun createFakeOpenDescriptor ( getFunction : FunctionDescriptor , classDescriptor : ClassDescriptor ) : FunctionDescriptor

{ <EOL> val copy = getFunction . original . copy ( classDescriptor , Modality . OPEN , getFunction . visibility , getFunction . kind , false ) <EOL> return copy . substitute ( ANY_SUBSTITUTOR ) ! ! <EOL> }


@ JvmStatic <EOL> fun findGetFunction ( localVariableDescriptorForReference : VariableDescriptor )

= <EOL> localVariableDescriptorForReference . type . memberScope . getContributedFunctions ( OperatorNameConventions . GET , NoLookupLocation . FROM_BACKEND ) . single ( )


override fun doGenerateBody ( codegen : ExpressionCodegen , signature : JvmMethodSignature )

{ <EOL> val v = codegen . v <EOL> val typeMapper = state . typeMapper <EOL> val targetKotlinType = target . type <EOL> if ( target is PropertyImportedFromObject ) { <EOL> val containingObject = target . containingObject <EOL> StackValue <EOL> . singleton ( containingObject , typeMapper ) <EOL> . put ( typeMapper . mapClass ( containingObject ) , containingObject . defaultType , v ) <EOL> } <EOL> if ( boundReceiverType != null ) { <EOL> capturedBoundReferenceReceiver ( asmType , boundReceiverType , boundReceiverKotlinType , isInliningStrategy ) <EOL> . put ( expectedReceiverType ! ! , expectedReceiverKotlinType , v ) <EOL> } else { <EOL> val receivers = originalFunctionDesc . valueParameters . dropLast ( if ( isGetter ) <NUM_LIT:0> else <NUM_LIT:1> ) <EOL> receivers . forEachIndexed { i , valueParameterDescriptor -> <EOL> val nullableAny = valueParameterDescriptor . builtIns . nullableAnyType <EOL> StackValue . local ( i + <NUM_LIT:1> , OBJECT_TYPE , nullableAny ) <EOL> . put ( typeMapper . mapType ( valueParameterDescriptor ) , valueParameterDescriptor . type , v ) <EOL> } <EOL> } <EOL> val value = when { <EOL> target is LocalVariableDescriptor -> codegen . findLocalOrCapturedValue ( target ) ! ! <EOL> target . isUnderlyingPropertyOfInlineClass ( ) -> { <EOL> if ( expectedReceiverType == null ) <EOL> throw AssertionError ( "<STR_LIT>" ) <EOL> val receiver = <EOL> if ( boundReceiverType != null ) <EOL> StackValue . onStack ( expectedReceiverType , expectedReceiverKotlinType ) <EOL> else <EOL> StackValue . none ( ) <EOL> StackValue . underlyingValueOfInlineClass ( typeMapper . mapType ( targetKotlinType ) , targetKotlinType , receiver ) <EOL> } <EOL> else -> codegen . intermediateValueForProperty ( target as PropertyDescriptor , false , null , StackValue . none ( ) ) <EOL> } <EOL> codegen . markStartLineNumber ( expression ) <EOL> if ( isGetter ) { <EOL> value . put ( OBJECT_TYPE , targetKotlinType , v ) <EOL> } else { <EOL> value . store ( StackValue . local ( codegen . frameMap . getIndex ( codegen . context . functionDescriptor . valueParameters . last ( ) ) , OBJECT_TYPE , targetKotlinType ) , v ) <EOL> } <EOL> v . areturn ( signature . returnType ) <EOL> }


{ <EOL> val l = listOf ( Wrapper ( EType . A ) , Wrapper ( null ) ) <EOL> val ll = l . map { <EOL> when ( it . t ) { <EOL> EType . A -> "<STR_LIT:O>" <EOL> null -> "<STR_LIT:K>" <EOL> } <EOL> } <EOL> return ll [ <NUM_LIT:0> ] + ll [ <NUM_LIT:1> ] <EOL> }


= x


{ <EOL> return Sample < Int > ( ) <EOL> }


{ <EOL> targetArgument <EOL> return "<STR_LIT:OK>" <EOL> }


public fun renderUseSiteTarget ( analysisSession : KtAnalysisSession , annotation : KtAnnotationApplication , owner : KtAnnotated , annotationRenderer : KtAnnotationRenderer , printer : PrettyPrinter , )


override fun renderUseSiteTarget ( analysisSession : KtAnalysisSession , annotation : KtAnnotationApplication , owner : KtAnnotated , annotationRenderer : KtAnnotationRenderer , printer : PrettyPrinter , )


{ <EOL> val useSite = annotation . useSiteTarget ? : return <EOL> printer . append ( useSite . renderName ) <EOL> printer . append ( '<CHAR_LIT::>' ) <EOL> }


{ <EOL> val print = when ( owner ) { <EOL> is KtReceiverParameterSymbol -> true <EOL> !is KtCallableSymbol -> return <EOL> is KtAnonymousFunctionSymbol -> true <EOL> is KtConstructorSymbol -> true <EOL> is KtFunctionSymbol -> true <EOL> is KtPropertyGetterSymbol -> annotation . useSiteTarget != AnnotationUseSiteTarget . PROPERTY_GETTER <EOL> is KtPropertySetterSymbol -> annotation . useSiteTarget != AnnotationUseSiteTarget . PROPERTY_SETTER <EOL> is KtSamConstructorSymbol -> true <EOL> is KtBackingFieldSymbol -> annotation . useSiteTarget != AnnotationUseSiteTarget . FIELD <EOL> is KtEnumEntrySymbol -> true <EOL> is KtValueParameterSymbol -> { <EOL> val containingSymbol = with ( analysisSession ) { owner . getContainingSymbol ( ) } <EOL> containingSymbol !is KtPropertySetterSymbol || annotation . useSiteTarget != AnnotationUseSiteTarget . SETTER_PARAMETER <EOL> } <EOL> is KtJavaFieldSymbol -> true <EOL> is KtLocalVariableSymbol -> true <EOL> is KtPropertySymbol -> annotation . useSiteTarget != AnnotationUseSiteTarget . PROPERTY <EOL> else -> return <EOL> } <EOL> if ( print ) { <EOL> WITH_USES_SITE . renderUseSiteTarget ( analysisSession , annotation , owner , annotationRenderer , printer ) <EOL> } <EOL> }


protected fun assign ( dim : Int , values : FloatArray )

{ <EOL> glBindBuffer ( GL_ARRAY_BUFFER , this . buffer ) <EOL> glBufferData ( GL_ARRAY_BUFFER , ( values . size * <NUM_LIT:4> ) . signExtend ( ) , values . refTo ( <NUM_LIT:0> ) , GL_STREAM_DRAW ) <EOL> glEnableVertexAttribArray ( this . location ) <EOL> glVertexAttribPointer ( this . location , dim , GL_FLOAT , GL_FALSE . convert ( ) , <NUM_LIT:0> , null ) <EOL> }


= this . assign ( <NUM_LIT:1> , values )


fun assign ( values : List < Vector2 > )

= this . assign ( <NUM_LIT:2> , values . flatten ( ) )


fun assign ( values : List < Vector3 > )

= this . assign ( <NUM_LIT:3> , values . flatten ( ) )


= glUniform1i ( this . location , value )


= glUniform2f ( this . location , value . x , value . y )


= glUniform3f ( this . location , value . x , value . y , value . z )


= <EOL> glUniformMatrix4fv ( this . location , <NUM_LIT:1> , GL_FALSE . convert ( ) , value . flatten ( ) . refTo ( <NUM_LIT:0> ) )


{ <EOL> glUseProgram ( this . program ) <EOL> glBindVertexArray ( vertexArrayObject ) <EOL> }


private fun compileGlShader ( type : GLenum , source : String )

= memScoped { <EOL> val shader = glCreateShader ( type ) <EOL> checkGlError ( ) <EOL> if ( shader == <NUM_LIT> ) throw Error ( "<STR_LIT>" ) <EOL> glShaderSource ( shader , <NUM_LIT:1> , cValuesOf ( source . cstr . getPointer ( memScope ) ) , null ) <EOL> glCompileShader ( shader ) <EOL> val statusVar = alloc < GLintVar > ( ) <EOL> glGetShaderiv ( shader , GL_COMPILE_STATUS , statusVar . ptr ) <EOL> if ( statusVar . value != GL_TRUE ) { <EOL> val logBuffer = allocArray < ByteVar > ( <NUM_LIT> ) <EOL> glGetShaderInfoLog ( shader , <NUM_LIT> , null , logBuffer ) <EOL> throw Error ( "<STR_LIT>" ) <EOL> } <EOL> checkGlError ( ) <EOL> shader <EOL> }


= memScoped { <EOL> val bufferVar = alloc < GLuintVar > ( ) <EOL> glGenBuffers ( <NUM_LIT:1> , bufferVar . ptr ) <EOL> checkGlError ( ) <EOL> bufferVar . value <EOL> }


{ <EOL> val error = glGetError ( ) . toInt ( ) <EOL> if ( error != <NUM_LIT:0> ) { <EOL> val errorString = when ( error ) { <EOL> GL_INVALID_ENUM -> "<STR_LIT>" <EOL> GL_INVALID_VALUE -> "<STR_LIT>" <EOL> GL_INVALID_OPERATION -> "<STR_LIT>" <EOL> GL_INVALID_FRAMEBUFFER_OPERATION -> "<STR_LIT>" <EOL> GL_OUT_OF_MEMORY -> "<STR_LIT>" <EOL> else -> "<STR_LIT>" <EOL> } <EOL> throw Error ( "<STR_LIT>" ) <EOL> } <EOL> }


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

= <EOL> visitor . visitReceiverParameter ( this , data )


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> override fun < E : FirElement , D > transform ( transformer : FirTransformer < D > , data : D ) : E

= <EOL> transformer . transformReceiverParameter ( this , data ) as E


abstract fun replaceTypeRef ( newTypeRef : FirTypeRef )


abstract override fun replaceAnnotations ( newAnnotations : List < FirAnnotation > )


abstract fun < D > transformTypeRef ( transformer : FirTransformer < D > , data : D ) : FirReceiverParameter


abstract override fun < D > transformAnnotations ( transformer : FirTransformer < D > , data : D ) : FirReceiverParameter


override fun apply ( project : Project )

{ <EOL> project . dynamicallyApplyWhenAndroidPluginIsApplied ( { <EOL> project . objects . newInstance ( KotlinAndroidTarget :: class . java , "<STR_LIT>" , project ) . also { target -> <EOL> val kotlinAndroidExtension = project . kotlinExtension as KotlinAndroidProjectExtension <EOL> kotlinAndroidExtension . targetFuture . complete ( target ) <EOL> project . configureCompilerOptionsForTarget ( kotlinAndroidExtension . compilerOptions , target . compilerOptions ) <EOL> kotlinAndroidExtension . compilerOptions . noJdk . value ( true ) . disallowChanges ( ) <EOL> @ Suppress ( "<STR_LIT:DEPRECATION>" ) val kotlinOptions = object : KotlinJvmOptions { <EOL> override val options : KotlinJvmCompilerOptions <EOL> get ( ) = kotlinAndroidExtension . compilerOptions <EOL> } <EOL> val ext = project . extensions . getByName ( "<STR_LIT>" ) as BaseExtension <EOL> ext . addExtension ( KOTLIN_OPTIONS_DSL_NAME , kotlinOptions ) <EOL> } <EOL> } ) { androidTarget -> <EOL> registry . register ( KotlinModelBuilder ( project . getKotlinPluginVersion ( ) , androidTarget ) ) <EOL> project . whenEvaluated { project . components . addAll ( androidTarget . components ) } <EOL> } <EOL> }


fun androidTargetHandler ( ) : AndroidProjectHandler

{ <EOL> val tasksProvider = KotlinTasksProvider ( ) <EOL> val androidGradlePluginVersion = AndroidGradlePluginVersion . currentOrNull <EOL> if ( androidGradlePluginVersion != null ) { <EOL> if ( androidGradlePluginVersion < minimalSupportedAgpVersion ) { <EOL> throw IllegalStateException ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> } <EOL> return AndroidProjectHandler ( tasksProvider ) <EOL> }


internal fun Project . dynamicallyApplyWhenAndroidPluginIsApplied ( kotlinAndroidTargetProvider : ( ) -> KotlinAndroidTarget , additionalConfiguration : ( KotlinAndroidTarget ) -> Unit = { } )

{ <EOL> var wasConfigured = false <EOL> androidPluginIds . forEach { pluginId -> <EOL> plugins . withId ( pluginId ) { <EOL> wasConfigured = true <EOL> val target = kotlinAndroidTargetProvider ( ) <EOL> androidTargetHandler ( ) . configureTarget ( target ) <EOL> additionalConfiguration ( target ) <EOL> } <EOL> } <EOL> afterEvaluate { <EOL> if ( ! wasConfigured ) { <EOL> throw GradleException ( """<STR_LIT>""" . trimMargin ( ) ) <EOL> } <EOL> } <EOL> }


override fun eval ( script : String , context : ScriptContext ) : Any ?

= compileAndEval ( script , context )


override fun eval ( script : Reader , context : ScriptContext ) : Any ?

= compileAndEval ( script . readText ( ) , context )


override fun compile ( script : String ) : CompiledScript

= compile ( script , getContext ( ) )


override fun compile ( script : Reader ) : CompiledScript

= compile ( script . readText ( ) , getContext ( ) )


override fun createBindings ( ) : Bindings

= SimpleBindings ( ) . apply { put ( KOTLIN_SCRIPT_ENGINE_BINDINGS_KEY , this ) }


override fun getFactory ( ) : ScriptEngineFactory

= myFactory


fun nextCodeLine ( context : ScriptContext , code : String )

= getCurrentState ( context ) . let { ReplCodeLine ( it . getNextLineNo ( ) , it . currentGeneration , code ) }


protected abstract fun createState ( lock : ReentrantReadWriteLock = ReentrantReadWriteLock ( ) ) : IReplStageState < * >


protected fun getCurrentState ( context : ScriptContext )

= <EOL> context . getBindings ( ScriptContext . ENGINE_SCOPE ) <EOL> . getOrPut ( KOTLIN_SCRIPT_STATE_BINDINGS_KEY , { <EOL> context . getBindings ( ScriptContext . ENGINE_SCOPE ) . put ( KOTLIN_SCRIPT_ENGINE_BINDINGS_KEY , this @ KotlinJsr223JvmScriptEngineBase ) <EOL> createState ( ) <EOL> } ) as IReplStageState < * >


open fun getInvokeWrapper ( context : ScriptContext ) : InvokeWrapper ?

= null


open fun overrideScriptArgs ( context : ScriptContext ) : ScriptArgsWithTypes ?

= null


open fun compileAndEval ( script : String , context : ScriptContext ) : Any ?

{ <EOL> val codeLine = nextCodeLine ( context , script ) <EOL> val state = getCurrentState ( context ) <EOL> return asJsr223EvalResult { <EOL> replEvaluator . compileAndEval ( state , codeLine , overrideScriptArgs ( context ) , getInvokeWrapper ( context ) ) <EOL> } <EOL> }


open fun compile ( script : String , context : ScriptContext ) : CompiledScript

{ <EOL> val codeLine = nextCodeLine ( context , script ) <EOL> val state = getCurrentState ( context ) <EOL> val result = replCompiler . compile ( state , codeLine ) <EOL> val compiled = when ( result ) { <EOL> is ReplCompileResult . Error -> throw ScriptException ( "<STR_LIT>" ) <EOL> is ReplCompileResult . Incomplete -> throw ScriptException ( "<STR_LIT>" ) <EOL> is ReplCompileResult . CompiledClasses -> result <EOL> } <EOL> return CompiledKotlinScript ( this , codeLine , compiled ) <EOL> }


open fun eval ( compiledScript : CompiledKotlinScript , context : ScriptContext ) : Any ?

{ <EOL> val state = getCurrentState ( context ) <EOL> return asJsr223EvalResult { <EOL> replEvaluator . eval ( state , compiledScript . compiledData , overrideScriptArgs ( context ) , getInvokeWrapper ( context ) ) <EOL> } <EOL> }


private fun asJsr223EvalResult ( body : ( ) -> ReplEvalResult ) : Any ?

{ <EOL> val result = try { <EOL> body ( ) <EOL> } catch ( e : Exception ) { <EOL> throw ScriptException ( e ) <EOL> } <EOL> return when ( result ) { <EOL> is ReplEvalResult . ValueResult -> result . value <EOL> is ReplEvalResult . UnitResult -> null <EOL> is ReplEvalResult . Error -> <EOL> when { <EOL> result is ReplEvalResult . Error . Runtime && result . cause != null -> <EOL> throw ScriptException ( ( result . cause as? java . lang . Exception ) ? : RuntimeException ( result . cause ) ) <EOL> result is ReplEvalResult . Error . CompileTime && result . location != null -> <EOL> throw ScriptException ( result . message , result . location . path , result . location . line , result . location . column ) <EOL> else -> throw ScriptException ( result . message ) <EOL> } <EOL> is ReplEvalResult . Incomplete -> throw ScriptException ( "<STR_LIT>" ) <EOL> is ReplEvalResult . HistoryMismatch -> throw ScriptException ( "<STR_LIT>" ) <EOL> } <EOL> }


override fun eval ( context : ScriptContext ) : Any ?

= engine . eval ( this , context )


override fun getEngine ( ) : ScriptEngine

= engine


private fun ReplCompileResult . Error . locationString ( )

= <EOL> if ( location == null ) "<STR_LIT>" <EOL> else "<STR_LIT>"


@ Test <EOL> fun testResolverRepoOrder ( )

{ <EOL> val res = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> Assertions . assertTrue ( res . metadata . newClasspath . size >= <NUM_LIT:2> ) <EOL> }


@ Test <EOL> fun testStandardLibraryResolver ( )

{ <EOL> val baseClassLoader = repl . currentClassLoader . parent <EOL> fun urlClassLoadersCount ( ) = <EOL> generateSequence ( repl . currentClassLoader ) { classLoader -> <EOL> classLoader . parent ? . takeIf { it != baseClassLoader } <EOL> } . filter { it is URLClassLoader } . count ( ) <EOL> urlClassLoadersCount ( ) shouldBe <NUM_LIT:1> <EOL> val res = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> assertEquals ( "<STR_LIT>" , res . renderedValue ) <EOL> urlClassLoadersCount ( ) shouldBe <NUM_LIT:2> <EOL> eval ( "<STR_LIT>" ) <EOL> urlClassLoadersCount ( ) shouldBe <NUM_LIT:2> <EOL> }


@ Test <EOL> fun testDefaultInfoSwitcher ( )

{ <EOL> val infoProvider = repl . resolutionInfoProvider <EOL> val initialDefaultResolutionInfo = infoProvider . fallback <EOL> Assertions . assertTrue ( initialDefaultResolutionInfo is AbstractLibraryResolutionInfo . ByClasspath ) <EOL> eval ( "<STR_LIT>" ) <EOL> Assertions . assertTrue ( infoProvider . fallback is AbstractLibraryResolutionInfo . ByGitRef ) <EOL> eval ( "<STR_LIT>" ) <EOL> Assertions . assertTrue ( infoProvider . fallback === initialDefaultResolutionInfo ) <EOL> }


{ <EOL> val commit = "<STR_LIT>" <EOL> val libsCommit = "<STR_LIT>" <EOL> val libraryPath = "<STR_LIT>" <EOL> val res1 = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> assertEquals ( <NUM_LIT:42> , res1 . renderedValue ) <EOL> val res2 = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> assertEquals ( <NUM_LIT> , res2 . renderedValue ) <EOL> val res3 = eval ( "<STR_LIT>" ) <EOL> assertEquals ( <NUM_LIT:1> , displays . count ( ) ) <EOL> assertUnit ( res3 . renderedValue ) <EOL> displays . clear ( ) <EOL> val res4 = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> assertEquals ( <NUM_LIT> , res4 . renderedValue ) <EOL> }


@ Test <EOL> fun testHttpRedirection ( )

{ <EOL> val res = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) . renderedValue <EOL> assertEquals ( <NUM_LIT:1> , res ) <EOL> }


@ Test <EOL> fun testLibraryRequestsRecording ( )

{ <EOL> eval ( "<STR_LIT>" ) <EOL> val res = eval ( "<STR_LIT>" ) . renderedValue <EOL> res . shouldBeInstanceOf < List < LibraryResolutionRequest > > ( ) <EOL> res . shouldHaveSize ( <NUM_LIT:3> ) <EOL> val expectedLibs = listOf ( "<STR_LIT:default>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> for ( i in res . indices ) { <EOL> res [ i ] . reference . name shouldBe expectedLibs [ i ] <EOL> res [ i ] . definition . originalDescriptorText . shouldNotBeBlank ( ) <EOL> } <EOL> }


@ Test <EOL> fun testLocalLibrariesStorage ( )

{ <EOL> @ Language ( "<STR_LIT>" ) <EOL> val descriptorText = <EOL> """<STR_LIT>""" . trimIndent ( ) <EOL> val libName = "<STR_LIT>" <EOL> val file = KERNEL_LIBRARIES . userLibrariesDir . resolve ( KERNEL_LIBRARIES . descriptorFileName ( libName ) ) <EOL> file . delete ( ) <EOL> file . parentFile . mkdirs ( ) <EOL> file . writeText ( descriptorText ) <EOL> val result = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> assertEquals ( <NUM_LIT> , result . renderedValue ) <EOL> file . delete ( ) <EOL> }


@ Test <EOL> fun `multiple integrations in one JAR with the filter enabled` ( )

{ <EOL> fun includeLib ( name : String ) = eval ( "<STR_LIT>" ) <EOL> includeLib ( "<STR_LIT>" ) <EOL> eval ( "<STR_LIT>" ) . renderedValue shouldBe <NUM_LIT:1> <EOL> evalError < ReplCompilerException > ( "<STR_LIT>" ) <EOL> includeLib ( "<STR_LIT>" ) <EOL> eval ( "<STR_LIT>" ) . renderedValue shouldBe <NUM_LIT:2> <EOL> eval ( """<STR_LIT>""" ) <EOL> . shouldBeTypeOf < EvalResultEx . Success > ( ) <EOL> }


@ Test <EOL> @ Disabled <EOL> fun kotlinSpark ( )

{ <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> var res : EvalResultEx ? = null <EOL> val resultThread = <EOL> thread ( contextClassLoader = repl . currentClassLoader ) { <EOL> res = eval ( "<STR_LIT>" ) <EOL> } <EOL> resultThread . join ( ) <EOL> val resultValue = res ? . renderedValue <EOL> resultValue . shouldBeInstanceOf < MimeTypedResult > ( ) <EOL> }


@ Test <EOL> fun `transitive sources are resolved even they are lacking for some of the dependencies in the graph` ( )

{ <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> val result = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> with ( result . metadata . newSources ) { <EOL> filter { "<STR_LIT>" in it } . shouldBeEmpty ( ) <EOL> filter { "<STR_LIT>" in it } . shouldNotBeEmpty ( ) <EOL> } <EOL> }


@ Test <EOL> fun `mpp dependencies are resolved to maven artifacts` ( )

{ <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> val result = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> with ( result . metadata . newClasspath ) { <EOL> filter { "<STR_LIT>" in it } . shouldNotBeEmpty ( ) <EOL> } <EOL> val client = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> ( client . renderedValue ! ! ) :: class . qualifiedName shouldBe "<STR_LIT>" <EOL> }


@ Test <EOL> @ Timeout ( <NUM_LIT> , unit = TimeUnit . SECONDS ) <EOL> fun `mpp dependencies are not resolved for dataframe and kandy` ( )

{ <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> }


@ Test <EOL> fun `options should not interfer` ( )

{ <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> }


@ Test <EOL> fun testGGDslSourcesResolution ( )

{ <EOL> eval ( "<STR_LIT>" ) <EOL> val res = <EOL> eval ( """<STR_LIT>""" . trimIndent ( ) , ) <EOL> res . metadata . newSources . shouldHaveSize ( <NUM_LIT> ) <EOL> }


@ Test <EOL> fun `some options could be ignored` ( )

{ <EOL> eval ( "<STR_LIT>" ) <EOL> val exception = evalError < ReplPreprocessingException > ( "<STR_LIT>" ) <EOL> exception . message shouldContain "<STR_LIT>" <EOL> }


@ Test <EOL> fun testCompletionForLibraryWithOrderedParameters ( )

{ <EOL> val lib = "<STR_LIT>" <EOL> complete ( "<STR_LIT>" ) . matches ( ) shouldHaveSize <NUM_LIT:0> <EOL> complete ( "<STR_LIT>" ) . matches ( ) . single ( ) shouldContain "<STR_LIT>" <EOL> complete ( "<STR_LIT>" ) . matches ( ) shouldHaveAtLeastSize <NUM_LIT> <EOL> complete ( "<STR_LIT>" ) . matches ( ) shouldHaveSize <NUM_LIT:2> <EOL> complete ( "<STR_LIT>" ) . matches ( ) shouldHaveSize <NUM_LIT:0> <EOL> complete ( "<STR_LIT>" ) . matches ( ) . apply { <EOL> shouldHaveAtLeastSize ( <NUM_LIT> ) <EOL> shouldNotContain ( "<STR_LIT>" ) <EOL> } <EOL> }


fun foo ( ) : String


private inline fun getHasFoo ( s : String )

= object : HasFoo { <EOL> override fun foo ( ) : String = s <EOL> }


{ <EOL> val hasFoo = getHasFoo ( "<STR_LIT>" ) <EOL> checkClass ( hasFoo :: class , expectedQualifiedName = null , expectedSimpleName = null , expectedToStringName = "<STR_LIT>" , expectedInstance = hasFoo , expectedNotInstance = Any ( ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


private fun checkClass ( clazz : KClass < * > , expectedQualifiedName : String ? , expectedSimpleName : String ? , expectedToStringName : String , expectedInstance : Any , expectedNotInstance : Any ? <EOL> )

{ <EOL> assertEquals ( expectedQualifiedName , clazz . qualifiedName ) <EOL> assertEquals ( expectedSimpleName , clazz . simpleName ) <EOL> assertEquals ( expectedToStringName , clazz . toString ( ) ) <EOL> assertTrue ( clazz . isInstance ( expectedInstance ) ) <EOL> if ( expectedNotInstance != null ) assertTrue ( ! clazz . isInstance ( expectedNotInstance ) ) <EOL> }


internal fun Appendable . writeTypes ( types : List < NamedTypeVariant > )

{ <EOL> types . filter { type -> type . variant . features . location == FILE_ROOT } . forEach { type -> <EOL> writeTypeDef ( type ) <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> append ( CLASS_FOR_NESTED ) <EOL> append ( "<STR_LIT>" ) <EOL> types . filter { named -> named . variant . features . location == NESTED } . forEach { type -> <EOL> writeTypeDef ( type , "<STR_LIT>" ) <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> append ( "<STR_LIT>" ) <EOL> append ( CLASS_FOR_INNER ) <EOL> append ( "<STR_LIT>" ) <EOL> types . filter { named -> named . variant . features . location == LOCAL } . forEach { type -> <EOL> writeTypeDef ( type , "<STR_LIT>" ) <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> types . forEach { type -> <EOL> writeCustomSerializer ( type ) <EOL> } <EOL> appendLine ( ) <EOL> types . forEach { type -> <EOL> writeContextualSerializer ( type ) <EOL> } <EOL> appendLine ( ) <EOL> types . forEach { type -> <EOL> writeUseSerializer ( type ) <EOL> } <EOL> appendLine ( ) <EOL> writeSerialInfo ( ) <EOL> appendLine ( ) <EOL> }


internal fun Appendable . writeHeader ( types : List < NamedTypeVariant > , generator : String )

{ <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( ) <EOL> writeUseSerializers ( types ) <EOL> writeUseContextualSerializers ( types ) <EOL> appendLine ( ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( ) <EOL> }


internal fun Appendable . writeUtils ( )

{ <EOL> append ( "<STR_LIT>" ) <EOL> append ( "<STR_LIT>" ) <EOL> append ( "<STR_LIT>" ) <EOL> append ( "<STR_LIT>" ) <EOL> appendLine ( TODO_SERIALIZER ) <EOL> }


private fun Appendable . writeTypeDef ( named : NamedTypeVariant , indent : String = "<STR_LIT>" )

{ <EOL> when ( named . variant ) { <EOL> is EnumVariant -> writeEnumDef ( named , indent ) <EOL> } <EOL> }


private fun Appendable . writeEnumDef ( named : NamedTypeVariant , indent : String )

{ <EOL> val enum = named . variant as EnumVariant <EOL> if ( enum . features . location == LOCAL ) { <EOL> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> val classUsage = named . classUsage <EOL> if ( enum . features . serializer == GENERATED ) { <EOL> append ( indent ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> if ( enum . features . serializer == CUSTOM_OBJECT || enum . features . serializer == CUSTOM_CLASS ) { <EOL> append ( indent ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> if ( SerialInfo . ON_TYPE in enum . options . serialInfo ) { <EOL> append ( indent ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> append ( indent ) <EOL> appendLine ( "<STR_LIT>" ) <EOL> enum . options . entries . forEach { entry -> <EOL> append ( indent ) <EOL> append ( "<STR_LIT>" ) <EOL> if ( SerialInfo . ON_ELEMENTS in enum . options . serialInfo ) { <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> append ( entry ) <EOL> appendLine ( "<STR_LIT:U+002C>" ) <EOL> } <EOL> append ( indent ) <EOL> appendLine ( "<STR_LIT:}>" ) <EOL> appendLine ( ) <EOL> }


private fun Appendable . writeUseSerializers ( types : List < NamedTypeVariant > )

{ <EOL> val serializers = types . mapNotNull { type -> type . useSerializer } <EOL> if ( serializers . isEmpty ( ) ) { <EOL> return <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> serializers . forEach { name -> <EOL> append ( name ) <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> appendLine ( "<STR_LIT:)>" ) <EOL> }


private fun Appendable . writeUseContextualSerializers ( types : List < NamedTypeVariant > )

{ <EOL> val types = types . filter { type -> type . useContextualSerializer != null } <EOL> if ( types . isEmpty ( ) ) { <EOL> return <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> types . forEach { type -> <EOL> append ( type . classUsage ) <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> appendLine ( "<STR_LIT:)>" ) <EOL> }


private fun Appendable . writeSerialInfo ( )

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


private fun Appendable . writeCustomSerializer ( type : NamedTypeVariant )

{ <EOL> when ( type . variant . features . serializer ) { <EOL> CUSTOM_CLASS -> { <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> CUSTOM_OBJECT -> { <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> else -> Unit <EOL> } <EOL> }


private fun Appendable . writeContextualSerializer ( type : NamedTypeVariant )

{ <EOL> when ( type . variant . features . serializer ) { <EOL> CONTEXTUAL , USE_CONTEXTUAL -> { <EOL> val usage = type . classUsage <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> else -> Unit <EOL> } <EOL> }


private fun Appendable . writeUseSerializer ( type : NamedTypeVariant )

{ <EOL> when ( type . variant . features . serializer ) { <EOL> CLASS_USE_SERIALIZER -> { <EOL> val usage = type . classUsage <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> else -> Unit <EOL> } <EOL> }


public fun print ( message : kotlin . Any ? ) : kotlin . Unit


public fun println ( ) : kotlin . Unit


public fun println ( message : kotlin . Any ? ) : kotlin . Unit


@ kotlin . SinceKotlin ( version = "<STR_LIT:1.6>" ) <EOL> public fun readln ( ) : kotlin . String


@ kotlin . SinceKotlin ( version = "<STR_LIT:1.6>" ) <EOL> public fun readlnOrNull ( ) : kotlin . String ?


override fun equals ( other : Any ? ) : Boolean

{ <EOL> return if ( other === this ) true else other is JavaElementPsiSourceWithSmartPointer < * > && originalPsi == other . originalPsi <EOL> }


= originalPsi . hashCode ( )


= analysisSession . firSymbolBuilder . typeBuilder . buildKtType ( this )


fun KtPsiDiagnostic . asKtDiagnostic ( ) : KtDiagnosticWithPsi < * >

= <EOL> KT_DIAGNOSTIC_CONVERTER . convert ( analysisSession , this as KtDiagnostic )


fun ConeDiagnostic . asKtDiagnostic ( source : KtSourceElement , callOrAssignmentSource : KtSourceElement ? , ) : KtDiagnosticWithPsi < * > ?

{ <EOL> val firDiagnostic = toFirDiagnostics ( analysisSession . useSiteSession , source , callOrAssignmentSource ) . firstOrNull ( ) ? : return null <EOL> check ( firDiagnostic is KtPsiDiagnostic ) <EOL> return firDiagnostic . asKtDiagnostic ( ) <EOL> }


fun createTypeCheckerContext ( ) : TypeCheckerState

{ <EOL> return analysisSession . firResolveSession . useSiteFirSession . typeContext . newTypeCheckerState ( errorTypesEqualToAnything = true , stubTypesEqualToAnything = true ) <EOL> }


fun FirQualifiedAccessExpression . createSubstitutorFromTypeArguments ( discardErrorTypes : Boolean = false ) : KtSubstitutor ?

{ <EOL> return createConeSubstitutorFromTypeArguments ( rootModuleSession , discardErrorTypes ) ? . toKtSubstitutor ( ) <EOL> }


fun FirQualifiedAccessExpression . createSubstitutorFromTypeArguments ( callableSymbol : FirCallableSymbol < * > , discardErrorTypes : Boolean = false ) : KtSubstitutor

{ <EOL> return createConeSubstitutorFromTypeArguments ( callableSymbol , rootModuleSession , discardErrorTypes ) . toKtSubstitutor ( ) <EOL> }


fun ConeSubstitutor . toKtSubstitutor ( ) : KtSubstitutor

{ <EOL> return analysisSession . firSymbolBuilder . typeBuilder . buildSubstitutor ( this ) <EOL> }


internal fun __ieee754_atan2 ( y : Double , x : Double ) : Double

{ <EOL> var z : Double <EOL> var k : Int <EOL> var m : Int <EOL> var hx : Int <EOL> var hy : Int <EOL> var ix : Int <EOL> var iy : Int <EOL> var lx : UInt <EOL> var ly : UInt <EOL> hx = __HI ( x ) ; ix = hx and <NUM_LIT> <EOL> lx = __LOu ( x ) <EOL> hy = __HI ( y ) ; iy = hy and <NUM_LIT> <EOL> ly = __LOu ( y ) <EOL> if ( ( ( ix or ( ( lx or lx . negate ( ) ) shr <NUM_LIT:31> ) . toInt ( ) ) > <NUM_LIT> ) || ( ( iy or ( ( ly or ly . negate ( ) ) shr <NUM_LIT:31> ) . toInt ( ) ) > <NUM_LIT> ) ) <EOL> return x + y <EOL> if ( ( ( hx - <NUM_LIT> ) or lx . toInt ( ) ) == <NUM_LIT:0> ) return atan ( y ) <EOL> m = ( ( hy shr <NUM_LIT:31> ) and <NUM_LIT:1> ) or ( ( hx shr <NUM_LIT> ) and <NUM_LIT:2> ) <EOL> if ( ( iy or ly . toInt ( ) ) == <NUM_LIT:0> ) { <EOL> when ( m ) { <EOL> <NUM_LIT:0> , <NUM_LIT:1> -> return y <EOL> <NUM_LIT:2> -> return pi + tiny <EOL> <NUM_LIT:3> -> return - pi - tiny <EOL> } <EOL> } <EOL> if ( ( ix or lx . toInt ( ) ) == <NUM_LIT:0> ) return if ( hy < <NUM_LIT:0> ) - pi_o_2 - tiny else pi_o_2 + tiny <EOL> if ( ix == <NUM_LIT> ) { <EOL> if ( iy == <NUM_LIT> ) { <EOL> when ( m ) { <EOL> <NUM_LIT:0> -> return pi_o_4 + tiny <EOL> <NUM_LIT:1> -> return - pi_o_4 - tiny <EOL> <NUM_LIT:2> -> return <NUM_LIT:3.0> * pi_o_4 + tiny <EOL> <NUM_LIT:3> -> return - <NUM_LIT:3.0> * pi_o_4 - tiny <EOL> } <EOL> } else { <EOL> when ( m ) { <EOL> <NUM_LIT:0> -> return zero <EOL> <NUM_LIT:1> -> return - zero <EOL> <NUM_LIT:2> -> return pi + tiny <EOL> <NUM_LIT:3> -> return - pi - tiny <EOL> } <EOL> } <EOL> } <EOL> if ( iy == <NUM_LIT> ) return if ( hy < <NUM_LIT:0> ) - pi_o_2 - tiny else pi_o_2 + tiny <EOL> k = ( iy - ix ) shr <NUM_LIT:20> <EOL> if ( k > <NUM_LIT> ) z = pi_o_2 + <NUM_LIT> * pi_lo <EOL> else if ( hx < <NUM_LIT:0> && k < - <NUM_LIT> ) z = <NUM_LIT:0.0> <EOL> else z = atan ( fabs ( y / x ) ) <EOL> when ( m ) { <EOL> <NUM_LIT:0> -> return z <EOL> <NUM_LIT:1> -> { <EOL> z = doubleSetWord ( d = z , hi = __HI ( z ) xor Int . MIN_VALUE ) <EOL> return z <EOL> } <EOL> <NUM_LIT:2> -> return pi - ( z - pi_lo ) <EOL> else -> return ( z - pi_lo ) - pi <EOL> } <EOL> }


override fun resolveDependencies ( sourceSetName : String ) : Set < IdeaKotlinDependency >

{ <EOL> return resolveDependencies ( extension . sourceSets . getByName ( sourceSetName ) ) <EOL> }


override fun resolveDependencies ( sourceSet : KotlinSourceSet ) : Set < IdeaKotlinDependency >

{ <EOL> return createDependencyResolver ( ) . resolve ( sourceSet ) <EOL> }


override fun resolveDependenciesSerialized ( sourceSetName : String ) : List < ByteArray >

{ <EOL> return serialize ( resolveDependencies ( sourceSetName ) ) <EOL> }


override fun resolveExtrasSerialized ( owner : Any ) : ByteArray ?

{ <EOL> if ( owner !is HasMutableExtras ) return null <EOL> return owner . extras . toByteArray ( createSerializationContext ( ) ) <EOL> }


override fun serialize ( dependencies : Iterable < IdeaKotlinDependency > ) : List < ByteArray >

{ <EOL> val context = createSerializationContext ( ) <EOL> return dependencies . map { dependency -> dependency . toByteArray ( context ) } <EOL> }


override fun < T : Any > serialize ( key : Extras . Key < T > , value : T ) : ByteArray ?

{ <EOL> val context = createSerializationContext ( ) <EOL> return context . extrasSerializationExtension . serializer ( key ) ? . serialize ( context , value ) <EOL> }


@ OptIn ( Idea222Api :: class ) <EOL> override fun registerDependencyResolver ( resolver : IdeDependencyResolver , constraint : SourceSetConstraint , phase : DependencyResolutionPhase , priority : Priority , )

{ <EOL> registeredDependencyResolvers . add ( RegisteredDependencyResolver ( extension . project . kotlinIdeMultiplatformImportStatistics , resolver , constraint , phase , priority ) ) <EOL> if ( resolver is IdeDependencyResolver . WithBuildDependencies ) { <EOL> val project = extension . project <EOL> val dependencies = project . provider { resolver . dependencies ( project ) } <EOL> extension . project . locateOrRegisterIdeResolveDependenciesTask ( ) . configure { it . dependsOn ( dependencies ) } <EOL> extension . project . prepareKotlinIdeaImportTask . configure { it . dependsOn ( dependencies ) } <EOL> } <EOL> }


override fun registerDependencyTransformer ( transformer : IdeDependencyTransformer , constraint : SourceSetConstraint , phase : DependencyTransformationPhase , )

{ <EOL> registeredDependencyTransformers . add ( RegisteredDependencyTransformer ( transformer , constraint , phase ) ) <EOL> }


override fun registerAdditionalArtifactResolver ( resolver : IdeAdditionalArtifactResolver , constraint : SourceSetConstraint , phase : AdditionalArtifactResolutionPhase , priority : Priority , )

{ <EOL> registeredAdditionalArtifactResolvers . add ( RegisteredAdditionalArtifactResolver ( extension . project . kotlinIdeMultiplatformImportStatistics , resolver , constraint , phase , priority ) ) <EOL> }


override fun registerDependencyEffect ( effect : IdeDependencyEffect , constraint : SourceSetConstraint )

{ <EOL> registeredDependencyEffects . add ( RegisteredDependencyEffect ( effect , constraint ) ) <EOL> }


override fun registerExtrasSerializationExtension ( extension : IdeaKotlinExtrasSerializationExtension )

{ <EOL> registeredExtrasSerializationExtensions . add ( extension ) <EOL> }


override fun registerImportAction ( action : IdeMultiplatformImportAction )

{ <EOL> IdeMultiplatformImportAction . extensionPoint . register ( extension . project , action ) <EOL> }


private fun createDependencyResolver ( ) : IdeDependencyResolver

{ <EOL> return IdeDependencyResolver ( DependencyResolutionPhase . values ( ) . map { phase -> createDependencyResolver ( phase ) } ) <EOL> . withAdditionalArtifactResolver ( createAdditionalArtifactsResolver ( ) ) <EOL> . withTransformer ( createDependencyTransformer ( ) ) <EOL> . withEffect ( createDependencyEffect ( ) ) <EOL> }


private fun createDependencyResolver ( phase : DependencyResolutionPhase )

= IdeDependencyResolver resolve @ { sourceSet -> <EOL> val applicableResolvers = registeredDependencyResolvers <EOL> . filter { it . phase == phase } <EOL> . filter { it . constraint ( sourceSet ) } <EOL> . groupBy { it . priority } <EOL> applicableResolvers . keys . sortedDescending ( ) . forEach { priority -> <EOL> val resolvers = applicableResolvers [ priority ] . orEmpty ( ) <EOL> if ( resolvers . isNotEmpty ( ) ) { <EOL> return@resolve IdeDependencyResolver ( resolvers ) . resolve ( sourceSet ) <EOL> } <EOL> } <EOL> emptySet ( ) <EOL> }


private fun createAdditionalArtifactsResolver ( )

= IdeAdditionalArtifactResolver ( AdditionalArtifactResolutionPhase . values ( ) . map { phase -> createAdditionalArtifactsResolver ( phase ) } )


private fun createAdditionalArtifactsResolver ( phase : AdditionalArtifactResolutionPhase ) : IdeAdditionalArtifactResolver

{ <EOL> if ( phase == SourcesAndDocumentationResolution && ideaGradleDownloadSourcesEnabledProperty . orNull ? . toBoolean ( ) == true && ideaGradleDownloadSourcesProperty . orNull ? . toBoolean ( ) == false ) { <EOL> return IdeAdditionalArtifactResolver . empty <EOL> } <EOL> return IdeAdditionalArtifactResolver resolve @ { sourceSet , dependencies -> <EOL> val applicableResolvers = registeredAdditionalArtifactResolvers <EOL> . filter { it . phase == phase } <EOL> . filter { it . constraint ( sourceSet ) } <EOL> . groupBy { it . priority } <EOL> applicableResolvers . keys . sortedDescending ( ) . forEach { priority -> <EOL> val resolvers = applicableResolvers [ priority ] . orEmpty ( ) <EOL> if ( resolvers . isNotEmpty ( ) ) { <EOL> resolvers . forEach { resolver -> resolver . resolve ( sourceSet , dependencies ) } <EOL> return@resolve <EOL> } <EOL> } <EOL> } <EOL> }


private fun createDependencyTransformer ( ) : IdeDependencyTransformer

{ <EOL> return IdeDependencyTransformer ( DependencyTransformationPhase . values ( ) . map { phase -> <EOL> createDependencyTransformer ( phase ) <EOL> } ) <EOL> }


private fun createDependencyTransformer ( phase : DependencyTransformationPhase ) : IdeDependencyTransformer

{ <EOL> return IdeDependencyTransformer { sourceSet , dependencies -> <EOL> IdeDependencyTransformer ( registeredDependencyTransformers . filter { it . phase == phase } . filter { it . constraint ( sourceSet ) } . map { it . transformer } ) . transform ( sourceSet , dependencies ) <EOL> } <EOL> }


private fun createDependencyEffect ( ) : IdeDependencyEffect

= IdeDependencyEffect { sourceSet , dependencies -> <EOL> registeredDependencyEffects <EOL> . filter { it . constraint ( sourceSet ) } <EOL> . forEach { it . effect ( sourceSet , dependencies ) } <EOL> }


private fun createSerializationContext ( ) : IdeaKotlinSerializationContext

{ <EOL> return IdeaKotlinSerializationContext ( logger = extension . project . logger , extrasSerializationExtensions = registeredExtrasSerializationExtensions . toList ( ) ) <EOL> }


override fun resolve ( sourceSet : KotlinSourceSet ) : Set < IdeaKotlinDependency >

{ <EOL> return runCatching { resolveTimed ( sourceSet ) } <EOL> . onFailure { error -> reportError ( sourceSet , error ) } <EOL> . onSuccess { result -> reportSuccess ( sourceSet , result ) } <EOL> . onSuccess { result -> attachResolvedByExtra ( result . dependencies ) } <EOL> . getOrNull ( ) ? . dependencies . orEmpty ( ) <EOL> }


private fun resolveTimed ( sourceSet : KotlinSourceSet ) : TimeMeasuredResult

{ <EOL> val ( time , result ) = measureTimeMillisWithResult { resolver . resolve ( sourceSet ) } <EOL> statistics . addExecutionTime ( resolver :: class . java , time ) <EOL> return TimeMeasuredResult ( time , result ) <EOL> }


private fun reportError ( sourceSet : KotlinSourceSet , error : Throwable )

{ <EOL> logger . error ( "<STR_LIT>" , error ) <EOL> }


private fun reportSuccess ( sourceSet : KotlinSourceSet , result : TimeMeasuredResult )

{ <EOL> if ( ! logger . isDebugEnabled ) return <EOL> logger . debug ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> }


private fun attachResolvedByExtra ( dependencies : Iterable < IdeaKotlinDependency > )

{ <EOL> dependencies . forEach { dependency -> <EOL> if ( dependency . resolvedBy == null ) dependency . resolvedBy = resolver <EOL> } <EOL> }


override fun resolve ( sourceSet : KotlinSourceSet , dependencies : Set < IdeaKotlinDependency > )

{ <EOL> runCatching { measureTimeMillis { resolver . resolve ( sourceSet , dependencies ) } } <EOL> . onFailure { logger . error ( "<STR_LIT>" , it ) } <EOL> . onSuccess { statistics . addExecutionTime ( resolver :: class . java , it ) } <EOL> }


= <EOL> testSharingStarted ( SharingStarted . Eagerly , SharingCommand . START ) { <EOL> subscriptions ( <NUM_LIT:1> ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> ) <EOL> delay ( <NUM_LIT:100> ) <EOL> }


= <EOL> testSharingStarted ( SharingStarted . Lazily ) { <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> ) <EOL> }


@ Test <EOL> fun testWhileSubscribed ( )

= <EOL> testSharingStarted ( SharingStarted . WhileSubscribed ( ) ) { <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> , SharingCommand . STOP ) <EOL> delay ( <NUM_LIT:100> ) <EOL> }


@ Test <EOL> fun testWhileSubscribedExpireImmediately ( )

= <EOL> testSharingStarted ( SharingStarted . WhileSubscribed ( replayExpirationMillis = <NUM_LIT:0> ) ) { <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> , SharingCommand . STOP_AND_RESET_REPLAY_CACHE ) <EOL> delay ( <NUM_LIT:100> ) <EOL> }


@ Test <EOL> fun testWhileSubscribedWithTimeout ( )

= <EOL> testSharingStarted ( SharingStarted . WhileSubscribed ( stopTimeoutMillis = <NUM_LIT:100> ) ) { <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> ) <EOL> delay ( <NUM_LIT> ) <EOL> subscriptions ( <NUM_LIT:1> ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> ) <EOL> afterTime ( <NUM_LIT:100> , SharingCommand . STOP ) <EOL> delay ( <NUM_LIT:100> ) <EOL> }


@ Test <EOL> fun testWhileSubscribedExpiration ( )

= <EOL> testSharingStarted ( SharingStarted . WhileSubscribed ( replayExpirationMillis = <NUM_LIT> ) ) { <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> , SharingCommand . STOP ) <EOL> delay ( <NUM_LIT> ) <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> , SharingCommand . STOP ) <EOL> afterTime ( <NUM_LIT> , SharingCommand . STOP_AND_RESET_REPLAY_CACHE ) <EOL> }


@ Test <EOL> fun testWhileSubscribedStopAndExpiration ( )

= <EOL> testSharingStarted ( SharingStarted . WhileSubscribed ( stopTimeoutMillis = <NUM_LIT> , replayExpirationMillis = <NUM_LIT> ) ) { <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> ) <EOL> delay ( <NUM_LIT> ) <EOL> subscriptions ( <NUM_LIT:1> ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> ) <EOL> afterTime ( <NUM_LIT> , SharingCommand . STOP ) <EOL> delay ( <NUM_LIT> ) <EOL> subscriptions ( <NUM_LIT:1> , SharingCommand . START ) <EOL> rampUpAndDown ( ) <EOL> subscriptions ( <NUM_LIT:0> ) <EOL> afterTime ( <NUM_LIT> , SharingCommand . STOP ) <EOL> afterTime ( <NUM_LIT> , SharingCommand . STOP_AND_RESET_REPLAY_CACHE ) <EOL> delay ( <NUM_LIT:100> ) <EOL> }


private suspend fun SharingStartedDsl . rampUpAndDown ( )

{ <EOL> for ( i in <NUM_LIT:2> .. <NUM_LIT:10> ) { <EOL> delay ( <NUM_LIT:100> ) <EOL> subscriptions ( i ) <EOL> } <EOL> delay ( <NUM_LIT> ) <EOL> for ( i in <NUM_LIT:9> downTo <NUM_LIT:1> ) { <EOL> subscriptions ( i ) <EOL> delay ( <NUM_LIT:100> ) <EOL> } <EOL> }


private fun testSharingStarted ( started : SharingStarted , initialCommand : SharingCommand ? = null , scenario : suspend SharingStartedDsl . ( ) -> Unit )

= withVirtualTime { <EOL> expect ( <NUM_LIT:1> ) <EOL> val dsl = SharingStartedDsl ( started , initialCommand , coroutineContext ) <EOL> dsl . launch ( ) <EOL> repeat ( <NUM_LIT:3> ) { <EOL> dsl . scenario ( ) <EOL> delay ( <NUM_LIT> ) <EOL> } <EOL> dsl . stop ( ) <EOL> finish ( <NUM_LIT:2> ) <EOL> }


{ <EOL> started <EOL> . command ( subscriptionCount . asStateFlow ( ) ) <EOL> . onEach { checkCommand ( it ) } <EOL> . launchIn ( scope ) <EOL> letItRun ( ) <EOL> }


fun checkCommand ( command : SharingCommand )

{ <EOL> assertTrue ( command != previousCommand ) <EOL> previousCommand = command <EOL> assertEquals ( expectedCommand , command ) <EOL> assertEquals ( expectedTime , dispatcher . currentTime ) <EOL> }


suspend fun subscriptions ( count : Int , command : SharingCommand ? = null )

{ <EOL> expectedTime = dispatcher . currentTime <EOL> subscriptionCount . value = count <EOL> if ( command != null ) { <EOL> afterTime ( <NUM_LIT:0> , command ) <EOL> } else { <EOL> letItRun ( ) <EOL> } <EOL> }


suspend fun afterTime ( time : Long = <NUM_LIT:0> , command : SharingCommand )

{ <EOL> expectedCommand = command <EOL> val remaining = ( time - <NUM_LIT:1> ) . coerceAtLeast ( <NUM_LIT:0> ) <EOL> expectedTime += remaining <EOL> delay ( remaining ) <EOL> letItRun ( ) <EOL> }


{ <EOL> delay ( <NUM_LIT:1> ) <EOL> assertEquals ( expectedCommand , previousCommand ) <EOL> expectedTime ++ <EOL> }


{ <EOL> scope . cancel ( ) <EOL> }


fun allocUnsafe ( bytes : Int ) : Buffer


fun readInt8 ( offset : Int ) : Byte


fun writeInt8 ( value : Byte , offset : Int )


{ <EOL> val testCaseDir = lowercaseFirstLetter ( this :: class . java . simpleName . substringBefore ( "<STR_LIT>" ) . substringBefore ( "<STR_LIT:Test>" ) , true ) <EOL> val testDir = testDirectoryName <EOL> return File ( KtTestUtil . getHomeDirectory ( ) ) <EOL> . resolve ( "<STR_LIT>" ) <EOL> . resolve ( testCaseDir ) <EOL> . resolve ( testDir ) <EOL> . also ( :: assertIsDirectory ) <EOL> }


protected fun doTestSuccessfulCommonization ( )

{ <EOL> val sourceModuleRoots : SourceModuleRoots = SourceModuleRoots . load ( getTestDataDir ( ) ) <EOL> val analyzedModules : AnalyzedModules = AnalyzedModules . create ( sourceModuleRoots , testRootDisposable ) <EOL> val results = MockResultsConsumer ( ) <EOL> runCommonization ( analyzedModules . toCommonizerParameters ( results ) ) <EOL> assertEquals ( Status . DONE , results . status ) <EOL> val sharedTarget : SharedCommonizerTarget = analyzedModules . sharedTarget <EOL> assertEquals ( sharedTarget , results . sharedTarget ) <EOL> val sharedModuleAsExpected : SerializedMetadata = analyzedModules . commonizedModules . getValue ( sharedTarget ) <EOL> val sharedModuleByCommonizer : SerializedMetadata = results . modulesByTargets . getValue ( sharedTarget ) . single ( ) . metadata <EOL> assertModulesAreEqual ( sharedModuleAsExpected , sharedModuleByCommonizer , sharedTarget ) <EOL> }


fun load ( directory : File ) : SourceModuleRoot

= SourceModuleRoot ( targetName = directory . name , location = directory )


fun load ( dataDir : File ) : SourceModuleRoots

= try { <EOL> val originalRoots = listRoots ( dataDir , ORIGINAL_ROOTS_DIR ) . mapKeys { LeafCommonizerTarget ( it . key ) } <EOL> val leafTargets = originalRoots . keys <EOL> val sharedTarget = SharedCommonizerTarget ( leafTargets ) <EOL> fun getTarget ( targetName : String ) : CommonizerTarget = <EOL> if ( targetName == SHARED_TARGET_NAME ) sharedTarget else leafTargets . first { it . name == targetName } <EOL> val commonizedRoots = listRoots ( dataDir , COMMONIZED_ROOTS_DIR ) . mapKeys { getTarget ( it . key ) } <EOL> val dependencyRoots = listRoots ( dataDir , DEPENDENCY_ROOTS_DIR ) . mapKeys { getTarget ( it . key ) } <EOL> SourceModuleRoots ( originalRoots , commonizedRoots , dependencyRoots ) <EOL> } catch ( e : Exception ) { <EOL> fail ( "<STR_LIT>" , cause = e ) <EOL> }


private fun listRoots ( dataDir : File , rootsDirName : String ) : Map < String , SourceModuleRoot >

= <EOL> dataDir . resolve ( rootsDirName ) . listFiles ( ) ? . toSet ( ) . orEmpty ( ) . map ( SourceModuleRoot :: load ) . associateBy { it . targetName }


fun withExpectByDependency ( dependency : ModuleDescriptor )

= <EOL> AnalyzedModuleDependencies ( regularDependencies = regularDependencies , expectByDependencies = expectByDependencies + dependency )


fun toCommonizerParameters ( resultsConsumer : ResultsConsumer , manifestDataProvider : ( CommonizerTarget ) -> NativeManifestDataProvider = { MockNativeManifestDataProvider ( it ) } , commonizerSettings : CommonizerSettings = DefaultCommonizerSettings , )

= CommonizerParameters ( outputTargets = setOf ( SharedCommonizerTarget ( leafTargets . toSet ( ) ) ) , manifestProvider = TargetDependent ( sharedTarget . withAllLeaves ( ) , manifestDataProvider ) , dependenciesProvider = TargetDependent ( sharedTarget . withAllLeaves ( ) ) { target -> <EOL> dependencyModules <EOL> . filter { ( registeredTarget , _ ) -> target in registeredTarget . withAllLeaves ( ) } <EOL> . values . flatten ( ) <EOL> . let ( MockModulesProvider :: create ) <EOL> } , targetProviders = TargetDependent ( leafTargets ) { leafTarget -> <EOL> TargetProvider ( target = leafTarget , modulesProvider = MockModulesProvider . create ( originalModules . getValue ( leafTarget ) ) ) <EOL> } , resultsConsumer = resultsConsumer , settings = commonizerSettings , )


fun create ( sourceModuleRoots : SourceModuleRoots , parentDisposable : Disposable ) : AnalyzedModules

= with ( sourceModuleRoots ) { <EOL> val ( dependencyModules : Map < CommonizerTarget , List < ModuleDescriptor > > , dependencies : AnalyzedModuleDependencies ) = <EOL> createDependencyModules ( sharedTarget , dependencyRoots , parentDisposable ) <EOL> val originalModules : Map < CommonizerTarget , ModuleDescriptor > = <EOL> createModules ( sharedTarget , originalRoots , dependencies , parentDisposable ) <EOL> val commonizedModules : Map < CommonizerTarget , SerializedMetadata > = <EOL> createModules ( sharedTarget , commonizedRoots , dependencies , parentDisposable ) <EOL> . mapValues { ( _ , moduleDescriptor ) -> MockModulesProvider . SERIALIZER . serializeModule ( moduleDescriptor ) } <EOL> return AnalyzedModules ( originalModules , commonizedModules , dependencyModules ) <EOL> }


private fun createDependencyModules ( sharedTarget : SharedCommonizerTarget , dependencyRoots : Map < out CommonizerTarget , SourceModuleRoot > , parentDisposable : Disposable ) : Pair < Map < CommonizerTarget , List < ModuleDescriptor > > , AnalyzedModuleDependencies >

{ <EOL> val customDependencyModules = <EOL> createModules ( sharedTarget , dependencyRoots , AnalyzedModuleDependencies . EMPTY , parentDisposable , isDependencyModule = true ) <EOL> val stdlibModule = DefaultBuiltIns . Instance . builtInsModule <EOL> val dependencyModules = ( sharedTarget . targets + sharedTarget ) . associateWith { target -> <EOL> listOfNotNull ( stdlibModule , customDependencyModules [ target ] ) <EOL> } <EOL> return dependencyModules to AnalyzedModuleDependencies ( regularDependencies = dependencyModules , expectByDependencies = dependencyModules . getValue ( sharedTarget ) . filter { module -> module !== stdlibModule } ) <EOL> }


private fun createModules ( sharedTarget : SharedCommonizerTarget , moduleRoots : Map < out CommonizerTarget , SourceModuleRoot > , dependencies : AnalyzedModuleDependencies , parentDisposable : Disposable , isDependencyModule : Boolean = false ) : Map < CommonizerTarget , ModuleDescriptor >

{ <EOL> val result = mutableMapOf < CommonizerTarget , ModuleDescriptor > ( ) <EOL> var dependenciesForOthers = dependencies <EOL> moduleRoots [ sharedTarget ] ? . let { moduleRoot -> <EOL> val commonModule = createModule ( sharedTarget , sharedTarget , moduleRoot , dependencies , parentDisposable , isDependencyModule ) <EOL> result [ sharedTarget ] = commonModule <EOL> dependenciesForOthers = dependencies . withExpectByDependency ( commonModule ) <EOL> } <EOL> moduleRoots . filterKeys { it != sharedTarget } . forEach { ( leafTarget , moduleRoot ) -> <EOL> result [ leafTarget ] = <EOL> createModule ( sharedTarget , leafTarget , moduleRoot , dependenciesForOthers , parentDisposable , isDependencyModule ) <EOL> } <EOL> return result <EOL> }


private fun createModule ( sharedTarget : SharedCommonizerTarget , currentTarget : CommonizerTarget , moduleRoot : SourceModuleRoot , dependencies : AnalyzedModuleDependencies , parentDisposable : Disposable , isDependencyModule : Boolean ) : ModuleDescriptor

{ <EOL> val moduleName : String = moduleRoot . location . parentFile . parentFile . name . let { <EOL> if ( isDependencyModule ) "<STR_LIT>" else it <EOL> } <EOL> check ( Name . isValidIdentifier ( moduleName ) ) <EOL> val configuration : CompilerConfiguration = newConfiguration ( ) <EOL> configuration . put ( CommonConfigurationKeys . MODULE_NAME , moduleName ) <EOL> val environment : KotlinCoreEnvironment = KotlinCoreEnvironment . createForTests ( parentDisposable = parentDisposable , initialConfiguration = configuration , extensionConfigs = EnvironmentConfigFiles . METADATA_CONFIG_FILES ) <EOL> val psiFactory = KtPsiFactory ( environment . project ) <EOL> val psiFiles : List < KtFile > = moduleRoot . location . walkTopDown ( ) <EOL> . filter { it . isFile } <EOL> . map { psiFactory . createFile ( it . name , KtTestUtil . doLoadFile ( it ) ) } <EOL> . toList ( ) <EOL> val module = CommonResolverForModuleFactory . analyzeFiles ( psiFiles , Name . special ( "<STR_LIT>" ) , dependOnBuiltIns = true , environment . configuration . languageVersionSettings , CommonPlatforms . defaultCommonPlatform , CompilerEnvironment , dependenciesContainer = DependenciesContainerImpl ( sharedTarget , currentTarget , dependencies ) , ) { content -> <EOL> environment . createPackagePartProvider ( content . moduleContentScope ) <EOL> } . moduleDescriptor <EOL> if ( ! isDependencyModule ) <EOL> module . accept ( PatchingTestDescriptorVisitor , Unit ) <EOL> return module <EOL> }


= listOf ( this ) + regularDependencies


= ModuleInfo . DependencyOnBuiltIns . LAST


override fun moduleDescriptorForModuleInfo ( moduleInfo : ModuleInfo )

= <EOL> moduleInfoToModule [ moduleInfo ] ? : error ( "<STR_LIT>" )


override fun registerDependencyForAllModules ( moduleInfo : ModuleInfo , descriptorForModule : ModuleDescriptorImpl )

= Unit


override fun packageFragmentProviderForModuleInfo ( moduleInfo : ModuleInfo ) : PackageFragmentProvider ?

= null


override fun visitModuleDeclaration ( descriptor : ModuleDescriptor , data : Unit )

{ <EOL> val packageFragmentProvider = ( descriptor as ModuleDescriptorImpl ) . packageFragmentProviderForModuleContentWithoutDependencies <EOL> fun recurse ( packageFqName : FqName ) { <EOL> val ownPackageMemberScopes = packageFragmentProvider . packageFragments ( packageFqName ) <EOL> . asSequence ( ) <EOL> . map { it . getMemberScope ( ) } <EOL> . filter { it != MemberScope . Empty } <EOL> . toList ( ) <EOL> if ( ownPackageMemberScopes . isNotEmpty ( ) ) { <EOL> val memberScope = ChainedMemberScope . create ( "<STR_LIT>" , ownPackageMemberScopes ) <EOL> visitMemberScope ( memberScope ) <EOL> } <EOL> packageFragmentProvider . getSubPackagesOf ( packageFqName , alwaysTrue ( ) ) . toSet ( ) . map { recurse ( it ) } <EOL> } <EOL> recurse ( FqName . ROOT ) <EOL> }


private fun visitMemberScope ( memberScope : MemberScope )

{ <EOL> memberScope . getContributedDescriptors ( ) . forEach { descriptor -> <EOL> when ( descriptor ) { <EOL> is ClassDescriptor -> { <EOL> descriptor . constructors . forEach ( :: visitCallableMemberDescriptor ) <EOL> visitMemberScope ( descriptor . unsubstitutedMemberScope ) <EOL> } <EOL> is SimpleFunctionDescriptor -> { <EOL> if ( descriptor . kind . isReal && ! descriptor . isKniBridgeFunction ( ) && ! descriptor . isDeprecatedTopLevelFunction ( ) ) { <EOL> visitCallableMemberDescriptor ( descriptor ) <EOL> } <EOL> } <EOL> else -> Unit <EOL> } <EOL> } <EOL> }


private fun visitCallableMemberDescriptor ( callableDescriptor : CallableMemberDescriptor )

{ <EOL> val comment = callableDescriptor . findPsi ( ) ? . text ? . lineSequence ( ) ? . firstOrNull ( ) ? . takeIf { it . startsWith ( "<STR_LIT>" ) } ? : return <EOL> val ( key , value ) = comment . substringAfter ( "<STR_LIT>" ) . split ( '<CHAR_LIT>' , limit = <NUM_LIT:2> ) . takeIf { it . size == <NUM_LIT:2> } ? . map { it . trim ( ) } ? : return <EOL> when ( key ) { <EOL> "<STR_LIT>" -> { <EOL> if ( ! value . toBoolean ( ) ) ( callableDescriptor as FunctionDescriptorImpl ) . setHasStableParameterNames ( false ) <EOL> } <EOL> else -> { <EOL> } <EOL> } <EOL> }


private fun SimpleFunctionDescriptor . isKniBridgeFunction ( )

= <EOL> name . asString ( ) . startsWith ( KNI_BRIDGE_FUNCTION_PREFIX )


private fun SimpleFunctionDescriptor . isDeprecatedTopLevelFunction ( )

= <EOL> containingDeclaration is PackageFragmentDescriptor && annotations . hasAnnotation ( DEPRECATED_ANNOTATION_FQN )


internal fun generateKotlinVersion ( apiDir : File , filePrinter : ( targetFile : File , Printer . ( ) -> Unit ) -> Unit )

{ <EOL> val kotlinVersionFqName = FqName ( "<STR_LIT>" ) <EOL> filePrinter ( fileFromFqName ( apiDir , kotlinVersionFqName ) ) { <EOL> generateDeclaration ( "<STR_LIT>" , kotlinVersionFqName , afterType = "<STR_LIT>" ) { <EOL> for ( languageVersion in LanguageVersion . values ( ) ) { <EOL> val prefix = when { <EOL> languageVersion . isUnsupported -> "<STR_LIT>" <EOL> languageVersion . isDeprecated -> "<STR_LIT>" <EOL> else -> "<STR_LIT>" <EOL> } <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> println ( "<STR_LIT:;>" ) <EOL> println ( ) <EOL> println ( "<STR_LIT>" ) <EOL> withIndent { <EOL> println ( "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> println ( ) <EOL> println ( "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> println ( "<STR_LIT:}>" ) <EOL> } <EOL> } <EOL> }

/**
 * ApiVersion and LanguageVersion are almost the same in the compiler api, so Gradle DSL options
 * exposes KotlinVersion that covers both of them.
 */


public fun chars ( value : String )

/**
 * A literal string.
 *
 * When formatting, the string is appended to the result as is,
 * and when parsing, the string is expected to be present in the input verbatim.
 */


public fun year ( padding : Padding = Padding . ZERO )

/**
 * A year number.
 *
 * By default, for years [-9999..9999], it's formatted as a decimal number, zero-padded to four digits, though
 * this padding can be disabled or changed to space padding by passing [padding].
 * For years outside this range, it's formatted as a decimal number with a leading sign, so the year 12345
 * is formatted as "+12345".
 */


public fun yearTwoDigits ( baseYear : Int )

/**
 * The last two digits of the ISO year.
 *
 * [baseYear] is the base year for the two-digit year.
 * For example, if [baseYear] is 1960, then this format correctly works with years [1960..2059].
 *
 * On formatting, when given a year in the valid range, it returns the last two digits of the year,
 * so 1993 becomes "93". When given a year outside the valid range, it returns the full year number
 * with a leading sign, so 1850 becomes "+1850", and -200 becomes "-200".
 *
 * On parsing, it accepts either a two-digit year or a full year number with a leading sign.
 * When given a two-digit year, it returns a year in the valid range, so "93" becomes 1993,
 * and when given a full year number with a leading sign, it parses the full year number,
 * so "+1850" becomes 1850.
 */


public fun monthNumber ( padding : Padding = Padding . ZERO )

/**
 * A month-of-year number, from 1 to 12.
 *
 * By default, it's padded with zeros to two digits. This can be changed by passing [padding].
 */


public fun monthName ( names : MonthNames )

/**
 * A month name (for example, "January").
 *
 * Example:
 * ```
 * monthName(MonthNames.ENGLISH_FULL)
 * ```
 */


public fun dayOfMonth ( padding : Padding = Padding . ZERO )

/**
 * A day-of-month number, from 1 to 31.
 *
 * By default, it's padded with zeros to two digits. This can be changed by passing [padding].
 */


public fun dayOfWeek ( names : DayOfWeekNames )

/**
 * A day-of-week name (for example, "Thursday").
 *
 * Example:
 * ```
 * dayOfWeek(DayOfWeekNames.ENGLISH_FULL)
 * ```
 */


public fun date ( format : DateTimeFormat < LocalDate > )

/**
 * An existing [DateTimeFormat] for the date part.
 *
 * Example:
 * ```
 * date(LocalDate.Formats.ISO)
 * ```
 */


public fun hour ( padding : Padding = Padding . ZERO )

/**
 * The hour of the day, from 0 to 23.
 *
 * By default, it's zero-padded to two digits, but this can be changed with [padding].
 */


public fun amPmHour ( padding : Padding = Padding . ZERO )

/**
 * The hour of the day in the 12-hour clock:
 *
 * * Midnight is 12,
 * * Hours 1-11 are 1-11,
 * * Noon is 12,
 * * Hours 13-23 are 1-11.
 *
 * To disambiguate between the first and the second halves of the day, [amPmMarker] should be used.
 *
 * By default, it's zero-padded to two digits, but this can be changed with [padding].
 *
 * @see [amPmMarker]
 */


public fun amPmMarker ( am : String , pm : String )

/**
 * The AM/PM marker, using the specified strings.
 *
 * [am] is used for the AM marker (0-11 hours), [pm] is used for the PM marker (12-23 hours).
 *
 * @see [amPmHour]
 */


public fun minute ( padding : Padding = Padding . ZERO )

/**
 * The minute of hour.
 *
 * By default, it's zero-padded to two digits, but this can be changed with [padding].
 */


public fun second ( padding : Padding = Padding . ZERO )

/**
 * The second of minute.
 *
 * By default, it's zero-padded to two digits, but this can be changed with [padding].
 *
 * This field has the default value of 0. If you want to omit it, use [optional].
 */


public fun secondFraction ( minLength : Int = <NUM_LIT:1> , maxLength : Int = <NUM_LIT:9> )

/**
 * The fractional part of the second without the leading dot.
 *
 * When formatting, the decimal fraction will be rounded to fit in the specified [maxLength] and will add
 * trailing zeroes to the specified [minLength].
 * Rounding is performed using the round-toward-zero rounding mode.
 *
 * When parsing, the parser will require that the fraction is at least [minLength] and at most [maxLength]
 * digits long.
 *
 * This field has the default value of 0. If you want to omit it, use [optional].
 *
 * See also the [secondFraction] overload that accepts just one parameter, the exact length of the fractional
 * part.
 *
 * @throws IllegalArgumentException if [minLength] is greater than [maxLength] or if either is not in the range 1..9.
 */


public fun secondFraction ( fixedLength : Int )

{ <EOL> secondFraction ( fixedLength , fixedLength ) <EOL> }

/**
 * The fractional part of the second without the leading dot.
 *
 * When formatting, the decimal fraction will add trailing zeroes or be rounded as necessary to always output
 * exactly the number of digits specified in [fixedLength].
 * Rounding is performed using the round-toward-zero rounding mode.
 *
 * When parsing, exactly [fixedLength] digits will be consumed.
 *
 * This field has the default value of 0. If you want to omit it, use [optional].
 *
 * See also the [secondFraction] overload that accepts two parameters, the minimum and maximum length of the
 * fractional part.
 *
 * @throws IllegalArgumentException if [fixedLength] is not in the range 1..9.
 *
 * @see secondFraction that accepts two parameters.
 */


public fun time ( format : DateTimeFormat < LocalTime > )

/**
 * An existing [DateTimeFormat] for the time part.
 *
 * Example:
 * ```
 * time(LocalTime.Formats.ISO)
 * ```
 */


public fun dateTime ( format : DateTimeFormat < LocalDateTime > )

/**
 * An existing [DateTimeFormat] for the date-time part.
 *
 * Example:
 * ```
 * dateTime(LocalDateTime.Formats.ISO)
 * ```
 */


public fun offsetHours ( padding : Padding = Padding . ZERO )

/**
 * The total number of hours in the UTC offset, including the sign.
 *
 * By default, it's zero-padded to two digits, but this can be changed with [padding].
 *
 * This field has the default value of 0. If you want to omit it, use [optional].
 */


public fun offsetMinutesOfHour ( padding : Padding = Padding . ZERO )

/**
 * The minute-of-hour of the UTC offset.
 *
 * By default, it's zero-padded to two digits, but this can be changed with [padding].
 *
 * This field has the default value of 0. If you want to omit it, use [optional].
 */


public fun offsetSecondsOfMinute ( padding : Padding = Padding . ZERO )

/**
 * The second-of-minute of the UTC offset.
 *
 * By default, it's zero-padded to two digits, but this can be changed with [padding].
 *
 * This field has the default value of 0. If you want to omit it, use [optional].
 */


public fun offset ( format : DateTimeFormat < UtcOffset > )

/**
 * An existing [DateTimeFormat] for the UTC offset part.
 *
 * Example:
 * ```
 * offset(UtcOffset.Formats.FOUR_DIGITS)
 * ```
 */


public fun timeZoneId ( )

/**
 * The IANA time zone identifier, for example, "Europe/Berlin".
 *
 * When formatting, the timezone identifier is supplied as is, without any validation.
 * On parsing, [TimeZone.availableZoneIds] is used to validate the identifier.
 */


public fun dateTimeComponents ( format : DateTimeFormat < DateTimeComponents > )

/**
 * An existing [DateTimeFormat].
 *
 * Example:
 * ```
 * dateTimeComponents(DateTimeComponents.Formats.RFC_1123)
 * ```
 */


internal fun DateTimeFormatBuilder . WithTime . secondFractionInternal ( minLength : Int , maxLength : Int , grouping : List < Int > )

{ <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> when ( this ) { <EOL> is AbstractWithTimeBuilder -> addFormatStructureForTime ( BasicFormatStructure ( FractionalSecondDirective ( minLength , maxLength , grouping ) ) ) <EOL> } <EOL> }

/**
 * The fractional part of the second without the leading dot.
 *
 * When formatting, the decimal fraction will round the number to fit in the specified [maxLength] and will add
 * trailing zeroes to the specified [minLength].
 *
 * Additionally, [grouping] is a list, where the i'th (1-based) element specifies how many trailing zeros to add during
 * formatting when the number would have i digits.
 *
 * When parsing, the parser will require that the fraction is at least [minLength] and at most [maxLength]
 * digits long.
 *
 * This field has the default value of 0. If you want to omit it, use [optional].
 *
 * @throws IllegalArgumentException if [minLength] is greater than [maxLength] or if either is not in the range 1..9.
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public fun < T : DateTimeFormatBuilder > T . alternativeParsing ( vararg alternativeFormats : T . ( ) -> Unit , primaryFormat : T . ( ) -> Unit ) : Unit

= when ( this ) { <EOL> is AbstractDateTimeFormatBuilder < * , * > -> <EOL> appendAlternativeParsingImpl ( * alternativeFormats as Array < out AbstractDateTimeFormatBuilder < * , * > . ( ) -> Unit > , mainFormat = primaryFormat as ( AbstractDateTimeFormatBuilder < * , * > . ( ) -> Unit ) ) <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> }

/**
 * A format along with other ways to parse the same portion of the value.
 *
 * When parsing, first, [primaryFormat] is used; if parsing the whole string fails using that, the formats
 * from [alternativeFormats] are tried in order.
 *
 * When formatting, the [primaryFormat] is used to format the value, and [alternativeFormats] are ignored.
 *
 * Example:
 * ```
 * alternativeParsing(
 * { dayOfMonth(); char('-'); monthNumber() },
 * { monthNumber(); char(' '); dayOfMonth() },
 * ) { monthNumber(); char('/'); dayOfMonth() }
 * ```
 *
 * This will always format a date as `MM/DD`, but will also accept `DD-MM` and `MM DD`.
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public fun < T : DateTimeFormatBuilder > T . optional ( ifZero : String = "<STR_LIT>" , format : T . ( ) -> Unit ) : Unit

= when ( this ) { <EOL> is AbstractDateTimeFormatBuilder < * , * > -> appendOptionalImpl ( onZero = ifZero , format as ( AbstractDateTimeFormatBuilder < * , * > . ( ) -> Unit ) ) <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> }

/**
 * An optional section.
 *
 * When formatting, the section is formatted if the value of any field in the block is not equal to the default value.
 * Only [optional] calls where all the fields have default values are permitted.
 *
 * Example:
 * ```
 * offsetHours(); char(':'); offsetMinutesOfHour()
 * optional { char(':'); offsetSecondsOfMinute() }
 * ```
 *
 * Here, because seconds have the default value of zero, they are formatted only if they are not equal to zero, so the
 * UTC offset `+18:30:00` gets formatted as `"+18:30"`, but `+18:30:01` becomes `"+18:30:01"`.
 *
 * When parsing, either [format] or, if that fails, the literal [ifZero] are parsed. If the [ifZero] string is parsed,
 * the values in [format] get assigned their default values.
 *
 * [ifZero] defines the string that is used if values are the default ones.
 *
 * @throws IllegalArgumentException if not all fields used in [format] have a default value.
 */


public fun DateTimeFormatBuilder . char ( value : Char ) : Unit

= chars ( value . toString ( ) )

/**
 * A literal character.
 *
 * This is a shorthand for `chars(value.toString())`.
 */


fun createEmpty ( ) : ActualSelf


fun appendAlternativeParsingImpl ( vararg otherFormats : ActualSelf . ( ) -> Unit , mainFormat : ActualSelf . ( ) -> Unit )

{ <EOL> val others = otherFormats . map { block -> <EOL> createEmpty ( ) . also { block ( it ) } . actualBuilder . build ( ) <EOL> } <EOL> val main = createEmpty ( ) . also { mainFormat ( it ) } . actualBuilder . build ( ) <EOL> actualBuilder . add ( AlternativesParsingFormatStructure ( main , others ) ) <EOL> }


fun appendOptionalImpl ( onZero : String , format : ActualSelf . ( ) -> Unit )

{ <EOL> actualBuilder . add ( OptionalFormatStructure ( onZero , createEmpty ( ) . also { format ( it ) } . actualBuilder . build ( ) ) ) <EOL> }


= actualBuilder . add ( ConstantFormatStructure ( value ) )


fun build ( ) : CachedFormatStructure < Target >

= CachedFormatStructure ( actualBuilder . build ( ) . formats )


internal fun < T > FormatStructure < T > . builderString ( constants : List < Pair < String , CachedFormatStructure < * > > > ) : String

= <EOL> when ( this ) { <EOL> is BasicFormatStructure -> directive . builderRepresentation <EOL> is ConstantFormatStructure -> if ( string . length == <NUM_LIT:1> ) { <EOL> "<STR_LIT>" <EOL> } else { <EOL> "<STR_LIT>" <EOL> } <EOL> is SignedFormatStructure -> { <EOL> if ( format is BasicFormatStructure && format . directive is UtcOffsetWholeHoursDirective ) { <EOL> format . directive . builderRepresentation <EOL> } else { <EOL> buildString { <EOL> if ( withPlusSign ) appendLine ( "<STR_LIT>" ) <EOL> else appendLine ( "<STR_LIT>" ) <EOL> appendLine ( format . builderString ( constants ) . prependIndent ( CODE_INDENT ) ) <EOL> append ( "<STR_LIT:}>" ) <EOL> } <EOL> } <EOL> } <EOL> is OptionalFormatStructure -> buildString { <EOL> if ( onZero == "<STR_LIT>" ) { <EOL> appendLine ( "<STR_LIT>" ) <EOL> } else { <EOL> appendLine ( "<STR_LIT>" ) <EOL> } <EOL> val subformat = format . builderString ( constants ) <EOL> if ( subformat . isNotEmpty ( ) ) { <EOL> appendLine ( subformat . prependIndent ( CODE_INDENT ) ) <EOL> } <EOL> append ( "<STR_LIT:}>" ) <EOL> } <EOL> is AlternativesParsingFormatStructure -> buildString { <EOL> append ( "<STR_LIT>" ) <EOL> for ( alternative in formats ) { <EOL> appendLine ( "<STR_LIT>" ) <EOL> val subformat = alternative . builderString ( constants ) <EOL> if ( subformat . isNotEmpty ( ) ) { <EOL> appendLine ( subformat . prependIndent ( CODE_INDENT ) ) <EOL> } <EOL> append ( "<STR_LIT>" ) <EOL> } <EOL> if ( this [ length - <NUM_LIT:2> ] == '<CHAR_LIT:U+002C>' ) { <EOL> repeat ( <NUM_LIT:2> ) { <EOL> deleteAt ( length - <NUM_LIT:1> ) <EOL> } <EOL> } <EOL> appendLine ( "<STR_LIT>" ) <EOL> appendLine ( mainFormat . builderString ( constants ) . prependIndent ( CODE_INDENT ) ) <EOL> append ( "<STR_LIT:}>" ) <EOL> } <EOL> is ConcatenatedFormatStructure -> buildString { <EOL> if ( formats . isNotEmpty ( ) ) { <EOL> var index = <NUM_LIT:0> <EOL> loop @ while ( index < formats . size ) { <EOL> searchConstant @ for ( constant in constants ) { <EOL> val constantDirectives = constant . second . formats <EOL> if ( formats . size - index >= constantDirectives . size ) { <EOL> for ( i in constantDirectives . indices ) { <EOL> if ( formats [ index + i ] != constantDirectives [ i ] ) { <EOL> continue@searchConstant <EOL> } <EOL> } <EOL> append ( constant . first ) <EOL> index += constantDirectives . size <EOL> if ( index < formats . size ) { <EOL> appendLine ( ) <EOL> } <EOL> continue@loop <EOL> } <EOL> } <EOL> if ( index == formats . size - <NUM_LIT:1> ) { <EOL> append ( formats . last ( ) . builderString ( constants ) ) <EOL> } else { <EOL> appendLine ( formats [ index ] . builderString ( constants ) ) <EOL> } <EOL> ++ index <EOL> } <EOL> } <EOL> } <EOL> }


= TODO ( )


= <EOL> color == null && width == null && radius == null


= ! isEmpty ( )


override fun createPointer ( ) : KtSymbolPointer < KtEnumEntrySymbol >

= withValidityAssertion { <EOL> KtPsiBasedSymbolPointer . createForSymbolFromSource < KtEnumEntrySymbol > ( this ) ? . let { <EOL> return it <EOL> } <EOL> val enumClassId = enumDescriptor . classId <EOL> if ( enumClassId != null ) { <EOL> return KtFe10DescEnumEntrySymbolPointer ( enumClassId , descriptor . name ) <EOL> } <EOL> return KtFe10NeverRestoringSymbolPointer ( ) <EOL> }


override fun equals ( other : Any ? ) : Boolean

= isEqualTo ( other )


= calculateHashCode ( )


{ <EOL> val nameMap = mutableMapOf < String , JsName > ( ) <EOL> fragments . forEach { f -> <EOL> f . buildRenames ( nameMap ) . run { <EOL> rename ( f . declarations ) <EOL> rename ( f . exports ) <EOL> f . imports . entries . forEach { ( declaration , importStatement ) -> <EOL> val importName = nameMap [ declaration ] <EOL> if ( importName == null && ! isEsModules ) { <EOL> error ( "<STR_LIT>" ) <EOL> } <EOL> importStatements . putIfAbsent ( declaration , rename ( importStatement . importStatementWithName ( importName ) ) ) <EOL> } <EOL> val classModels = ( mutableMapOf < JsName , JsIrIcClassModel > ( ) + f . classes ) <EOL> . also { f . classes . clear ( ) } <EOL> classModels . entries . forEach { ( name , model ) -> <EOL> f . classes [ rename ( name ) ] = JsIrIcClassModel ( model . superClasses . map { rename ( it ) } ) . also { <EOL> it . preDeclarationBlock . statements += model . preDeclarationBlock . statements <EOL> it . postDeclarationBlock . statements += model . postDeclarationBlock . statements <EOL> rename ( it . preDeclarationBlock ) <EOL> rename ( it . postDeclarationBlock ) <EOL> } <EOL> } <EOL> rename ( f . initializers ) <EOL> rename ( f . eagerInitializers ) <EOL> } <EOL> } <EOL> for ( ( tag , crossModuleJsImport ) in crossModuleReferences . jsImports ) { <EOL> val importName = nameMap [ tag ] ? : error ( "<STR_LIT>" ) <EOL> importStatements . putIfAbsent ( tag , crossModuleJsImport . renameImportedSymbolInternalName ( importName ) ) <EOL> } <EOL> importStatementsWithEffect . addAll ( crossModuleReferences . jsImportsWithEffect ) <EOL> if ( crossModuleReferences . exports . isNotEmpty ( ) ) { <EOL> val internalModuleName = ReservedJsNames . makeInternalModuleName ( ) <EOL> if ( isEsModules ) { <EOL> val exportedElements = crossModuleReferences . exports . entries . map { ( tag , hash ) -> <EOL> val internalName = nameMap [ tag ] ? : error ( "<STR_LIT>" ) <EOL> JsExport . Element ( internalName . makeRef ( ) , JsName ( hash , false ) ) <EOL> } <EOL> additionalExports += JsExport ( JsExport . Subject . Elements ( exportedElements ) ) <EOL> } else { <EOL> val createExportBlock = jsAssignment ( ReservedJsNames . makeCrossModuleNameRef ( internalModuleName ) , JsAstUtils . or ( ReservedJsNames . makeCrossModuleNameRef ( internalModuleName ) , JsObjectLiteral ( ) ) ) . makeStmt ( ) <EOL> additionalExports += createExportBlock <EOL> crossModuleReferences . exports . entries . forEach { ( tag , hash ) -> <EOL> val internalName = nameMap [ tag ] ? : error ( "<STR_LIT>" ) <EOL> val crossModuleRef = ReservedJsNames . makeCrossModuleNameRef ( ReservedJsNames . makeInternalModuleName ( ) ) <EOL> additionalExports += jsAssignment ( JsNameRef ( hash , crossModuleRef ) , JsNameRef ( internalName ) ) . makeStmt ( ) <EOL> } <EOL> } <EOL> } <EOL> }