private fun convertThrow ( throwExpression : LighterASTNode ) : FirExpression

{ <EOL> var firExpression : FirExpression ? = null <EOL> throwExpression . forEachChildren { <EOL> if ( it . isExpression ( ) ) firExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> return buildThrowExpression { <EOL> source = throwExpression . toFirSourceElement ( ) <EOL> exception = firExpression ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseThrow
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitThrowExpression
 */


private fun convertThisExpression ( thisExpression : LighterASTNode ) : FirQualifiedAccessExpression

{ <EOL> val label : String ? = thisExpression . getLabelName ( ) <EOL> return buildThisReceiverExpression { <EOL> val sourceElement = thisExpression . toFirSourceElement ( ) <EOL> source = sourceElement <EOL> calleeReference = buildExplicitThisReference { <EOL> labelName = label <EOL> source = sourceElement . fakeElement ( KtFakeSourceElementKind . ReferenceInAtomicQualifiedAccess ) <EOL> } <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseThisExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitThisExpression
 */


private fun convertSuperExpression ( superExpression : LighterASTNode ) : FirQualifiedAccessExpression

{ <EOL> val label : String ? = superExpression . getLabelName ( ) <EOL> var superTypeRef : FirTypeRef = implicitType <EOL> superExpression . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> TYPE_REFERENCE -> superTypeRef = declarationBuilder . convertType ( it ) <EOL> } <EOL> } <EOL> return buildPropertyAccessExpression { <EOL> val sourceElement = superExpression . toFirSourceElement ( ) <EOL> source = sourceElement <EOL> calleeReference = buildExplicitSuperReference { <EOL> labelName = label <EOL> this . superTypeRef = superTypeRef <EOL> source = sourceElement . fakeElement ( KtFakeSourceElementKind . ReferenceInAtomicQualifiedAccess ) <EOL> } <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseSuperExpression
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitSuperExpression
 */


fun convertValueArguments ( valueArguments : LighterASTNode ) : List < FirExpression >

{ <EOL> return valueArguments . forEachChildrenReturnList { node , container -> <EOL> when ( node . tokenType ) { <EOL> VALUE_ARGUMENT -> container += convertValueArgument ( node ) <EOL> LAMBDA_EXPRESSION , <EOL> LABELED_EXPRESSION , <EOL> ANNOTATED_EXPRESSION , <EOL> -> container += getAsFirExpression < FirAnonymousFunctionExpression > ( node ) . apply { <EOL> @ OptIn ( RawFirApi :: class ) <EOL> replaceIsTrailingLambda ( newIsTrailingLambda = true ) <EOL> } <EOL> } <EOL> } <EOL> }

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


private fun convertValueArgument ( valueArgument : LighterASTNode ) : FirExpression

{ <EOL> var identifier : String ? = null <EOL> var isSpread = false <EOL> var firExpression : FirExpression ? = null <EOL> valueArgument . forEachChildren { <EOL> when ( it . tokenType ) { <EOL> VALUE_ARGUMENT_NAME -> identifier = it . asText <EOL> MUL -> isSpread = true <EOL> STRING_TEMPLATE -> firExpression = convertStringTemplate ( it ) <EOL> is KtConstantExpressionElementType -> firExpression = convertConstantExpression ( it ) <EOL> else -> if ( it . isExpression ( ) ) firExpression = getAsFirExpression ( it , "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val calculatedFirExpression = <EOL> firExpression ? : buildErrorExpression ( null , ConeSyntaxDiagnostic ( "<STR_LIT>" ) ) <EOL> return when { <EOL> identifier != null -> buildNamedArgumentExpression { <EOL> source = valueArgument . toFirSourceElement ( ) <EOL> expression = calculatedFirExpression <EOL> this . isSpread = isSpread <EOL> name = identifier . nameAsSafeName ( ) <EOL> } <EOL> isSpread -> buildSpreadArgumentExpression { <EOL> source = valueArgument . toFirSourceElement ( ) <EOL> expression = calculatedFirExpression <EOL> } <EOL> else -> calculatedFirExpression <EOL> } <EOL> }

/**
 * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseValueArgument
 * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.toFirExpression(org.jetbrains.kotlin.psi.ValueArgument)
 */


override fun chooseMaximallySpecificCandidates ( candidates : Set < Candidate > , discriminateAbstracts : Boolean ) : Set < Candidate >

{ <EOL> if ( candidates . size <= <NUM_LIT:1> ) return candidates <EOL> var currentCandidates = candidates <EOL> var index = <NUM_LIT:0> <EOL> while ( currentCandidates . size > <NUM_LIT:1> && index < conflictResolvers . size ) { <EOL> val conflictResolver = conflictResolvers [ index ++ ] <EOL> currentCandidates = conflictResolver . chooseMaximallySpecificCandidates ( currentCandidates , discriminateAbstracts ) <EOL> } <EOL> return currentCandidates <EOL> }


{ <EOL> testCast < TestKlass > ( TestKlass ( ) , true ) <EOL> testCast < TestKlass > ( null , false ) <EOL> testCastToNullable < TestKlass > ( null , true ) <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> if ( ! b ) { <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }


fun < T : Any > testCast ( x : Any ? , expectSuccess : Boolean )

{ <EOL> try { <EOL> x as T <EOL> } catch ( e : Throwable ) { <EOL> ensure ( ! expectSuccess ) <EOL> return <EOL> } <EOL> ensure ( expectSuccess ) <EOL> }


fun < T : Any > testCastToNullable ( x : Any ? , expectSuccess : Boolean )

{ <EOL> try { <EOL> x as T ? <EOL> } catch ( e : Throwable ) { <EOL> ensure ( ! expectSuccess ) <EOL> return <EOL> } <EOL> ensure ( expectSuccess ) <EOL> }


{ <EOL> return expr . length <EOL> }


{ <EOL> val averageMobileDuration = log <EOL> . filter { it . os in setOf ( OS . IOS , OS . ANDROID ) } <EOL> . map ( SiteVisit :: duration ) <EOL> . average ( ) <EOL> println ( averageMobileDuration ) <EOL> }


fun kill ( signal : String ? = definedExternally )


fun send ( message : Any , callback : ( ( error : Error ? ) -> Unit ) ? = definedExternally ) : Boolean


fun send ( message : Any , sendHandle : net . Socket ? = definedExternally , callback : ( ( error : Error ? ) -> Unit ) ? = definedExternally ) : Boolean


fun send ( message : Any , sendHandle : net . Server ? = definedExternally , callback : ( ( error : Error ? ) -> Unit ) ? = definedExternally ) : Boolean


fun send ( message : Any , sendHandle : net . Socket ? = definedExternally , options : MessageOptions ? = definedExternally , callback : ( ( error : Error ? ) -> Unit ) ? = definedExternally ) : Boolean


fun send ( message : Any , sendHandle : net . Server ? = definedExternally , options : MessageOptions ? = definedExternally , callback : ( ( error : Error ? ) -> Unit ) ? = definedExternally ) : Boolean


fun disconnect ( )


fun unref ( )


fun ref ( )


fun addListener ( event : String , listener : ( args : Array < Any > ) -> Unit ) : ChildProcess


fun addListener ( event : String , listener : ( code : Number , signal : String ) -> Unit ) : ChildProcess


fun addListener ( event : String , listener : ( ) -> Unit ) : ChildProcess


fun addListener ( event : String , listener : ( err : Error ) -> Unit ) : ChildProcess


fun addListener ( event : String , listener : ( code : Number ? , signal : String ? ) -> Unit ) : ChildProcess


fun addListener ( event : String , listener : ( message : Any , sendHandle : dynamic ) -> Unit ) : ChildProcess


fun emit ( event : String , vararg args : Any ) : Boolean


fun emit ( event : Any , vararg args : Any ) : Boolean


fun emit ( event : String , code : Number , signal : String ) : Boolean


fun emit ( event : String ) : Boolean


fun emit ( event : String , err : Error ) : Boolean


fun emit ( event : String , code : Number ? , signal : String ? ) : Boolean


fun emit ( event : String , message : Any , sendHandle : net . Socket ) : Boolean


fun emit ( event : String , message : Any , sendHandle : net . Server ) : Boolean


fun on ( event : String , listener : ( args : Array < Any > ) -> Unit ) : ChildProcess


fun on ( event : String , listener : ( code : Number , signal : String ) -> Unit ) : ChildProcess


fun on ( event : String , listener : ( ) -> Unit ) : ChildProcess


fun on ( event : String , listener : ( err : Error ) -> Unit ) : ChildProcess


fun on ( event : String , listener : ( code : Number ? , signal : String ? ) -> Unit ) : ChildProcess


fun on ( event : String , listener : ( message : Any , sendHandle : dynamic ) -> Unit ) : ChildProcess


fun once ( event : String , listener : ( args : Array < Any > ) -> Unit ) : ChildProcess


fun once ( event : String , listener : ( code : Number , signal : String ) -> Unit ) : ChildProcess


fun once ( event : String , listener : ( ) -> Unit ) : ChildProcess


fun once ( event : String , listener : ( err : Error ) -> Unit ) : ChildProcess


fun once ( event : String , listener : ( code : Number ? , signal : String ? ) -> Unit ) : ChildProcess


fun once ( event : String , listener : ( message : Any , sendHandle : dynamic ) -> Unit ) : ChildProcess


fun prependListener ( event : String , listener : ( args : Array < Any > ) -> Unit ) : ChildProcess


fun prependListener ( event : String , listener : ( code : Number , signal : String ) -> Unit ) : ChildProcess


fun prependListener ( event : String , listener : ( ) -> Unit ) : ChildProcess


fun prependListener ( event : String , listener : ( err : Error ) -> Unit ) : ChildProcess


fun prependListener ( event : String , listener : ( code : Number ? , signal : String ? ) -> Unit ) : ChildProcess


fun prependListener ( event : String , listener : ( message : Any , sendHandle : dynamic ) -> Unit ) : ChildProcess


fun prependOnceListener ( event : String , listener : ( args : Array < Any > ) -> Unit ) : ChildProcess


fun prependOnceListener ( event : String , listener : ( code : Number , signal : String ) -> Unit ) : ChildProcess


fun prependOnceListener ( event : String , listener : ( ) -> Unit ) : ChildProcess


fun prependOnceListener ( event : String , listener : ( err : Error ) -> Unit ) : ChildProcess


fun prependOnceListener ( event : String , listener : ( code : Number ? , signal : String ? ) -> Unit ) : ChildProcess


fun prependOnceListener ( event : String , listener : ( message : Any , sendHandle : dynamic ) -> Unit ) : ChildProcess


external fun spawn ( command : String , options : SpawnOptionsWithoutStdio ? = definedExternally ) : ChildProcessWithoutNullStreams


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < String ? , String ? , String ? > ) : ChildProcessByStdio < Writable , Readable , Readable >


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < String ? , String ? , dynamic > ) : ChildProcessByStdio < Writable , Readable , Nothing ? >


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < String ? , dynamic , String ? > ) : ChildProcessByStdio < Writable , Nothing ? , Readable >


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < dynamic , String ? , String ? > ) : ChildProcessByStdio < Nothing ? , Readable , Readable >


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < String ? , dynamic , dynamic > ) : ChildProcessByStdio < Writable , Nothing ? , Nothing ? >


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < dynamic , String ? , dynamic > ) : ChildProcessByStdio < Nothing ? , Readable , Nothing ? >


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < dynamic , dynamic , String ? > ) : ChildProcessByStdio < Nothing ? , Nothing ? , Readable >


external fun spawn ( command : String , options : SpawnOptionsWithStdioTuple < dynamic , dynamic , dynamic > ) : ChildProcessByStdio < Nothing ? , Nothing ? , Nothing ? >


external fun spawn ( command : String , options : SpawnOptions ) : ChildProcess


external fun spawn ( command : String , args : ReadonlyArray < String > ? = definedExternally , options : SpawnOptionsWithoutStdio ? = definedExternally ) : ChildProcessWithoutNullStreams


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < String ? , String ? , String ? > ) : ChildProcessByStdio < Writable , Readable , Readable >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < String ? , String ? , dynamic > ) : ChildProcessByStdio < Writable , Readable , Nothing ? >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < String ? , dynamic , String ? > ) : ChildProcessByStdio < Writable , Nothing ? , Readable >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < dynamic , String ? , String ? > ) : ChildProcessByStdio < Nothing ? , Readable , Readable >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < String ? , dynamic , dynamic > ) : ChildProcessByStdio < Writable , Nothing ? , Nothing ? >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < dynamic , String ? , dynamic > ) : ChildProcessByStdio < Nothing ? , Readable , Nothing ? >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < dynamic , dynamic , String ? > ) : ChildProcessByStdio < Nothing ? , Nothing ? , Readable >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptionsWithStdioTuple < dynamic , dynamic , dynamic > ) : ChildProcessByStdio < Nothing ? , Nothing ? , Nothing ? >


external fun spawn ( command : String , args : ReadonlyArray < String > , options : SpawnOptions ) : ChildProcess


external fun exec ( command : String , callback : ( ( error : ExecException ? , stdout : String , stderr : String ) -> Unit ) ? = definedExternally ) : ChildProcess


external fun exec ( command : String , options : `T$0` , callback : ( ( error : ExecException ? , stdout : Buffer , stderr : Buffer ) -> Unit ) ? = definedExternally ) : ChildProcess


external fun exec ( command : String , options : `T$1` , callback : ( ( error : ExecException ? , stdout : String , stderr : String ) -> Unit ) ? = definedExternally ) : ChildProcess


external fun exec ( command : String , options : `T$2` , callback : ( ( error : ExecException ? , stdout : dynamic , stderr : dynamic ) -> Unit ) ? = definedExternally ) : ChildProcess


external fun exec ( command : String , options : ExecOptions , callback : ( ( error : ExecException ? , stdout : String , stderr : String ) -> Unit ) ? = definedExternally ) : ChildProcess


