@ Test <EOL> fun testCleanerDestroyWithChild ( )

{ <EOL> val worker = Worker . start ( ) <EOL> val called = AtomicBoolean ( false ) ; <EOL> var funBoxWeak : WeakReference < FunBox > ? = null <EOL> var cleanerWeak : WeakReference < Cleaner > ? = null <EOL> worker . execute ( TransferMode . SAFE , { <EOL> val funBox = FunBox { called . value = true } <EOL> funBoxWeak = WeakReference ( funBox ) <EOL> val cleaner = createCleaner ( funBox ) { it . call ( ) } <EOL> cleanerWeak = WeakReference ( cleaner ) <EOL> Pair ( called , cleaner ) <EOL> } ) { ( called , cleaner ) -> <EOL> assertFalse ( called . value ) <EOL> } . result <EOL> GC . collect ( ) <EOL> worker . requestTermination ( ) . result <EOL> waitWorkerTermination ( worker ) <EOL> performGCOnCleanerWorker ( ) <EOL> assertNull ( cleanerWeak ! ! . value ) <EOL> assertTrue ( called . value ) <EOL> assertNull ( funBoxWeak ! ! . value ) <EOL> }


@ Test <EOL> fun testCleanerDestroyInMain ( )

{ <EOL> val worker = Worker . start ( ) <EOL> val called = AtomicBoolean ( false ) ; <EOL> var funBoxWeak : WeakReference < FunBox > ? = null <EOL> var cleanerWeak : WeakReference < Cleaner > ? = null <EOL> { <EOL> val result = worker . execute ( TransferMode . SAFE , { called } ) { called -> <EOL> val funBox = FunBox { called . value = true } <EOL> val cleaner = createCleaner ( funBox ) { it . call ( ) } <EOL> Triple ( cleaner , WeakReference ( funBox ) , WeakReference ( cleaner ) ) <EOL> } . result <EOL> val cleaner = result . first <EOL> funBoxWeak = result . second <EOL> cleanerWeak = result . third <EOL> assertFalse ( called . value ) <EOL> } ( ) <EOL> GC . collect ( ) <EOL> worker . execute ( TransferMode . SAFE , { } ) { GC . collect ( ) } . result <EOL> performGCOnCleanerWorker ( ) <EOL> assertNull ( cleanerWeak ! ! . value ) <EOL> assertTrue ( called . value ) <EOL> assertNull ( funBoxWeak ! ! . value ) <EOL> worker . requestTermination ( ) . result <EOL> }


@ Test <EOL> fun testCleanerDestroyShared ( )

{ <EOL> val worker = Worker . start ( ) <EOL> val called = AtomicBoolean ( false ) ; <EOL> var funBoxWeak : WeakReference < FunBox > ? = null <EOL> var cleanerWeak : WeakReference < Cleaner > ? = null <EOL> val cleanerHolder : AtomicReference < Cleaner ? > = AtomicReference ( null ) ; <EOL> { <EOL> val funBox = FunBox { called . value = true } <EOL> funBoxWeak = WeakReference ( funBox ) <EOL> val cleaner = createCleaner ( funBox ) { it . call ( ) } <EOL> cleanerWeak = WeakReference ( cleaner ) <EOL> cleanerHolder . value = cleaner <EOL> worker . execute ( TransferMode . SAFE , { Pair ( called , cleanerHolder ) } ) { ( called , cleanerHolder ) -> <EOL> cleanerHolder . value = null <EOL> assertFalse ( called . value ) <EOL> } . result <EOL> } ( ) <EOL> GC . collect ( ) <EOL> worker . execute ( TransferMode . SAFE , { } ) { GC . collect ( ) } . result <EOL> performGCOnCleanerWorker ( ) <EOL> assertNull ( cleanerWeak ! ! . value ) <EOL> assertTrue ( called . value ) <EOL> assertNull ( funBoxWeak ! ! . value ) <EOL> worker . requestTermination ( ) . result <EOL> }


{ <EOL> val worker = Worker . start ( ) <EOL> tlsValue = <NUM_LIT:12> <EOL> val value = AtomicInt ( <NUM_LIT:0> ) <EOL> worker . execute ( TransferMode . SAFE , { value } ) { <EOL> tlsValue = <NUM_LIT> <EOL> createCleaner ( it ) { <EOL> it . value = tlsValue <EOL> } <EOL> Unit <EOL> } . result <EOL> worker . execute ( TransferMode . SAFE , { } ) { GC . collect ( ) } . result <EOL> performGCOnCleanerWorker ( ) <EOL> assertEquals ( <NUM_LIT:11> , value . value ) <EOL> worker . requestTermination ( ) . result <EOL> }


= x + y


{ <EOL> var x = <NUM_LIT:0> <EOL> run { <EOL> x += add ( <NUM_LIT:1> , try { <NUM_LIT:1> } catch ( e : Throwable ) { <NUM_LIT:42> } ) <EOL> } <EOL> }


@ GCUnsafeCall ( "<STR_LIT>" ) <EOL> internal actual external fun formatToExactDecimals ( value : Double , decimals : Int ) : String


fun run ( f : ( Foo < String > ) -> Foo < Long > ) : Foo < Long >

{ <EOL> return f ( Foo < String > ( <NUM_LIT:42> ) ) <EOL> }


{ <EOL> return run { f -> <EOL> Foo < Long > ( f . x + <NUM_LIT:1> ) <EOL> } <EOL> }


fun nullableFoo ( f : Foo < Long > ? ) : Foo < Long >

= f ! !


fun listOfFoo ( f : List < Foo < String > > ) : Foo < String >

= f [ <NUM_LIT:0> ]


{ <EOL> val b = Bar ( ) <EOL> if ( b . invokeFun ( ) . x != <NUM_LIT> ) return "<STR_LIT:FailU+00201>" <EOL> if ( b . nullableFoo ( Foo < Long > ( <NUM_LIT:1> ) ) . x != <NUM_LIT:1> ) return "<STR_LIT:FailU+00202>" <EOL> val f : Foo < Long > ? = Foo < Long > ( <NUM_LIT:2> ) <EOL> if ( b . nullableFoo ( f ) . x != <NUM_LIT:2> ) return "<STR_LIT:FailU+00203>" <EOL> val ls = listOf ( Foo < String > ( <NUM_LIT:3> ) ) <EOL> if ( b . listOfFoo ( ls ) . x != <NUM_LIT:3> ) return "<STR_LIT:FailU+00204>" <EOL> return "<STR_LIT:OK>" <EOL> }


fun addExecutionTime ( clazz : Class < * > , timeInMillis : Long )

{ <EOL> times [ clazz ] = times . getOrDefault ( clazz , <NUM_LIT:0> ) + timeInMillis <EOL> }


fun getExecutionTimes ( ) : Map < Class < * > , Long >

{ <EOL> return times . toMap ( ) <EOL> }


{ <EOL> times . clear ( ) <EOL> }


{ <EOL> val mutableProperty = Klass < T > :: mutableProperty <EOL> mutableProperty . set ( this , Generic < T > ( ) ) <EOL> }


{ <EOL> val mutableProperty = Klass < Int > :: mutableProperty <EOL> mutableProperty . set ( Klass < Int > ( ) , Generic < Int > ( ) ) <EOL> }


{ <EOL> val mutableProperty = Klass < A > :: mutableProperty <EOL> mutableProperty . set ( Klass < A > ( ) , Generic < A > ( ) ) <EOL> }


fun < S : CharSequence > testGenericTypeWithBounds ( )

{ <EOL> val mutableProperty = Klass < S > :: mutableProperty <EOL> mutableProperty . set ( Klass < S > ( ) , Generic < S > ( ) ) <EOL> }


= <NUM_LIT:1>


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


{ <EOL> try { <EOL> flameThrower ( ) <EOL> } catch ( e : Throwable ) { <EOL> return "<STR_LIT:OK>" <EOL> } <EOL> return "<STR_LIT>" <EOL> }


inline fun < T , R > with ( receiver : T , block : T . ( ) -> R ) : R

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


inline fun < T , R > T . let ( block : ( T ) -> R ) : R

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


{ <EOL> val a = with ( <NUM_LIT:1> ) { <EOL> this . let { it } <EOL> } . let { <NUM_LIT:2> } <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:42> , <NUM_LIT> + <NUM_LIT:2> ) <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:42> , <NUM_LIT> * <NUM_LIT:2> ) <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:42> , <NUM_LIT> - <NUM_LIT:8> ) <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:42> , <NUM_LIT> / <NUM_LIT:3> ) <EOL> }


override fun KtDeclarationSymbol . sirDeclaration ( ) : SirDeclaration

= withSirAnalyse ( sirSession , ktAnalysisSession ) { <EOL> when ( val ktSymbol = this @ sirDeclaration ) { <EOL> is KtNamedClassOrObjectSymbol -> { <EOL> SirClassFromKtSymbol ( ktSymbol = ktSymbol , analysisApiSession = ktAnalysisSession , sirSession = sirSession , ) <EOL> } <EOL> is KtConstructorSymbol -> { <EOL> SirInitFromKtSymbol ( ktSymbol = ktSymbol , analysisApiSession = ktAnalysisSession , sirSession = sirSession , ) <EOL> } <EOL> is KtFunctionLikeSymbol -> { <EOL> SirFunctionFromKtSymbol ( ktSymbol = ktSymbol , analysisApiSession = ktAnalysisSession , sirSession = sirSession , ) <EOL> } <EOL> is KtVariableSymbol -> { <EOL> SirVariableFromKtSymbol ( ktSymbol = ktSymbol , analysisApiSession = ktAnalysisSession , sirSession = sirSession , ) <EOL> } <EOL> is KtTypeAliasSymbol -> { <EOL> SirTypealiasFromKtSymbol ( ktSymbol = ktSymbol , analysisApiSession = ktAnalysisSession , sirSession = sirSession , ) <EOL> } <EOL> else -> TODO ( "<STR_LIT>" ) <EOL> } <EOL> }


fun bar ( x : Int ) : Int


= x . hashCode ( )


{ <EOL> val foo : Foo = Foo ( :: baz ) <EOL> val result = foo . bar ( <NUM_LIT:42> ) <EOL> return if ( result == <NUM_LIT:42> ) <EOL> "<STR_LIT:OK>" <EOL> else "<STR_LIT>" <EOL> }


{ <EOL> val v = tr as G ? <EOL> checkSubtype < G < String > > ( v ! ! ) <EOL> }


= suspendCoroutine { <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> c = it as Continuation < Any > <EOL> }


= <EOL> if ( this == <NUM_LIT:42> ) "<STR_LIT:OK>" else "<STR_LIT>"


suspend fun generic ( ) : T


= suspendMe ( )


{ <EOL> c . startCoroutine ( handleExceptionContinuation { <EOL> result = it . message ! ! <EOL> } ) <EOL> }


{ <EOL> builder { <EOL> val base : Base < * > = Derived ( ) <EOL> ( base . generic ( ) as IC ) . s . toResultString ( ) <EOL> } <EOL> c ? . resumeWithException ( IllegalStateException ( "<STR_LIT:OK>" ) ) <EOL> return result <EOL> }


fun fromBoundedValueWithStep1 ( codegen : ExpressionCodegen , forExpression : KtForExpression , boundedValue : BoundedValue , comparisonGenerator : ComparisonGenerator , inverseBoundsEvaluationOrder : Boolean = false )

= <EOL> ForInSimpleProgressionLoopGenerator ( codegen , forExpression , boundedValue , inverseBoundsEvaluationOrder , comparisonGenerator , <NUM_LIT:1> )


fun fromBoundedValueWithStepMinus1 ( codegen : ExpressionCodegen , forExpression : KtForExpression , boundedValue : BoundedValue , comparisonGenerator : ComparisonGenerator , inverseBoundsEvaluationOrder : Boolean = false )

= <EOL> ForInSimpleProgressionLoopGenerator ( codegen , forExpression , boundedValue , inverseBoundsEvaluationOrder , comparisonGenerator , - <NUM_LIT:1> )


{ <EOL> if ( inverseBoundsEvaluationOrder ) { <EOL> StackValue . local ( endVar , asmElementType ) . store ( endValue , v ) <EOL> loopParameter ( ) . store ( startValue , v ) <EOL> } else { <EOL> loopParameter ( ) . store ( startValue , v ) <EOL> StackValue . local ( endVar , asmElementType ) . store ( endValue , v ) <EOL> } <EOL> if ( ! isStartInclusive ) incrementLoopVariable ( ) <EOL> }


override fun checkEmptyLoop ( loopExit : Label )

{ <EOL> if ( isEndInclusive ) { <EOL> super . checkEmptyLoop ( loopExit ) <EOL> } <EOL> }


override fun checkPreCondition ( loopExit : Label )

{ <EOL> if ( ! isEndInclusive ) { <EOL> loopParameter ( ) . put ( asmElementType , elementType , v ) <EOL> v . load ( endVar , asmElementType ) <EOL> if ( step > <NUM_LIT:0> ) <EOL> comparisonGenerator . jumpIfGreaterOrEqual ( v , loopExit ) <EOL> else <EOL> comparisonGenerator . jumpIfLessOrEqual ( v , loopExit ) <EOL> } <EOL> }


override fun checkPostConditionAndIncrement ( loopExit : Label )

{ <EOL> if ( isEndInclusive ) { <EOL> super . checkPostConditionAndIncrement ( loopExit ) <EOL> } else { <EOL> incrementLoopVariable ( ) <EOL> } <EOL> }


= "<STR_LIT>"


= bar ( )


override fun visitIsExpression ( expression : KtIsExpression , contextWithExpectedType : ExpressionTypingContext ) : KotlinTypeInfo