external fun exec ( command : String , options : `T$3` , callback : ( ( error : ExecException ? , stdout : dynamic , stderr : dynamic ) -> Unit ) ? = definedExternally ) : ChildProcess


external fun execFile ( file : String ) : ChildProcess


external fun execFile ( file : String , options : `T$3` ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? = definedExternally ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? , options : `T$3` ) : ChildProcess


external fun execFile ( file : String , callback : ( error : Error ? , stdout : String , stderr : String ) -> Unit ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? , callback : ( error : Error ? , stdout : String , stderr : String ) -> Unit ) : ChildProcess


external fun execFile ( file : String , options : ExecFileOptionsWithBufferEncoding , callback : ( error : Error ? , stdout : Buffer , stderr : Buffer ) -> Unit ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? , options : ExecFileOptionsWithBufferEncoding , callback : ( error : Error ? , stdout : Buffer , stderr : Buffer ) -> Unit ) : ChildProcess


external fun execFile ( file : String , options : ExecFileOptionsWithStringEncoding , callback : ( error : Error ? , stdout : String , stderr : String ) -> Unit ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? , options : ExecFileOptionsWithStringEncoding , callback : ( error : Error ? , stdout : String , stderr : String ) -> Unit ) : ChildProcess


external fun execFile ( file : String , options : ExecFileOptionsWithOtherEncoding , callback : ( error : Error ? , stdout : dynamic , stderr : dynamic ) -> Unit ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? , options : ExecFileOptionsWithOtherEncoding , callback : ( error : Error ? , stdout : dynamic , stderr : dynamic ) -> Unit ) : ChildProcess


external fun execFile ( file : String , options : ExecFileOptions , callback : ( error : Error ? , stdout : String , stderr : String ) -> Unit ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? , options : ExecFileOptions , callback : ( error : Error ? , stdout : String , stderr : String ) -> Unit ) : ChildProcess


external fun execFile ( file : String , options : `T$3` , callback : ( ( error : Error ? , stdout : dynamic , stderr : dynamic ) -> Unit ) ? ) : ChildProcess


external fun execFile ( file : String , args : ReadonlyArray < String > ? , options : `T$3` , callback : ( ( error : Error ? , stdout : dynamic , stderr : dynamic ) -> Unit ) ? ) : ChildProcess


external fun fork ( modulePath : String , args : ReadonlyArray < String > ? = definedExternally , options : ForkOptions ? = definedExternally ) : ChildProcess


external fun spawnSync ( command : String ) : SpawnSyncReturns < Buffer >


external fun spawnSync ( command : String , options : SpawnSyncOptionsWithStringEncoding ? = definedExternally ) : SpawnSyncReturns < String >


external fun spawnSync ( command : String , options : SpawnSyncOptionsWithBufferEncoding ? = definedExternally ) : SpawnSyncReturns < Buffer >


external fun spawnSync ( command : String , options : SpawnSyncOptions ? = definedExternally ) : SpawnSyncReturns < Buffer >


external fun spawnSync ( command : String , args : ReadonlyArray < String > ? = definedExternally , options : SpawnSyncOptionsWithStringEncoding ? = definedExternally ) : SpawnSyncReturns < String >


external fun spawnSync ( command : String , args : ReadonlyArray < String > ? = definedExternally , options : SpawnSyncOptionsWithBufferEncoding ? = definedExternally ) : SpawnSyncReturns < Buffer >


external fun spawnSync ( command : String , args : ReadonlyArray < String > ? = definedExternally , options : SpawnSyncOptions ? = definedExternally ) : SpawnSyncReturns < Buffer >


external fun execSync ( command : String ) : Buffer


external fun execSync ( command : String , options : ExecSyncOptionsWithStringEncoding ? = definedExternally ) : String


external fun execSync ( command : String , options : ExecSyncOptionsWithBufferEncoding ? = definedExternally ) : Buffer


external fun execSync ( command : String , options : ExecSyncOptions ? = definedExternally ) : Buffer


external fun execFileSync ( command : String ) : Buffer


external fun execFileSync ( command : String , options : ExecFileSyncOptionsWithStringEncoding ? = definedExternally ) : String


external fun execFileSync ( command : String , options : ExecFileSyncOptionsWithBufferEncoding ? = definedExternally ) : Buffer


external fun execFileSync ( command : String , options : ExecFileSyncOptions ? = definedExternally ) : Buffer


external fun execFileSync ( command : String , args : ReadonlyArray < String > ? = definedExternally , options : ExecFileSyncOptionsWithStringEncoding ? = definedExternally ) : String


external fun execFileSync ( command : String , args : ReadonlyArray < String > ? = definedExternally , options : ExecFileSyncOptionsWithBufferEncoding ? = definedExternally ) : Buffer


external fun execFileSync ( command : String , args : ReadonlyArray < String > ? = definedExternally , options : ExecFileSyncOptions ? = definedExternally ) : Buffer


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

{ <EOL> val annotations = declaration . annotations <EOL> if ( annotations . isEmpty ( ) ) return <EOL> val annotationsMap = hashMapOf < ConeKotlinType , MutableList < AnnotationUseSiteTarget ? > > ( ) <EOL> val session = context . session <EOL> for ( annotation in annotations ) { <EOL> val unexpandedClassId = annotation . unexpandedClassId ? : continue <EOL> val annotationClassId = annotation . toAnnotationClassId ( session ) ? : continue <EOL> if ( annotationClassId . isLocal ) continue <EOL> val annotationClass = session . symbolProvider . getClassLikeSymbolByClassId ( annotationClassId ) ? : continue <EOL> val useSiteTarget = annotation . useSiteTarget <EOL> val expandedType = annotation . annotationTypeRef . coneType . fullyExpandedType ( context . session ) <EOL> val existingTargetsForAnnotation = annotationsMap . getOrPut ( expandedType ) { arrayListOf ( ) } <EOL> val duplicateAnnotation = useSiteTarget in existingTargetsForAnnotation || <EOL> existingTargetsForAnnotation . any { ( it == null ) != ( useSiteTarget == null ) } <EOL> if ( duplicateAnnotation && session . annotationPlatformSupport . symbolContainsRepeatableAnnotation ( annotationClass , session ) && annotationClass . getAnnotationRetention ( session ) != AnnotationRetention . SOURCE ) { <EOL> if ( session . languageVersionSettings . supportsFeature ( LanguageFeature . RepeatableAnnotations ) ) { <EOL> val explicitContainer = annotationClass . resolveContainerAnnotation ( session ) <EOL> if ( explicitContainer != null && annotations . any { it . toAnnotationClassId ( session ) == explicitContainer } ) { <EOL> reporter . reportOn ( annotation . source , FirJvmErrors . REPEATED_ANNOTATION_WITH_CONTAINER , unexpandedClassId , explicitContainer , context ) <EOL> } <EOL> } else { <EOL> reporter . reportOn ( annotation . source , FirJvmErrors . NON_SOURCE_REPEATED_ANNOTATION , context ) <EOL> } <EOL> } <EOL> existingTargetsForAnnotation . add ( useSiteTarget ) <EOL> } <EOL> if ( declaration is FirRegularClass ) { <EOL> val javaRepeatable = annotations . getAnnotationByClassId ( JvmStandardClassIds . Annotations . Java . Repeatable , session ) <EOL> if ( javaRepeatable != null ) { <EOL> checkJavaRepeatableAnnotationDeclaration ( javaRepeatable , declaration , context , reporter ) <EOL> } else { <EOL> val kotlinRepeatable = annotations . getAnnotationByClassId ( StandardClassIds . Annotations . Repeatable , session ) <EOL> if ( kotlinRepeatable != null ) { <EOL> checkKotlinRepeatableAnnotationDeclaration ( kotlinRepeatable , declaration , context , reporter ) <EOL> } <EOL> } <EOL> } <EOL> }


private fun FirClassLikeSymbol < * > . resolveContainerAnnotation ( session : FirSession ) : ClassId ?

{ <EOL> val repeatableAnnotation = getAnnotationByClassId ( StandardClassIds . Annotations . Repeatable , session ) <EOL> ? : getAnnotationByClassId ( JvmStandardClassIds . Annotations . Java . Repeatable , session ) <EOL> ? : return null <EOL> return repeatableAnnotation . resolveContainerAnnotation ( ) <EOL> }


private fun FirAnnotation . resolveContainerAnnotation ( ) : ClassId ?

{ <EOL> val value = findArgumentByName ( StandardClassIds . Annotations . ParameterNames . value ) ? : return null <EOL> val classCallArgument = ( value as? FirGetClassCall ) ? . argument ? : return null <EOL> if ( classCallArgument is FirResolvedQualifier ) { <EOL> return classCallArgument . classId <EOL> } else if ( classCallArgument is FirClassReferenceExpression ) { <EOL> val type = classCallArgument . classTypeRef . coneType . lowerBoundIfFlexible ( ) as? ConeClassLikeType ? : return null <EOL> return type . lookupTag . classId <EOL> } <EOL> return null <EOL> }


private fun checkJavaRepeatableAnnotationDeclaration ( javaRepeatable : FirAnnotation , annotationClass : FirRegularClass , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> val containerClassId = javaRepeatable . resolveContainerAnnotation ( ) ? : return <EOL> val containerClassSymbol = <EOL> context . session . symbolProvider . getClassLikeSymbolByClassId ( containerClassId ) as? FirRegularClassSymbol ? : return <EOL> checkRepeatableAnnotationContainer ( annotationClass , containerClassSymbol , javaRepeatable . source , context , reporter ) <EOL> }


private fun checkKotlinRepeatableAnnotationDeclaration ( kotlinRepeatable : FirAnnotation , declaration : FirRegularClass , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> val unsubsitutedScope = declaration . unsubstitutedScope ( context ) <EOL> if ( unsubsitutedScope . getSingleClassifier ( REPEATABLE_ANNOTATION_CONTAINER_NAME ) != null ) { <EOL> reporter . reportOn ( kotlinRepeatable . source , FirJvmErrors . REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER , context ) <EOL> } <EOL> }


private fun checkRepeatableAnnotationContainer ( annotationClass : FirRegularClass , containerClass : FirRegularClassSymbol , annotationSource : KtSourceElement ? , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> checkContainerParameters ( containerClass , annotationClass , annotationSource , context , reporter ) <EOL> checkContainerRetention ( containerClass , annotationClass , annotationSource , context , reporter ) <EOL> checkContainerTarget ( containerClass , annotationClass , annotationSource , context , reporter ) <EOL> }


private fun checkContainerParameters ( containerClass : FirRegularClassSymbol , annotationClass : FirRegularClass , annotationSource : KtSourceElement ? , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> val containerCtor = <EOL> containerClass . declarationSymbols . find { it is FirConstructorSymbol && it . isPrimary } as? FirConstructorSymbol <EOL> ? : return <EOL> val valueParameterSymbols = containerCtor . valueParameterSymbols <EOL> val parameterName = StandardClassIds . Annotations . ParameterNames . value <EOL> val value = valueParameterSymbols . find { it . name == parameterName } <EOL> if ( value == null || ! value . resolvedReturnTypeRef . coneType . fullyExpandedType ( context . session ) . isArrayType || value . resolvedReturnTypeRef . type . typeArguments . single ( ) . type != annotationClass . defaultType ( ) ) { <EOL> reporter . reportOn ( annotationSource , FirJvmErrors . REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY , containerClass . classId , annotationClass . classId , context ) <EOL> return <EOL> } <EOL> val otherNonDefault = valueParameterSymbols . find { it . name != parameterName && ! it . hasDefaultValue } <EOL> if ( otherNonDefault != null ) { <EOL> reporter . reportOn ( annotationSource , FirJvmErrors . REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER , containerClass . classId , otherNonDefault . name , context ) <EOL> return <EOL> } <EOL> }


private fun checkContainerRetention ( containerClass : FirRegularClassSymbol , annotationClass : FirRegularClass , annotationSource : KtSourceElement ? , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> val annotationRetention = annotationClass . symbol . getAnnotationRetention ( context . session ) <EOL> val containerRetention = containerClass . getAnnotationRetention ( context . session ) <EOL> if ( containerRetention < annotationRetention ) { <EOL> reporter . reportOn ( annotationSource , FirJvmErrors . REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION , containerClass . classId , containerRetention . name , annotationClass . classId , annotationRetention . name , context ) <EOL> } <EOL> }


private fun checkContainerTarget ( containerClass : FirRegularClassSymbol , annotationClass : FirRegularClass , annotationSource : KtSourceElement ? , context : CheckerContext , reporter : DiagnosticReporter )

{ <EOL> val annotationTargets = annotationClass . getAllowedAnnotationTargets ( context . session ) <EOL> val containerTargets = containerClass . getAllowedAnnotationTargets ( context . session ) <EOL> for ( target in containerTargets ) { <EOL> val ok = when ( target ) { <EOL> in annotationTargets -> true <EOL> KotlinTarget . ANNOTATION_CLASS -> <EOL> KotlinTarget . CLASS in annotationTargets || <EOL> KotlinTarget . TYPE in annotationTargets <EOL> KotlinTarget . CLASS -> <EOL> KotlinTarget . TYPE in annotationTargets <EOL> KotlinTarget . TYPE_PARAMETER -> <EOL> KotlinTarget . TYPE in annotationTargets <EOL> else -> false <EOL> } <EOL> if ( ! ok ) { <EOL> reporter . reportOn ( annotationSource , FirJvmErrors . REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET , containerClass . classId , annotationClass . classId , context ) <EOL> return <EOL> } <EOL> } <EOL> }


fun < S : T > takeFoo ( foo : Foo < in S > )


fun < K : Inv < out Inv < out Number > > > main ( )