{ <EOL> val context = contextWithExpectedType . replaceExpectedType ( NO_EXPECTED_TYPE ) . replaceContextDependency ( INDEPENDENT ) <EOL> val leftHandSide = expression . leftHandSide <EOL> val typeInfo = facade . safeGetTypeInfo ( leftHandSide , context ) <EOL> val knownType = typeInfo . type <EOL> val typeReference = expression . typeReference <EOL> if ( typeReference != null && knownType != null ) { <EOL> val dataFlowValue = components . dataFlowValueFactory . createDataFlowValue ( leftHandSide , knownType , context ) <EOL> val conditionInfo = checkTypeForIs ( context , expression , expression . isNegated , knownType , typeReference , dataFlowValue ) . thenInfo <EOL> val newDataFlowInfo = conditionInfo . and ( typeInfo . dataFlowInfo ) <EOL> context . trace . record ( BindingContext . DATAFLOW_INFO_AFTER_CONDITION , expression , newDataFlowInfo ) <EOL> } <EOL> expression . reportDeprecatedDefinitelyNotNullSyntax ( expression . typeReference , contextWithExpectedType ) <EOL> val resultTypeInfo = components . dataFlowAnalyzer . checkType ( typeInfo . replaceType ( components . builtIns . booleanType ) , expression , contextWithExpectedType ) <EOL> if ( typeReference != null ) { <EOL> val rhsType = context . trace [ BindingContext . TYPE , typeReference ] <EOL> val rttiInformation = RttiExpressionInformation ( subject = leftHandSide , sourceType = knownType , targetType = rhsType , operation = if ( expression . isNegated ) RttiOperation . NOT_IS else RttiOperation . IS ) <EOL> components . rttiExpressionCheckers . forEach { <EOL> it . check ( rttiInformation , expression , context . trace ) <EOL> } <EOL> } <EOL> return resultTypeInfo <EOL> }


override fun visitWhenExpression ( expression : KtWhenExpression , context : ExpressionTypingContext )

= <EOL> visitWhenExpression ( expression , context , false )


protected abstract fun createDataFlowValue ( contextAfterSubject : ExpressionTypingContext , builtIns : KotlinBuiltIns ) : DataFlowValue


abstract fun makeValueArgument ( ) : ValueArgument ?


open fun getCalleeExpressionForSpecialCall ( ) : KtExpression ?

= null


fun initDataFlowValue ( contextAfterSubject : ExpressionTypingContext , builtIns : KotlinBuiltIns )

{ <EOL> dataFlowValue = createDataFlowValue ( contextAfterSubject , builtIns ) <EOL> }


override fun createDataFlowValue ( contextAfterSubject : ExpressionTypingContext , builtIns : KotlinBuiltIns )

= <EOL> dataFlowValueFactory . createDataFlowValue ( expression , type , contextAfterSubject )


override fun makeValueArgument ( ) : ValueArgument

= <EOL> CallMaker . makeExternalValueArgument ( expression )


= <EOL> DataFlowValue ( IdentifierInfo . Variable ( descriptor , DataFlowValue . Kind . STABLE_VALUE , contextAfterSubject . trace . bindingContext [ BindingContext . BOUND_INITIALIZER_VALUE , descriptor ] ) , descriptor . type )


override fun makeValueArgument ( ) : ValueArgument ?

= <EOL> variable . initializer ? . let { <EOL> CallMaker . makeExternalValueArgument ( KtPsiFactory ( variable . project , true ) . createExpression ( variable . name ! ! ) , it ) <EOL> }


override fun getCalleeExpressionForSpecialCall ( ) : KtExpression

= <EOL> variable


= <EOL> DataFlowValue . nullValue ( builtIns )


= null


fun visitWhenExpression ( expression : KtWhenExpression , contextWithExpectedType : ExpressionTypingContext , @ Suppress ( "<STR_LIT:UNUSED_PARAMETER>" ) isStatement : Boolean ) : KotlinTypeInfo

{ <EOL> val trace = contextWithExpectedType . trace <EOL> WhenChecker . checkDeprecatedWhenSyntax ( trace , expression ) <EOL> WhenChecker . checkSealedWhenIsReserved ( trace , expression . whenKeyword ) <EOL> components . dataFlowAnalyzer . recordExpectedType ( trace , expression , contextWithExpectedType . expectedType ) <EOL> val contextBeforeSubject = contextWithExpectedType . replaceExpectedType ( NO_EXPECTED_TYPE ) . replaceContextDependency ( INDEPENDENT ) <EOL> val subjectExpression = expression . subjectExpression <EOL> val subjectVariable = expression . subjectVariable <EOL> val subject = when { <EOL> subjectVariable != null -> <EOL> processVariableSubject ( subjectVariable , contextBeforeSubject ) <EOL> subjectExpression != null -> <EOL> Subject . Expression ( subjectExpression , facade . getTypeInfo ( subjectExpression , contextBeforeSubject ) , components . dataFlowValueFactory ) <EOL> else -> <EOL> Subject . None ( ) <EOL> } <EOL> val contextAfterSubject = run { <EOL> var result = contextBeforeSubject <EOL> subject . scopeWithSubject ? . let { result = result . replaceScope ( it ) } <EOL> subject . dataFlowInfo ? . let { result = result . replaceDataFlowInfo ( it ) } <EOL> result <EOL> } <EOL> val contextWithExpectedTypeAndSubjectVariable = <EOL> subject . scopeWithSubject ? . let { contextWithExpectedType . replaceScope ( it ) } ? : contextWithExpectedType <EOL> subject . initDataFlowValue ( contextAfterSubject , components . builtIns ) <EOL> val possibleTypesForSubject = <EOL> subject . typeInfo ? . dataFlowInfo ? . getStableTypes ( subject . dataFlowValue , components . languageVersionSettings ) <EOL> ? : emptySet ( ) <EOL> checkSmartCastsInSubjectIfRequired ( expression , contextBeforeSubject , subject . type , possibleTypesForSubject ) <EOL> val dataFlowInfoForEntries = analyzeConditionsInWhenEntries ( expression , contextAfterSubject , subject ) <EOL> val whenReturnType = inferTypeForWhenExpression ( expression , subject , contextWithExpectedTypeAndSubjectVariable , contextAfterSubject , dataFlowInfoForEntries ) <EOL> val whenResultValue = <EOL> whenReturnType ? . let { facade . components . dataFlowValueFactory . createDataFlowValue ( expression , it , contextAfterSubject ) } <EOL> val branchesTypeInfo = <EOL> joinWhenExpressionBranches ( expression , contextAfterSubject , whenReturnType , subject . jumpOutPossible , whenResultValue ) <EOL> val isExhaustive = WhenChecker . isWhenExhaustive ( expression , trace ) <EOL> val branchesDataFlowInfo = branchesTypeInfo . dataFlowInfo <EOL> val resultDataFlowInfo = if ( expression . elseExpression == null && ! isExhaustive ) { <EOL> branchesDataFlowInfo . or ( contextAfterSubject . dataFlowInfo ) <EOL> } else { <EOL> branchesDataFlowInfo <EOL> } <EOL> if ( whenReturnType != null && isExhaustive && expression . elseExpression == null && KotlinBuiltIns . isNothing ( whenReturnType ) ) { <EOL> trace . record ( BindingContext . IMPLICIT_EXHAUSTIVE_WHEN , expression ) <EOL> } <EOL> val branchesType = branchesTypeInfo . type ? : return noTypeInfo ( resultDataFlowInfo ) <EOL> val resultType = components . dataFlowAnalyzer . checkType ( branchesType , expression , contextWithExpectedType ) <EOL> ConfusingWhenBranchSyntaxChecker . check ( expression , contextWithExpectedType . languageVersionSettings , trace ) <EOL> return createTypeInfo ( resultType , resultDataFlowInfo , branchesTypeInfo . jumpOutPossible , contextWithExpectedType . dataFlowInfo ) <EOL> }


private fun processVariableSubject ( subjectVariable : KtProperty , contextBeforeSubject : ExpressionTypingContext ) : Subject

{ <EOL> val trace = contextBeforeSubject . trace <EOL> if ( ! components . languageVersionSettings . supportsFeature ( LanguageFeature . VariableDeclarationInWhenSubject ) ) { <EOL> trace . report ( UNSUPPORTED_FEATURE . on ( subjectVariable , Pair ( LanguageFeature . VariableDeclarationInWhenSubject , components . languageVersionSettings ) ) ) <EOL> } else { <EOL> val illegalDeclarationString = when { <EOL> subjectVariable . isVar -> "<STR_LIT>" <EOL> subjectVariable . initializer == null -> "<STR_LIT>" <EOL> subjectVariable . hasDelegateExpression ( ) -> "<STR_LIT>" <EOL> subjectVariable . getter != null || subjectVariable . setter != null -> "<STR_LIT>" <EOL> else -> null <EOL> } <EOL> if ( illegalDeclarationString != null ) { <EOL> trace . report ( ILLEGAL_DECLARATION_IN_WHEN_SUBJECT . on ( subjectVariable , illegalDeclarationString ) ) <EOL> } <EOL> } <EOL> val scopeWithSubjectVariable = <EOL> ExpressionTypingUtils . newWritableScopeImpl ( contextBeforeSubject , LexicalScopeKind . WHEN , components . overloadChecker ) <EOL> val ( typeInfo , descriptor ) = <EOL> components . localVariableResolver . process ( subjectVariable , contextBeforeSubject , contextBeforeSubject . scope , facade ) <EOL> scopeWithSubjectVariable . addVariableDescriptor ( descriptor ) <EOL> val subjectTypeInfo = typeInfo . replaceType ( descriptor . type ) <EOL> return Subject . Variable ( subjectVariable , descriptor , subjectTypeInfo , scopeWithSubjectVariable ) <EOL> }


private fun inferTypeForWhenExpression ( expression : KtWhenExpression , subject : Subject , contextWithExpectedType : ExpressionTypingContext , contextAfterSubject : ExpressionTypingContext , dataFlowInfoForEntries : List < DataFlowInfo > ) : KotlinType ?

{ <EOL> if ( expression . entries . all { it . expression == null } ) { <EOL> return components . builtIns . unitType <EOL> } <EOL> val wrappedArgumentExpressions = wrapWhenEntryExpressionsAsSpecialCallArguments ( expression ) <EOL> val callForWhen = createCallForSpecialConstruction ( expression , subject . getCalleeExpressionForSpecialCall ( ) ? : expression , wrappedArgumentExpressions ) <EOL> val dataFlowInfoForArguments = createDataFlowInfoForArgumentsOfWhenCall ( callForWhen , contextAfterSubject . dataFlowInfo , dataFlowInfoForEntries ) <EOL> val resolvedCall = components . controlStructureTypingUtils . resolveSpecialConstructionAsCall ( callForWhen , ResolveConstruct . WHEN , object : AbstractList < String > ( ) { <EOL> override fun get ( index : Int ) : String = "<STR_LIT>" <EOL> override val size : Int get ( ) = wrappedArgumentExpressions . size <EOL> } , Collections . nCopies ( wrappedArgumentExpressions . size , false ) , contextWithExpectedType , dataFlowInfoForArguments ) <EOL> return resolvedCall . resultingDescriptor . returnType <EOL> }


private fun wrapWhenEntryExpressionsAsSpecialCallArguments ( expression : KtWhenExpression ) : List < KtExpression >

{ <EOL> val psiFactory = KtPsiFactory ( expression . project ) <EOL> return expression . entries . mapNotNull { whenEntry -> <EOL> whenEntry . expression ? . let { psiFactory . wrapInABlockWrapper ( it ) } <EOL> } <EOL> }


private fun analyzeConditionsInWhenEntries ( expression : KtWhenExpression , contextAfterSubject : ExpressionTypingContext , subject : Subject ) : ArrayList < DataFlowInfo >

{ <EOL> val argumentDataFlowInfos = ArrayList < DataFlowInfo > ( ) <EOL> var inputDataFlowInfo = contextAfterSubject . dataFlowInfo <EOL> for ( whenEntry in expression . entries ) { <EOL> val conditionsInfo = analyzeWhenEntryConditions ( whenEntry , contextAfterSubject . replaceDataFlowInfo ( inputDataFlowInfo ) , subject ) <EOL> inputDataFlowInfo = inputDataFlowInfo . and ( conditionsInfo . elseInfo ) <EOL> if ( whenEntry . expression != null ) { <EOL> argumentDataFlowInfos . add ( conditionsInfo . thenInfo ) <EOL> } <EOL> } <EOL> return argumentDataFlowInfos <EOL> }


private fun joinWhenExpressionBranches ( expression : KtWhenExpression , contextAfterSubject : ExpressionTypingContext , resultType : KotlinType ? , jumpOutPossibleInSubject : Boolean , whenResultValue : DataFlowValue ? <EOL> ) : KotlinTypeInfo

{ <EOL> val bindingContext = contextAfterSubject . trace . bindingContext <EOL> var currentDataFlowInfo : DataFlowInfo ? = null <EOL> var jumpOutPossible = jumpOutPossibleInSubject <EOL> var errorTypeExistInBranch = false <EOL> for ( whenEntry in expression . entries ) { <EOL> val entryExpression = whenEntry . expression ? : continue <EOL> val entryTypeInfo = BindingContextUtils . getRecordedTypeInfo ( entryExpression , bindingContext ) ? : continue <EOL> val entryType = entryTypeInfo . type <EOL> if ( entryType == null ) { <EOL> errorTypeExistInBranch = true <EOL> } <EOL> val entryDataFlowInfo = <EOL> if ( whenResultValue != null && entryType != null ) { <EOL> val entryValue = <EOL> facade . components . dataFlowValueFactory . createDataFlowValue ( entryExpression , entryType , contextAfterSubject ) <EOL> entryTypeInfo . dataFlowInfo . assign ( whenResultValue , entryValue , components . languageVersionSettings ) <EOL> } else { <EOL> entryTypeInfo . dataFlowInfo <EOL> } <EOL> currentDataFlowInfo = when { <EOL> entryType != null && KotlinBuiltIns . isNothing ( entryType ) -> currentDataFlowInfo <EOL> currentDataFlowInfo != null -> currentDataFlowInfo . or ( entryDataFlowInfo ) <EOL> else -> entryDataFlowInfo <EOL> } <EOL> jumpOutPossible = jumpOutPossible or entryTypeInfo . jumpOutPossible <EOL> } <EOL> val resultDataFlowInfo = currentDataFlowInfo ? : contextAfterSubject . dataFlowInfo <EOL> return if ( resultType == null || errorTypeExistInBranch && KotlinBuiltIns . isNothing ( resultType ) ) <EOL> noTypeInfo ( resultDataFlowInfo ) <EOL> else <EOL> createTypeInfo ( resultType , resultDataFlowInfo , jumpOutPossible , resultDataFlowInfo ) <EOL> }


private fun checkSmartCastsInSubjectIfRequired ( expression : KtWhenExpression , contextBeforeSubject : ExpressionTypingContext , subjectType : KotlinType , possibleTypesForSubject : Set < KotlinType > )

{ <EOL> val subjectExpression = expression . subjectExpression ? : return <EOL> for ( possibleCastType in possibleTypesForSubject . reversed ( ) ) { <EOL> val possibleCastClass = possibleCastType . constructor . declarationDescriptor as? ClassDescriptor ? : continue <EOL> if ( possibleCastClass . kind == ClassKind . ENUM_CLASS || possibleCastClass . modality == Modality . SEALED ) { <EOL> if ( checkSmartCastToExpectedTypeInSubject ( contextBeforeSubject , subjectExpression , subjectType , possibleCastType ) ) { <EOL> return <EOL> } <EOL> } <EOL> } <EOL> val isNullableType = TypeUtils . isNullableType ( subjectType ) <EOL> val bindingContext = contextBeforeSubject . trace . bindingContext <EOL> if ( isNullableType && ! WhenChecker . containsNullCase ( expression , bindingContext ) ) { <EOL> val notNullableType = TypeUtils . makeNotNullable ( subjectType ) <EOL> if ( checkSmartCastToExpectedTypeInSubject ( contextBeforeSubject , subjectExpression , subjectType , notNullableType ) ) { <EOL> return <EOL> } <EOL> } <EOL> }


private fun checkSmartCastToExpectedTypeInSubject ( contextBeforeSubject : ExpressionTypingContext , subjectExpression : KtExpression , subjectType : KotlinType , expectedType : KotlinType ) : Boolean

{ <EOL> val trace = TemporaryBindingTrace . create ( contextBeforeSubject . trace , "<STR_LIT>" ) <EOL> val subjectContext = contextBeforeSubject . replaceExpectedType ( expectedType ) . replaceBindingTrace ( trace ) <EOL> val castResult = facade . components . dataFlowAnalyzer . checkPossibleCast ( subjectType , KtPsiUtil . safeDeparenthesize ( subjectExpression ) , subjectContext ) <EOL> if ( castResult != null && castResult . isCorrect ) { <EOL> trace . commit ( ) <EOL> return true <EOL> } <EOL> return false <EOL> }


private fun analyzeWhenEntryConditions ( whenEntry : KtWhenEntry , context : ExpressionTypingContext , subject : Subject ) : ConditionalDataFlowInfo

{ <EOL> if ( whenEntry . isElse ) { <EOL> return ConditionalDataFlowInfo ( context . dataFlowInfo ) <EOL> } <EOL> var entryInfo : ConditionalDataFlowInfo ? = null <EOL> var contextForCondition = context <EOL> for ( condition in whenEntry . conditions ) { <EOL> val conditionInfo = checkWhenCondition ( subject , condition , contextForCondition ) <EOL> entryInfo = entryInfo ? . let { <EOL> ConditionalDataFlowInfo ( it . thenInfo . or ( conditionInfo . thenInfo ) , it . elseInfo . and ( conditionInfo . elseInfo ) ) <EOL> } ? : conditionInfo <EOL> contextForCondition = contextForCondition . replaceDataFlowInfo ( conditionInfo . elseInfo ) <EOL> } <EOL> return entryInfo ? : ConditionalDataFlowInfo ( context . dataFlowInfo ) <EOL> }


private fun checkWhenCondition ( subject : Subject , condition : KtWhenCondition , context : ExpressionTypingContext ) : ConditionalDataFlowInfo

{ <EOL> var newDataFlowInfo = noChange ( context ) <EOL> condition . accept ( object : KtVisitorVoid ( ) { <EOL> override fun visitWhenConditionInRange ( condition : KtWhenConditionInRange ) { <EOL> val rangeExpression = condition . rangeExpression ? : return <EOL> if ( subject is Subject . None ) { <EOL> context . trace . report ( EXPECTED_CONDITION . on ( condition ) ) <EOL> val dataFlowInfo = facade . getTypeInfo ( rangeExpression , context ) . dataFlowInfo <EOL> newDataFlowInfo = ConditionalDataFlowInfo ( dataFlowInfo ) <EOL> return <EOL> } <EOL> val argumentForSubject = subject . makeValueArgument ( ) ? : return <EOL> val typeInfo = facade . checkInExpression ( condition , condition . operationReference , argumentForSubject , rangeExpression , context ) <EOL> val dataFlowInfo = typeInfo . dataFlowInfo <EOL> newDataFlowInfo = ConditionalDataFlowInfo ( dataFlowInfo ) <EOL> val type = typeInfo . type <EOL> if ( type == null || ! isBoolean ( type ) ) { <EOL> context . trace . report ( TYPE_MISMATCH_IN_RANGE . on ( condition ) ) <EOL> } <EOL> } <EOL> override fun visitWhenConditionIsPattern ( condition : KtWhenConditionIsPattern ) { <EOL> if ( subject is Subject . None ) { <EOL> context . trace . report ( EXPECTED_CONDITION . on ( condition ) ) <EOL> } <EOL> val typeReference = condition . typeReference ? : return <EOL> val result = checkTypeForIs ( context , condition , condition . isNegated , subject . type , typeReference , subject . dataFlowValue ) <EOL> newDataFlowInfo = if ( condition . isNegated ) ConditionalDataFlowInfo ( result . elseInfo , result . thenInfo ) else result <EOL> val rhsType = context . trace [ BindingContext . TYPE , typeReference ] <EOL> if ( subject !is Subject . None ) { <EOL> val rttiInformation = RttiExpressionInformation ( subject = subject . element ! ! , sourceType = subject . type , targetType = rhsType , operation = if ( condition . isNegated ) RttiOperation . NOT_IS else RttiOperation . IS ) <EOL> components . rttiExpressionCheckers . forEach { <EOL> it . check ( rttiInformation , condition , context . trace ) <EOL> } <EOL> } <EOL> } <EOL> override fun visitWhenConditionWithExpression ( condition : KtWhenConditionWithExpression ) { <EOL> val expression = condition . expression ? : return <EOL> val basicDataFlowInfo = <EOL> checkTypeForExpressionCondition ( context , expression , subject ) <EOL> val moduleDescriptor = DescriptorUtils . getContainingModule ( context . scope . ownerDescriptor ) <EOL> val dataFlowInfoFromES = <EOL> components . effectSystem . getDataFlowInfoWhenEquals ( subject . valueExpression , expression , context . trace , moduleDescriptor ) <EOL> newDataFlowInfo = basicDataFlowInfo . and ( dataFlowInfoFromES ) <EOL> } <EOL> override fun visitKtElement ( element : KtElement ) { <EOL> context . trace . report ( UNSUPPORTED . on ( element , this :: class . java . canonicalName ) ) <EOL> } <EOL> } ) <EOL> return newDataFlowInfo <EOL> }


private fun checkTypeForExpressionCondition ( context : ExpressionTypingContext , expression : KtExpression , subject : Subject ) : ConditionalDataFlowInfo

{ <EOL> var newContext = context <EOL> val typeInfo = facade . getTypeInfo ( expression , newContext ) <EOL> val type = typeInfo . type ? : return noChange ( newContext ) <EOL> newContext = newContext . replaceDataFlowInfo ( typeInfo . dataFlowInfo ) <EOL> if ( subject is Subject . None ) { <EOL> val booleanType = components . builtIns . booleanType <EOL> val checkedTypeInfo = components . dataFlowAnalyzer . checkType ( typeInfo , expression , newContext . replaceExpectedType ( booleanType ) ) <EOL> if ( KotlinTypeChecker . DEFAULT . equalTypes ( booleanType , checkedTypeInfo . type ? : type ) ) { <EOL> val ifInfo = components . dataFlowAnalyzer . extractDataFlowInfoFromCondition ( expression , true , newContext ) <EOL> val elseInfo = components . dataFlowAnalyzer . extractDataFlowInfoFromCondition ( expression , false , newContext ) <EOL> return ConditionalDataFlowInfo ( ifInfo , elseInfo ) <EOL> } <EOL> return noChange ( newContext ) <EOL> } <EOL> checkTypeCompatibility ( newContext , type , subject . type , expression ) <EOL> val expressionDataFlowValue = facade . components . dataFlowValueFactory . createDataFlowValue ( expression , type , newContext ) <EOL> val subjectStableTypes = <EOL> listOf ( subject . type ) + context . dataFlowInfo . getStableTypes ( subject . dataFlowValue , components . languageVersionSettings ) <EOL> val expressionStableTypes = <EOL> listOf ( type ) + newContext . dataFlowInfo . getStableTypes ( expressionDataFlowValue , components . languageVersionSettings ) <EOL> PrimitiveNumericComparisonCallChecker . inferPrimitiveNumericComparisonType ( context . trace , subjectStableTypes , expressionStableTypes , expression ) <EOL> val result = noChange ( newContext ) <EOL> return ConditionalDataFlowInfo ( result . thenInfo . equate ( subject . dataFlowValue , expressionDataFlowValue , identityEquals = facade . components . dataFlowAnalyzer . typeHasEqualsFromAny ( subject . type , expression ) , languageVersionSettings = components . languageVersionSettings ) , result . elseInfo . disequate ( subject . dataFlowValue , expressionDataFlowValue , components . languageVersionSettings ) ) <EOL> }


private fun checkTypeForIs ( context : ExpressionTypingContext , isCheck : KtElement , negated : Boolean , subjectType : KotlinType , typeReferenceAfterIs : KtTypeReference , subjectDataFlowValue : DataFlowValue ) : ConditionalDataFlowInfo

{ <EOL> val typeResolutionContext = <EOL> TypeResolutionContext ( context . scope , context . trace , true , true , context . isDebuggerContext ) <EOL> val possiblyBareTarget = components . typeResolver . resolvePossiblyBareType ( typeResolutionContext , typeReferenceAfterIs ) <EOL> val targetType = TypeReconstructionUtil . reconstructBareType ( typeReferenceAfterIs , possiblyBareTarget , subjectType , context . trace , components . builtIns ) <EOL> if ( targetType . isDynamic ( ) ) { <EOL> context . trace . report ( DYNAMIC_NOT_ALLOWED . on ( typeReferenceAfterIs ) ) <EOL> } <EOL> val targetDescriptor = TypeUtils . getClassDescriptor ( targetType ) <EOL> if ( targetDescriptor != null && DescriptorUtils . isEnumEntry ( targetDescriptor ) ) { <EOL> context . trace . report ( IS_ENUM_ENTRY . on ( typeReferenceAfterIs ) ) <EOL> } <EOL> if ( ! subjectType . containsError ( ) && ! TypeUtils . isNullableType ( subjectType ) && targetType . isMarkedNullable ) { <EOL> val element = typeReferenceAfterIs . typeElement <EOL> assert ( element is KtNullableType ) { "<STR_LIT>" + KtNullableType :: class . java . name } <EOL> context . trace . report ( USELESS_NULLABLE_CHECK . on ( element as KtNullableType ) ) <EOL> } <EOL> val typesAreCompatible = checkTypeCompatibility ( context , targetType , subjectType , typeReferenceAfterIs ) <EOL> detectRedundantIs ( context , subjectType , targetType , isCheck , negated , subjectDataFlowValue , typesAreCompatible ) <EOL> if ( context . languageVersionSettings . supportsFeature ( LanguageFeature . ProperCheckAnnotationsTargetInTypeUsePositions ) ) { <EOL> components . annotationChecker . check ( typeReferenceAfterIs , context . trace ) <EOL> } <EOL> if ( CastDiagnosticsUtil . isCastErased ( subjectType , targetType , KotlinTypeChecker . DEFAULT ) ) { <EOL> context . trace . report ( CANNOT_CHECK_FOR_ERASED . on ( typeReferenceAfterIs , targetType ) ) <EOL> } <EOL> return context . dataFlowInfo . let { <EOL> ConditionalDataFlowInfo ( it . establishSubtyping ( subjectDataFlowValue , targetType , components . languageVersionSettings ) , it ) <EOL> } <EOL> }


private fun detectRedundantIs ( context : ExpressionTypingContext , subjectType : KotlinType , targetType : KotlinType , isCheck : KtElement , negated : Boolean , subjectDataFlowValue : DataFlowValue , typesAreCompatible : Boolean )

{ <EOL> if ( subjectType . containsError ( ) || targetType . containsError ( ) ) return <EOL> val possibleTypes = <EOL> DataFlowAnalyzer . getAllPossibleTypes ( subjectType , context , subjectDataFlowValue , context . languageVersionSettings ) <EOL> if ( typesAreCompatible && ! targetType . isError ) { <EOL> val nonTrivialTypes = possibleTypes . filterNot { it . isAnyOrNullableAny ( ) } <EOL> . takeIf { it . isNotEmpty ( ) } <EOL> ? : possibleTypes <EOL> if ( nonTrivialTypes . none { CastDiagnosticsUtil . isCastPossible ( it , targetType , components . platformToKotlinClassMapper , components . platformSpecificCastChecker ) } ) { <EOL> context . trace . report ( USELESS_IS_CHECK . on ( isCheck , negated ) ) <EOL> } <EOL> } <EOL> if ( CastDiagnosticsUtil . isRefinementUseless ( possibleTypes , targetType , false ) ) { <EOL> context . trace . report ( USELESS_IS_CHECK . on ( isCheck , ! negated ) ) <EOL> } <EOL> }


private fun noChange ( context : ExpressionTypingContext )

= ConditionalDataFlowInfo ( context . dataFlowInfo )


private fun checkTypeCompatibility ( context : ExpressionTypingContext , type : KotlinType , subjectType : KotlinType , reportErrorOn : KtElement ) : Boolean