{ <EOL> val foo = Foo < K > ( ) <EOL> Bar < Inv < Inv < Int > > > ( ) . takeFoo ( foo ) <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:100> , C ( ) . testClassVal ) <EOL> assertEquals ( <NUM_LIT> , C ( ) . testJvmFieldVal ) <EOL> assertEquals ( <NUM_LIT> , C . testCompanionObjectVal ) <EOL> assertEquals ( <NUM_LIT> , C . testJvmStaticCompanionObjectVal ) <EOL> assertEquals ( <NUM_LIT> , C . testJvmFieldCompanionObjectVal ) <EOL> assertEquals ( <NUM_LIT> , IFoo . testInterfaceCompanionObjectVal ) <EOL> assertEquals ( <NUM_LIT> , IBar . testJvmFieldInInterfaceCompanionObject ) <EOL> assertEquals ( <NUM_LIT> , Obj . testObjectVal ) <EOL> assertEquals ( <NUM_LIT> , Obj . testJvmStaticObjectVal ) <EOL> assertEquals ( <NUM_LIT> , Obj . testJvmFieldObjectVal ) <EOL> assertEquals ( <NUM_LIT> , testTopLevelVal ) <EOL> return "<STR_LIT:OK>" <EOL> }


override fun getResolveExtensionScopeWithTopLevelDeclarations ( ) : KtScope

{ <EOL> val tools = analysisSession . extensionTools <EOL> if ( tools . isEmpty ( ) ) return KtEmptyScope ( token ) <EOL> return KtFirResolveExtensionScope ( analysisSession , tools ) <EOL> }


@ OptIn ( KtModuleStructureInternals :: class ) <EOL> override fun isResolveExtensionFile ( file : VirtualFile ) : Boolean

= <EOL> file . navigationTargetsProvider != null


@ OptIn ( KtModuleStructureInternals :: class ) <EOL> override fun getResolveExtensionNavigationElements ( originalPsi : KtElement ) : Collection < PsiElement >

{ <EOL> val targetsProvider = originalPsi . containingFile ? . virtualFile ? . navigationTargetsProvider ? : return emptyList ( ) <EOL> return with ( targetsProvider ) { analysisSession . getNavigationTargets ( originalPsi ) } <EOL> }


override fun getCallableSymbols ( nameFilter : KtScopeNameFilter ) : Sequence < KtCallableSymbol >

= withValidityAssertion { <EOL> getTopLevelDeclarations ( nameFilter ) { it . getTopLevelCallables ( ) } <EOL> }


override fun getCallableSymbols ( names : Collection < Name > ) : Sequence < KtCallableSymbol >

= withValidityAssertion { <EOL> if ( names . isEmpty ( ) ) return emptySequence ( ) <EOL> val namesSet = names . toSet ( ) <EOL> return getCallableSymbols { it in namesSet } <EOL> }


override fun getClassifierSymbols ( nameFilter : KtScopeNameFilter ) : Sequence < KtClassifierSymbol >

= withValidityAssertion { <EOL> getTopLevelDeclarations ( nameFilter ) { it . getTopLevelClassifiers ( ) } <EOL> }


override fun getClassifierSymbols ( names : Collection < Name > ) : Sequence < KtClassifierSymbol >

= withValidityAssertion { <EOL> if ( names . isEmpty ( ) ) return emptySequence ( ) <EOL> val namesSet = names . toSet ( ) <EOL> return getClassifierSymbols { it in namesSet } <EOL> }


private inline fun < D : KtNamedDeclaration , reified S : KtDeclarationSymbol > getTopLevelDeclarations ( crossinline nameFilter : KtScopeNameFilter , crossinline getDeclarationsByProvider : ( LLFirResolveExtensionToolDeclarationProvider ) -> Sequence < D > , ) : Sequence < S >

= sequence { <EOL> for ( tool in tools ) { <EOL> for ( declaration in getDeclarationsByProvider ( tool . declarationProvider ) ) { <EOL> val declarationName = declaration . nameAsName ? : continue <EOL> if ( ! nameFilter ( declarationName ) ) continue <EOL> with ( analysisSession ) { <EOL> yield ( declaration . getSymbol ( ) as S ) <EOL> } <EOL> } <EOL> } <EOL> }


override fun getConstructors ( ) : Sequence < KtConstructorSymbol >

= withValidityAssertion { <EOL> emptySequence ( ) <EOL> }


override fun getPackageSymbols ( nameFilter : KtScopeNameFilter ) : Sequence < KtPackageSymbol >