{ <EOL> if ( TypeIntersector . isIntersectionEmpty ( type , subjectType ) ) { <EOL> context . trace . report ( INCOMPATIBLE_TYPES . on ( reportErrorOn , type , subjectType ) ) <EOL> return false <EOL> } <EOL> checkEnumsForCompatibility ( context , reportErrorOn , subjectType , type ) <EOL> if ( KotlinBuiltIns . isNullableNothing ( type ) && ! TypeUtils . isNullableType ( subjectType ) ) { <EOL> context . trace . report ( SENSELESS_NULL_IN_WHEN . on ( reportErrorOn ) ) <EOL> } <EOL> return true <EOL> }


override fun process ( annotations : MutableSet < out TypeElement > ? , roundEnv : RoundEnvironment ) : Boolean

{ <EOL> val element = processingEnv . elementUtils . getTypeElement ( "<STR_LIT>" ) <EOL> val containerAnnotation = element . annotationMirrors . singleOrNull { <EOL> it . annotationType . asElement ( ) . simpleName . contentEquals ( "<STR_LIT>" ) && <EOL> it . annotationType . asElement ( ) . enclosingElement . simpleName . contentEquals ( "<STR_LIT>" ) <EOL> } <EOL> if ( containerAnnotation == null ) { <EOL> processingEnv . messager . printMessage ( Diagnostic . Kind . ERROR , "<STR_LIT>" + "<STR_LIT>" , element , ) <EOL> return true <EOL> } <EOL> val expected = "<STR_LIT>" <EOL> val actual = containerAnnotation . elementValues . toString ( ) <EOL> if ( actual != expected ) { <EOL> processingEnv . messager . printMessage ( Diagnostic . Kind . ERROR , "<STR_LIT>" ) <EOL> } <EOL> return true <EOL> }


override fun getSupportedSourceVersion ( ) : SourceVersion

= <EOL> SourceVersion . RELEASE_6


override fun getSupportedAnnotationTypes ( ) : Set < String >

= <EOL> setOf ( "<STR_LIT>" )


{ <EOL> val data = ProgrammingLanguage ( "<STR_LIT>" , SimpleDateFormat ( "<STR_LIT>" ) . parse ( "<STR_LIT>" ) ) <EOL> println ( Json . encodeToString ( data ) ) <EOL> }


fun < T > raiseConcern ( message : String , fallback : ( ) -> T ) : T

{ <EOL> val mode = getPanicMode ( ) <EOL> logger . debug ( message ) <EOL> return when ( mode ) { <EOL> PanicMode . ALWAYS_FAIL -> throw Exception ( message ) <EOL> PanicMode . NEVER_FAIL -> fallback . invoke ( ) <EOL> } <EOL> }


override fun accept ( visitor : InstructionVisitor )

{ <EOL> visitor . visitMarkInstruction ( this ) <EOL> }


override fun < R > accept ( visitor : InstructionVisitorWithResult < R > ) : R

= visitor . visitMarkInstruction ( this )


= MarkInstruction ( element , blockScope )


= "<STR_LIT>"


public open fun foo ( vararg s : String )

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


{ <EOL> Server ( ) . processRequest ( ) <EOL> ServerEx ( ) . processRequest ( ) <EOL> }


= x . compareTo ( y )


= y is Double && x . compareTo ( y ) == <NUM_LIT:0>


= x is Double && y is Double && x . compareTo ( y ) == <NUM_LIT:0>


= y is Float && x . compareTo ( y ) == <NUM_LIT:0>


= x is Float && y is Float && x . compareTo ( y ) == <NUM_LIT:0>


= x is Float && y is Double && x . compareTo ( y ) == <NUM_LIT:0>


= x is Double && y is Float && x . compareTo ( y ) == <NUM_LIT:0>


= compareTo ( x )


= x is Float && compareTo ( x ) == <NUM_LIT:0>


= x is Double && compareTo ( x ) == <NUM_LIT:0>


fun < X > pullXb ( x : X ) : BiType < X , LevelB >

= TODO ( )


fun < Y > pullYb ( y : Y ) : BiType < LevelB , Y >

= TODO ( )


fun < X > pullXn ( x : X ) : BiType < X , Nothing >

= TODO ( )


fun < Y > pullYn ( y : Y ) : BiType < Nothing , Y >

= TODO ( )


fun < X > adjustIt ( fn : ( ) -> X ) : X

= TODO ( )


= TODO ( )


fun < X > callAdjustIt ( t : BiType < * , * > , x : X , level : LevelA )

{ <EOL> val x1 = adjustIt ( { t . pullXb ( x ) } ) <EOL> x1 <EOL> val x2 = adjustIt ( { t . pullXn ( x ) } ) <EOL> x2 <EOL> val x3 = adjustIt ( { t . pullXb ( x ) } , { t . pullYb ( level ) } ) <EOL> x3 <EOL> val x4 = adjustIt ( { t . pullXn ( x ) } , { t . pullYn ( level ) } ) <EOL> x4 <EOL> }


fun benchmarksProject ( buildVersion : BuildType )

= Project { <EOL> this . id ( "<STR_LIT>" ) <EOL> this . name = "<STR_LIT>" <EOL> params { <EOL> param ( "<STR_LIT>" , "<STR_LIT:true>" ) <EOL> } <EOL> val benchmarkAll = benchmarkAll ( buildVersion ) <EOL> val benchmarks = listOf ( benchmark ( "<STR_LIT:js>" , Platform . Linux , buildVersion ) , benchmark ( "<STR_LIT:jvm>" , Platform . Linux , buildVersion ) , * platforms . map { benchmark ( "<STR_LIT:native>" , it , buildVersion ) } . toTypedArray ( ) ) <EOL> benchmarks . forEach { benchmark -> <EOL> benchmarkAll . dependsOnSnapshot ( benchmark , onFailure = FailureAction . ADD_PROBLEM ) <EOL> benchmarkAll . dependsOn ( benchmark ) { <EOL> artifacts { <EOL> artifactRules = "<STR_LIT>" <EOL> } <EOL> } <EOL> } <EOL> buildTypesOrder = listOf ( benchmarkAll , * benchmarks . toTypedArray ( ) ) <EOL> }


fun Project . benchmarkAll ( buildVersion : BuildType )

= BuildType { <EOL> id ( "<STR_LIT>" ) <EOL> this . name = "<STR_LIT>" <EOL> type = BuildTypeSettings . Type . COMPOSITE <EOL> dependsOnSnapshot ( buildVersion ) <EOL> buildNumberPattern = buildVersion . depParamRefs . buildNumber . ref <EOL> commonConfigure ( ) <EOL> failureConditions { <EOL> executionTimeoutMin = <NUM_LIT> <EOL> } <EOL> } . also { buildType ( it ) }


fun Project . benchmark ( target : String , platform : Platform , buildVersion : BuildType )

= buildType ( "<STR_LIT>" , platform ) { <EOL> dependsOnSnapshot ( buildVersion ) <EOL> params { <EOL> param ( versionSuffixParameter , buildVersion . depParamRefs [ versionSuffixParameter ] . ref ) <EOL> param ( teamcitySuffixParameter , buildVersion . depParamRefs [ teamcitySuffixParameter ] . ref ) <EOL> } <EOL> steps { <EOL> gradle { <EOL> name = "<STR_LIT>" <EOL> tasks = benchmarkTask ( target , platform ) <EOL> jdkHome = "<STR_LIT>" <EOL> gradleParams = "<STR_LIT>" <EOL> buildFile = "<STR_LIT>" <EOL> gradleWrapperPath = "<STR_LIT>" <EOL> } <EOL> } <EOL> artifactRules = "<STR_LIT>" <EOL> requirements { <EOL> benchmarkAgentInstanceTypeRequirement ( platform ) <EOL> } <EOL> failureConditions { <EOL> executionTimeoutMin = <NUM_LIT> <EOL> } <EOL> }


fun benchmarkTask ( target : String , platform : Platform ) : String

= when ( target ) { <EOL> "<STR_LIT:js>" , "<STR_LIT:jvm>" -> "<STR_LIT>" <EOL> "<STR_LIT:native>" -> "<STR_LIT>" <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> }


fun Requirements . benchmarkAgentInstanceTypeRequirement ( platform : Platform )

{ <EOL> if ( platform == Platform . Linux || platform == Platform . Windows ) { <EOL> matches ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> } <EOL> }


@ Test <EOL> fun `should parse versions` ( )

{ <EOL> assertParsedVersion ( input = "<STR_LIT>" , expectedMajor = <NUM_LIT:1> , expectedMinor = <NUM_LIT:7> , expectedPatch = <NUM_LIT> ) <EOL> assertParsedVersion ( input = "<STR_LIT>" , expectedMajor = <NUM_LIT:2> , expectedMinor = <NUM_LIT:0> , expectedPatch = <NUM_LIT:0> ) <EOL> assertParsedVersion ( input = "<STR_LIT>" , expectedMajor = <NUM_LIT:1> , expectedMinor = <NUM_LIT:8> , expectedPatch = <NUM_LIT> ) <EOL> assertParsedVersion ( input = "<STR_LIT>" , expectedMajor = <NUM_LIT:1> , expectedMinor = <NUM_LIT:5> , expectedPatch = <NUM_LIT> ) <EOL> assertParsedVersion ( input = "<STR_LIT>" , expectedMajor = <NUM_LIT:2> , expectedMinor = <NUM_LIT:7> , expectedPatch = <NUM_LIT> ) <EOL> assertParsedVersion ( input = "<STR_LIT>" , expectedMajor = <NUM_LIT:1> , expectedMinor = <NUM_LIT:7> , expectedPatch = <NUM_LIT:100> ) <EOL> }


@ Test <EOL> fun `should return null on non parsable string` ( )

{ <EOL> assertNull ( parse ( "<STR_LIT:1.7>" ) ) <EOL> assertNull ( parse ( "<STR_LIT:1>" ) ) <EOL> assertNull ( parse ( "<STR_LIT:6>" ) ) <EOL> assertNull ( parse ( "<STR_LIT>" ) ) <EOL> assertNull ( parse ( "<STR_LIT>" ) ) <EOL> assertNull ( parse ( "<STR_LIT>" ) ) <EOL> assertNull ( parse ( "<STR_LIT>" ) ) <EOL> }


@ Test <EOL> fun `should compare simple versions` ( )

{ <EOL> assertEquals ( <NUM_LIT:0> , KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:0> ) . compareTo ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:0> ) ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:10> ) >= KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:10> ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:10> ) < KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:20> ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:10> ) > KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:0> ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT> ) <= KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT> ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT> ) < KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:20> ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT> ) > KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> ) > KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:8> , <NUM_LIT:0> ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:31> ) < KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:0> ) ) <EOL> }


@ Test <EOL> fun `should compare custom dev versions with trailing strings` ( )

{ <EOL> assertEquals ( <NUM_LIT:0> , KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:0> ) . compareTo ( parseNotNull ( "<STR_LIT>" ) ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:10> ) >= parseNotNull ( "<STR_LIT>" ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:10> ) < parseNotNull ( "<STR_LIT>" ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:6> , <NUM_LIT:10> ) > parseNotNull ( "<STR_LIT>" ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT> ) <= parseNotNull ( "<STR_LIT>" ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT> ) < parseNotNull ( "<STR_LIT>" ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT> ) > parseNotNull ( "<STR_LIT>" ) ) <EOL> assertTrue ( KotlinGradlePluginVersion ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> ) > parseNotNull ( "<STR_LIT>" ) ) <EOL> }


private fun assertParsedVersion ( input : String , expectedMajor : Int , expectedMinor : Int , expectedPatch : Int )

{ <EOL> val kgpVersion = parseNotNull ( input ) <EOL> assertEquals ( expectedMajor , kgpVersion . major ) <EOL> assertEquals ( expectedMinor , kgpVersion . minor ) <EOL> assertEquals ( expectedPatch , kgpVersion . patch ) <EOL> assertEquals ( KotlinGradlePluginVersion ( expectedMajor , expectedMinor , expectedPatch ) , kgpVersion ) <EOL> }


private fun parseNotNull ( input : String ) : KotlinGradlePluginVersion

= assertNotNull ( parse ( input ) )


private fun parse ( input : String ) : KotlinGradlePluginVersion ?

= parseKotlinVersion ( input )


public abstract fun getSmartCastedInfo ( expression : KtExpression ) : KtSmartCastInfo ?


public abstract fun getImplicitReceiverSmartCast ( expression : KtExpression ) : Collection < KtImplicitReceiverSmartCast >


public fun KtExpression . getSmartCastInfo ( ) : KtSmartCastInfo ?

= <EOL> withValidityAssertion { analysisSession . smartCastProvider . getSmartCastedInfo ( this ) }

/**
 * Gets the smart-cast information of the given expression or null if the expression is not smart casted.
 */


public fun KtExpression . getImplicitReceiverSmartCast ( ) : Collection < KtImplicitReceiverSmartCast >

= <EOL> withValidityAssertion { analysisSession . smartCastProvider . getImplicitReceiverSmartCast ( this ) }

/**
 * Returns the list of implicit smart-casts which are required for the expression to be called. Includes only implicit
 * smart-casts:
 *
 * ```kt
 * if (this is String) {
 * this.substring() // 'this' receiver is explicit, so no implicit smart-cast here.
 *
 * smartcast() // 'this' receiver is implicit, therefore there is implicit smart-cast involved.
 * }
 * ```
 */


fun testResource ( resourcePath : String ) : URL

= object { } :: class . java . classLoader . getResource ( resourcePath ) ! !


= testResource ( "<STR_LIT>" )


operator fun getValue ( t : Any ? , p : KProperty < * > ) : Int

= inner


operator fun setValue ( t : Any ? , p : KProperty < * > , i : Int )

{ inner = i }