= withValidityAssertion { <EOL> sequence { <EOL> val seenTopLevelPackages = mutableSetOf < Name > ( ) <EOL> for ( tool in tools ) { <EOL> for ( packageName in tool . packageFilter . getAllSubPackages ( FqName . ROOT ) ) { <EOL> if ( seenTopLevelPackages . add ( packageName ) && nameFilter ( packageName ) ) { <EOL> yield ( analysisSession . firSymbolBuilder . createPackageSymbol ( FqName . ROOT . child ( packageName ) ) ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> }


override fun getPossibleCallableNames ( ) : Set < Name >

= withValidityAssertion { <EOL> tools . flatMapTo ( mutableSetOf ( ) ) { it . declarationProvider . getTopLevelCallableNames ( ) } <EOL> }


override fun getPossibleClassifierNames ( ) : Set < Name >

= withValidityAssertion { <EOL> tools . flatMapTo ( mutableSetOf ( ) ) { it . declarationProvider . getTopLevelClassifierNames ( ) } <EOL> }


actual override fun < T : Number > pow ( mat : MultiArray < T , D2 > , n : Int ) : NDArray < T , D2 >

= ktLinAlg . pow ( mat , n )


@ Input <EOL> internal fun getUrlString ( )

= url . map ( URL :: toString )


@ Input <EOL> @ Optional <EOL> internal fun getPackageListUrlString ( )

= packageListUrl . map ( URL :: toString )


override fun build ( ) : ExternalDocumentationLinkImpl

= ExternalDocumentationLink ( url = checkNotNull ( url . get ( ) ) { "<STR_LIT>" } , packageListUrl = packageListUrl . orNull , )


{ <EOL> func1 ( WeakReference ( Any ( ) ) . get ( ) ! ! ) <EOL> }


fun excludeUnused ( headerName : String ? ) : Boolean

/**
 * Whether unused declarations from given header should be excluded.
 *
 * @param headerName header path relative to the appropriate include path element (e.g. `time.h` or `curl/curl.h`),
 * or `null` for builtin declarations.
 */


fun excludeAll ( headerId : HeaderId ) : Boolean

/**
 * Whether all declarations from this header should be excluded.
 *
 * Note: the declarations from such headers can be actually present in the internal representation,
 * but not included into the root collections.
 */


fun defaultCompilerArgs ( language : Language ) : List < String >

= <EOL> listOf ( "<STR_LIT>" , "<STR_LIT>" , ) + when ( language ) { <EOL> Language . C -> emptyList ( ) <EOL> Language . CPP -> emptyList ( ) <EOL> Language . OBJECTIVE_C -> listOf ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


fun buildNativeIndex ( library : NativeLibrary , verbose : Boolean ) : IndexerResult

= buildNativeIndexImpl ( library , verbose )

/**
 * Retrieves the definitions from given C header file using given compiler arguments (e.g. defines).
 */


= returnType . containsInstancetype ( )


fun getReturnType ( container : ObjCClassOrProtocol ) : Type

= if ( returnType . containsInstancetype ( ) ) { <EOL> returnType . substituteInstancetype ( container ) <EOL> } else { <EOL> returnType <EOL> }


private fun Type . containsInstancetype ( ) : Boolean

= when ( this ) { <EOL> is ObjCInstanceType -> true <EOL> is ObjCBlockPointer -> this . returnType . containsInstancetype ( ) <EOL> is FunctionType -> this . returnType . containsInstancetype ( ) <EOL> is PointerType -> this . pointeeType . containsInstancetype ( ) <EOL> else -> false <EOL> }


private fun Type . substituteInstancetype ( container : ObjCClassOrProtocol ) : Type

= when ( this ) { <EOL> is ObjCInstanceType -> when ( container ) { <EOL> is ObjCClass -> ObjCObjectPointer ( container , this . nullability , protocols = emptyList ( ) ) <EOL> is ObjCProtocol -> ObjCIdType ( this . nullability , protocols = listOf ( container ) ) <EOL> } <EOL> is ObjCBlockPointer -> this . copy ( returnType = this . returnType . substituteInstancetype ( container ) ) <EOL> is FunctionType -> this . copy ( returnType = this . returnType . substituteInstancetype ( container ) ) <EOL> is PointerType -> this . copy ( pointeeType = this . pointeeType . substituteInstancetype ( container ) ) <EOL> else -> this <EOL> }


fun getType ( container : ObjCClassOrProtocol ) : Type

= getter . getReturnType ( container )


fun CxxMethodInfo . isConst ( ) : Boolean

= receiverType . pointeeIsConst


private fun fromCArray ( ptr : CPointer < CPointerVar < ByteVar > > , count : Int )

= <EOL> Array ( count , { index -> ( ptr + index ) ! ! . pointed . value ! ! . toKString ( ) } )


fun execute ( command : String , callback : ( ( Array < String > , Array < String > ) -> Int ) ? = null )

{ <EOL> memScoped { <EOL> val error = this . alloc < CPointerVar < ByteVar > > ( ) <EOL> val callbackStable = if ( callback != null ) StableRef . create ( callback ) else null <EOL> try { <EOL> if ( sqlite3_exec ( db , command , if ( callback != null ) staticCFunction { <EOL> ptr , count , data , columns -> <EOL> val callbackFunction = <EOL> ptr ! ! . asStableRef < ( Array < String > , Array < String > ) -> Int > ( ) . get ( ) <EOL> val columnsArray = fromCArray ( columns ! ! , count ) <EOL> val dataArray = fromCArray ( data ! ! , count ) <EOL> callbackFunction ( columnsArray , dataArray ) <EOL> } else null , callbackStable ? . asCPointer ( ) , error . ptr ) != <NUM_LIT:0> ) <EOL> throw KSqliteError ( "<STR_LIT>" ) <EOL> } finally { <EOL> callbackStable ? . dispose ( ) <EOL> sqlite3_free ( error . value ) <EOL> } <EOL> } <EOL> }


= input . replace ( "<STR_LIT>" , "<STR_LIT>" )


= "<STR_LIT>"


{ <EOL> if ( db != null ) { <EOL> sqlite3_close ( db ) <EOL> db = null <EOL> } <EOL> }


inline fun withSqlite ( path : String , function : ( KSqlite ) -> Unit )

{ <EOL> val db = KSqlite ( path ) <EOL> try { <EOL> function ( db ) <EOL> } finally { <EOL> db . close ( ) <EOL> } <EOL> }


inline fun withSqlite ( db : KSqlite , function : ( KSqlite ) -> Unit )

{ <EOL> try { <EOL> function ( db ) <EOL> } finally { <EOL> db . close ( ) <EOL> } <EOL> }


{ <EOL> val p = <NUM_LIT:2> < <NUM_LIT:1> ; <EOL> if ( ! ! ! ! ! p ) { <EOL> return "<STR_LIT:OK>" <EOL> } else { <EOL> return "<STR_LIT:fail>" <EOL> } <EOL> }


= i


= A < caret > ( <NUM_LIT:1> )


fun defineNativeTargets ( platform : String , archs : List < String > ) : List < KonanTarget >

{ <EOL> class UnknownArchitectureException ( platform : String , arch : String ) : <EOL> IllegalArgumentException ( "<STR_LIT>" ) <EOL> val targets : MutableSet < KonanTarget > = mutableSetOf ( ) <EOL> when { <EOL> platform . startsWith ( "<STR_LIT>" ) -> { <EOL> targets . addAll ( archs . map { arch -> <EOL> when ( arch ) { <EOL> "<STR_LIT>" , "<STR_LIT>" -> KonanTarget . IOS_ARM64 <EOL> else -> throw UnknownArchitectureException ( platform , arch ) <EOL> } <EOL> } ) <EOL> } <EOL> platform . startsWith ( "<STR_LIT>" ) -> { <EOL> targets . addAll ( archs . map { arch -> <EOL> when ( arch ) { <EOL> "<STR_LIT>" , "<STR_LIT>" -> KonanTarget . IOS_SIMULATOR_ARM64 <EOL> "<STR_LIT>" -> KonanTarget . IOS_X64 <EOL> else -> throw UnknownArchitectureException ( platform , arch ) <EOL> } <EOL> } ) <EOL> } <EOL> platform . startsWith ( "<STR_LIT>" ) -> { <EOL> targets . addAll ( archs . map { arch -> <EOL> when ( arch ) { <EOL> "<STR_LIT>" -> KonanTarget . WATCHOS_ARM32 <EOL> "<STR_LIT>" -> KonanTarget . WATCHOS_ARM64 <EOL> "<STR_LIT>" -> KonanTarget . WATCHOS_DEVICE_ARM64 <EOL> else -> throw UnknownArchitectureException ( platform , arch ) <EOL> } <EOL> } ) <EOL> } <EOL> platform . startsWith ( "<STR_LIT>" ) -> { <EOL> targets . addAll ( archs . map { arch -> <EOL> when ( arch ) { <EOL> "<STR_LIT>" , "<STR_LIT>" -> KonanTarget . WATCHOS_SIMULATOR_ARM64 <EOL> "<STR_LIT>" -> KonanTarget . WATCHOS_X64 <EOL> else -> throw UnknownArchitectureException ( platform , arch ) <EOL> } <EOL> } ) <EOL> } <EOL> platform . startsWith ( "<STR_LIT>" ) -> { <EOL> targets . addAll ( archs . map { arch -> <EOL> when ( arch ) { <EOL> "<STR_LIT>" , "<STR_LIT>" -> KonanTarget . TVOS_ARM64 <EOL> else -> throw UnknownArchitectureException ( platform , arch ) <EOL> } <EOL> } ) <EOL> } <EOL> platform . startsWith ( "<STR_LIT>" ) -> { <EOL> targets . addAll ( archs . map { arch -> <EOL> when ( arch ) { <EOL> "<STR_LIT>" , "<STR_LIT>" -> KonanTarget . TVOS_SIMULATOR_ARM64 <EOL> "<STR_LIT>" -> KonanTarget . TVOS_X64 <EOL> else -> throw UnknownArchitectureException ( platform , arch ) <EOL> } <EOL> } ) <EOL> } <EOL> platform . startsWith ( "<STR_LIT>" ) -> { <EOL> targets . addAll ( archs . map { arch -> <EOL> when ( arch ) { <EOL> "<STR_LIT>" -> KonanTarget . MACOS_ARM64 <EOL> "<STR_LIT>" -> KonanTarget . MACOS_X64 <EOL> else -> throw UnknownArchitectureException ( platform , arch ) <EOL> } <EOL> } ) <EOL> } <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> return targets . toList ( ) <EOL> }


override fun visitFunction ( declaration : IrFunction , data : JsGenerationContext ) : JsStatement

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


override fun visitBlockBody ( body : IrBlockBody , context : JsGenerationContext ) : JsStatement

{ <EOL> return JsBlock ( body . statements . map { it . accept ( this , context ) } . toSmartList ( ) ) . withSource ( body , context , container = context . currentFunction ) <EOL> }


override fun visitBlock ( expression : IrBlock , context : JsGenerationContext ) : JsStatement

{ <EOL> val newContext = ( expression as? IrReturnableBlock ) ? . inlineFunction ? . let { <EOL> context . newFile ( it . file , context . currentFunction , context . localNames ) <EOL> } ? : context <EOL> val container = expression . innerInlinedBlockOrThis . statements <EOL> val statements = container . map { it . accept ( this , newContext ) } . toSmartList ( ) <EOL> return if ( expression is IrReturnableBlock ) { <EOL> val label = context . getNameForReturnableBlock ( expression ) <EOL> val wrappedStatements = statements . wrapInCommentsInlineFunctionCall ( expression ) <EOL> if ( label != null ) { <EOL> JsLabel ( label , JsBlock ( wrappedStatements ) ) <EOL> } else { <EOL> JsCompositeBlock ( wrappedStatements ) <EOL> } <EOL> } else { <EOL> JsBlock ( statements ) <EOL> } . withSource ( expression , context ) <EOL> }


private fun List < JsStatement > . wrapInCommentsInlineFunctionCall ( expression : IrReturnableBlock ) : List < JsStatement >

{ <EOL> val inlineFunction = expression . inlineFunction ? : return this <EOL> val correspondingProperty = ( inlineFunction as? IrSimpleFunction ) ? . correspondingPropertySymbol <EOL> val owner = correspondingProperty ? . owner ? : inlineFunction <EOL> val funName = owner . fqNameWhenAvailable ? : owner . name <EOL> return listOf ( JsSingleLineComment ( "<STR_LIT>" ) ) + this <EOL> }


override fun visitComposite ( expression : IrComposite , context : JsGenerationContext ) : JsStatement

{ <EOL> return if ( expression . statements . isEmpty ( ) ) { <EOL> JsEmpty <EOL> } else { <EOL> JsBlock ( expression . statements . map { it . accept ( this , context ) } . toSmartList ( ) ) . withSource ( expression , context ) <EOL> } <EOL> }


override fun visitExpression ( expression : IrExpression , context : JsGenerationContext ) : JsStatement

{ <EOL> return expression . accept ( IrElementToJsExpressionTransformer ( ) , context ) . makeStmt ( ) <EOL> }


override fun visitFunctionExpression ( expression : IrFunctionExpression , context : JsGenerationContext ) : JsStatement

{ <EOL> return expression . function . accept ( IrFunctionToJsTransformer ( ) , context ) . makeStmt ( ) <EOL> }


override fun visitBreak ( jump : IrBreak , context : JsGenerationContext ) : JsStatement

{ <EOL> return JsBreak ( context . getNameForLoop ( jump . loop ) ? . let { JsNameRef ( it ) } ) . withSource ( jump , context ) <EOL> }


override fun visitContinue ( jump : IrContinue , context : JsGenerationContext ) : JsStatement

{ <EOL> return JsContinue ( context . getNameForLoop ( jump . loop ) ? . let { JsNameRef ( it ) } ) . withSource ( jump , context ) <EOL> }


private fun IrExpression . maybeOptimizeIntoSwitch ( context : JsGenerationContext , transformer : ( ( ) -> JsExpression ) -> JsStatement ) : JsStatement

{ <EOL> if ( this is IrWhen ) { <EOL> val stmtTransformer : ( ( ) -> JsStatement ) -> JsStatement = { <EOL> transformer { <EOL> val stmt = it ( ) <EOL> assert ( stmt is JsExpressionStatement ) { "<STR_LIT>" } <EOL> ( stmt as JsExpressionStatement ) . expression <EOL> } <EOL> } <EOL> SwitchOptimizer ( context , isExpression = true , stmtTransformer ) . tryOptimize ( this ) ? . let { return it } <EOL> } <EOL> return transformer { accept ( IrElementToJsExpressionTransformer ( ) , context ) } <EOL> }


override fun visitSetField ( expression : IrSetField , context : JsGenerationContext ) : JsStatement

{ <EOL> val fieldName = context . getNameForField ( expression . symbol . owner ) <EOL> val expressionTransformer = IrElementToJsExpressionTransformer ( ) <EOL> val dest = jsElementAccess ( fieldName , expression . receiver ? . accept ( expressionTransformer , context ) ) <EOL> return expression . value . maybeOptimizeIntoSwitch ( context ) { jsAssignment ( dest , it ( ) ) . withSource ( expression , context ) . makeStmt ( ) } <EOL> }


override fun visitSetValue ( expression : IrSetValue , context : JsGenerationContext ) : JsStatement

{ <EOL> val owner = expression . symbol . owner <EOL> val ref = JsNameRef ( context . getNameForValueDeclaration ( owner ) ) <EOL> return expression . value . maybeOptimizeIntoSwitch ( context ) { jsAssignment ( ref , it ( ) ) . withSource ( expression , context ) . makeStmt ( ) } <EOL> }


override fun visitReturn ( expression : IrReturn , context : JsGenerationContext ) : JsStatement

{ <EOL> val lastStatementTransformer : ( ( ) -> JsExpression ) -> JsStatement = <EOL> when ( val targetSymbol = expression . returnTargetSymbol ) { <EOL> is IrReturnableBlockSymbol -> { <EOL> { <EOL> context . getNameForReturnableBlock ( targetSymbol . owner ) <EOL> . takeIf { ! expression . isTheLastReturnStatementIn ( targetSymbol ) } <EOL> ? . run { JsBreak ( makeRef ( ) ) } ? : JsEmpty <EOL> } <EOL> } <EOL> is IrFunctionSymbol -> { <EOL> { JsReturn ( it ( ) ) } <EOL> } <EOL> } <EOL> return expression . value <EOL> . maybeOptimizeIntoSwitch ( context , lastStatementTransformer ) <EOL> . withSource ( expression , context ) <EOL> }


override fun visitThrow ( expression : IrThrow , context : JsGenerationContext ) : JsStatement

{ <EOL> return expression . value . maybeOptimizeIntoSwitch ( context ) { JsThrow ( it ( ) ) } . withSource ( expression , context ) <EOL> }


override fun visitVariable ( declaration : IrVariable , context : JsGenerationContext ) : JsStatement

{ <EOL> val varName = context . getNameForValueDeclaration ( declaration ) <EOL> val value = declaration . initializer <EOL> if ( value is IrWhen ) { <EOL> val varRef = varName . makeRef ( ) <EOL> val transformer : ( ( ) -> JsStatement ) -> JsStatement = { <EOL> val expr = ( it ( ) as JsExpressionStatement ) . expression <EOL> JsBinaryOperation ( JsBinaryOperator . ASG , varRef , expr ) . makeStmt ( ) <EOL> } <EOL> SwitchOptimizer ( context , isExpression = true , transformer ) . tryOptimize ( value ) ? . let { <EOL> return JsBlock ( JsVars ( JsVars . JsVar ( varName ) ) , it ) . withSource ( declaration , context ) <EOL> } <EOL> } <EOL> val jsInitializer = value ? . accept ( IrElementToJsExpressionTransformer ( ) , context ) <EOL> val syntheticVariable = when ( declaration . origin ) { <EOL> IrDeclarationOrigin . IR_TEMPORARY_VARIABLE -> true <EOL> IrDeclarationOrigin . IR_TEMPORARY_VARIABLE_FOR_INLINED_PARAMETER -> true <EOL> IrDeclarationOrigin . IR_TEMPORARY_VARIABLE_FOR_INLINED_EXTENSION_RECEIVER -> true <EOL> ES6_DELEGATING_CONSTRUCTOR_CALL_REPLACEMENT -> true <EOL> else -> false <EOL> } <EOL> val variable = JsVars . JsVar ( varName , jsInitializer ) . apply { <EOL> withSource ( declaration , context , useNameOf = declaration ) <EOL> synthetic = syntheticVariable <EOL> } <EOL> return JsVars ( variable ) . apply { synthetic = syntheticVariable } <EOL> }


override fun visitDelegatingConstructorCall ( expression : IrDelegatingConstructorCall , context : JsGenerationContext ) : JsStatement

{ <EOL> if ( expression . symbol . owner . constructedClassType . isAny ( ) ) { <EOL> return JsEmpty <EOL> } <EOL> return expression . accept ( IrElementToJsExpressionTransformer ( ) , context ) . makeStmt ( ) <EOL> }


override fun visitCall ( expression : IrCall , data : JsGenerationContext ) : JsStatement

{ <EOL> if ( expression . symbol . isUnitInstanceFunction ( data . staticContext . backendContext ) ) { <EOL> return JsEmpty <EOL> } <EOL> if ( data . checkIfJsCode ( expression . symbol ) || data . checkIfHasAssociatedJsCode ( expression . symbol ) ) { <EOL> return JsCallTransformer ( expression , data ) . generateStatement ( ) <EOL> } <EOL> return translateCall ( expression , data , IrElementToJsExpressionTransformer ( ) ) . withSource ( expression , data ) . makeStmt ( ) <EOL> }


override fun visitInstanceInitializerCall ( expression : IrInstanceInitializerCall , context : JsGenerationContext ) : JsStatement

{ <EOL> return JsEmpty <EOL> }


override fun visitTry ( aTry : IrTry , context : JsGenerationContext ) : JsStatement

{ <EOL> val jsTryBlock = aTry . tryResult . accept ( this , context ) . asBlock ( ) <EOL> val jsCatch = aTry . catches . singleOrNull ( ) ? . let { <EOL> val name = context . getNameForValueDeclaration ( it . catchParameter ) <EOL> val jsCatchBlock = it . result . accept ( this , context ) <EOL> JsCatch ( emptyScope , name . ident , jsCatchBlock ) . withSource ( it , context ) <EOL> } <EOL> val jsFinallyBlock = aTry . finallyExpression ? . accept ( this , context ) ? . asBlock ( ) <EOL> return JsTry ( jsTryBlock , jsCatch , jsFinallyBlock ) . withSource ( aTry , context ) <EOL> }


override fun visitWhen ( expression : IrWhen , context : JsGenerationContext ) : JsStatement

{ <EOL> return SwitchOptimizer ( context ) . tryOptimize ( expression ) ? : expression . toJsNode ( this , context , :: JsIf ) ? : JsEmpty <EOL> }


override fun visitWhileLoop ( loop : IrWhileLoop , context : JsGenerationContext ) : JsStatement

{ <EOL> val label = context . getNameForLoop ( loop ) <EOL> val loopStatement = JsWhile ( loop . condition . accept ( IrElementToJsExpressionTransformer ( ) , context ) , loop . body ? . accept ( this , context ) ? : JsEmpty ) <EOL> return label ? . let { JsLabel ( it , loopStatement ) } ? : loopStatement <EOL> }


override fun visitDoWhileLoop ( loop : IrDoWhileLoop , context : JsGenerationContext ) : JsStatement

{ <EOL> val label = context . getNameForLoop ( loop ) <EOL> val loopStatement = <EOL> JsDoWhile ( loop . condition . accept ( IrElementToJsExpressionTransformer ( ) , context ) , loop . body ? . accept ( this , context ) ? : JsEmpty ) <EOL> return label ? . let { JsLabel ( it , loopStatement ) } ? : loopStatement <EOL> }


{ <EOL> isDisposed = true <EOL> }


= debugName


{ <EOL> foo1 { x -> x } <EOL> foo2 { x : Int , y : Int -> <EOL> val x = x <EOL> } <EOL> foo3 { ( x , y ) -> <EOL> val x = x <EOL> } <EOL> }


override fun computePackagePartsInfos ( packageFqName : FqName ) : List < PackagePartsCacheData >

= <EOL> packagePartProvider . findPackageParts ( packageFqName . asString ( ) ) . mapNotNull { partName -> <EOL> computePackagePartInfo ( packageFqName , partName ) <EOL> }


private fun computePackagePartInfo ( packageFqName : FqName , partName : String ) : PackagePartsCacheData ?

{ <EOL> if ( partName in KotlinBuiltins ) return null <EOL> val classId = ClassId . topLevel ( JvmClassName . byInternalName ( partName ) . fqNameForTopLevelClassMaybeWithDollars ) <EOL> if ( ! javaFacade . hasTopLevelClassOf ( classId ) ) return null <EOL> val ( kotlinClass , byteContent ) = <EOL> kotlinClassFinder . findKotlinClassOrContent ( classId , ownMetadataVersion ) as? KotlinClassFinder . Result . KotlinClass ? : return null <EOL> val facadeName = kotlinClass . classHeader . multifileClassName ? . takeIf { it . isNotEmpty ( ) } <EOL> val facadeFqName = facadeName ? . let { JvmClassName . byInternalName ( it ) . fqNameForTopLevelClassMaybeWithDollars } <EOL> val facadeBinaryClass = facadeFqName ? . let { <EOL> kotlinClassFinder . findKotlinClass ( ClassId . topLevel ( it ) , ownMetadataVersion ) <EOL> } <EOL> val moduleData = moduleDataProvider . getModuleData ( kotlinClass . containingLibrary . toPath ( ) ) ? : return null <EOL> val header = kotlinClass . classHeader <EOL> val data = header . data ? : header . incompatibleData ? : return null <EOL> val strings = header . strings ? : return null <EOL> val ( nameResolver , packageProto ) = parseProto ( kotlinClass ) { <EOL> JvmProtoBufUtil . readPackageDataFrom ( data , strings ) <EOL> } ? : return null <EOL> val source = JvmPackagePartSource ( kotlinClass , packageProto , nameResolver , kotlinClass . incompatibility , kotlinClass . isPreReleaseInvisible , kotlinClass . abiStability , ) <EOL> return PackagePartsCacheData ( packageProto , FirDeserializationContext . createForPackage ( packageFqName , packageProto , nameResolver , moduleData , JvmBinaryAnnotationDeserializer ( session , kotlinClass , kotlinClassFinder , byteContent ) , JavaAwareFlexibleTypeFactory , FirJvmConstDeserializer ( session , facadeBinaryClass ? : kotlinClass , BuiltInSerializerProtocol ) , source ) , ) <EOL> }


override fun createFlexibleType ( proto : ProtoBuf . Type , lowerBound : ConeSimpleKotlinType , upperBound : ConeSimpleKotlinType , ) : ConeFlexibleType

= when ( proto . hasExtension ( JvmProtoBuf . isRaw ) ) { <EOL> true -> ConeRawType . create ( lowerBound , upperBound ) <EOL> false -> ConeFlexibleType ( lowerBound , upperBound ) <EOL> }


override fun computePackageSetWithNonClassDeclarations ( ) : Set < String >

= packagePartProvider . computePackageSetWithNonClassDeclarations ( )


override fun knownTopLevelClassesInPackage ( packageFqName : FqName ) : Set < String > ?

= javaFacade . knownClassNamesInPackage ( packageFqName )


override fun extractClassMetadata ( classId : ClassId , parentContext : FirDeserializationContext ? ) : ClassMetadataFindResult ?

{ <EOL> if ( ! javaFacade . hasTopLevelClassOf ( classId ) ) return null <EOL> val result = kotlinClassFinder . findKotlinClassOrContent ( classId , ownMetadataVersion ) <EOL> if ( result !is KotlinClassFinder . Result . KotlinClass ) { <EOL> if ( parentContext != null || ( classId . isNestedClass && getClass ( classId . outermostClassId ) ? . fir !is FirJavaClass ) ) { <EOL> return null <EOL> } <EOL> val knownContent = ( result as? KotlinClassFinder . Result . ClassFileContent ) ? . content <EOL> val javaClass = javaFacade . findClass ( classId , knownContent ) ? : return null <EOL> return ClassMetadataFindResult . NoMetadata { symbol -> <EOL> javaFacade . convertJavaClassToFir ( symbol , classId . outerClassId ? . let ( :: getClass ) , javaClass ) <EOL> } <EOL> } <EOL> val kotlinClass = result . kotlinJvmBinaryClass <EOL> if ( kotlinClass . classHeader . kind != KotlinClassHeader . Kind . CLASS || kotlinClass . classId != classId ) return null <EOL> val data = kotlinClass . classHeader . data ? : kotlinClass . classHeader . incompatibleData ? : return null <EOL> val strings = kotlinClass . classHeader . strings ? : return null <EOL> val ( nameResolver , classProto ) = parseProto ( kotlinClass ) { <EOL> JvmProtoBufUtil . readClassDataFrom ( data , strings ) <EOL> } ? : return null <EOL> return ClassMetadataFindResult . Metadata ( nameResolver , classProto , JvmBinaryAnnotationDeserializer ( session , kotlinClass , kotlinClassFinder , result . byteContent ) , moduleDataProvider . getModuleData ( kotlinClass . containingLibrary ? . toPath ( ) ) , KotlinJvmBinarySourceElement ( kotlinClass , kotlinClass . incompatibility , kotlinClass . isPreReleaseInvisible , kotlinClass . abiStability , ) , classPostProcessor = { loadAnnotationsFromClassFile ( result , it ) } , JavaAwareFlexibleTypeFactory , ) <EOL> }


override fun isNewPlaceForBodyGeneration ( classProto : ProtoBuf . Class ) : Boolean

= <EOL> JvmFlags . IS_COMPILED_IN_JVM_DEFAULT_MODE . get ( classProto . getExtension ( JvmProtoBuf . jvmClassFlags ) )


override fun getPackage ( fqName : FqName ) : FqName ?

= <EOL> javaFacade . getPackage ( fqName )


private fun loadAnnotationsFromClassFile ( kotlinClass : KotlinClassFinder . Result . KotlinClass , symbol : FirRegularClassSymbol )

{ <EOL> val annotations = mutableListOf < FirAnnotation > ( ) <EOL> var hasPublishedApi = false <EOL> kotlinClass . kotlinJvmBinaryClass . loadClassAnnotations ( object : KotlinJvmBinaryClass . AnnotationVisitor { <EOL> override fun visitAnnotation ( classId : ClassId , source : SourceElement ) : KotlinJvmBinaryClass . AnnotationArgumentVisitor ? { <EOL> if ( classId == StandardClassIds . Annotations . PublishedApi ) { <EOL> hasPublishedApi = true <EOL> } <EOL> return annotationsLoader . loadAnnotationIfNotSpecial ( classId , annotations ) <EOL> } <EOL> override fun visitEnd ( ) { <EOL> } <EOL> } , kotlinClass . byteContent , ) <EOL> symbol . fir . run { <EOL> replaceAnnotations ( annotations . toMutableOrEmpty ( ) ) <EOL> replaceDeprecationsProvider ( symbol . fir . getDeprecationsProvider ( session ) ) <EOL> setLazyPublishedVisibility ( hasPublishedApi , null , session ) <EOL> } <EOL> }


private fun String ? . toPath ( ) : Path ?

{ <EOL> return this ? . let { Paths . get ( it ) . normalize ( ) } <EOL> }


private inline fun < T : Any > parseProto ( klass : KotlinJvmBinaryClass , block : ( ) -> T ) : T ?

= <EOL> try { <EOL> block ( ) <EOL> } catch ( e : Throwable ) { <EOL> if ( session . languageVersionSettings . getFlag ( AnalysisFlags . skipMetadataVersionCheck ) || klass . classHeader . metadataVersion . isCompatible ( ownMetadataVersion ) ) { <EOL> throw if ( e is InvalidProtocolBufferException ) <EOL> IllegalStateException ( "<STR_LIT>" , e ) <EOL> else e <EOL> } <EOL> null <EOL> }


fun up ( s : String , value : Int ) : Int

{ <EOL> global += s <EOL> return value <EOL> }


{ <EOL> var n : Int = <NUM_LIT:0> <EOL> for ( i in <NUM_LIT:3> .. <NUM_LIT:0> ) <EOL> n ++ <EOL> assertEquals ( <NUM_LIT:0> , n ) <EOL> for ( i in <NUM_LIT:0> .. <NUM_LIT:3> ) <EOL> n ++ <EOL> assertEquals ( <NUM_LIT:4> , n ) <EOL> for ( i in up ( "<STR_LIT:A>" , <NUM_LIT:0> ) .. up ( "<STR_LIT:B>" , <NUM_LIT:5> ) ) { <EOL> } <EOL> assertEquals ( "<STR_LIT>" , global ) <EOL> global = "<STR_LIT>" <EOL> for ( i in try { up ( "<STR_LIT:A>" , <NUM_LIT:0> ) } finally { } .. up ( "<STR_LIT:B>" , <NUM_LIT:5> ) ) { <EOL> } <EOL> assertEquals ( "<STR_LIT>" , global ) <EOL> global = "<STR_LIT>" <EOL> for ( i in up ( "<STR_LIT:A>" , <NUM_LIT:0> ) .. try { up ( "<STR_LIT:B>" , <NUM_LIT:5> ) } finally { } ) { <EOL> } <EOL> assertEquals ( "<STR_LIT>" , global ) <EOL> global = "<STR_LIT>" <EOL> for ( i in try { up ( "<STR_LIT:A>" , <NUM_LIT:0> ) } finally { } .. try { up ( "<STR_LIT:B>" , <NUM_LIT:5> ) } finally { } ) { <EOL> } <EOL> assertEquals ( "<STR_LIT>" , global ) <EOL> var sLong = <NUM_LIT:0L> <EOL> for ( i in <NUM_LIT:0L> .. <NUM_LIT> ) <EOL> sLong += i <EOL> assertEquals ( <NUM_LIT> , sLong ) <EOL> global = "<STR_LIT>" <EOL> for ( s in "<STR_LIT>" ) <EOL> global += s <EOL> assertEquals ( "<STR_LIT>" , global ) <EOL> for ( s in ( ( "<STR_LIT>" ) ) ) <EOL> global += s <EOL> assertEquals ( "<STR_LIT>" , global ) <EOL> for ( s in ( ( "<STR_LIT>" ) ) ) <EOL> global += s <EOL> assertEquals ( "<STR_LIT>" , global ) <EOL> return "<STR_LIT:OK>" <EOL> }


= json . decodeFromString ( Impl . serializer ( ) , implString )


= json . decodeFromString ( serializer , polyString )


@ Benchmark <EOL> fun polyChildDecode ( )

= json . decodeFromString ( wrapperSerializer , wrapperString )


@ Benchmark <EOL> fun polyChildEncode ( )

= json . encodeToString ( wrapperSerializer , wrapper )


fun compareJarsInternal ( oldSnapshot : AbiSnapshot , newSnapshot : AbiSnapshot , caches : IncrementalCacheCommon )

= diffCache . computeIfAbsent ( Pair ( oldSnapshot , newSnapshot ) ) { ( snapshot , actual ) -> doCompute ( snapshot , actual , caches , emptyList ( ) ) }


fun inScope ( fqName : FqName , scopes : Collection < String > )

= scopes . any { scope -> fqName . toString ( ) . startsWith ( scope ) }


fun doCompute ( snapshot : AbiSnapshot , actual : AbiSnapshot , caches : IncrementalCacheCommon , scopes : Collection < String > ) : DirtyData

{ <EOL> val dirtyFqNames = mutableListOf < FqName > ( ) <EOL> val dirtyLookupSymbols = mutableListOf < LookupSymbol > ( ) <EOL> for ( ( fqName , protoData ) in snapshot . protos ) { <EOL> if ( ! inScope ( fqName , scopes ) ) continue <EOL> val newProtoData = actual . protos [ fqName ] <EOL> if ( newProtoData == null ) { <EOL> val ( fqNames , symbols ) = addProtoInfo ( protoData , fqName ) <EOL> dirtyFqNames . addAll ( fqNames ) <EOL> dirtyLookupSymbols . addAll ( symbols ) <EOL> } else { <EOL> if ( protoData is ClassProtoData && newProtoData is ClassProtoData ) { <EOL> ProtoCompareGenerated ( protoData . nameResolver , newProtoData . nameResolver , protoData . proto . typeTable , newProtoData . proto . typeTable ) <EOL> val diff = DifferenceCalculatorForClass ( protoData , newProtoData ) . difference ( ) <EOL> if ( diff . isClassAffected ) { <EOL> dirtyFqNames . add ( fqName ) <EOL> assert ( ! fqName . isRoot ) { "<STR_LIT>" } <EOL> val scope = fqName . parent ( ) . asString ( ) <EOL> val name = fqName . shortName ( ) . identifier <EOL> dirtyLookupSymbols . add ( LookupSymbol ( name , scope ) ) <EOL> } <EOL> for ( member in diff . changedMembersNames ) { <EOL> val subtypeFqNames = withSubtypes ( fqName , listOf ( caches ) ) <EOL> dirtyFqNames . addAll ( subtypeFqNames ) <EOL> for ( subtypeFqName in subtypeFqNames ) { <EOL> dirtyLookupSymbols . add ( LookupSymbol ( member , subtypeFqName . asString ( ) ) ) <EOL> dirtyLookupSymbols . add ( LookupSymbol ( SAM_LOOKUP_NAME . asString ( ) , subtypeFqName . asString ( ) ) ) <EOL> } <EOL> } <EOL> } else if ( protoData is PackagePartProtoData && newProtoData is PackagePartProtoData ) { <EOL> val diff = DifferenceCalculatorForPackageFacade ( protoData , newProtoData ) . difference ( ) <EOL> for ( member in diff . changedMembersNames ) { <EOL> dirtyLookupSymbols . add ( LookupSymbol ( member , fqName . asString ( ) ) ) <EOL> } <EOL> } else { <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> DirtyData ( dirtyLookupSymbols , dirtyFqNames ) <EOL> val oldFqNames = snapshot . protos . keys <EOL> dirtyFqNames . addAll ( actual . protos . keys . filter { ! oldFqNames . contains ( it ) } ) <EOL> return DirtyData ( dirtyLookupSymbols , dirtyFqNames ) <EOL> }


private fun addProtoInfo ( protoData : ProtoData , fqName : FqName , ) : Pair < List < FqName > , List < LookupSymbol > >

{ <EOL> val fqNames = ArrayList < FqName > ( ) <EOL> val symbols = ArrayList < LookupSymbol > ( ) <EOL> when ( protoData ) { <EOL> is ClassProtoData -> { <EOL> fqNames . add ( fqName ) <EOL> symbols . addAll ( protoData . getNonPrivateMembers ( ) . map { LookupSymbol ( it , fqName . asString ( ) ) } ) <EOL> } <EOL> is PackagePartProtoData -> { <EOL> symbols . addAll ( protoData . proto . functionOrBuilderList . filterNot { Flags . VISIBILITY . get ( it . flags ) == PRIVATE } . map { LookupSymbol ( protoData . nameResolver . getString ( it . name ) , fqName . asString ( ) ) } . toSet ( ) ) <EOL> } <EOL> } <EOL> return Pair ( fqNames , symbols ) <EOL> }


@ BeforeClass <EOL> @ JvmStatic <EOL> fun setUpClass ( )

{ <EOL> connection = DriverManager . getConnection ( URL , USER_NAME , PASSWORD ) <EOL> connection . createStatement ( ) . use { st -> <EOL> val dropDatabaseQuery = "<STR_LIT>" <EOL> st . executeUpdate ( dropDatabaseQuery ) <EOL> val createDatabaseQuery = "<STR_LIT>" <EOL> st . executeUpdate ( createDatabaseQuery ) <EOL> val useDatabaseQuery = "<STR_LIT>" <EOL> st . executeUpdate ( useDatabaseQuery ) <EOL> } <EOL> connection . createStatement ( ) . use { st -> st . execute ( "<STR_LIT>" ) } <EOL> connection . createStatement ( ) . use { st -> st . execute ( "<STR_LIT>" ) } <EOL> @ Language ( "<STR_LIT>" ) <EOL> val createTableQuery = """<STR_LIT>""" <EOL> connection . createStatement ( ) . execute ( createTableQuery . trimIndent ( ) ) <EOL> @ Language ( "<STR_LIT>" ) <EOL> val createTableQuery2 = """<STR_LIT>""" <EOL> connection . createStatement ( ) . execute ( createTableQuery2 . trimIndent ( ) ) <EOL> @ Language ( "<STR_LIT>" ) <EOL> val insertData1 = """<STR_LIT>""" . trimIndent ( ) <EOL> @ Language ( "<STR_LIT>" ) <EOL> val insertData2 = """<STR_LIT>""" . trimIndent ( ) <EOL> connection . prepareStatement ( insertData1 ) . use { st -> <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:3> ) { <EOL> st . setBoolean ( <NUM_LIT:1> , true ) <EOL> st . setByte ( <NUM_LIT:2> , i . toByte ( ) ) <EOL> st . setShort ( <NUM_LIT:3> , ( i * <NUM_LIT:10> ) . toShort ( ) ) <EOL> st . setInt ( <NUM_LIT:4> , i * <NUM_LIT:100> ) <EOL> st . setInt ( <NUM_LIT:5> , i * <NUM_LIT:100> ) <EOL> st . setInt ( <NUM_LIT:6> , i * <NUM_LIT:100> ) <EOL> st . setInt ( <NUM_LIT:7> , i * <NUM_LIT:100> ) <EOL> st . setInt ( <NUM_LIT:8> , i * <NUM_LIT:100> ) <EOL> st . setInt ( <NUM_LIT:9> , i * <NUM_LIT:100> ) <EOL> st . setFloat ( <NUM_LIT:10> , i * <NUM_LIT> ) <EOL> st . setDouble ( <NUM_LIT:11> , i * <NUM_LIT> ) <EOL> st . setBigDecimal ( <NUM_LIT:12> , BigDecimal ( i * <NUM_LIT:10> ) ) <EOL> st . setDate ( <NUM_LIT> , java . sql . Date ( System . currentTimeMillis ( ) ) ) <EOL> st . setTimestamp ( <NUM_LIT> , java . sql . Timestamp ( System . currentTimeMillis ( ) ) ) <EOL> st . setTimestamp ( <NUM_LIT> , java . sql . Timestamp ( System . currentTimeMillis ( ) ) ) <EOL> st . setTime ( <NUM_LIT:16> , java . sql . Time ( System . currentTimeMillis ( ) ) ) <EOL> st . setInt ( <NUM_LIT> , <NUM_LIT> ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setBytes ( <NUM_LIT:20> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT:23> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT:31> , "<STR_LIT>" ) <EOL> st . executeUpdate ( ) <EOL> } <EOL> } <EOL> connection . prepareStatement ( insertData2 ) . use { st -> <EOL> for ( i in <NUM_LIT:1> .. <NUM_LIT:3> ) { <EOL> st . setBoolean ( <NUM_LIT:1> , false ) <EOL> st . setByte ( <NUM_LIT:2> , ( i * <NUM_LIT:2> ) . toByte ( ) ) <EOL> st . setShort ( <NUM_LIT:3> , ( i * <NUM_LIT:20> ) . toShort ( ) ) <EOL> st . setInt ( <NUM_LIT:4> , i * <NUM_LIT> ) <EOL> st . setInt ( <NUM_LIT:5> , i * <NUM_LIT> ) <EOL> st . setInt ( <NUM_LIT:6> , i * <NUM_LIT> ) <EOL> st . setInt ( <NUM_LIT:7> , i * <NUM_LIT> ) <EOL> st . setInt ( <NUM_LIT:8> , i * <NUM_LIT> ) <EOL> st . setInt ( <NUM_LIT:9> , i * <NUM_LIT> ) <EOL> st . setFloat ( <NUM_LIT:10> , i * <NUM_LIT> ) <EOL> st . setDouble ( <NUM_LIT:11> , i * <NUM_LIT> ) <EOL> st . setBigDecimal ( <NUM_LIT:12> , BigDecimal ( i * <NUM_LIT:20> ) ) <EOL> st . setDate ( <NUM_LIT> , java . sql . Date ( System . currentTimeMillis ( ) ) ) <EOL> st . setTimestamp ( <NUM_LIT> , java . sql . Timestamp ( System . currentTimeMillis ( ) ) ) <EOL> st . setTimestamp ( <NUM_LIT> , java . sql . Timestamp ( System . currentTimeMillis ( ) ) ) <EOL> st . setTime ( <NUM_LIT:16> , java . sql . Time ( System . currentTimeMillis ( ) ) ) <EOL> st . setInt ( <NUM_LIT> , <NUM_LIT> ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setBytes ( <NUM_LIT:20> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT:23> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setBytes ( <NUM_LIT> , "<STR_LIT>" . toByteArray ( ) ) <EOL> st . setString ( <NUM_LIT> , null ) <EOL> st . setString ( <NUM_LIT> , null ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT> , "<STR_LIT>" ) <EOL> st . setString ( <NUM_LIT:31> , "<STR_LIT>" ) <EOL> st . executeUpdate ( ) <EOL> } <EOL> } <EOL> }


@ AfterClass <EOL> @ JvmStatic <EOL> fun tearDownClass ( )

{ <EOL> try { <EOL> connection . createStatement ( ) . use { st -> st . execute ( "<STR_LIT>" ) } <EOL> connection . createStatement ( ) . use { st -> st . execute ( "<STR_LIT>" ) } <EOL> connection . createStatement ( ) . use { st -> st . execute ( "<STR_LIT>" ) } <EOL> connection . close ( ) <EOL> } catch ( e : SQLException ) { <EOL> e . printStackTrace ( ) <EOL> } <EOL> }


@ Test <EOL> fun `basic test for reading sql tables` ( )

{ <EOL> val df1 = DataFrame . readSqlTable ( connection , "<STR_LIT>" ) . cast < Table1MySql > ( ) <EOL> val result = df1 . filter { it [ Table1MySql :: id ] == <NUM_LIT:1> } <EOL> result [ <NUM_LIT:0> ] [ <NUM_LIT> ] shouldBe "<STR_LIT>" <EOL> val schema = DataFrame . getSchemaForSqlTable ( connection , "<STR_LIT>" ) <EOL> schema . columns [ "<STR_LIT:id>" ] ! ! . type shouldBe typeOf < Int > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < String > ( ) <EOL> val df2 = DataFrame . readSqlTable ( connection , "<STR_LIT>" ) . cast < Table2MySql > ( ) <EOL> val result2 = df2 . filter { it [ Table2MySql :: id ] == <NUM_LIT:1> } <EOL> result2 [ <NUM_LIT:0> ] [ <NUM_LIT> ] shouldBe null <EOL> val schema2 = DataFrame . getSchemaForSqlTable ( connection , "<STR_LIT>" ) <EOL> schema2 . columns [ "<STR_LIT:id>" ] ! ! . type shouldBe typeOf < Int > ( ) <EOL> schema2 . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < String ? > ( ) <EOL> }


@ Test <EOL> fun `read from sql query` ( )

{ <EOL> @ Language ( "<STR_LIT>" ) <EOL> val sqlQuery = """<STR_LIT>""" . trimIndent ( ) <EOL> val df = DataFrame . readSqlQuery ( connection , sqlQuery = sqlQuery ) . cast < Table3MySql > ( ) <EOL> val result = df . filter { it [ Table3MySql :: id ] == <NUM_LIT:1> } <EOL> result [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] shouldBe "<STR_LIT>" <EOL> val schema = DataFrame . getSchemaForSqlQuery ( connection , sqlQuery = sqlQuery ) <EOL> schema . columns [ "<STR_LIT:id>" ] ! ! . type shouldBe typeOf < Int > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Char > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Char ? > ( ) <EOL> }


@ Test <EOL> fun `read from all tables` ( )

{ <EOL> val dataframes = DataFrame . readAllSqlTables ( connection ) <EOL> val table1Df = dataframes [ <NUM_LIT:0> ] . cast < Table1MySql > ( ) <EOL> table1Df . rowsCount ( ) shouldBe <NUM_LIT:3> <EOL> table1Df . filter { it [ Table1MySql :: integerCol ] > <NUM_LIT:100> } . rowsCount ( ) shouldBe <NUM_LIT:2> <EOL> table1Df [ <NUM_LIT:0> ] [ <NUM_LIT:11> ] shouldBe <NUM_LIT> <EOL> table1Df [ <NUM_LIT:0> ] [ <NUM_LIT> ] shouldBe "<STR_LIT>" <EOL> val table2Df = dataframes [ <NUM_LIT:1> ] . cast < Table2MySql > ( ) <EOL> table2Df . rowsCount ( ) shouldBe <NUM_LIT:3> <EOL> table2Df . filter { it [ Table2MySql :: integerCol ] != null && it [ Table2MySql :: integerCol ] ! ! > <NUM_LIT> } <EOL> . rowsCount ( ) shouldBe <NUM_LIT:1> <EOL> table2Df [ <NUM_LIT:0> ] [ <NUM_LIT:11> ] shouldBe <NUM_LIT> <EOL> table2Df [ <NUM_LIT:0> ] [ <NUM_LIT> ] shouldBe null <EOL> }


@ Test <EOL> fun `reading numeric types` ( )

{ <EOL> val df1 = DataFrame . readSqlTable ( connection , "<STR_LIT>" ) . cast < Table1MySql > ( ) <EOL> val result = df1 . select ( "<STR_LIT>" ) . add ( "<STR_LIT>" ) { it [ Table1MySql :: tinyintCol ] } <EOL> result [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT:1> . toByte ( ) <EOL> val result1 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: smallintCol ] } <EOL> result1 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT:10> . toShort ( ) <EOL> val result2 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: mediumintCol ] } <EOL> result2 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT:100> <EOL> val result3 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: mediumintUnsignedCol ] } <EOL> result3 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT:100> <EOL> val result4 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: integerUnsignedCol ] } <EOL> result4 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT> <EOL> val result5 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: bigintCol ] } <EOL> result5 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT:100> <EOL> val result6 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: floatCol ] } <EOL> result6 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT> <EOL> val result7 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: doubleCol ] } <EOL> result7 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe <NUM_LIT> <EOL> val result8 = df1 . select ( "<STR_LIT>" ) <EOL> . add ( "<STR_LIT>" ) { it [ Table1MySql :: decimalCol ] } <EOL> result8 [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] shouldBe BigDecimal ( "<STR_LIT:10>" ) <EOL> val schema = DataFrame . getSchemaForSqlTable ( connection , "<STR_LIT>" ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Int > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Int > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Int > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Int > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Long > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Long > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Float > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < Double > ( ) <EOL> schema . columns [ "<STR_LIT>" ] ! ! . type shouldBe typeOf < BigDecimal > ( ) <EOL> }


= suspendCoroutine < Unit > { c -> <EOL> i ++ <EOL> proceed = { c . resume ( Unit ) } <EOL> }


{ <EOL> suspend fun local ( ) { <EOL> suspendHere ( ) <EOL> suspendHere ( ) <EOL> suspendHere ( ) <EOL> suspendHere ( ) <EOL> suspendHere ( ) <EOL> } <EOL> local ( ) <EOL> local ( ) <EOL> }


{ <EOL> val continuation = object : Continuation < Unit > { <EOL> override val context : CoroutineContext <EOL> get ( ) = EmptyCoroutineContext <EOL> override fun resumeWith ( value : Result < Unit > ) { <EOL> value . getOrThrow ( ) <EOL> proceed = { <EOL> result = "<STR_LIT:OK>" <EOL> finished = true <EOL> } <EOL> } <EOL> } <EOL> c . startCoroutine ( continuation ) <EOL> }


{ <EOL> builder { <EOL> callLocal ( ) <EOL> } <EOL> for ( counter in <NUM_LIT:0> until <NUM_LIT:10> ) { <EOL> if ( i != counter + <NUM_LIT:1> ) return "<STR_LIT>" <EOL> proceed ( ) <EOL> } <EOL> if ( i != <NUM_LIT:10> ) return "<STR_LIT>" <EOL> if ( finished ) return "<STR_LIT>" <EOL> proceed ( ) <EOL> if ( ! finished ) return "<STR_LIT>" <EOL> return result <EOL> }


fun < S : T > takeFoo ( foo : Foo < in S > )


fun < K : Out < L > , L : N , N : Number > main ( )

{ <EOL> val foo = Foo < K > ( ) <EOL> Bar < Out < Int > > ( ) . takeFoo ( foo ) <EOL> }


override fun handleContentChange ( element : KtStringTemplateExpression , range : TextRange , newContent : String ) : KtStringTemplateExpression ?

{ <EOL> val node = element . node <EOL> val oldText = node . text <EOL> fun wrapAsInOld ( content : String ) = oldText . substring ( <NUM_LIT:0> , range . startOffset ) + content + oldText . substring ( range . endOffset ) <EOL> fun makeKtExpressionFromText ( text : String ) : KtExpression { <EOL> val ktExpression = KtPsiFactory ( element . project ) . createExpression ( text ) <EOL> if ( ktExpression !is KtStringTemplateExpression ) { <EOL> LOG . error ( "<STR_LIT>" ) <EOL> } <EOL> return ktExpression <EOL> } <EOL> val newContentPreprocessed : String = <EOL> if ( element . isSingleQuoted ( ) ) { <EOL> val expressionFromText = makeKtExpressionFromText ( "<STR_LIT>" ) <EOL> if ( expressionFromText is KtStringTemplateExpression ) { <EOL> expressionFromText . entries . joinToString ( "<STR_LIT>" ) { entry -> <EOL> when ( entry ) { <EOL> is KtStringTemplateEntryWithExpression -> entry . text <EOL> else -> StringUtil . escapeStringCharacters ( entry . text ) <EOL> } <EOL> } <EOL> } else newContent <EOL> } else newContent <EOL> val newKtExpression = makeKtExpressionFromText ( wrapAsInOld ( newContentPreprocessed ) ) <EOL> node . replaceAllChildrenToChildrenOf ( newKtExpression . node ) <EOL> return node . getPsi ( KtStringTemplateExpression :: class . java ) <EOL> }


override fun getRangeInElement ( element : KtStringTemplateExpression ) : TextRange

{ <EOL> return element . getContentRange ( ) <EOL> }


public fun ColumnSet < * > . colsOfKind ( kind : ColumnKind , vararg others : ColumnKind , filter : ColumnFilter < * > = { true } , ) : TransformableColumnSet < * >

= <EOL> columnsOfKindInternal ( kinds = headPlusArray ( kind , others ) . toSet ( ) , filter = filter )

/**
 * @include [CommonColsOfKindDocs]
 * @set [CommonColsOfKindDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { `[cols][ColumnsSelectionDsl.cols]` { it.`[name][ColumnReference.name]`.`[startsWith][String.startsWith]`("my") }.`[colsOfKind][ColumnSet.colsOfKind]`(`[Value][ColumnKind.Value]`, `[Frame][ColumnKind.Frame]`) }`
 *
 * `// NOTE: This can be shortened to just:`
 *
 * `df.`[select][DataFrame.select]` { `[colsOfKind][ColumnsSelectionDsl.colsOfKind]`(`[Value][ColumnKind.Value]`, `[Frame][ColumnKind.Frame]`) { it.`[name][ColumnReference.name]`.`[startsWith][String.startsWith]`("my") } }`
 */


public fun ColumnsSelectionDsl < * > . colsOfKind ( kind : ColumnKind , vararg others : ColumnKind , filter : ColumnFilter < * > = { true } , ) : TransformableColumnSet < * >

= <EOL> asSingleColumn ( ) . columnsOfKindInternal ( kinds = headPlusArray ( kind , others ) . toSet ( ) , filter = filter )

/**
 * @include [CommonColsOfKindDocs]
 * @set [CommonColsOfKindDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { `[colsOfKind][ColumnsSelectionDsl.colsOfKind]`(`[Value][ColumnKind.Value]`, `[Frame][ColumnKind.Frame]`) { it.`[name][ColumnReference.name]`.`[startsWith][String.startsWith]`("my") } }`
 */


public fun SingleColumn < DataRow < * > > . colsOfKind ( kind : ColumnKind , vararg others : ColumnKind , filter : ColumnFilter < * > = { true } , ) : TransformableColumnSet < * >

= <EOL> this . ensureIsColumnGroup ( ) . columnsOfKindInternal ( kinds = headPlusArray ( kind , others ) . toSet ( ) , filter = filter )

/**
 * @include [CommonColsOfKindDocs]
 * @set [CommonColsOfKindDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { myColumnGroup.`[colsOfKind][SingleColumn.colsOfKind]`(`[Value][ColumnKind.Value]`, `[Frame][ColumnKind.Frame]`) }`
 */


public fun String . colsOfKind ( kind : ColumnKind , vararg others : ColumnKind , filter : ColumnFilter < * > = { true } , ) : TransformableColumnSet < * >

= <EOL> columnGroup ( this ) . colsOfKind ( kind , * others , filter = filter )

/**
 * @include [CommonColsOfKindDocs]
 * @set [CommonColsOfKindDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { "myColumnGroup".`[colsOfKind][SingleColumn.colsOfKind]`(`[Value][ColumnKind.Value]`, `[Frame][ColumnKind.Frame]`) }`
 */


public fun KProperty < * > . colsOfKind ( kind : ColumnKind , vararg others : ColumnKind , filter : ColumnFilter < * > = { true } , ) : TransformableColumnSet < * >

/**
 * @include [CommonColsOfKindDocs]
 * @set [CommonColsOfKindDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { Type::myColumnGroup.`[colsOfKind][KProperty.colsOfKind]`(`[Value][ColumnKind.Value]`, `[Frame][ColumnKind.Frame]`) }`
 */


public fun ColumnPath . colsOfKind ( kind : ColumnKind , vararg others : ColumnKind , filter : ColumnFilter < * > = { true } , ) : TransformableColumnSet < * >

/**
 * @include [CommonColsOfKindDocs]
 * @set [CommonColsOfKindDocs.ExampleArg]
 *
 * `df.`[select][DataFrame.select]` { "pathTo"["myColumnGroup"].`[colsOfKind][ColumnPath.colsOfKind]`(`[Value][ColumnKind.Value]`, `[Frame][ColumnKind.Frame]`) }`
 */


internal fun ColumnsResolver < * > . columnsOfKindInternal ( kinds : Set < ColumnKind > , filter : ColumnFilter < * > , ) : TransformableColumnSet < * >

= colsInternal { <EOL> it . kind ( ) in kinds && filter ( it ) <EOL> }

/**
 * Returns a TransformableColumnSet containing the columns of given kind(s) that satisfy the given filter.
 *
 * @param filter The filter function to apply on each column. Must accept a ColumnWithPath object and return a Boolean.
 * @return A [TransformableColumnSet] containing the columns of given kinds that satisfy the filter.
 */


{ <EOL> when ( dir ) { <EOL> Direction . NORTH -> return <NUM_LIT:1> <EOL> Direction . SOUTH -> return <NUM_LIT:2> <EOL> Direction . WEST -> return <NUM_LIT:3> <EOL> Direction . EAST -> return <NUM_LIT:4> <EOL> } <EOL> }


@ OptIn ( DokkaPluginApiPreview :: class ) <EOL> override fun pluginApiPreviewAcknowledgement ( ) : PluginApiPreviewAcknowledgement

= <EOL> PluginApiPreviewAcknowledgement


@ Test <EOL> fun canCreateALazyScheme ( )

{ <EOL> val scheme = schemeOf ( "<STR_LIT>" ) <EOL> val lazyScheme = LazyScheme ( scheme ) <EOL> val schemeCopy = lazyScheme . toScheme ( ) <EOL> assertEquals ( scheme , schemeCopy ) <EOL> }


@ Test <EOL> fun canCreateALazySchemeWithOpenParameters ( )


@ Test <EOL> fun canCreateALazySchemeWithAnonymousParameters ( )


@ Test <EOL> fun canUpdateLazySchemeThroughBindings ( )

{ <EOL> val lazyScheme = LazyScheme ( schemeOf ( "<STR_LIT>" ) ) <EOL> val bindings = lazyScheme . bindings <EOL> bindings . unify ( lazyScheme . target , lazyScheme . parameters . first ( ) . target ) <EOL> assertEquals ( schemeOf ( "<STR_LIT>" ) , lazyScheme . toScheme ( ) ) <EOL> }


{ <EOL> val lazyScheme = LazyScheme ( schemeOf ( "<STR_LIT>" ) ) <EOL> val bindings = lazyScheme . bindings <EOL> val a = bindings . closed ( "<STR_LIT:a>" ) <EOL> val b = bindings . closed ( "<STR_LIT:b>" ) <EOL> val c = bindings . closed ( "<STR_LIT:c>" ) <EOL> bindings . unify ( lazyScheme . target , a ) <EOL> bindings . unify ( lazyScheme . parameters [ <NUM_LIT:0> ] . target , b ) <EOL> bindings . unify ( lazyScheme . parameters [ <NUM_LIT:1> ] . target , c ) <EOL> assertEquals ( schemeOf ( "<STR_LIT>" ) , lazyScheme . toScheme ( ) ) <EOL> }


@ Test <EOL> fun canCreateAnyParameterScheme ( )

{ <EOL> val lazyScheme = LazyScheme ( schemeOf ( "<STR_LIT>" ) ) <EOL> assertTrue ( lazyScheme . anyParameters ) <EOL> assertTrue ( lazyScheme . parameters . isEmpty ( ) ) <EOL> }


internal fun schemeOf ( text : String ) : Scheme

{ <EOL> val eos = '<CHAR_LIT>' <EOL> var current = <NUM_LIT:0> <EOL> fun skipWhiteSpace ( ) { <EOL> while ( current < text . length ) { <EOL> when ( text [ current ] ) { <EOL> '<CHAR_LIT:U+0020>' , '<CHAR_LIT>' , '<CHAR_LIT:\n>' , '<CHAR_LIT:\r>' -> { <EOL> current ++ <EOL> continue <EOL> } <EOL> } <EOL> break <EOL> } <EOL> } <EOL> fun expect ( c : Char ) { <EOL> if ( c == eos ) return <EOL> if ( current < text . length && text [ current ] != c ) error ( "<STR_LIT>" ) <EOL> current ++ <EOL> skipWhiteSpace ( ) <EOL> } <EOL> fun isChar ( c : Char ) = <EOL> if ( current < text . length && c == text [ current ] ) { <EOL> current ++ <EOL> true <EOL> } else false <EOL> fun expectToken ( ) : String = buildString { <EOL> var charSeen = false <EOL> while ( current < text . length ) { <EOL> val ch = text [ current ] <EOL> if ( ( ch in '<CHAR_LIT:a>' .. '<CHAR_LIT:z>' ) || ( ch in '<CHAR_LIT:A>' .. '<CHAR_LIT:Z>' ) ) { <EOL> append ( ch ) <EOL> current ++ <EOL> charSeen = true <EOL> continue <EOL> } <EOL> break <EOL> } <EOL> if ( ! charSeen ) error ( "<STR_LIT>" ) <EOL> skipWhiteSpace ( ) <EOL> } <EOL> fun expectNumber ( ) : Int { <EOL> var numberSeen = false <EOL> var result = <NUM_LIT:0> <EOL> while ( current < text . length ) { <EOL> val ch = text [ current ] <EOL> if ( ch in '<CHAR_LIT:0>' .. '<CHAR_LIT:9>' ) { <EOL> result = result * <NUM_LIT:10> + ( ch - '<CHAR_LIT:0>' ) <EOL> current ++ <EOL> numberSeen = true <EOL> continue <EOL> } <EOL> break <EOL> } <EOL> if ( ! numberSeen ) error ( "<STR_LIT>" ) <EOL> skipWhiteSpace ( ) <EOL> return result <EOL> } <EOL> fun < T > delimited ( start : Char , end : Char , block : ( ) -> T ) : T { <EOL> skipWhiteSpace ( ) <EOL> expect ( start ) <EOL> return block ( ) . also { expect ( end ) } <EOL> } <EOL> fun < T > optional ( start : Char , end : Char = '<CHAR_LIT>' , block : ( ) -> T ) : T ? = run { <EOL> skipWhiteSpace ( ) <EOL> if ( text [ current ] == start ) { <EOL> delimited ( start , end , block ) <EOL> } else null <EOL> } <EOL> fun isVariableStart ( ) = current < text . length && when ( text [ current ] ) { <EOL> '<CHAR_LIT:0>' , '<CHAR_LIT:1>' , '<CHAR_LIT:2>' , '<CHAR_LIT:3>' , '<CHAR_LIT:4>' , '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT:9>' , '<CHAR_LIT:_>' , '<CHAR_LIT:\\>' -> true <EOL> else -> false <EOL> } <EOL> fun item ( ) : Item = if ( isVariableStart ( ) ) { <EOL> if ( text [ current ] == '<CHAR_LIT:\\>' ) expect ( '<CHAR_LIT:\\>' ) <EOL> if ( text [ current ] == '<CHAR_LIT:_>' ) { <EOL> expect ( '<CHAR_LIT:_>' ) <EOL> Open ( - <NUM_LIT:1> ) <EOL> } else { <EOL> Open ( expectNumber ( ) ) <EOL> } <EOL> } else Token ( expectToken ( ) ) <EOL> fun < T > list ( continueBlock : ( first : Boolean ) -> Boolean , block : ( ) -> T ) : List < T > = <EOL> if ( continueBlock ( true ) ) { <EOL> skipWhiteSpace ( ) <EOL> val result = mutableListOf < T > ( ) <EOL> while ( true ) { <EOL> result . add ( block ( ) ) <EOL> if ( ! continueBlock ( false ) ) break <EOL> skipWhiteSpace ( ) <EOL> } <EOL> result <EOL> } else emptyList ( ) <EOL> fun scheme ( ) : Scheme = delimited ( '<CHAR_LIT>' , '<CHAR_LIT>' ) { <EOL> val target = item ( ) <EOL> val anyParameters = isChar ( '<CHAR_LIT:*>' ) <EOL> val parameters = if ( anyParameters ) emptyList ( ) else list ( { <EOL> ( text [ current ] == '<CHAR_LIT:U+002C>' ) . also { if ( it ) expect ( '<CHAR_LIT:U+002C>' ) } <EOL> } ) { scheme ( ) } <EOL> val result = optional ( '<CHAR_LIT::>' ) { scheme ( ) } <EOL> Scheme ( target , parameters , result , anyParameters ) <EOL> } <EOL> return scheme ( ) <EOL> }


= get ( )


= "<STR_LIT:OK>"


{ <EOL> return Impl ( ) ( ) <EOL> }


private fun getCompilationResults ( tasksPaths : Iterable < String > , success : Boolean ) : String

{ <EOL> val status = success && tasksPaths . all { timeListener . tasksTimes . containsKey ( it ) } <EOL> val time = tasksPaths . map { timeListener . getTime ( it ) } . sum ( ) <EOL> return "<STR_LIT>" <EOL> }


private fun getAllExecutedTasks ( compilation : KotlinCompilation < * > ) : List < Task >

{ <EOL> val tasks = mutableListOf ( compilation . compileTaskProvider . get ( ) as Task ) <EOL> compilation . associatedCompilations . toList ( ) . forEach { <EOL> tasks += getAllExecutedTasks ( it ) <EOL> } <EOL> return tasks <EOL> }


private fun folderSize ( directory : File ) : Long

{ <EOL> var length : Long = <NUM_LIT:0> <EOL> directory . listFiles ( ) ? . forEach { <EOL> length += if ( it . isFile ) it . length ( ) else folderSize ( it ) <EOL> } <EOL> return length <EOL> }


private fun compilerFlagsFromBinary ( ) : List < String >

{ <EOL> val result = mutableListOf < String > ( ) <EOL> if ( binary . buildType . optimized ) { <EOL> result . add ( "<STR_LIT>" ) <EOL> } <EOL> if ( binary . buildType . debuggable ) { <EOL> result . add ( "<STR_LIT>" ) <EOL> } <EOL> result . addAll ( binary . freeCompilerArgs ) <EOL> return result <EOL> }


private fun getPerformanceCompilerOptions ( )

= <EOL> ( compilerFlagsFromBinary ( ) + binary . linkTask . toolOptions . freeCompilerArgs . get ( ) ) <EOL> . filter { it in listOf ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) } . map { "<STR_LIT>" }


{ <EOL> val compileTasks = if ( settings . includeAssociatedTasks ) <EOL> getAllExecutedTasks ( binary . compilation ) <EOL> else <EOL> listOf ( binary . compilation . compileTaskProvider . get ( ) ) <EOL> val allExecutedTasks = listOf ( binary . linkTask ) + compileTasks <EOL> val upToDateTasks = allExecutedTasks . filter { it . state . upToDate } . map { it . name } <EOL> if ( upToDateTasks . isNotEmpty ( ) ) { <EOL> if ( outputFile . exists ( ) ) { <EOL> project . delete ( outputFile . absolutePath ) <EOL> } <EOL> project . logger . warn ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> return <EOL> } <EOL> val successStatus = allExecutedTasks . all { it . state . failure == null } <EOL> var codeSize : String ? = null <EOL> if ( TrackableMetric . CODE_SIZE in settings . metrics ) { <EOL> codeSize = binary . outputFile . let { <EOL> if ( it . exists ( ) ) { <EOL> val size = if ( it . isDirectory ) folderSize ( it ) else it . length ( ) <EOL> "<STR_LIT>" <EOL> } else null <EOL> } <EOL> } <EOL> var compileTime : String ? = null <EOL> if ( TrackableMetric . COMPILE_TIME in settings . metrics ) { <EOL> compileTime = getCompilationResults ( allExecutedTasks . map { it . path } , successStatus ) <EOL> } <EOL> if ( ! reportDirectory . exists ( ) ) { <EOL> project . mkdir ( reportDirectory . absolutePath ) <EOL> } <EOL> val name = settings . binaryNamesForReport [ binary ] ! ! <EOL> outputFile . writeText ( name ) <EOL> outputFile . appendText ( "<STR_LIT>" ) <EOL> if ( compileTime != null ) { <EOL> outputFile . appendText ( "<STR_LIT>" ) <EOL> } <EOL> if ( codeSize != null ) { <EOL> outputFile . appendText ( "<STR_LIT>" ) <EOL> } <EOL> }


protected fun doTestWithJavac ( ktFilePath : String )

{ <EOL> doTest ( ktFilePath , true ) <EOL> }


protected fun doTestWithoutJavac ( ktFilePath : String )

{ <EOL> doTest ( ktFilePath , false ) <EOL> }


protected open fun doTest ( ktFilePath : String , useJavac : Boolean )

{ <EOL> Assert . assertTrue ( ktFilePath . endsWith ( "<STR_LIT>" ) ) <EOL> val ktFile = File ( ktFilePath ) <EOL> val javaFile = File ( ktFilePath . replaceFirst ( "<STR_LIT>" . toRegex ( ) , "<STR_LIT>" ) ) <EOL> val javaErrorFile = File ( ktFilePath . replaceFirst ( "<STR_LIT>" . toRegex ( ) , "<STR_LIT>" ) ) <EOL> val out = File ( tmpdir , "<STR_LIT>" ) <EOL> val directives = KotlinTestUtils . parseDirectives ( ktFile . readText ( ) ) <EOL> if ( useFir && directives . contains ( "<STR_LIT>" ) ) return <EOL> val compiledSuccessfully = if ( useJavac ) { <EOL> compileKotlinWithJava ( listOf ( javaFile ) , listOf ( ktFile ) , out , testRootDisposable ) <EOL> } else { <EOL> KotlinTestUtils . compileKotlinWithJava ( listOf ( javaFile ) , listOf ( ktFile ) , out , testRootDisposable , javaErrorFile , this :: updateConfiguration ) <EOL> } <EOL> if ( ! compiledSuccessfully ) return <EOL> val configuration = newConfiguration ( ConfigurationKind . ALL , TestJdkKind . FULL_JDK , KtTestUtil . getAnnotationsJar ( ) , out ) <EOL> configuration . put ( JVMConfigurationKeys . USE_PSI_CLASS_FILES_READING , true ) <EOL> val environment = KotlinCoreEnvironment . createForTests ( testRootDisposable , configuration , EnvironmentConfigFiles . JVM_CONFIG_FILES ) <EOL> setupLanguageVersionSettingsForCompilerTests ( ktFile . readText ( ) , environment ) <EOL> val analysisResult = JvmResolveUtil . analyze ( environment ) <EOL> val packageView = analysisResult . moduleDescriptor . getPackage ( LoadDescriptorUtil . TEST_PACKAGE_FQNAME ) <EOL> assertFalse ( "<STR_LIT>" , packageView . isEmpty ( ) ) <EOL> val expectedFile = File ( ktFilePath . replaceFirst ( "<STR_LIT>" . toRegex ( ) , "<STR_LIT>" ) ) <EOL> validateAndCompareDescriptorWithFile ( packageView , CONFIGURATION , expectedFile ) <EOL> }


fun updateConfiguration ( configuration : CompilerConfiguration )

{ <EOL> configureIrFir ( configuration ) <EOL> }


@ Throws ( IOException :: class ) <EOL> fun compileKotlinWithJava ( javaFiles : List < File > , ktFiles : List < File > , outDir : File , disposable : Disposable ) : Boolean

{ <EOL> val environment = createEnvironmentWithMockJdkAndIdeaAnnotations ( disposable ) <EOL> setupLanguageVersionSettingsForMultifileCompilerTests ( ktFiles , environment ) <EOL> environment . configuration . put ( JVMConfigurationKeys . USE_JAVAC , true ) <EOL> environment . configuration . put ( JVMConfigurationKeys . COMPILE_JAVA , true ) <EOL> environment . configuration . put ( JVMConfigurationKeys . OUTPUT_DIRECTORY , outDir ) <EOL> environment . configuration . put ( CLIConfigurationKeys . MESSAGE_COLLECTOR_KEY , MessageCollector . NONE ) <EOL> updateConfiguration ( environment . configuration ) <EOL> environment . registerJavac ( javaFiles = javaFiles , kotlinFiles = listOf ( KotlinTestUtils . loadKtFile ( environment . project , ktFiles . first ( ) ) ) ) <EOL> if ( ! ktFiles . isEmpty ( ) ) { <EOL> LoadDescriptorUtil . compileKotlinToDirAndGetModule ( ktFiles , outDir , environment ) <EOL> } else { <EOL> val mkdirs = outDir . mkdirs ( ) <EOL> assert ( mkdirs ) { "<STR_LIT>" } <EOL> } <EOL> return JavacWrapper . getInstance ( environment . project ) . use { it . compile ( ) } <EOL> }


inline fun bar ( block : ( ) -> String ) : String

{ <EOL> return block ( ) <EOL> }


{ <EOL> while ( true ) break <EOL> return bar { return "<STR_LIT:def>" } <EOL> }


fun foobar ( x : String , y : String , z : String )

= x + y + z


{ <EOL> val test = foobar ( "<STR_LIT:abc>" , bar2 ( ) , "<STR_LIT>" ) <EOL> return if ( test == "<STR_LIT>" ) <EOL> "<STR_LIT:OK>" <EOL> else "<STR_LIT>" <EOL> }


override fun getLoggerInstance ( p0 : String ) : Logger

= NoopIntellijLogger


override fun isDebugEnabled ( ) : Boolean

= false


override fun isTraceEnabled ( ) : Boolean

= false


override fun debug ( message : String ? )


override fun debug ( message : String ? , t : Throwable ? )


override fun debug ( message : String , vararg details : Any ? )


override fun debugValues ( header : String , values : MutableCollection < * > )


override fun trace ( message : String ? )


override fun info ( message : String ? )


override fun info ( message : String ? , t : Throwable ? )


override fun warn ( message : String ? , t : Throwable ? )


override fun warn ( message : String ? )


override fun error ( message : String ? , t : Throwable ? , vararg details : String ? )


override fun error ( message : String ? )


override fun error ( message : String ? , vararg attachments : Attachment ? )


override fun error ( message : String ? , t : Throwable ? , vararg attachments : Attachment ? )


override fun error ( message : String ? , vararg details : String ? )


override fun error ( message : String ? , t : Throwable ? )


override fun check ( metadata1 : KotlinClassMetadata . MultiFileClassFacade , metadata2 : KotlinClassMetadata . MultiFileClassFacade , report : MultiFileClassFacadeMetadataReport , )

{ <EOL> val list1 = getList ( metadata1 ) <EOL> val list2 = getList ( metadata2 ) <EOL> val diff = compareLists ( list1 . sorted ( ) , list2 . sorted ( ) ) ? : return <EOL> report . addMembersListDiffs ( diff ) <EOL> }


abstract fun getList ( metadata : KotlinClassMetadata . MultiFileClassFacade ) : List < String >


fun multiFileClassFacadeMetadataListChecker ( name : String , listGetter : ( KotlinClassMetadata . MultiFileClassFacade ) -> List < String > )

= <EOL> object : MultiFileClassFacadeMetadataListChecker ( name ) { <EOL> override fun getList ( metadata : KotlinClassMetadata . MultiFileClassFacade ) = listGetter ( metadata ) <EOL> }


= null


{ <EOL> if ( ( null as NativePtr ? ) != null ) return "<STR_LIT>" <EOL> if ( ( null as? NativePtr ) != null ) return "<STR_LIT>" <EOL> if ( null !is NativePtr ? ) return "<STR_LIT>" <EOL> if ( null is NativePtr ) return "<STR_LIT>" <EOL> if ( ( null as COpaquePointer ? ) != null ) return "<STR_LIT>" <EOL> if ( ( null as? COpaquePointer ) != null ) return "<STR_LIT>" <EOL> if ( null !is COpaquePointer ? ) return "<STR_LIT>" <EOL> if ( null is COpaquePointer ) return "<STR_LIT>" <EOL> if ( ( getNp ( ) as NativePtr ? ) != null ) return "<STR_LIT>" <EOL> if ( ( getNp ( ) as? NativePtr ) != null ) return "<STR_LIT>" <EOL> if ( getNp ( ) !is NativePtr ? ) return "<STR_LIT>" <EOL> if ( getNp ( ) is NativePtr ) return "<STR_LIT>" <EOL> if ( ( getOp ( ) as COpaquePointer ? ) != null ) return "<STR_LIT>" <EOL> if ( ( getOp ( ) as? COpaquePointer ) != null ) return "<STR_LIT>" <EOL> if ( getOp ( ) !is COpaquePointer ? ) return "<STR_LIT>" <EOL> if ( getOp ( ) is COpaquePointer ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


= A :: foo


fun get ( ) : T


fun < T > expectsSam ( sam : Sam < T > )

= sam . get ( )


= "<STR_LIT>"


= expectsSam ( :: foo )


{ <EOL> val actual = Array ( <NUM_LIT:2> ) { FloatArray ( <NUM_LIT:2> ) { <NUM_LIT> } } <EOL> val expected = Array ( <NUM_LIT:2> ) { FloatArray ( <NUM_LIT:2> ) { <NUM_LIT> } } <EOL> expected [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] = <NUM_LIT> <EOL> expected [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] = - <NUM_LIT> <EOL> expected [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] = <NUM_LIT> <EOL> expected [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] = - <NUM_LIT> <EOL> val shape = Shape . make ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> EagerSession . create ( ) . use { session -> <EOL> val tf = Ops . create ( session ) <EOL> val instance = GlorotNormal ( seed = SEED ) <EOL> val operand = <EOL> instance . initialize ( FAN_IN , FAN_OUT , tf , shapeOperand ( tf , shape ) , DEFAULT_LAYER_NAME ) <EOL> operand . asOutput ( ) . tensor ( ) . copyTo ( actual ) <EOL> assertArrayEquals ( expected [ <NUM_LIT:0> ] , actual [ <NUM_LIT:0> ] , EPS ) <EOL> assertArrayEquals ( expected [ <NUM_LIT:1> ] , actual [ <NUM_LIT:1> ] , EPS ) <EOL> assertEquals ( "<STR_LIT>" , instance . toString ( ) ) <EOL> } <EOL> }