{ <EOL> val c = A ( ) <EOL> if ( c . prop != <NUM_LIT:1> ) return "<STR_LIT>" <EOL> c . prop = <NUM_LIT:2> <EOL> if ( c . prop != <NUM_LIT:2> ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


@ Test <EOL> fun testSequentialDecoding ( )

{ <EOL> SimpleObject . serializer ( ) . deserialize ( DummySequentialDecoder ( ) ) <EOL> }


fun check ( c : TopDownAnalysisContext )

{ <EOL> core . check ( c ) <EOL> }


{ <EOL> checkClasses ( c ) <EOL> checkMembers ( c ) <EOL> }


private fun checkClasses ( c : TopDownAnalysisContext )

{ <EOL> for ( classOrObject in c . declaredClasses ! ! . keys ) { <EOL> if ( classOrObject is KtClass ) { <EOL> checkClassHeader ( classOrObject ) <EOL> } <EOL> } <EOL> }


fun checkClassHeader ( klass : KtClass ) : Boolean

{ <EOL> var noError = true <EOL> for ( specifier in klass . superTypeListEntries ) { <EOL> noError = noError and specifier . typeReference ? . checkTypePosition ( context , OUT_VARIANCE ) <EOL> } <EOL> return noError and klass . checkTypeParameters ( context , OUT_VARIANCE ) <EOL> }


private fun checkMembers ( c : TopDownAnalysisContext )

{ <EOL> for ( ( declaration , descriptor ) in c . members ) { <EOL> checkMember ( declaration , descriptor ) <EOL> } <EOL> }


fun checkMember ( member : KtCallableDeclaration , descriptor : CallableMemberDescriptor )

= <EOL> DescriptorVisibilities . isPrivate ( descriptor . visibility ) || checkCallableDeclaration ( context , member , descriptor )


private fun TypeParameterDescriptor . varianceWithManual ( )

= <EOL> if ( manualVariance != null && this . original == manualVariance . descriptor ) manualVariance . variance else variance


fun recordPrivateToThisIfNeeded ( descriptor : CallableMemberDescriptor )

{ <EOL> if ( isIrrelevant ( descriptor ) || descriptor . visibility != DescriptorVisibilities . PRIVATE ) return <EOL> val psiElement = descriptor . source . getPsi ( ) as? KtCallableDeclaration ? : return <EOL> if ( ! checkCallableDeclaration ( context , psiElement , descriptor ) ) { <EOL> recordPrivateToThis ( descriptor ) <EOL> } <EOL> }


private fun checkCallableDeclaration ( trace : BindingContext , declaration : KtCallableDeclaration , descriptor : CallableDescriptor ) : Boolean

{ <EOL> if ( isIrrelevant ( descriptor ) ) return true <EOL> var noError = true <EOL> noError = noError and declaration . checkTypeParameters ( trace , IN_VARIANCE ) <EOL> noError = noError and declaration . receiverTypeReference ? . checkTypePosition ( trace , IN_VARIANCE ) <EOL> for ( parameter in declaration . valueParameters ) { <EOL> noError = noError and parameter . typeReference ? . checkTypePosition ( trace , IN_VARIANCE ) <EOL> } <EOL> val returnTypePosition = if ( descriptor is VariableDescriptor && descriptor . isVar ) INVARIANT else OUT_VARIANCE <EOL> noError = noError and declaration . createTypeBindingForReturnType ( trace ) ? . checkTypePosition ( returnTypePosition ) <EOL> return noError <EOL> }


private fun KtTypeParameterListOwner . checkTypeParameters ( trace : BindingContext , typePosition : Variance ) : Boolean

{ <EOL> var noError = true <EOL> for ( typeParameter in typeParameters ) { <EOL> noError = noError and typeParameter . extendsBound ? . checkTypePosition ( trace , typePosition ) <EOL> } <EOL> for ( typeConstraint in typeConstraints ) { <EOL> noError = noError and typeConstraint . boundTypeReference ? . checkTypePosition ( trace , typePosition ) <EOL> } <EOL> return noError <EOL> }


private fun KtTypeReference . checkTypePosition ( trace : BindingContext , position : Variance )

= <EOL> createTypeBinding ( trace ) ? . checkTypePosition ( position )


private fun TypeBinding < PsiElement > . checkTypePosition ( position : Variance )

= checkTypePosition ( type , position )


private fun TypeBinding < PsiElement > . checkTypePosition ( containingType : KotlinType , position : Variance ) : Boolean

{ <EOL> val classifierDescriptor = type . constructor . declarationDescriptor <EOL> if ( classifierDescriptor is TypeParameterDescriptor ) { <EOL> val declarationVariance = classifierDescriptor . varianceWithManual ( ) <EOL> if ( ! declarationVariance . allowsPosition ( position ) && ! type . annotations . hasAnnotation ( StandardNames . FqNames . unsafeVariance ) ) { <EOL> val varianceConflictDiagnosticData = VarianceConflictDiagnosticData ( containingType , classifierDescriptor , position ) <EOL> when { <EOL> isArgumentFromQualifier -> <EOL> diagnosticSink . report ( Errors . TYPE_VARIANCE_CONFLICT . on ( languageVersionSettings ? : LanguageVersionSettingsImpl . DEFAULT , psiElement , varianceConflictDiagnosticData ) ) <EOL> isInAbbreviation -> <EOL> diagnosticSink . report ( Errors . TYPE_VARIANCE_CONFLICT_IN_EXPANDED_TYPE . on ( psiElement , varianceConflictDiagnosticData ) ) <EOL> else -> <EOL> diagnosticSink . report ( Errors . TYPE_VARIANCE_CONFLICT . errorFactory . on ( psiElement , varianceConflictDiagnosticData ) ) <EOL> } <EOL> } <EOL> return declarationVariance . allowsPosition ( position ) <EOL> } <EOL> var noError = true <EOL> for ( argument in arguments ) { <EOL> if ( argument ? . typeParameter == null || argument . projection . isStarProjection ) continue <EOL> val newPosition = when ( TypeCheckingProcedure . getEffectiveProjectionKind ( argument . typeParameter ! ! , argument . projection ) ! ! ) { <EOL> EnrichedProjectionKind . OUT -> position <EOL> EnrichedProjectionKind . IN -> position . opposite ( ) <EOL> EnrichedProjectionKind . INV -> INVARIANT <EOL> EnrichedProjectionKind . STAR -> null <EOL> } <EOL> if ( newPosition != null ) { <EOL> noError = noError and argument . binding . checkTypePosition ( containingType , newPosition ) <EOL> } <EOL> } <EOL> return noError <EOL> }


private fun isIrrelevant ( descriptor : CallableDescriptor ) : Boolean

{ <EOL> val containingClass = descriptor . containingDeclaration as? ClassDescriptor ? : return true <EOL> return containingClass . typeConstructor . parameters . all { it . varianceWithManual ( ) == INVARIANT } <EOL> }


private fun recordPrivateToThis ( descriptor : CallableMemberDescriptor )

{ <EOL> when ( descriptor ) { <EOL> is FunctionDescriptorImpl -> descriptor . visibility = DescriptorVisibilities . PRIVATE_TO_THIS <EOL> is PropertyDescriptorImpl -> { <EOL> descriptor . visibility = DescriptorVisibilities . PRIVATE_TO_THIS <EOL> for ( accessor in descriptor . accessors ) { <EOL> ( accessor as PropertyAccessorDescriptorImpl ) . visibility = DescriptorVisibilities . PRIVATE_TO_THIS <EOL> } <EOL> } <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> }


private infix fun Boolean . and ( other : Boolean ? )

= if ( other == null ) this else this and other


fun @ receiver : Ann String . f ( ) : String

= "<STR_LIT>"


fun @ receiver : Ann String ? . topLevelF ( ) : String

= "<STR_LIT>"


{ <EOL> if ( a !is Int ) return intArrayOf ( ) <EOL> return intArrayOf ( a ) <EOL> }


{ <EOL> if ( a !is IntArray ) return intArrayOf ( ) <EOL> return intArrayOf ( * a ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun UIntArray . elementAt ( index : Int ) : UInt

{ <EOL> return get ( index ) <EOL> }

/**
 * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
 *
 * @sample samples.collections.Collections.Elements.elementAt
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun ULongArray . elementAt ( index : Int ) : ULong

{ <EOL> return get ( index ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun UByteArray . elementAt ( index : Int ) : UByte

{ <EOL> return get ( index ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun UShortArray . elementAt ( index : Int ) : UShort

{ <EOL> return get ( index ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public actual fun UIntArray . asList ( ) : List < UInt >

{ <EOL> return object : AbstractList < UInt > ( ) , RandomAccess { <EOL> override val size : Int get ( ) = this@asList . size <EOL> override fun isEmpty ( ) : Boolean = this@asList . isEmpty ( ) <EOL> override fun contains ( element : UInt ) : Boolean = this@asList . contains ( element ) <EOL> override fun get ( index : Int ) : UInt = this@asList [ index ] <EOL> override fun indexOf ( element : UInt ) : Int = this@asList . indexOf ( element ) <EOL> override fun lastIndexOf ( element : UInt ) : Int = this@asList . lastIndexOf ( element ) <EOL> } <EOL> }

/**
 * Returns a [List] that wraps the original array.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public actual fun ULongArray . asList ( ) : List < ULong >

{ <EOL> return object : AbstractList < ULong > ( ) , RandomAccess { <EOL> override val size : Int get ( ) = this@asList . size <EOL> override fun isEmpty ( ) : Boolean = this@asList . isEmpty ( ) <EOL> override fun contains ( element : ULong ) : Boolean = this@asList . contains ( element ) <EOL> override fun get ( index : Int ) : ULong = this@asList [ index ] <EOL> override fun indexOf ( element : ULong ) : Int = this@asList . indexOf ( element ) <EOL> override fun lastIndexOf ( element : ULong ) : Int = this@asList . lastIndexOf ( element ) <EOL> } <EOL> }


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public actual fun UByteArray . asList ( ) : List < UByte >

{ <EOL> return object : AbstractList < UByte > ( ) , RandomAccess { <EOL> override val size : Int get ( ) = this@asList . size <EOL> override fun isEmpty ( ) : Boolean = this@asList . isEmpty ( ) <EOL> override fun contains ( element : UByte ) : Boolean = this@asList . contains ( element ) <EOL> override fun get ( index : Int ) : UByte = this@asList [ index ] <EOL> override fun indexOf ( element : UByte ) : Int = this@asList . indexOf ( element ) <EOL> override fun lastIndexOf ( element : UByte ) : Int = this@asList . lastIndexOf ( element ) <EOL> } <EOL> }


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public actual fun UShortArray . asList ( ) : List < UShort >

{ <EOL> return object : AbstractList < UShort > ( ) , RandomAccess { <EOL> override val size : Int get ( ) = this@asList . size <EOL> override fun isEmpty ( ) : Boolean = this@asList . isEmpty ( ) <EOL> override fun contains ( element : UShort ) : Boolean = this@asList . contains ( element ) <EOL> override fun get ( index : Int ) : UShort = this@asList [ index ] <EOL> override fun indexOf ( element : UShort ) : Int = this@asList . indexOf ( element ) <EOL> override fun lastIndexOf ( element : UShort ) : Int = this@asList . lastIndexOf ( element ) <EOL> } <EOL> }


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public infix fun UIntArray . contentEquals ( other : UIntArray ) : Boolean

{ <EOL> return this . contentEquals ( other ) <EOL> }

/**
 * Checks if the two specified arrays are *structurally* equal to one another.
 *
 * Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
 *
 * @param other the array to compare with this array.
 * @return `true` if the two arrays are structurally equal, `false` otherwise.
 *
 * @sample samples.collections.Arrays.ContentOperations.intArrayContentEquals
 */


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public infix fun ULongArray . contentEquals ( other : ULongArray ) : Boolean


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public infix fun UByteArray . contentEquals ( other : UByteArray ) : Boolean


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public infix fun UShortArray . contentEquals ( other : UShortArray ) : Boolean


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun UIntArray . contentHashCode ( ) : Int

{ <EOL> return this . contentHashCode ( ) <EOL> }

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun ULongArray . contentHashCode ( ) : Int


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun UByteArray . contentHashCode ( ) : Int


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun UShortArray . contentHashCode ( ) : Int


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun UIntArray . contentToString ( ) : String

{ <EOL> return this . contentToString ( ) <EOL> }

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 *
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun ULongArray . contentToString ( ) : String


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun UByteArray . contentToString ( ) : String


@ Deprecated ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ DeprecatedSinceKotlin ( hiddenSince = "<STR_LIT:1.4>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> public fun UShortArray . contentToString ( ) : String


internal fun getTaskResult ( event : TaskFinishEvent )

= when ( val result = event . result ) { <EOL> is TaskSuccessResult -> when { <EOL> result . isFromCache -> TaskExecutionState . FROM_CACHE <EOL> result . isUpToDate -> TaskExecutionState . UP_TO_DATE <EOL> else -> TaskExecutionState . SUCCESS <EOL> } <EOL> is TaskSkippedResult -> TaskExecutionState . SKIPPED <EOL> is TaskFailureResult -> TaskExecutionState . FAILED <EOL> else -> TaskExecutionState . UNKNOWN <EOL> }


internal fun prepareData ( event : TaskFinishEvent , projectName : String , uuid : String , label : String ? , kotlinVersion : String , buildOperationRecord : BuildOperationRecord , onlyKotlinTask : Boolean = true , additionalTags : Set < StatTag > = emptySet ( ) , metricsToShow : Set < String > ? = null ) : GradleCompileStatisticsData ?

{ <EOL> val result = event . result <EOL> val taskPath = event . descriptor . taskPath <EOL> return prepareData ( getTaskResult ( event ) , taskPath , result . startTime , result . endTime - result . startTime , projectName , uuid , label , kotlinVersion , buildOperationRecord , onlyKotlinTask , additionalTags , metricsToShow ) <EOL> }


internal fun prepareData ( taskResult : TaskExecutionState ? , taskPath : String , startTime : Long , finishTime : Long , projectName : String , uuid : String , label : String ? , kotlinVersion : String , buildOperationRecord : BuildOperationRecord , onlyKotlinTask : Boolean = true , additionalTags : Set < StatTag > = emptySet ( ) , metricsToShow : Set < String > ? = null ) : GradleCompileStatisticsData ?

{ <EOL> if ( onlyKotlinTask && ! ( buildOperationRecord is TaskRecord && buildOperationRecord . isFromKotlinPlugin ) ) { <EOL> return null <EOL> } <EOL> val buildMetrics = buildOperationRecord . buildMetrics <EOL> val performanceMetrics = collectBuildPerformanceMetrics ( buildMetrics ) <EOL> val buildTimesMetrics = collectBuildMetrics ( buildMetrics , startTime , System . currentTimeMillis ( ) ) <EOL> val buildAttributes = collectBuildAttributes ( buildMetrics ) <EOL> val changes = if ( buildOperationRecord is TaskRecord && buildOperationRecord . changedFiles is SourcesChanges . Known ) { <EOL> buildOperationRecord . changedFiles . modifiedFiles . map { it . absolutePath } + buildOperationRecord . changedFiles . removedFiles . map { it . absolutePath } <EOL> } else { <EOL> emptyList < String > ( ) <EOL> } <EOL> val kotlinLanguageVersion = if ( buildOperationRecord is TaskRecord ) buildOperationRecord . kotlinLanguageVersion else null <EOL> return GradleCompileStatisticsData ( durationMs = buildOperationRecord . totalTimeMs , taskResult = taskResult ? . name , label = label , buildTimesMetrics = filterMetrics ( metricsToShow , buildTimesMetrics ) , performanceMetrics = filterMetrics ( metricsToShow , performanceMetrics ) , projectName = projectName , taskName = taskPath , changes = changes , tags = collectTags ( buildOperationRecord , additionalTags ) , nonIncrementalAttributes = buildAttributes , hostName = BuildReportsService . hostName , kotlinVersion = kotlinVersion , kotlinLanguageVersion = kotlinLanguageVersion ? . version , buildUuid = uuid , compilerArguments = collectCompilerArguments ( buildOperationRecord ) , gcCountMetrics = buildMetrics . gcMetrics . asGcCountMap ( ) , gcTimeMetrics = buildMetrics . gcMetrics . asGcTimeMap ( ) , finishTime = finishTime , startTimeMs = startTime , fromKotlinPlugin = buildOperationRecord . isFromKotlinPlugin , skipMessage = buildOperationRecord . skipMessage , icLogLines = buildOperationRecord . icLogLines ) <EOL> }


fun collectCompilerArguments ( buildOperationRecord : BuildOperationRecord ? ) : List < String >

{ <EOL> return if ( buildOperationRecord is TaskRecord ) { <EOL> buildOperationRecord . compilerArguments . asList ( ) <EOL> } else emptyList ( ) <EOL> }


private fun < E : BuildTime > filterMetrics ( expectedMetrics : Set < String > ? , buildTimesMetrics : Map < E , Long > ) : Map < E , Long >

= expectedMetrics ? . let { buildTimesMetrics . filterKeys { metric -> it . contains ( metric . getName ( ) ) } } ? : buildTimesMetrics


private fun collectBuildAttributes ( buildMetrics : BuildMetrics < GradleBuildTime , GradleBuildPerformanceMetric > ? ) : Set < BuildAttribute >

{ <EOL> return buildMetrics ? . buildAttributes ? . asMap ( ) ? . filter { it . value > <NUM_LIT:0> } ? . keys ? : emptySet ( ) <EOL> }


private fun collectBuildPerformanceMetrics ( buildMetrics : BuildMetrics < GradleBuildTime , GradleBuildPerformanceMetric > ? <EOL> ) : Map < GradleBuildPerformanceMetric , Long >

{ <EOL> return buildMetrics ? . buildPerformanceMetrics ? . asMap ( ) <EOL> ? . filterValues { value -> value != <NUM_LIT:0L> } <EOL> ? . filterKeys { key -> <EOL> key !in listOf ( GradleBuildPerformanceMetric . START_WORKER_EXECUTION , GradleBuildPerformanceMetric . CALL_WORKER , GradleBuildPerformanceMetric . CALL_KOTLIN_DAEMON , GradleBuildPerformanceMetric . START_KOTLIN_DAEMON_EXECUTION ) <EOL> } <EOL> ? : emptyMap ( ) <EOL> }


private fun collectBuildMetrics ( buildMetrics : BuildMetrics < GradleBuildTime , GradleBuildPerformanceMetric > ? , gradleTaskStartTime : Long ? = null , taskFinishEventTime : Long ? = null , ) : Map < GradleBuildTime , Long >

{ <EOL> val taskBuildMetrics = HashMap < GradleBuildTime , Long > ( buildMetrics ? . buildTimes ? . asMapMs ( ) ) <EOL> val performanceMetrics = buildMetrics ? . buildPerformanceMetrics ? . asMap ( ) ? : emptyMap ( ) <EOL> gradleTaskStartTime ? . let { startTime -> <EOL> performanceMetrics [ GradleBuildPerformanceMetric . START_TASK_ACTION_EXECUTION ] ? . let { actionStartTime -> <EOL> taskBuildMetrics . put ( GradleBuildTime . GRADLE_TASK_PREPARATION , actionStartTime - startTime ) <EOL> } <EOL> } <EOL> taskFinishEventTime ? . let { listenerNotificationTime -> <EOL> performanceMetrics [ GradleBuildPerformanceMetric . FINISH_KOTLIN_DAEMON_EXECUTION ] ? . let { daemonFinishTime -> <EOL> taskBuildMetrics . put ( GradleBuildTime . TASK_FINISH_LISTENER_NOTIFICATION , listenerNotificationTime - daemonFinishTime ) <EOL> } <EOL> } <EOL> performanceMetrics [ GradleBuildPerformanceMetric . CALL_WORKER ] ? . let { callWorkerTime -> <EOL> performanceMetrics [ GradleBuildPerformanceMetric . START_WORKER_EXECUTION ] ? . let { startWorkerExecutionTime -> <EOL> taskBuildMetrics . put ( GradleBuildTime . RUN_WORKER_DELAY , TimeUnit . NANOSECONDS . toMillis ( startWorkerExecutionTime - callWorkerTime ) ) <EOL> } <EOL> } <EOL> return taskBuildMetrics . filterValues { value -> value != <NUM_LIT:0L> } <EOL> }


private fun collectTags ( buildOperation : BuildOperationRecord ? , additionalTags : Set < StatTag > ) : Set < StatTag >

{ <EOL> val tags = HashSet ( additionalTags ) <EOL> if ( buildOperation is TaskRecord ) { <EOL> tags . addAll ( collectTaskRecordTags ( buildOperation ) ) <EOL> } <EOL> val nonIncrementalAttributes = collectBuildAttributes ( buildOperation ? . buildMetrics ) <EOL> if ( nonIncrementalAttributes . isEmpty ( ) ) { <EOL> tags . add ( StatTag . INCREMENTAL ) <EOL> } else { <EOL> tags . add ( StatTag . NON_INCREMENTAL ) <EOL> } <EOL> return tags <EOL> }


private fun collectTaskRecordTags ( taskRecord : TaskRecord ? , ) : Set < StatTag >

{ <EOL> val tags = HashSet < StatTag > ( ) <EOL> taskRecord ? . kotlinLanguageVersion ? . also { <EOL> tags . add ( getLanguageVersionTag ( it ) ) <EOL> } <EOL> taskRecord ? . statTags ? . let { tags . addAll ( it ) } <EOL> return tags <EOL> }


private fun getLanguageVersionTag ( languageVersion : KotlinVersion ) : StatTag

{ <EOL> return when { <EOL> languageVersion < KotlinVersion . KOTLIN_2_0 -> StatTag . KOTLIN_1 <EOL> else -> StatTag . KOTLIN_2 <EOL> } <EOL> }


fun A . create ( init : A . ( ) -> Unit ) : A

{ <EOL> init ( ) <EOL> return this <EOL> }


{ <EOL> val a = A ( ) . create { <EOL> c = <NUM_LIT:1> + t <EOL> } <EOL> if ( a . c != <NUM_LIT:4> ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


private fun Expect < Struct > . isOfType ( type : String )

{ <EOL> feature { f ( it :: type ) } . toEqual ( type ) <EOL> }


private fun hasStruct ( name : String , expectedField : Expect < StructField > . ( ) -> Unit , vararg expectedFields : Expect < StructField > . ( ) -> Unit , ) : Expect < StructField > . ( ) -> Unit

{ <EOL> return { <EOL> feature { f ( it :: name ) } . toEqual ( name ) <EOL> feature { f ( it :: type ) } . toBeAnInstanceOf ( fun Expect < StructType > . ( ) { <EOL> feature { f ( it . value :: fields ) } . notToEqualNull ( ) . toContain . inAnyOrder . only . entries ( expectedField , * expectedFields ) <EOL> } ) <EOL> } <EOL> }


private fun hasField ( name : String , type : String ) : Expect < StructField > . ( ) -> Unit

= { <EOL> feature { f ( it :: name ) } . toEqual ( name ) <EOL> feature { f ( it :: type ) } . isA < TypeName > ( ) . feature { f ( it :: value ) } . toEqual ( type ) <EOL> }


fun < T > shuffle ( x : List < T > ) : List < T >

= x


{ <EOL> val s : ( List < String > ) -> List < String > = :: shuffle <EOL> }


{ <EOL> return Iterable ( { <EOL> iterator ( { <EOL> var i = <NUM_LIT:1> <EOL> while ( i <= <NUM_LIT:3> ) { <EOL> yield ( i ) <EOL> i ++ <EOL> } <EOL> } ) <EOL> } ) <EOL> }


{ <EOL> return Iterable ( { <EOL> iterator ( { <EOL> yieldAll ( f ( ) ) <EOL> yieldAll ( f ( ) ) <EOL> } ) <EOL> } ) <EOL> }


{ <EOL> for ( x in g ( ) ) { <EOL> console . log ( x ) <EOL> } <EOL> }


override fun containsKey ( key : Any ) : Boolean

= true


override fun containsValue ( value : Any ) : Boolean

= true


= Any ( )


override fun remove ( key : Any ) : Any ?

= Any ( )


= true


override fun put ( key : Any , value : Any ) : Any ?

= throw UnsupportedOperationException ( )


override fun putAll ( from : Map < out Any , Any > ) : Unit


{ <EOL> val n = NotEmptyMap as MutableMap < Any ? , Any ? > <EOL> if ( n . get ( null ) != null ) return "<STR_LIT:failU+00201>" <EOL> if ( n . containsKey ( null ) ) return "<STR_LIT:failU+00202>" <EOL> if ( n . containsValue ( null ) ) return "<STR_LIT:failU+00203>" <EOL> if ( n . remove ( null ) != null ) return "<STR_LIT:failU+00204>" <EOL> if ( n . get ( "<STR_LIT>" ) == null ) return "<STR_LIT:failU+00205>" <EOL> if ( ! n . containsKey ( "<STR_LIT>" ) ) return "<STR_LIT>" <EOL> if ( ! n . containsValue ( "<STR_LIT>" ) ) return "<STR_LIT>" <EOL> if ( n . remove ( "<STR_LIT>" ) == null ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


protected fun findFirDeclarationToResolve ( ktFile : KtFile , testServices : TestServices , firResolveSession : LLFirResolveSession , ) : Pair < FirElementWithResolveState , ( ( FirResolvePhase ) -> Unit ) >

= when { <EOL> Directives . RESOLVE_FILE in testServices . moduleStructure . allDirectives -> { <EOL> val session = firResolveSession . useSiteFirSession as LLFirResolvableModuleSession <EOL> val file = session . moduleComponents . firFileBuilder . buildRawFirFileWithCaching ( ktFile ) <EOL> file to fun ( phase : FirResolvePhase ) { <EOL> file . lazyResolveToPhaseByDirective ( phase , testServices ) <EOL> } <EOL> } <EOL> else -> { <EOL> val ktDeclaration = if ( Directives . RESOLVE_SCRIPT in testServices . moduleStructure . allDirectives ) { <EOL> ktFile . script ! ! <EOL> } else { <EOL> testServices . expressionMarkerProvider . getElementOfTypeAtCaret < KtDeclaration > ( ktFile ) <EOL> } <EOL> val declarationSymbol = ktDeclaration . resolveToFirSymbol ( firResolveSession ) <EOL> val firDeclaration = chooseMemberDeclarationIfNeeded ( declarationSymbol , testServices . moduleStructure , firResolveSession ) . fir <EOL> firDeclaration to fun ( phase : FirResolvePhase ) { <EOL> firDeclaration . lazyResolveToPhaseByDirective ( phase , testServices ) <EOL> } <EOL> } <EOL> }


protected fun chooseMemberDeclarationIfNeeded ( symbol : FirBasedSymbol < * > , moduleStructure : TestModuleStructure , session : LLFirResolveSession , ) : FirBasedSymbol < * >

{ <EOL> val directives = moduleStructure . allDirectives <EOL> val memberClassFilters = listOfNotNull ( directives . singleOrZeroValue ( Directives . MEMBER_CLASS_FILTER ) , directives . singleOrZeroValue ( Directives . MEMBER_NAME_FILTER ) , ) . ifEmpty { return symbol } <EOL> val ( classSymbol , declarations ) = when ( symbol ) { <EOL> is FirClassSymbol -> symbol to symbol . declarationSymbols <EOL> is FirScriptSymbol -> { <EOL> symbol to symbol . fir . let { it . parameters + it . declarations } . map { it . symbol } <EOL> } <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> val filter = { declaration : FirBasedSymbol < * > -> memberClassFilters . all { it . invoke ( declaration ) } } <EOL> val filteredSymbols = declarations . filter ( filter ) <EOL> return when ( filteredSymbols . size ) { <EOL> <NUM_LIT:0> -> { <EOL> ( classSymbol as? FirClassSymbol ) ? . let { deepSearch ( it , session , filter ) } <EOL> ? : error ( "<STR_LIT>" ) <EOL> } <EOL> <NUM_LIT:1> -> filteredSymbols . single ( ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } . let { resultSymbol -> <EOL> val isGetter = directives . singleOrZeroValue ( Directives . IS_GETTER ) <EOL> if ( isGetter == null ) { <EOL> resultSymbol <EOL> } else { <EOL> requireIsInstance < FirPropertySymbol > ( resultSymbol ) <EOL> if ( isGetter ) resultSymbol . getterSymbol ! ! else resultSymbol . setterSymbol ! ! <EOL> } <EOL> } <EOL> }


private fun deepSearch ( classSymbol : FirClassSymbol < * > , session : LLFirResolveSession , filter : ( FirBasedSymbol < * > ) -> Boolean , ) : FirBasedSymbol < * > ?

{ <EOL> val baseScope = classSymbol . unsubstitutedScope ( session . useSiteFirSession , session . getScopeSessionFor ( session . useSiteFirSession ) , false , FirResolvePhase . STATUS , ) <EOL> val scopes : List < FirContainingNamesAwareScope > = listOfNotNull ( baseScope , FirSyntheticPropertiesScope . createIfSyntheticNamesProviderIsDefined ( session . useSiteFirSession , classSymbol . defaultType ( ) , baseScope , ) ) <EOL> val declarations = mutableListOf < FirBasedSymbol < * > > ( ) <EOL> for ( typeScope in scopes ) { <EOL> val names = typeScope . getCallableNames ( ) <EOL> for ( name in names ) { <EOL> typeScope . processFunctionsByName ( name ) { <EOL> if ( filter ( it ) ) { <EOL> declarations += it <EOL> } <EOL> } <EOL> typeScope . processPropertiesByName ( name ) { <EOL> if ( filter ( it ) ) { <EOL> declarations += it <EOL> } <EOL> } <EOL> typeScope . processDeclaredConstructors { <EOL> if ( filter ( it ) ) { <EOL> declarations += it <EOL> } <EOL> } <EOL> } <EOL> } <EOL> return declarations . singleOrNull ( ) ? : error ( "<STR_LIT>" ) <EOL> }


override fun configureTest ( builder : TestConfigurationBuilder )

{ <EOL> super . configureTest ( builder ) <EOL> with ( builder ) { <EOL> useDirectives ( Directives ) <EOL> } <EOL> }


protected fun FirElementWithResolveState . lazyResolveToPhaseByDirective ( toPhase : FirResolvePhase , testServices : TestServices )

{ <EOL> when ( testServices . moduleStructure . allDirectives . singleOrZeroValue ( Directives . LAZY_MODE ) ) { <EOL> LazyResolveMode . Regular , null -> lazyResolveToPhase ( toPhase ) <EOL> LazyResolveMode . Recursive -> lazyResolveToPhaseRecursively ( toPhase ) <EOL> LazyResolveMode . WithCallableMembers -> { <EOL> if ( this !is FirClass ) { <EOL> error ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> lazyResolveToPhaseWithCallableMembers ( toPhase ) <EOL> } <EOL> } <EOL> }


internal fun lazyResolveRenderer ( builder : StringBuilder ) : FirRenderer

= FirRenderer ( builder = builder , declarationRenderer = FirDeclarationRendererWithFilteredAttributes ( ) , resolvePhaseRenderer = FirResolvePhaseRenderer ( ) , errorExpressionRenderer = FirErrorExpressionExtendedRenderer ( ) , )


internal operator fun List < FirFile > . contains ( element : FirElementWithResolveState ) : Boolean

= if ( element is FirFile ) { <EOL> element in this <EOL> } else { <EOL> any { file -> <EOL> findElementIn < FirElementWithResolveState > ( file ) { <EOL> it == element <EOL> } != null <EOL> } <EOL> }


abstract fun markDiagnostic ( diagnostic : KtDiagnostic ) : List < TextRange >


abstract fun isValid ( element : AbstractKtSourceElement ) : Boolean


@ ParameterizedTest ( name = "<STR_LIT>" ) <EOL> @ ArgumentsSource ( AllSupportedTestedVersionsArgumentsProvider :: class ) <EOL> fun execute ( buildVersions : BuildVersions )

{ <EOL> runAndAssertOutcomeAndContents ( buildVersions , TaskOutcome . SUCCESS ) <EOL> runAndAssertOutcomeAndContents ( buildVersions , TaskOutcome . FROM_CACHE ) <EOL> }


@ ParameterizedTest ( name = "<STR_LIT>" ) <EOL> @ ArgumentsSource ( AllSupportedTestedVersionsArgumentsProvider :: class ) <EOL> fun localDirectoryPointingToRoot ( buildVersions : BuildVersions )

{ <EOL> fun String . findAndReplace ( oldValue : String , newValue : String ) : String { <EOL> assertTrue ( oldValue in this , "<STR_LIT>" ) <EOL> return replace ( oldValue , newValue ) <EOL> } <EOL> val projectKts = projectDir . resolve ( "<STR_LIT>" ) <EOL> projectKts . readText ( ) <EOL> . findAndReplace ( "<STR_LIT>" , "<STR_LIT>" , ) <EOL> . findAndReplace ( "<STR_LIT>" , "<STR_LIT>" , ) <EOL> . also { projectKts . writeText ( it ) } <EOL> runAndAssertOutcomeAndContents ( buildVersions , TaskOutcome . SUCCESS ) <EOL> projectDir . resolve ( "<STR_LIT>" ) . writeText ( "<STR_LIT>" ) <EOL> runAndAssertOutcomeAndContents ( buildVersions , TaskOutcome . FROM_CACHE ) <EOL> projectKts . readText ( ) <EOL> . findAndReplace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> . also { projectKts . writeText ( it ) } <EOL> runAndAssertOutcome ( buildVersions , TaskOutcome . SUCCESS ) <EOL> }


private fun runAndAssertOutcomeAndContents ( buildVersions : BuildVersions , expectedOutcome : TaskOutcome )

{ <EOL> runAndAssertOutcome ( buildVersions , expectedOutcome ) <EOL> File ( projectDir , "<STR_LIT>" ) . assertHtmlOutputDir ( ) <EOL> }


private fun runAndAssertOutcome ( buildVersions : BuildVersions , expectedOutcome : TaskOutcome )

{ <EOL> val result = createGradleRunner ( buildVersions , "<STR_LIT:clean>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) . buildRelaxed ( ) <EOL> assertEquals ( expectedOutcome , assertNotNull ( result . task ( "<STR_LIT>" ) ) . outcome ) <EOL> }


override fun serializeSingleFileMetadata ( file : FirFile ) : ProtoBuf . PackageFragment

{ <EOL> val session : FirSession <EOL> val scopeSession : ScopeSession <EOL> val firProvider : FirProvider <EOL> val components = fir2IrActualizedResult ? . components <EOL> if ( components != null ) { <EOL> session = components . session <EOL> scopeSession = components . scopeSession <EOL> firProvider = components . firProvider <EOL> } else { <EOL> val sessionAndScopeSession = firFilesAndSessions [ file ] ? : error ( "<STR_LIT>" ) <EOL> session = sessionAndScopeSession . first <EOL> scopeSession = sessionAndScopeSession . second <EOL> firProvider = session . firProvider <EOL> } <EOL> return serializeSingleFirFile ( file , session , scopeSession , actualizedExpectDeclarations , FirKLibSerializerExtension ( session , scopeSession , firProvider , metadataVersion , components ? . let ( :: ConstValueProviderImpl ) , allowErrorTypes = false , exportKDoc , components ? . annotationsFromPluginRegistrar ? . createAdditionalMetadataProvider ( ) , ) , languageVersionSettings , produceHeaderKlib , ) <EOL> }


override fun forEachFile ( block : ( Int , FirFile , KtSourceFile , FqName ) -> Unit )

{ <EOL> firFilesAndSessions . keys . forEachIndexed { i , firFile -> <EOL> block ( i , firFile , firFile . sourceFile ! ! , firFile . packageFqName ) <EOL> } <EOL> }


= ReturnNestedFQ . getNested ( )


= X . B . value


override fun getScriptConfigurationResult ( file : KtFile ) : ScriptCompilationConfigurationResult ?

= cacheLock . read { <EOL> calculateRefinedConfiguration ( file , null ) <EOL> }


override fun getScriptConfigurationResult ( file : KtFile , providedConfiguration : ScriptCompilationConfiguration ? <EOL> ) : ScriptCompilationConfigurationResult ?

= cacheLock . read { <EOL> calculateRefinedConfiguration ( file , providedConfiguration ) <EOL> }


private fun calculateRefinedConfiguration ( file : KtFile , providedConfiguration : ScriptCompilationConfiguration ? <EOL> ) : ScriptCompilationConfigurationResult ?

{ <EOL> val path = file . virtualFilePath <EOL> val cached = cache [ path ] <EOL> return if ( cached != null ) cached <EOL> else { <EOL> val scriptDef = file . findScriptDefinition ( ) <EOL> if ( scriptDef != null ) { <EOL> val result = <EOL> refineScriptCompilationConfiguration ( KtFileScriptSource ( file ) , scriptDef , project , providedConfiguration , knownVirtualFileSources ) <EOL> project . getService ( ScriptReportSink :: class . java ) ? . attachReports ( file . virtualFile , result . reports ) <EOL> cacheLock . write { <EOL> cache . put ( path , result ) <EOL> } <EOL> result <EOL> } else null <EOL> } <EOL> }


fun unwindInstructions ( irFunction : IrFunction , environment : IrInterpreterEnvironment ) : List < Instruction > ?

{ <EOL> val fqName = irFunction . fqName <EOL> return fqNameToHandler [ fqName ] ? . unwind ( irFunction , environment ) ? : when { <EOL> EnumIntrinsics . canHandleFunctionWithName ( fqName , irFunction . origin ) -> EnumIntrinsics . unwind ( irFunction , environment ) <EOL> else -> null <EOL> } <EOL> }


override fun PageContentBuilder . DocumentableContentBuilder . annotationsBlock ( d : AnnotationTarget )

{ <EOL> annotationsBlockWithIgnored ( d , ignoredAnnotations , strategy , listBrackets , classExtension ) <EOL> }


override fun PageContentBuilder . DocumentableContentBuilder . annotationsInline ( d : AnnotationTarget )

{ <EOL> annotationsInlineWithIgnored ( d , ignoredAnnotations , strategy , listBrackets , classExtension ) <EOL> }


override fun < T : Documentable > WithExtraProperties < T > . modifiers ( ) : SourceSetDependent < Set < ExtraModifiers > >

{ <EOL> return extra [ AdditionalModifiers ] ? . content ? . entries ? . associate { <EOL> it . key to it . value . filterIsInstance < ExtraModifiers . KotlinOnlyModifiers > ( ) . toSet ( ) <EOL> } ? : emptyMap ( ) <EOL> }


override fun Annotations . Annotation . isIgnored ( ) : Boolean

= this in ignoredAnnotations


{ <EOL> Fo < caret > o ( ) <EOL> }


override fun check ( declaration : KtDeclaration , descriptor : DeclarationDescriptor , context : DeclarationCheckerContext )

{ <EOL> if ( ! AnnotationsUtils . isNativeObject ( descriptor ) ) return <EOL> val trace = context . trace <EOL> if ( ! DescriptorUtils . isTopLevelDeclaration ( descriptor ) ) { <EOL> if ( isDirectlyExternal ( declaration , descriptor ) && descriptor !is PropertyAccessorDescriptor ) { <EOL> trace . report ( ErrorsJs . NESTED_EXTERNAL_DECLARATION . on ( declaration ) ) <EOL> } <EOL> } <EOL> if ( descriptor is ClassDescriptor ) { <EOL> val classKind = when { <EOL> descriptor . isData -> "<STR_LIT>" <EOL> descriptor . isInner -> "<STR_LIT>" <EOL> descriptor . isInline -> "<STR_LIT>" <EOL> descriptor . isValue -> "<STR_LIT>" <EOL> descriptor . isFun -> "<STR_LIT>" <EOL> DescriptorUtils . isAnnotationClass ( descriptor ) -> "<STR_LIT>" <EOL> else -> null <EOL> } <EOL> if ( classKind != null ) { <EOL> trace . report ( ErrorsJs . WRONG_EXTERNAL_DECLARATION . on ( declaration , classKind ) ) <EOL> } <EOL> if ( DescriptorUtils . isEnumClass ( descriptor ) && context . moduleDescriptor . platform ? . isWasm ( ) != true ) { <EOL> trace . report ( ErrorsJs . ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING . on ( declaration ) ) <EOL> } <EOL> } <EOL> if ( descriptor is PropertyAccessorDescriptor && isDirectlyExternal ( declaration , descriptor ) ) { <EOL> trace . report ( ErrorsJs . WRONG_EXTERNAL_DECLARATION . on ( declaration , "<STR_LIT>" ) ) <EOL> } else if ( descriptor !is ConstructorDescriptor && descriptor !is FieldDescriptor && isPrivateMemberOfExternalClass ( descriptor ) ) { <EOL> trace . report ( ErrorsJs . WRONG_EXTERNAL_DECLARATION . on ( declaration , "<STR_LIT>" ) ) <EOL> } <EOL> val containingDeclarationsIsInterface = descriptor . containingDeclaration . let { it is ClassDescriptor && it . kind == ClassKind . INTERFACE } <EOL> if ( descriptor is ClassDescriptor && descriptor . kind != ClassKind . INTERFACE && ( ! allowCompanionInInterface || ! descriptor . isCompanionObject ) && containingDeclarationsIsInterface ) { <EOL> trace . report ( ErrorsJs . NESTED_CLASS_IN_EXTERNAL_INTERFACE . on ( declaration ) ) <EOL> } <EOL> if ( allowCompanionInInterface && descriptor . isCompanionObject ( ) && containingDeclarationsIsInterface && descriptor . name != DEFAULT_NAME_FOR_COMPANION_OBJECT ) { <EOL> trace . report ( ErrorsJs . NAMED_COMPANION_IN_EXTERNAL_INTERFACE . on ( declaration ) ) <EOL> } <EOL> if ( descriptor !is PropertyAccessorDescriptor && descriptor . isExtension ) { <EOL> val target = when ( descriptor ) { <EOL> is FunctionDescriptor -> "<STR_LIT>" <EOL> is PropertyDescriptor -> "<STR_LIT>" <EOL> else -> "<STR_LIT>" <EOL> } <EOL> trace . report ( ErrorsJs . WRONG_EXTERNAL_DECLARATION . on ( declaration , target ) ) <EOL> } <EOL> if ( descriptor is ClassDescriptor && descriptor . kind != ClassKind . ANNOTATION_CLASS ) { <EOL> val superClasses = ( listOfNotNull ( descriptor . getSuperClassNotAny ( ) ) + descriptor . getSuperInterfaces ( ) ) . toMutableSet ( ) <EOL> if ( descriptor . kind == ClassKind . ENUM_CLASS || descriptor . kind == ClassKind . ENUM_ENTRY ) { <EOL> superClasses . removeAll { it . fqNameUnsafe == StandardNames . FqNames . _enum } <EOL> } <EOL> if ( superClasses . any { ! AnnotationsUtils . isNativeObject ( it ) && it . fqNameSafe != StandardNames . FqNames . throwable } ) { <EOL> trace . report ( ErrorsJs . EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE . on ( declaration ) ) <EOL> } <EOL> } <EOL> if ( descriptor is FunctionDescriptor && descriptor . isInline ) { <EOL> trace . report ( ErrorsJs . INLINE_EXTERNAL_DECLARATION . on ( declaration ) ) <EOL> } <EOL> fun reportOnParametersAndReturnTypesIf ( diagnosticFactory : DiagnosticFactory0 < KtElement > , condition : ( KotlinType ) -> Boolean ) { <EOL> if ( descriptor is CallableMemberDescriptor && ! ( descriptor is PropertyAccessorDescriptor && descriptor . isDefault ) ) { <EOL> fun checkTypeIsNotInlineClass ( type : KotlinType , elementToReport : KtElement ) { <EOL> if ( condition ( type ) ) { <EOL> trace . report ( diagnosticFactory . on ( elementToReport ) ) <EOL> } <EOL> } <EOL> for ( p in descriptor . valueParameters ) { <EOL> val ktParam = p . source . getPsi ( ) as? KtParameter ? : declaration <EOL> checkTypeIsNotInlineClass ( p . varargElementType ? : p . type , ktParam ) <EOL> } <EOL> val elementToReport = when ( declaration ) { <EOL> is KtCallableDeclaration -> declaration . typeReference <EOL> is KtPropertyAccessor -> declaration . returnTypeReference <EOL> else -> declaration <EOL> } <EOL> elementToReport ? . let { <EOL> checkTypeIsNotInlineClass ( descriptor . returnType ! ! , it ) <EOL> } <EOL> } <EOL> } <EOL> val valueClassInExternalDiagnostic = <EOL> if ( context . languageVersionSettings . supportsFeature ( LanguageFeature . JsAllowValueClassesInExternals ) ) <EOL> ErrorsJs . INLINE_CLASS_IN_EXTERNAL_DECLARATION_WARNING <EOL> else <EOL> ErrorsJs . INLINE_CLASS_IN_EXTERNAL_DECLARATION <EOL> reportOnParametersAndReturnTypesIf ( valueClassInExternalDiagnostic , KotlinType :: isInlineClassType ) <EOL> if ( ! context . languageVersionSettings . supportsFeature ( LanguageFeature . JsEnableExtensionFunctionInExternals ) ) { <EOL> reportOnParametersAndReturnTypesIf ( ErrorsJs . EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION , KotlinType :: isExtensionFunctionType ) <EOL> } <EOL> if ( descriptor is CallableMemberDescriptor && descriptor . isNonAbstractMemberOfInterface ( ) && ! descriptor . isNullableProperty ( ) ) { <EOL> trace . report ( ErrorsJs . NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE . on ( declaration ) ) <EOL> } <EOL> checkBody ( declaration , descriptor , trace , trace . bindingContext ) <EOL> checkDelegation ( declaration , descriptor , trace ) <EOL> checkAnonymousInitializer ( declaration , trace ) <EOL> checkEnumEntry ( declaration , trace ) <EOL> if ( ! context . languageVersionSettings . supportsFeature ( LanguageFeature . JsExternalPropertyParameters ) ) { <EOL> checkConstructorPropertyParam ( declaration , descriptor , trace ) <EOL> } <EOL> }


private fun checkBody ( declaration : KtDeclaration , descriptor : DeclarationDescriptor , diagnosticHolder : DiagnosticSink , bindingContext : BindingContext )

{ <EOL> if ( declaration is KtProperty && descriptor is PropertyAccessorDescriptor ) return <EOL> if ( declaration is KtDeclarationWithBody && ! declaration . hasValidExternalBody ( bindingContext ) ) { <EOL> diagnosticHolder . report ( ErrorsJs . WRONG_BODY_OF_EXTERNAL_DECLARATION . on ( declaration . bodyExpression ! ! ) ) <EOL> } else if ( declaration is KtDeclarationWithInitializer && declaration . initializer ? . isDefinedExternallyExpression ( bindingContext ) == false ) { <EOL> diagnosticHolder . report ( ErrorsJs . WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION . on ( declaration . initializer ! ! ) ) <EOL> } <EOL> if ( declaration is KtCallableDeclaration ) { <EOL> for ( defaultValue in declaration . valueParameters . mapNotNull { it . defaultValue } ) { <EOL> if ( ! defaultValue . isDefinedExternallyExpression ( bindingContext ) ) { <EOL> diagnosticHolder . report ( ErrorsJs . WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER . on ( defaultValue ) ) <EOL> } <EOL> } <EOL> } <EOL> }


private fun checkDelegation ( declaration : KtDeclaration , descriptor : DeclarationDescriptor , diagnosticHolder : DiagnosticSink )

{ <EOL> if ( descriptor !is MemberDescriptor || ! descriptor . isEffectivelyExternal ( ) ) return <EOL> if ( declaration is KtClassOrObject ) { <EOL> for ( superTypeEntry in declaration . superTypeListEntries ) { <EOL> when ( superTypeEntry ) { <EOL> is KtSuperTypeCallEntry -> { <EOL> diagnosticHolder . report ( ErrorsJs . EXTERNAL_DELEGATED_CONSTRUCTOR_CALL . on ( superTypeEntry . valueArgumentList ! ! ) ) <EOL> } <EOL> is KtDelegatedSuperTypeEntry -> { <EOL> diagnosticHolder . report ( ErrorsJs . EXTERNAL_DELEGATION . on ( superTypeEntry ) ) <EOL> } <EOL> } <EOL> } <EOL> } else if ( declaration is KtSecondaryConstructor ) { <EOL> val delegationCall = declaration . getDelegationCall ( ) <EOL> if ( ! delegationCall . isImplicit ) { <EOL> diagnosticHolder . report ( ErrorsJs . EXTERNAL_DELEGATED_CONSTRUCTOR_CALL . on ( delegationCall ) ) <EOL> } <EOL> } else if ( declaration is KtProperty && descriptor !is PropertyAccessorDescriptor ) { <EOL> declaration . delegate ? . let { delegate -> <EOL> diagnosticHolder . report ( ErrorsJs . EXTERNAL_DELEGATION . on ( delegate ) ) <EOL> } <EOL> } <EOL> }


private fun checkAnonymousInitializer ( declaration : KtDeclaration , diagnosticHolder : DiagnosticSink )

{ <EOL> if ( declaration !is KtClassOrObject ) return <EOL> for ( anonymousInitializer in declaration . getAnonymousInitializers ( ) ) { <EOL> diagnosticHolder . report ( ErrorsJs . EXTERNAL_ANONYMOUS_INITIALIZER . on ( anonymousInitializer ) ) <EOL> } <EOL> }


private fun checkEnumEntry ( declaration : KtDeclaration , diagnosticHolder : DiagnosticSink )

{ <EOL> if ( declaration !is KtEnumEntry ) return <EOL> declaration . body ? . let { <EOL> diagnosticHolder . report ( ErrorsJs . EXTERNAL_ENUM_ENTRY_WITH_BODY . on ( it ) ) <EOL> } <EOL> }


private fun checkConstructorPropertyParam ( declaration : KtDeclaration , descriptor : DeclarationDescriptor , diagnosticHolder : DiagnosticSink )

{ <EOL> if ( descriptor !is PropertyDescriptor || declaration !is KtParameter ) return <EOL> val containingClass = descriptor . containingDeclaration as ClassDescriptor <EOL> if ( containingClass . isData || DescriptorUtils . isAnnotationClass ( containingClass ) ) return <EOL> diagnosticHolder . report ( ErrorsJs . EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER . on ( declaration ) ) <EOL> }


private fun isDirectlyExternal ( declaration : KtDeclaration , descriptor : DeclarationDescriptor ) : Boolean

{ <EOL> if ( declaration is KtProperty && descriptor is PropertyAccessorDescriptor ) return false <EOL> return declaration . hasModifier ( KtTokens . EXTERNAL_KEYWORD ) || <EOL> AnnotationsUtils . hasAnnotation ( descriptor , PredefinedAnnotation . NATIVE ) <EOL> }


private fun isPrivateMemberOfExternalClass ( descriptor : DeclarationDescriptor ) : Boolean

{ <EOL> if ( descriptor is PropertyAccessorDescriptor && descriptor . visibility == descriptor . correspondingProperty . visibility ) return false <EOL> if ( descriptor !is MemberDescriptor || descriptor . visibility != DescriptorVisibilities . PRIVATE ) return false <EOL> val containingDeclaration = descriptor . containingDeclaration as? ClassDescriptor ? : return false <EOL> return AnnotationsUtils . isNativeObject ( containingDeclaration ) <EOL> }


private fun CallableMemberDescriptor . isNonAbstractMemberOfInterface ( )

= <EOL> modality != Modality . ABSTRACT && <EOL> DescriptorUtils . isInterface ( containingDeclaration ) && <EOL> this !is PropertyAccessorDescriptor


private fun CallableMemberDescriptor . isNullableProperty ( )

= this is PropertyDescriptor && TypeUtils . isNullableType ( type )


private fun KtDeclarationWithBody . hasValidExternalBody ( bindingContext : BindingContext ) : Boolean

{ <EOL> if ( ! hasBody ( ) ) return true <EOL> val body = bodyExpression ! ! <EOL> return when { <EOL> ! hasBlockBody ( ) -> body . isDefinedExternallyExpression ( bindingContext ) <EOL> body is KtBlockExpression -> { <EOL> val statement = body . statements . singleOrNull ( ) ? : return false <EOL> statement . isDefinedExternallyExpression ( bindingContext ) <EOL> } <EOL> else -> false <EOL> } <EOL> }


private fun KtExpression . isDefinedExternallyExpression ( bindingContext : BindingContext ) : Boolean

{ <EOL> val descriptor = getResolvedCall ( bindingContext ) ? . resultingDescriptor as? PropertyDescriptor ? : return false <EOL> val container = descriptor . containingDeclaration as? PackageFragmentDescriptor ? : return false <EOL> return DEFINED_EXTERNALLY_PROPERTY_NAMES . any { container . fqNameUnsafe == it . parent ( ) && descriptor . name == it . shortName ( ) } <EOL> }


@ A1 ( ) <EOL> @ A2 ( ) <EOL> @ AA ( ) <EOL> fun test2 ( )


= "<STR_LIT:OK>"


{ <EOL> val klass = Obj . Inner :: class . java <EOL> val cons = klass . getConstructors ( ) ! ! [ <NUM_LIT:0> ] <EOL> val inner = cons . newInstance ( * ( arrayOfNulls < String > ( <NUM_LIT:0> ) as Array < String > ) ) <EOL> return "<STR_LIT:OK>" <EOL> }


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


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

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


fun readNumbers ( text : String ) : List < Int ? >

{ <EOL> val result = mutableListOf < Int ? > ( ) <EOL> for ( line in text . lineSequence ( ) ) { <EOL> val numberOrNull = line . toIntOrNull ( ) <EOL> result . add ( numberOrNull ) <EOL> } <EOL> return result <EOL> }


fun addValidNumbers ( numbers : List < Int ? > )

{ <EOL> var sumOfValidNumbers = <NUM_LIT:0> <EOL> var invalidNumbers = <NUM_LIT:0> <EOL> for ( number in numbers ) { <EOL> if ( number != null ) { <EOL> sumOfValidNumbers += number <EOL> } else { <EOL> invalidNumbers ++ <EOL> } <EOL> } <EOL> println ( "<STR_LIT>" ) <EOL> println ( "<STR_LIT>" ) <EOL> }


{ <EOL> val input = """<STR_LIT>""" . trimIndent ( ) <EOL> val numbers = readNumbers ( input ) <EOL> addValidNumbers ( numbers ) <EOL> }


{ <EOL> createC ( ) . baz ( ) <EOL> }


inline fun < reified T : CharSequence > f ( x : Array < out Any > )

= x as Array < T >


= try { <EOL> f < String > ( arrayOf < Int > ( <NUM_LIT:42> ) ) <EOL> "<STR_LIT:Fail>" <EOL> } catch ( e : Exception ) { <EOL> "<STR_LIT:OK>" <EOL> }


@ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleAndroidTest <EOL> fun generateStubsTaskShouldRunIncrementallyOnChangesInAndroidVariantJavaSources ( gradleVersion : GradleVersion , agpVersion : String , jdkVersion : JdkVersions . ProvidedJdk , )

{ <EOL> project ( "<STR_LIT>" . withPrefix , gradleVersion , buildOptions = defaultBuildOptions . copy ( androidVersion = agpVersion ) , buildJdk = jdkVersion . location ) { <EOL> val javaFile = subProject ( "<STR_LIT:app>" ) . javaSourcesDir ( ) . resolve ( "<STR_LIT>" ) <EOL> javaFile . writeText ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT>" ) { <EOL> assertTasksExecuted ( "<STR_LIT>" ) <EOL> } <EOL> javaFile . writeText ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT>" ) { <EOL> assertTasksExecuted ( "<STR_LIT>" ) <EOL> assertOutputDoesNotContain ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }