= Wrapper ( "<STR_LIT>" ) . prop


fun processClassOrObject ( scope : LexicalWritableScope ? , context : ExpressionTypingContext , containingDeclaration : DeclarationDescriptor , classOrObject : KtClassOrObject )

{ <EOL> val module = DescriptorUtils . getContainingModule ( containingDeclaration ) <EOL> val project = classOrObject . project <EOL> val moduleContext = globalContext . withProject ( project ) . withModule ( module ) <EOL> val container = createContainerForLazyLocalClassifierAnalyzer ( moduleContext , context . trace , platform , lookupTracker , languageVersionSettings , context . statementFilter , LocalClassDescriptorHolder ( scope , classOrObject , containingDeclaration , storageManager , context , module , descriptorResolver , functionDescriptorResolver , typeResolver , annotationResolver , supertypeLoopChecker , languageVersionSettings , SyntheticResolveExtension . getInstance ( project ) , delegationFilter , wrappedTypeFactory , kotlinTypeChecker , samConversionResolver , additionalClassPartsProvider , sealedClassInheritorsProvider ) , analyzerServices , controlFlowInformationProviderFactory , absentDescriptorHandler ) <EOL> container . get < LazyTopDownAnalyzer > ( ) . analyzeDeclarations ( TopDownAnalysisMode . LocalDeclarations , listOf ( classOrObject ) , context . dataFlowInfo , localContext = context ) <EOL> }


fun isMyClass ( element : PsiElement ) : Boolean

= element == myClass


fun insideMyClass ( element : PsiElement ) : Boolean

= PsiTreeUtil . isAncestor ( myClass , element , false )


fun getClassDescriptor ( classOrObject : KtClassOrObject , declarationScopeProvider : DeclarationScopeProvider ) : ClassDescriptor

{ <EOL> assert ( isMyClass ( classOrObject ) ) { "<STR_LIT>" } <EOL> if ( classDescriptor == null ) { <EOL> classDescriptor = LazyClassDescriptor ( object : LazyClassContext { <EOL> override val declarationScopeProvider = declarationScopeProvider <EOL> override val inferenceSession = expressionTypingContext . inferenceSession <EOL> override val storageManager = this@LocalClassDescriptorHolder . storageManager <EOL> override val trace = expressionTypingContext . trace <EOL> override val moduleDescriptor = this@LocalClassDescriptorHolder . moduleDescriptor <EOL> override val descriptorResolver = this@LocalClassDescriptorHolder . descriptorResolver <EOL> override val functionDescriptorResolver = this@LocalClassDescriptorHolder . functionDescriptorResolver <EOL> override val typeResolver = this@LocalClassDescriptorHolder . typeResolver <EOL> override val declarationProviderFactory = object : DeclarationProviderFactory { <EOL> override fun getClassMemberDeclarationProvider ( classLikeInfo : KtClassLikeInfo ) : ClassMemberDeclarationProvider { <EOL> return PsiBasedClassMemberDeclarationProvider ( storageManager , classLikeInfo ) <EOL> } <EOL> override fun getPackageMemberDeclarationProvider ( packageFqName : FqName ) : PackageMemberDeclarationProvider ? { <EOL> throw UnsupportedOperationException ( "<STR_LIT>" ) <EOL> } <EOL> override fun diagnoseMissingPackageFragment ( fqName : FqName , file : KtFile ? ) { <EOL> throw UnsupportedOperationException ( ) <EOL> } <EOL> } <EOL> override val annotationResolver = this@LocalClassDescriptorHolder . annotationResolver <EOL> override val lookupTracker : LookupTracker = LookupTracker . DO_NOTHING <EOL> override val supertypeLoopChecker = this@LocalClassDescriptorHolder . supertypeLoopChecker <EOL> override val languageVersionSettings = this@LocalClassDescriptorHolder . languageVersionSettings <EOL> override val syntheticResolveExtension = this@LocalClassDescriptorHolder . syntheticResolveExtension <EOL> override val delegationFilter : DelegationFilter = this@LocalClassDescriptorHolder . delegationFilter <EOL> override val wrappedTypeFactory : WrappedTypeFactory = this@LocalClassDescriptorHolder . wrappedTypeFactory <EOL> override val kotlinTypeCheckerOfOwnerModule : NewKotlinTypeChecker = this@LocalClassDescriptorHolder . kotlinTypeChecker <EOL> override val samConversionResolver : SamConversionResolver = this@LocalClassDescriptorHolder . samConversionResolver <EOL> override val additionalClassPartsProvider : AdditionalClassPartsProvider = <EOL> this@LocalClassDescriptorHolder . additionalClassPartsProvider <EOL> override val sealedClassInheritorsProvider : SealedClassInheritorsProvider = <EOL> this@LocalClassDescriptorHolder . sealedClassInheritorsProvider <EOL> } , containingDeclaration , classOrObject . nameAsSafeName , KtClassInfoUtil . createClassOrObjectInfo ( classOrObject ) , classOrObject . hasModifier ( KtTokens . EXTERNAL_KEYWORD ) ) <EOL> writableScope ? . addClassifierDescriptor ( classDescriptor ! ! ) <EOL> } <EOL> return classDescriptor ! ! <EOL> }


fun getResolutionScopeForClass ( classOrObject : KtClassOrObject ) : LexicalScope

{ <EOL> assert ( isMyClass ( classOrObject ) ) { "<STR_LIT>" } <EOL> return expressionTypingContext . scope <EOL> }


override fun getClassDescriptor ( classOrObject : KtClassOrObject , location : LookupLocation ) : ClassDescriptor

{ <EOL> if ( localClassDescriptorManager . isMyClass ( classOrObject ) ) { <EOL> return localClassDescriptorManager . getClassDescriptor ( classOrObject , scopeProvider ) <EOL> } <EOL> return super . getClassDescriptor ( classOrObject , location ) <EOL> }


override fun getClassDescriptorIfAny ( classOrObject : KtClassOrObject , location : LookupLocation ) : ClassDescriptor ?

{ <EOL> if ( localClassDescriptorManager . isMyClass ( classOrObject ) ) { <EOL> return localClassDescriptorManager . getClassDescriptor ( classOrObject , scopeProvider ) <EOL> } <EOL> return super . getClassDescriptorIfAny ( classOrObject , location ) <EOL> }


override fun getResolutionScopeForDeclaration ( elementOfDeclaration : PsiElement ) : LexicalScope

{ <EOL> if ( localClassDescriptorManager . isMyClass ( elementOfDeclaration ) ) { <EOL> return localClassDescriptorManager . getResolutionScopeForClass ( elementOfDeclaration as KtClassOrObject ) <EOL> } <EOL> return super . getResolutionScopeForDeclaration ( elementOfDeclaration ) <EOL> }


override fun getOuterDataFlowInfoForDeclaration ( elementOfDeclaration : PsiElement ) : DataFlowInfo

{ <EOL> if ( localClassDescriptorManager . insideMyClass ( elementOfDeclaration ) ) { <EOL> return localClassDescriptorManager . expressionTypingContext . dataFlowInfo <EOL> } <EOL> return super . getOuterDataFlowInfoForDeclaration ( elementOfDeclaration ) <EOL> }


= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val result = runCatching { doSelect ( ) } <EOL> expect ( <NUM_LIT:3> ) <EOL> verifyStackTrace ( "<STR_LIT>" , result . exceptionOrNull ( ) ! ! ) <EOL> finish ( <NUM_LIT:4> ) <EOL> }


{ <EOL> val job = CompletableDeferred ( Unit ) <EOL> return select { <EOL> job . onJoin { <EOL> yield ( ) <EOL> expect ( <NUM_LIT:2> ) <EOL> throw RecoverableTestException ( ) <EOL> } <EOL> } <EOL> }


@ Test <EOL> fun testSelectCompletedAwait ( )

= runTest { <EOL> val deferred = CompletableDeferred < Unit > ( ) <EOL> deferred . completeExceptionally ( RecoverableTestException ( ) ) <EOL> val result = runCatching { doSelectAwait ( deferred ) } <EOL> verifyStackTrace ( "<STR_LIT>" , result . exceptionOrNull ( ) ! ! ) <EOL> }


private suspend fun doSelectAwait ( deferred : Deferred < Unit > ) : Int

{ <EOL> return select { <EOL> deferred . onAwait { <EOL> yield ( ) <EOL> <NUM_LIT:42> <EOL> } <EOL> } <EOL> }


@ Test <EOL> fun testSelectOnReceive ( )

= runTest { <EOL> val c = Channel < Unit > ( ) <EOL> c . close ( ) <EOL> val result = kotlin . runCatching { doSelectOnReceive ( c ) } <EOL> verifyStackTrace ( "<STR_LIT>" , result . exceptionOrNull ( ) ! ! ) <EOL> }


private suspend fun doSelectOnReceive ( c : Channel < Unit > )

{ <EOL> select < Unit > { <EOL> c . onReceive { <EOL> expectUnreached ( ) <EOL> } <EOL> } <EOL> }


abstract fun Canvas . drawDetection ( detection : T )

/**
 * Draw given detection result on the [Canvas].
 */


open fun onDetectionSet ( detection : T ? )

= Unit

/**
 * Called when a new detection result is set.
 */


{ <EOL> synchronized ( this ) { <EOL> _detection = detection <EOL> onDetectionSet ( detection ) <EOL> postInvalidate ( ) <EOL> } <EOL> }

/**
 * Set current detection result or null if nothing was detected.
 */


{ <EOL> super . onDraw ( canvas ) <EOL> synchronized ( this ) { <EOL> val detection = _detection <EOL> if ( detection != null ) { <EOL> canvas . drawDetection ( detection ) <EOL> } <EOL> } <EOL> }


= bar


= it . hasNext ( ) . also { hasNextCtr ++ }


= it . next ( ) . also { nextCtr ++ }


= CountingIterableIterator ( s . iterator ( ) )


{ <EOL> val s = StringBuilder ( ) <EOL> for ( ( _ , x ) in xs . withIndex ( ) ) { <EOL> s . append ( "<STR_LIT>" ) <EOL> } <EOL> val ss = s . toString ( ) <EOL> if ( ss != "<STR_LIT>" ) return "<STR_LIT>" <EOL> if ( xs . hasNextCtr != <NUM_LIT:5> ) return "<STR_LIT>" <EOL> if ( xs . nextCtr != <NUM_LIT:4> ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


fun bar ( r : ( ) -> Int = this :: p ) : Int


= r ( )


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


@ Test <EOL> fun testExampleContext01 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext01 . main ( ) } . verifyLinesStartUnordered ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext02 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext02 . main ( ) } . verifyLinesStart ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext03 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext03 . main ( ) } . verifyLinesFlexibleThread ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext04 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext04 . main ( ) } . verifyLines ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext05 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext05 . main ( ) } . also { lines -> <EOL> check ( lines . size == <NUM_LIT:1> && lines [ <NUM_LIT:0> ] . startsWith ( "<STR_LIT>" ) ) <EOL> } <EOL> }


@ Test <EOL> fun testExampleContext06 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext06 . main ( ) } . verifyLines ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext07 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext07 . main ( ) } . verifyLines ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext08 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext08 . main ( ) } . verifyLinesFlexibleThread ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext09 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext09 . main ( ) } . verifyLinesFlexibleThread ( "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext10 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext10 . main ( ) } . verifyLines ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun testExampleContext11 ( )

{ <EOL> test ( "<STR_LIT>" ) { kotlinx . coroutines . guide . exampleContext11 . main ( ) } . verifyLinesFlexibleThread ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> }


{ <EOL> prevSender = sender <EOL> }


suspend fun sendTo ( recipient : String , sender : String , message : String )


suspend fun message ( sender : String , message : String )


private suspend fun receivedMessage ( id : String , command : String )

{ <EOL> when { <EOL> command . startsWith ( "<STR_LIT>" ) -> server . who ( id ) <EOL> command . startsWith ( "<STR_LIT>" ) -> { <EOL> val newName = command . removePrefix ( "<STR_LIT>" ) . trim ( ) <EOL> when { <EOL> newName . isEmpty ( ) -> server . sendTo ( id , "<STR_LIT>" , "<STR_LIT>" ) <EOL> else -> server . message ( id , newName ) <EOL> } <EOL> } <EOL> command . startsWith ( "<STR_LIT:/>" ) -> server . sendTo ( id , "<STR_LIT>" , "<STR_LIT>" ) <EOL> else -> server . message ( id , command ) <EOL> } <EOL> }


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


{ <EOL> builder { <EOL> receivedMessage ( "<STR_LIT:OK>" , "<STR_LIT>" ) <EOL> } <EOL> return prevSender <EOL> }


= internalVal


@ JvmStatic <EOL> fun getOverriddenBuiltinFunctionWithErasedValueParametersInJava ( functionDescriptor : FunctionDescriptor ) : FunctionDescriptor ?

{ <EOL> if ( ! functionDescriptor . name . sameAsBuiltinMethodWithErasedValueParameters ) return null <EOL> return functionDescriptor . firstOverridden { it . hasErasedValueParametersInJava } as FunctionDescriptor ? <EOL> }


@ JvmStatic <EOL> fun getDefaultValueForOverriddenBuiltinFunction ( functionDescriptor : FunctionDescriptor ) : TypeSafeBarrierDescription ?

{ <EOL> if ( functionDescriptor . name !in ERASED_VALUE_PARAMETERS_SHORT_NAMES ) return null <EOL> return functionDescriptor . firstOverridden { <EOL> it . computeJvmSignature ( ) in SIGNATURE_TO_DEFAULT_VALUES_MAP . keys <EOL> } ? . let { SIGNATURE_TO_DEFAULT_VALUES_MAP [ it . computeJvmSignature ( ) ] } <EOL> }


fun CallableMemberDescriptor . isBuiltinWithSpecialDescriptorInJvm ( ) : Boolean

{ <EOL> if ( ! KotlinBuiltIns . isBuiltIn ( this ) ) return false <EOL> return getSpecialSignatureInfo ( ) ? . isObjectReplacedWithTypeParameter ? : false || doesOverrideBuiltinWithDifferentJvmName ( ) <EOL> }


@ JvmStatic <EOL> fun CallableMemberDescriptor . getSpecialSignatureInfo ( ) : SpecialSignatureInfo ?

{ <EOL> if ( name !in ERASED_VALUE_PARAMETERS_SHORT_NAMES ) return null <EOL> val builtinSignature = firstOverridden { it is FunctionDescriptor && it . hasErasedValueParametersInJava } ? . computeJvmSignature ( ) <EOL> ? : return null <EOL> return getSpecialSignatureInfo ( builtinSignature ) <EOL> }


fun getJvmName ( functionDescriptor : SimpleFunctionDescriptor ) : Name ?

{ <EOL> return SIGNATURE_TO_JVM_REPRESENTATION_NAME [ functionDescriptor . computeJvmSignature ( ) ? : return null ] <EOL> }


fun isBuiltinFunctionWithDifferentNameInJvm ( functionDescriptor : SimpleFunctionDescriptor ) : Boolean

{ <EOL> return KotlinBuiltIns . isBuiltIn ( functionDescriptor ) && functionDescriptor . firstOverridden { <EOL> SIGNATURE_TO_JVM_REPRESENTATION_NAME . containsKey ( functionDescriptor . computeJvmSignature ( ) ) <EOL> } != null <EOL> }


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> fun < T : CallableMemberDescriptor > T . getOverriddenBuiltinWithDifferentJvmName ( ) : T ?

{ <EOL> if ( name !in SpecialGenericSignatures . ORIGINAL_SHORT_NAMES && propertyIfAccessor . name !in BuiltinSpecialProperties . SPECIAL_SHORT_NAMES ) return null <EOL> return when ( this ) { <EOL> is PropertyDescriptor , is PropertyAccessorDescriptor -> <EOL> firstOverridden { ClassicBuiltinSpecialProperties . hasBuiltinSpecialPropertyFqName ( it . propertyIfAccessor ) } as T ? <EOL> is SimpleFunctionDescriptor -> <EOL> firstOverridden { <EOL> BuiltinMethodsWithDifferentJvmName . isBuiltinFunctionWithDifferentNameInJvm ( it as SimpleFunctionDescriptor ) <EOL> } as T ? <EOL> else -> null <EOL> } <EOL> }


fun CallableMemberDescriptor . doesOverrideBuiltinWithDifferentJvmName ( ) : Boolean

= getOverriddenBuiltinWithDifferentJvmName ( ) != null


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> fun < T : CallableMemberDescriptor > T . getOverriddenSpecialBuiltin ( ) : T ?

{ <EOL> getOverriddenBuiltinWithDifferentJvmName ( ) ? . let { return it } <EOL> if ( ! name . sameAsBuiltinMethodWithErasedValueParameters ) return null <EOL> return firstOverridden { <EOL> KotlinBuiltIns . isBuiltIn ( it ) && it . getSpecialSignatureInfo ( ) != null <EOL> } as T ? <EOL> }


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> fun < T : CallableMemberDescriptor > T . getOverriddenBuiltinReflectingJvmDescriptor ( ) : T ?

{ <EOL> getOverriddenBuiltinWithDifferentJvmName ( ) ? . let { return it } <EOL> if ( ! name . sameAsBuiltinMethodWithErasedValueParameters ) return null <EOL> return firstOverridden { <EOL> KotlinBuiltIns . isBuiltIn ( it ) && it . getSpecialSignatureInfo ( ) ? . isObjectReplacedWithTypeParameter ? : false <EOL> } ? . original as T ? <EOL> }


fun getJvmMethodNameIfSpecial ( callableMemberDescriptor : CallableMemberDescriptor ) : String ?

{ <EOL> val overriddenBuiltin = getOverriddenBuiltinThatAffectsJvmName ( callableMemberDescriptor ) ? . propertyIfAccessor <EOL> ? : return null <EOL> return when ( overriddenBuiltin ) { <EOL> is PropertyDescriptor -> overriddenBuiltin . getBuiltinSpecialPropertyGetterName ( ) <EOL> is SimpleFunctionDescriptor -> BuiltinMethodsWithDifferentJvmName . getJvmName ( overriddenBuiltin ) ? . asString ( ) <EOL> else -> null <EOL> } <EOL> }


private fun getOverriddenBuiltinThatAffectsJvmName ( callableMemberDescriptor : CallableMemberDescriptor ) : CallableMemberDescriptor ?

= <EOL> if ( KotlinBuiltIns . isBuiltIn ( callableMemberDescriptor ) ) callableMemberDescriptor . getOverriddenBuiltinWithDifferentJvmName ( ) <EOL> else null


fun ClassDescriptor . hasRealKotlinSuperClassWithOverrideOf ( specialCallableDescriptor : CallableDescriptor ) : Boolean

{ <EOL> val builtinContainerDefaultType = ( specialCallableDescriptor . containingDeclaration as ClassDescriptor ) . defaultType <EOL> var superClassDescriptor = DescriptorUtils . getSuperClassDescriptor ( this ) <EOL> while ( superClassDescriptor != null ) { <EOL> if ( superClassDescriptor !is JavaClassDescriptor ) { <EOL> val doesOverrideBuiltinDeclaration = <EOL> TypeCheckingProcedure . findCorrespondingSupertype ( superClassDescriptor . defaultType , builtinContainerDefaultType ) != null <EOL> if ( doesOverrideBuiltinDeclaration ) { <EOL> return ! KotlinBuiltIns . isBuiltIn ( superClassDescriptor ) <EOL> } <EOL> } <EOL> superClassDescriptor = DescriptorUtils . getSuperClassDescriptor ( superClassDescriptor ) <EOL> } <EOL> return false <EOL> }


fun CallableMemberDescriptor . isFromJavaOrBuiltins ( )

= isFromJava || KotlinBuiltIns . isBuiltIn ( this )


= i < <NUM_LIT:1>


{ <EOL> var x = <NUM_LIT:0> <EOL> do { <EOL> var z = <NUM_LIT:2> <EOL> if ( shouldContinue ( x ++ ) ) { <EOL> continue <EOL> } <EOL> var y = <NUM_LIT:12> <EOL> } while ( x < z ) <EOL> }


override fun foo ( x : String ) : String

= "<STR_LIT>"


override fun bar ( x : String ) : String

= "<STR_LIT>"


= "<STR_LIT>"


fun foo ( x : String = "<STR_LIT>" ) : String

= "<STR_LIT>"


fun bar ( x : String = "<STR_LIT>" ) : String

= "<STR_LIT>"


fun foo ( x : String = "<STR_LIT>" ) : String


fun bar ( x : String = "<STR_LIT>" ) : String


{ <EOL> var o : I = C ( ) <EOL> var r = o . foo ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . foo ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . bar ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . bar ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> o = D ( ) <EOL> r = o . foo ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . foo ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . bar ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . bar ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> o = E ( ) <EOL> r = o . foo ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . foo ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . bar ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = o . bar ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> val p : K = F ( ) <EOL> r = p . foo ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = p . foo ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = p . bar ( ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> r = p . bar ( "<STR_LIT>" ) <EOL> if ( r != "<STR_LIT>" ) return "<STR_LIT>" <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> foo ( ) <EOL> baz ( ) <EOL> }


{ acquired -- }


{ <EOL> runBlocking { <EOL> repeat ( <NUM_LIT> ) { <EOL> launch { <EOL> val resource = withTimeout ( <NUM_LIT> ) { <EOL> delay ( <NUM_LIT> ) <EOL> Resource ( ) <EOL> } <EOL> resource . close ( ) <EOL> } <EOL> } <EOL> } <EOL> println ( acquired ) <EOL> }


fun test ( a : Any ? , b : Any ? , c : Any )

= <EOL> a ? : b ? : c


override fun doTest ( testDirectoryPath : Path )

{ <EOL> val files = compileToKnmFiles ( testDirectoryPath ) <EOL> for ( knmFile in files ) { <EOL> checkKnmStubConsistency ( knmFile ) <EOL> } <EOL> }


private fun checkKnmStubConsistency ( knmFile : VirtualFile )

{ <EOL> val decompiler = knmTestSupport . createDecompiler ( ) <EOL> val stubTreeBinaryFile = decompiler . stubBuilder . buildFileStub ( FileContentImpl . createByFile ( knmFile , environment . project ) ) ! ! <EOL> val fileViewProviderForDecompiledFile = decompiler . createFileViewProvider ( knmFile , PsiManager . getInstance ( project ) , physical = false , ) <EOL> val stubTreeForDecompiledFile = KtFileStubBuilder ( ) . buildStubTree ( KlibDecompiledFile ( fileViewProviderForDecompiledFile ) { virtualFile -> <EOL> decompiler . buildDecompiledTextForTests ( virtualFile ) <EOL> } ) <EOL> Assert . assertEquals ( "<STR_LIT>" , stubTreeForDecompiledFile . serializeToString ( ) , stubTreeBinaryFile . serializeToString ( ) ) <EOL> }


fun createConfiguration ( module : TestModule ) : DiagnosticsRenderingConfiguration

{ <EOL> return DiagnosticsRenderingConfiguration ( platform = null , withNewInference = module . languageVersionSettings . supportsFeature ( LanguageFeature . NewInference ) , languageVersionSettings = module . languageVersionSettings , skipDebugInfoDiagnostics = testServices . compilerConfigurationProvider . getCompilerConfiguration ( module ) . getBoolean ( JVMConfigurationKeys . IR ) ) <EOL> }


fun reportDiagnostic ( diagnostic : Diagnostic , module : TestModule , file : TestFile , configuration : DiagnosticsRenderingConfiguration , withNewInferenceModeEnabled : Boolean )

{ <EOL> globalMetadataInfoHandler . addMetadataInfosForFile ( file , diagnostic . toMetaInfo ( module , file , configuration . withNewInference , withNewInferenceModeEnabled ) ) <EOL> }


private fun Diagnostic . toMetaInfo ( module : TestModule , file : TestFile , newInferenceEnabled : Boolean , withNewInferenceModeEnabled : Boolean ) : List < DiagnosticCodeMetaInfo >

= textRanges . map { range -> <EOL> val metaInfo = DiagnosticCodeMetaInfo ( range , ClassicMetaInfoUtils . renderDiagnosticNoArgs , this ) <EOL> if ( withNewInferenceModeEnabled ) { <EOL> metaInfo . attributes += if ( newInferenceEnabled ) OldNewInferenceMetaInfoProcessor . NI else OldNewInferenceMetaInfoProcessor . OI <EOL> } <EOL> if ( file !in module . files ) { <EOL> val targetPlatform = module . targetPlatform <EOL> metaInfo . attributes += when { <EOL> targetPlatform . isJvm ( ) -> "<STR_LIT>" <EOL> targetPlatform . isJs ( ) -> "<STR_LIT>" <EOL> targetPlatform . isNative ( ) -> "<STR_LIT>" <EOL> targetPlatform . isCommon ( ) -> "<STR_LIT>" <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val existing = globalMetadataInfoHandler . getExistingMetaInfosForActualMetadata ( file , metaInfo ) <EOL> if ( existing . any { it . description != null } ) { <EOL> metaInfo . replaceRenderConfiguration ( ClassicMetaInfoUtils . renderDiagnosticWithArgs ) <EOL> } <EOL> metaInfo <EOL> }


override fun processorEnabled ( module : TestModule ) : Boolean

{ <EOL> return DiagnosticsDirectives . WITH_NEW_INFERENCE in module . directives <EOL> }


override fun firstAttributeEnabled ( module : TestModule ) : Boolean

{ <EOL> return module . languageVersionSettings . supportsFeature ( LanguageFeature . NewInference ) <EOL> }


fun TestServices . withNewInferenceModeEnabled ( ) : Boolean

{ <EOL> return DiagnosticsDirectives . WITH_NEW_INFERENCE in moduleStructure . allDirectives <EOL> }


= declaredMemberIndex . isComputed ( )


protected abstract fun computeMemberIndex ( ) : DeclaredMemberIndex


protected abstract fun computeNonDeclaredFunctions ( result : MutableCollection < SimpleFunctionDescriptor > , name : Name )


protected open fun computeImplicitlyDeclaredFunctions ( result : MutableCollection < SimpleFunctionDescriptor > , name : Name )


protected abstract fun getDispatchReceiverParameter ( ) : ReceiverParameterDescriptor ?


private fun MutableSet < SimpleFunctionDescriptor > . retainMostSpecificMethods ( )

{ <EOL> val groups = groupBy { it . computeJvmDescriptor ( withReturnType = false ) } . values <EOL> for ( group in groups ) { <EOL> if ( group . size == <NUM_LIT:1> ) continue <EOL> val mostSpecificMethods = group . selectMostSpecificInEachOverridableGroup { this } <EOL> removeAll ( group ) <EOL> addAll ( mostSpecificMethods ) <EOL> } <EOL> }


protected open fun JavaMethodDescriptor . isVisibleAsFunction ( )

= true


protected abstract fun resolveMethodSignature ( method : JavaMethod , methodTypeParameters : List < TypeParameterDescriptor > , returnType : KotlinType , valueParameters : List < ValueParameterDescriptor > ) : MethodSignatureData


protected fun resolveMethodToFunctionDescriptor ( method : JavaMethod ) : JavaMethodDescriptor

{ <EOL> val annotations = c . resolveAnnotations ( method ) <EOL> val functionDescriptorImpl = JavaMethodDescriptor . createJavaMethod ( ownerDescriptor , annotations , method . name , c . components . sourceElementFactory . source ( method ) , declaredMemberIndex ( ) . findRecordComponentByName ( method . name ) != null && method . valueParameters . isEmpty ( ) ) <EOL> val c = c . childForMethod ( functionDescriptorImpl , method ) <EOL> val methodTypeParameters = method . typeParameters . map { p -> c . typeParameterResolver . resolveTypeParameter ( p ) ! ! } <EOL> val valueParameters = resolveValueParameters ( c , functionDescriptorImpl , method . valueParameters ) <EOL> val returnType = computeMethodReturnType ( method , c ) <EOL> val effectiveSignature = resolveMethodSignature ( method , methodTypeParameters , returnType , valueParameters . descriptors ) <EOL> functionDescriptorImpl . initialize ( effectiveSignature . receiverType ? . let { <EOL> DescriptorFactory . createExtensionReceiverParameterForCallable ( functionDescriptorImpl , it , Annotations . EMPTY ) <EOL> } , getDispatchReceiverParameter ( ) , emptyList ( ) , effectiveSignature . typeParameters , effectiveSignature . valueParameters , effectiveSignature . returnType , Modality . convertFromFlags ( sealed = false , method . isAbstract , ! method . isFinal ) , method . visibility . toDescriptorVisibility ( ) , if ( effectiveSignature . receiverType != null ) mapOf ( JavaMethodDescriptor . ORIGINAL_VALUE_PARAMETER_FOR_EXTENSION_RECEIVER to valueParameters . descriptors . first ( ) ) else emptyMap < CallableDescriptor . UserDataKey < ValueParameterDescriptor > , ValueParameterDescriptor > ( ) ) <EOL> functionDescriptorImpl . setParameterNamesStatus ( effectiveSignature . hasStableParameterNames , valueParameters . hasSynthesizedNames ) <EOL> if ( effectiveSignature . errors . isNotEmpty ( ) ) { <EOL> c . components . signaturePropagator . reportSignatureErrors ( functionDescriptorImpl , effectiveSignature . errors ) <EOL> } <EOL> return functionDescriptorImpl <EOL> }


protected fun computeMethodReturnType ( method : JavaMethod , c : LazyJavaResolverContext ) : KotlinType

{ <EOL> val annotationMethod = method . containingClass . isAnnotationType <EOL> val returnTypeAttrs = TypeUsage . COMMON . toAttributes ( isForAnnotationParameter = annotationMethod ) <EOL> return c . typeResolver . transformJavaType ( method . returnType , returnTypeAttrs ) <EOL> }


protected fun resolveValueParameters ( c : LazyJavaResolverContext , function : FunctionDescriptor , jValueParameters : List < JavaValueParameter > ) : ResolvedValueParameters

{ <EOL> var synthesizedNames = false <EOL> val descriptors = jValueParameters . withIndex ( ) . map { ( index , javaParameter ) -> <EOL> val annotations = c . resolveAnnotations ( javaParameter ) <EOL> val typeUsage = TypeUsage . COMMON . toAttributes ( ) <EOL> val ( outType , varargElementType ) = <EOL> if ( javaParameter . isVararg ) { <EOL> val paramType = javaParameter . type as? JavaArrayType <EOL> ? : throw AssertionError ( "<STR_LIT>" ) <EOL> val outType = c . typeResolver . transformArrayType ( paramType , typeUsage , true ) <EOL> outType to c . module . builtIns . getArrayElementType ( outType ) <EOL> } else { <EOL> c . typeResolver . transformJavaType ( javaParameter . type , typeUsage ) to null <EOL> } <EOL> val name = if ( function . name . asString ( ) == "<STR_LIT:equals>" && jValueParameters . size == <NUM_LIT:1> && c . module . builtIns . nullableAnyType == outType ) { <EOL> Name . identifier ( "<STR_LIT:other>" ) <EOL> } else { <EOL> val javaName = javaParameter . name <EOL> if ( javaName == null ) synthesizedNames = true <EOL> javaName ? : Name . identifier ( "<STR_LIT>" ) <EOL> } <EOL> ValueParameterDescriptorImpl ( function , null , index , annotations , name , outType , false , false , false , varargElementType , c . components . sourceElementFactory . source ( javaParameter ) ) <EOL> } . toList ( ) <EOL> return ResolvedValueParameters ( descriptors , synthesizedNames ) <EOL> }


= functionNamesLazy


= propertyNamesLazy


= classNamesLazy


override fun definitelyDoesNotContainName ( name : Name ) : Boolean

{ <EOL> return name !in functionNamesLazy && name !in propertyNamesLazy && name !in classNamesLazy <EOL> }


override fun getContributedFunctions ( name : Name , location : LookupLocation ) : Collection < SimpleFunctionDescriptor >

{ <EOL> if ( name !in getFunctionNames ( ) ) return emptyList ( ) <EOL> return functions ( name ) <EOL> }


protected abstract fun computeFunctionNames ( kindFilter : DescriptorKindFilter , nameFilter : ( ( Name ) -> Boolean ) ? ) : Set < Name >


protected abstract fun computeNonDeclaredProperties ( name : Name , result : MutableCollection < PropertyDescriptor > )


protected abstract fun computePropertyNames ( kindFilter : DescriptorKindFilter , nameFilter : ( ( Name ) -> Boolean ) ? ) : Set < Name >


private fun resolveProperty ( field : JavaField ) : PropertyDescriptor

{ <EOL> var propertyDescriptor = createPropertyDescriptor ( field ) <EOL> propertyDescriptor . initialize ( null , null , null , null ) <EOL> val propertyType = getPropertyType ( field ) <EOL> propertyDescriptor . setType ( propertyType , listOf ( ) , getDispatchReceiverParameter ( ) , null , emptyList ( ) ) <EOL> ( ownerDescriptor as? ClassDescriptor ) ? . let { classDescriptor -> <EOL> propertyDescriptor = c . components . syntheticPartsProvider . modifyField ( classDescriptor , propertyDescriptor , c ) <EOL> } <EOL> if ( DescriptorUtils . shouldRecordInitializerForProperty ( propertyDescriptor , propertyDescriptor . type ) ) { <EOL> propertyDescriptor . setCompileTimeInitializerFactory { <EOL> c . storageManager . createNullableLazyValue { <EOL> c . components . javaPropertyInitializerEvaluator . getInitializerConstant ( field , propertyDescriptor ) <EOL> } <EOL> } <EOL> } <EOL> c . components . javaResolverCache . recordField ( field , propertyDescriptor ) <EOL> return propertyDescriptor <EOL> }


private fun createPropertyDescriptor ( field : JavaField ) : PropertyDescriptorImpl

{ <EOL> val isVar = ! field . isFinal <EOL> val annotations = c . resolveAnnotations ( field ) <EOL> return JavaPropertyDescriptor . create ( ownerDescriptor , annotations , Modality . FINAL , field . visibility . toDescriptorVisibility ( ) , isVar , field . name , c . components . sourceElementFactory . source ( field ) , field . isFinalStatic ) <EOL> }


private fun getPropertyType ( field : JavaField ) : KotlinType

{ <EOL> val propertyType = c . typeResolver . transformJavaType ( field . type , TypeUsage . COMMON . toAttributes ( ) ) <EOL> val isNotNullable = <EOL> ( KotlinBuiltIns . isPrimitiveType ( propertyType ) || KotlinBuiltIns . isString ( propertyType ) ) && <EOL> field . isFinalStatic && field . hasConstantNotNullInitializer <EOL> if ( isNotNullable ) { <EOL> return TypeUtils . makeNotNullable ( propertyType ) <EOL> } <EOL> return propertyType <EOL> }


override fun getContributedVariables ( name : Name , location : LookupLocation ) : Collection < PropertyDescriptor >

{ <EOL> if ( name !in getVariableNames ( ) ) return emptyList ( ) <EOL> return properties ( name ) <EOL> }


override fun getContributedDescriptors ( kindFilter : DescriptorKindFilter , nameFilter : ( Name ) -> Boolean )

= allDescriptors ( )


protected fun computeDescriptors ( kindFilter : DescriptorKindFilter , nameFilter : ( Name ) -> Boolean ) : List < DeclarationDescriptor >

{ <EOL> val location = NoLookupLocation . WHEN_GET_ALL_DESCRIPTORS <EOL> val result = LinkedHashSet < DeclarationDescriptor > ( ) <EOL> if ( kindFilter . acceptsKinds ( DescriptorKindFilter . CLASSIFIERS_MASK ) ) { <EOL> for ( name in computeClassNames ( kindFilter , nameFilter ) ) { <EOL> if ( nameFilter ( name ) ) { <EOL> result . addIfNotNull ( getContributedClassifier ( name , location ) ) <EOL> } <EOL> } <EOL> } <EOL> if ( kindFilter . acceptsKinds ( DescriptorKindFilter . FUNCTIONS_MASK ) && ! kindFilter . excludes . contains ( NonExtensions ) ) { <EOL> for ( name in computeFunctionNames ( kindFilter , nameFilter ) ) { <EOL> if ( nameFilter ( name ) ) { <EOL> result . addAll ( getContributedFunctions ( name , location ) ) <EOL> } <EOL> } <EOL> } <EOL> if ( kindFilter . acceptsKinds ( DescriptorKindFilter . VARIABLES_MASK ) && ! kindFilter . excludes . contains ( NonExtensions ) ) { <EOL> for ( name in computePropertyNames ( kindFilter , nameFilter ) ) { <EOL> if ( nameFilter ( name ) ) { <EOL> result . addAll ( getContributedVariables ( name , location ) ) <EOL> } <EOL> } <EOL> } <EOL> return result . toList ( ) <EOL> }


protected abstract fun computeClassNames ( kindFilter : DescriptorKindFilter , nameFilter : ( ( Name ) -> Boolean ) ? ) : Set < Name >


= "<STR_LIT>"


override fun printScopeStructure ( p : Printer )

{ <EOL> p . println ( this :: class . java . simpleName , "<STR_LIT>" ) <EOL> p . pushIndent ( ) <EOL> p . println ( "<STR_LIT>" ) <EOL> p . popIndent ( ) <EOL> p . println ( "<STR_LIT:}>" ) <EOL> }


public fun AnyCol . isColumnGroup ( ) : Boolean

= kind ( ) == ColumnKind . Group


public fun AnyCol . isFrameColumn ( ) : Boolean

= kind ( ) == ColumnKind . Frame


public fun AnyCol . isValueColumn ( ) : Boolean

= kind ( ) == ColumnKind . Value


public fun AnyCol . isSubtypeOf ( type : KType ) : Boolean

= this . type . isSubtypeOf ( type ) && ( ! this . type . isMarkedNullable || type . isMarkedNullable )


public inline fun < reified T > AnyCol . isSubtypeOf ( ) : Boolean

= isSubtypeOf ( typeOf < T > ( ) )


public inline fun < reified T > AnyCol . isType ( ) : Boolean

= type ( ) == typeOf < T > ( )


public fun AnyCol . isNumber ( ) : Boolean

= isSubtypeOf < Number ? > ( )


public fun AnyCol . isList ( ) : Boolean

= typeClass == List :: class


public fun AnyCol . isComparable ( ) : Boolean

= isSubtypeOf < Comparable < * > ? > ( )


@ PublishedApi <EOL> internal fun AnyCol . isPrimitive ( ) : Boolean

= typeClass . isPrimitive ( )


internal fun KClass < * > . isPrimitive ( ) : Boolean

= isSubclassOf ( Number :: class ) || this == String :: class || this == Char :: class || this == Array :: class || isSubclassOf ( Collection :: class )


fun f ( ) : String


= value


= <NUM_LIT:2>


{ <EOL> return A ( ) . f ( ) + D ( ) . f ( ) <EOL> }


fun source ( @ Language ( "<STR_LIT:kotlin>" ) sourceCode : String )


fun InlineSourceTestEnvironment . createModuleDescriptor ( @ Language ( "<STR_LIT:kotlin>" ) sourceCode : String ) : ModuleDescriptor

= <EOL> createModuleDescriptor ( kotlinCoreEnvironment , testTempDir , listOf ( sourceCode ) )


fun InlineSourceTestEnvironment . createModuleDescriptor ( build : InlineSourceCodeCollector . ( ) -> Unit ) : ModuleDescriptor

{ <EOL> val sources = mutableListOf < String > ( ) <EOL> object : InlineSourceCodeCollector { <EOL> override fun source ( sourceCode : String ) { <EOL> sources . add ( sourceCode ) <EOL> } <EOL> } . build ( ) <EOL> return createModuleDescriptor ( kotlinCoreEnvironment , testTempDir , sources . toList ( ) ) <EOL> }


fun JsImportedModule . getRequireName ( isEsm : Boolean = false ) : String

{ <EOL> return relativeRequirePath ? . let { <EOL> val extension = if ( isEsm ) ESM_EXTENSION else REGULAR_EXTENSION <EOL> "<STR_LIT>" <EOL> } ? : externalName <EOL> }


{ <EOL> return d . toString ( ) <EOL> }


fun lowerTypeModel ( ownerContext : NodeOwner < TypeModel > ) : TypeModel

= ownerContext . node


fun lower ( statement : StatementModel ) : StatementModel


fun lowerLambdaParameterModel ( ownerContext : NodeOwner < LambdaParameterModel > ) : LambdaParameterModel

= ownerContext . node


fun lower ( expression : ExpressionModel ) : ExpressionModel

{ <EOL> return when ( expression ) { <EOL> is UnaryExpressionModel -> expression . copy ( operand = lower ( expression . operand ) ) <EOL> is ConditionalExpressionModel -> expression . copy ( condition = lower ( expression . condition ) , whenTrue = lower ( expression . whenTrue ) , whenFalse = lower ( expression . whenFalse ) ) <EOL> is IndexExpressionModel -> expression . copy ( array = lower ( expression . array ) , index = lower ( expression . index ) ) <EOL> is CallExpressionModel -> expression . copy ( expression = lower ( expression . expression ) , arguments = expression . arguments . map { lower ( it ) } , typeParameters = expression . typeParameters . map { lowerTypeModel ( NodeOwner ( it , null ) ) } ) <EOL> is PropertyAccessExpressionModel -> expression . copy ( left = lower ( expression . left ) , right = lower ( expression . right ) ) <EOL> is LambdaExpressionModel -> expression . copy ( body = expression . body . copy ( statements = expression . body . statements . map { lower ( it ) } ) , parameters = expression . parameters . map { lowerLambdaParameterModel ( NodeOwner ( it , null ) ) } ) <EOL> is BinaryExpressionModel -> expression . copy ( left = lower ( expression . left ) , right = lower ( expression . right ) ) <EOL> is AsExpressionModel -> expression . copy ( expression = lower ( expression . expression ) , type = lowerTypeModel ( NodeOwner ( expression . type , null ) ) ) <EOL> is NonNullExpressionModel -> expression . copy ( expression = lower ( expression . expression ) ) <EOL> is ParenthesizedExpressionModel -> expression . copy ( expression = lower ( expression . expression ) ) <EOL> is TemplateExpressionModel -> expression . copy ( tokens = expression . tokens . map { lowerTemplateToken ( it ) } ) <EOL> is BooleanLiteralExpressionModel -> expression <EOL> is NumericLiteralExpressionModel -> expression <EOL> is StringLiteralExpressionModel -> lowerStringLiteralModel ( expression ) <EOL> is IdentifierExpressionModel -> expression <EOL> else -> { <EOL> logger . debug ( "<STR_LIT>" ) <EOL> expression <EOL> } <EOL> } <EOL> }


fun lowerStringLiteralModel ( literal : StringLiteralExpressionModel ) : StringLiteralExpressionModel

{ <EOL> return literal <EOL> }


fun lowerTemplateToken ( token : TemplateTokenModel ) : TemplateTokenModel

{ <EOL> return when ( token ) { <EOL> is ExpressionTemplateTokenModel -> token . copy ( expression = lower ( token . expression ) ) <EOL> is StringTemplateTokenModel -> token <EOL> else -> { <EOL> logger . debug ( "<STR_LIT>" ) <EOL> token <EOL> } <EOL> } <EOL> }


override fun canParse ( docComment : DocComment ) : Boolean

{ <EOL> return docComment is JavaDocComment <EOL> }


override fun parse ( docComment : DocComment , context : PsiNamedElement ) : DocumentationNode

{ <EOL> val javaDocComment = docComment as JavaDocComment <EOL> return parsePsiDocComment ( javaDocComment . comment , context ) <EOL> }


internal fun parsePsiDocComment ( docComment : PsiDocComment , context : PsiNamedElement ) : DocumentationNode

{ <EOL> val description = listOfNotNull ( docComment . getDescription ( ) ) <EOL> val tags = docComment . tags . mapNotNull { tag -> <EOL> parseDocTag ( tag , docComment , context ) <EOL> } <EOL> return DocumentationNode ( description + tags ) <EOL> }


private fun PsiDocComment . getDescription ( ) : Description ?

{ <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = descriptionElements . asIterable ( ) , commentResolutionContext = CommentResolutionContext ( this , DescriptionJavadocTag ) , ) <EOL> return docTags . takeIf { it . isNotEmpty ( ) } ? . let { <EOL> Description ( wrapTagIfNecessary ( it ) ) <EOL> } <EOL> }


private fun parseDocTag ( tag : PsiDocTag , docComment : PsiDocComment , analysedElement : PsiNamedElement ) : TagWrapper ?

{ <EOL> return when ( tag . name ) { <EOL> ParamJavadocTag . name -> parseParamTag ( tag , docComment , analysedElement ) <EOL> ThrowsJavadocTag . name , ExceptionJavadocTag . name -> parseThrowsTag ( tag , docComment ) <EOL> ReturnJavadocTag . name -> parseReturnTag ( tag , docComment ) <EOL> SinceJavadocTag . name -> parseSinceTag ( tag , docComment ) <EOL> AuthorJavadocTag . name -> parseAuthorTag ( tag , docComment ) <EOL> SeeJavadocTag . name -> parseSeeTag ( tag , docComment ) <EOL> DeprecatedJavadocTag . name -> parseDeprecatedTag ( tag , docComment ) <EOL> else -> emptyTagWrapper ( tag , docComment ) <EOL> } <EOL> }


private fun parseParamTag ( tag : PsiDocTag , docComment : PsiDocComment , analysedElement : PsiNamedElement ) : TagWrapper ?

{ <EOL> val paramName = tag . dataElements . firstOrNull ( ) ? . text . orEmpty ( ) <EOL> val paramIndex = when ( analysedElement ) { <EOL> is PsiMethod -> when { <EOL> paramName . startsWith ( '<CHAR_LIT>' ) -> { <EOL> val pName = paramName . removeSurrounding ( "<STR_LIT:<>" , "<STR_LIT:>>" ) <EOL> analysedElement . typeParameters . indexOfFirst { it . name == pName } <EOL> } <EOL> else -> analysedElement . parameterList . parameters . indexOfFirst { it . name == paramName } <EOL> } <EOL> is PsiClass -> when { <EOL> paramName . startsWith ( '<CHAR_LIT>' ) -> { <EOL> val pName = paramName . removeSurrounding ( "<STR_LIT:<>" , "<STR_LIT:>>" ) <EOL> analysedElement . typeParameters . indexOfFirst { it . name == pName } <EOL> } <EOL> else -> analysedElement . recordComponents . indexOfFirst { it . name == paramName } <EOL> } <EOL> else -> return null <EOL> } <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = tag . contentElementsWithSiblingIfNeeded ( ) . drop ( <NUM_LIT:1> ) , commentResolutionContext = CommentResolutionContext ( comment = docComment , tag = ParamJavadocTag ( paramName , paramIndex ) ) ) <EOL> return Param ( root = wrapTagIfNecessary ( docTags ) , name = paramName ) <EOL> }


private fun parseThrowsTag ( tag : PsiDocTag , docComment : PsiDocComment ) : Throws

{ <EOL> val resolvedElement = tag . resolveToElement ( ) <EOL> val exceptionAddress = resolvedElement ? . let { DRI . from ( it ) } <EOL> val fullyQualifiedExceptionName = <EOL> resolvedElement ? . getKotlinFqName ( ) ? : tag . dataElements . firstOrNull ( ) ? . text . orEmpty ( ) <EOL> val javadocTag = when ( tag . name ) { <EOL> ThrowsJavadocTag . name -> ThrowsJavadocTag ( fullyQualifiedExceptionName ) <EOL> ExceptionJavadocTag . name -> ExceptionJavadocTag ( fullyQualifiedExceptionName ) <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = tag . dataElements . drop ( <NUM_LIT:1> ) , commentResolutionContext = CommentResolutionContext ( comment = docComment , tag = javadocTag ) , ) <EOL> return Throws ( root = wrapTagIfNecessary ( docTags ) , name = fullyQualifiedExceptionName , exceptionAddress = exceptionAddress ) <EOL> }


private fun parseReturnTag ( tag : PsiDocTag , docComment : PsiDocComment ) : Return

{ <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = tag . contentElementsWithSiblingIfNeeded ( ) , commentResolutionContext = CommentResolutionContext ( comment = docComment , tag = ReturnJavadocTag ) , ) <EOL> return Return ( root = wrapTagIfNecessary ( docTags ) ) <EOL> }


private fun parseSinceTag ( tag : PsiDocTag , docComment : PsiDocComment ) : Since

{ <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = tag . contentElementsWithSiblingIfNeeded ( ) , commentResolutionContext = CommentResolutionContext ( comment = docComment , tag = ReturnJavadocTag ) , ) <EOL> return Since ( root = wrapTagIfNecessary ( docTags ) ) <EOL> }


private fun parseAuthorTag ( tag : PsiDocTag , docComment : PsiDocComment ) : Author

{ <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = tag . contentElementsWithSiblingIfNeeded ( ) , commentResolutionContext = CommentResolutionContext ( comment = docComment , tag = AuthorJavadocTag ) , ) <EOL> return Author ( root = wrapTagIfNecessary ( docTags ) ) <EOL> }


private fun parseSeeTag ( tag : PsiDocTag , docComment : PsiDocComment ) : See

{ <EOL> val referenceElement = tag . referenceElement ( ) <EOL> val fullyQualifiedSeeReference = tag . resolveToElement ( ) ? . getKotlinFqName ( ) <EOL> ? : referenceElement ? . text . orEmpty ( ) . removePrefix ( "<STR_LIT:#>" ) <EOL> val context = CommentResolutionContext ( comment = docComment , tag = SeeJavadocTag ( fullyQualifiedSeeReference ) ) <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = tag . dataElements . dropWhile { <EOL> it is PsiWhiteSpace || it . isDocReferenceHolder ( ) || it == referenceElement <EOL> } , commentResolutionContext = context , ) <EOL> return See ( root = wrapTagIfNecessary ( docTags ) , name = fullyQualifiedSeeReference , address = referenceElement ? . toDocumentationLink ( context = context ) ? . dri ) <EOL> }


private fun PsiElement . isDocReferenceHolder ( ) : Boolean

{ <EOL> return ( this as? LazyParseablePsiElement ) ? . elementType == JavaDocElementType . DOC_REFERENCE_HOLDER <EOL> }


private fun parseDeprecatedTag ( tag : PsiDocTag , docComment : PsiDocComment ) : Deprecated

{ <EOL> val docTags = psiDocTagParser . parseAsParagraph ( tag . contentElementsWithSiblingIfNeeded ( ) , CommentResolutionContext ( comment = docComment , tag = DeprecatedJavadocTag ) , ) <EOL> return Deprecated ( root = wrapTagIfNecessary ( docTags ) ) <EOL> }


private fun wrapTagIfNecessary ( tags : List < DocTag > ) : CustomDocTag

{ <EOL> val isFile = ( tags . singleOrNull ( ) as? CustomDocTag ) ? . name == MARKDOWN_ELEMENT_FILE_NAME <EOL> return if ( isFile ) { <EOL> tags . first ( ) as CustomDocTag <EOL> } else { <EOL> CustomDocTag ( tags , name = MARKDOWN_ELEMENT_FILE_NAME ) <EOL> } <EOL> }


private fun emptyTagWrapper ( tag : PsiDocTag , docComment : PsiDocComment , ) : CustomTagWrapper

{ <EOL> val docTags = psiDocTagParser . parseAsParagraph ( psiElements = tag . contentElementsWithSiblingIfNeeded ( ) , commentResolutionContext = CommentResolutionContext ( docComment , null ) , ) <EOL> return CustomTagWrapper ( root = wrapTagIfNecessary ( docTags ) , name = tag . name ) <EOL> }


private fun PsiElement . toDocumentationLink ( labelElement : PsiElement ? = null , context : CommentResolutionContext ) : DocumentationLink ?

{ <EOL> val resolvedElement = this . resolveToGetDri ( ) ? : return null <EOL> val label = labelElement ? : defaultLabel ( ) <EOL> val docTags = psiDocTagParser . parse ( listOfNotNull ( label ) , context ) <EOL> return DocumentationLink ( dri = DRI . from ( resolvedElement ) , children = docTags ) <EOL> }


override fun getConfigurableDisplayName ( ) : String

= KotlinLanguage . NAME


= KotlinLanguage . INSTANCE


override fun createCustomSettings ( settings : CodeStyleSettings ) : CustomCodeStyleSettings

{ <EOL> return KotlinCodeStyleSettings ( settings ) . apply { <EOL> this . ALLOW_TRAILING_COMMA = true <EOL> this . ALLOW_TRAILING_COMMA_ON_CALL_SITE = true <EOL> } <EOL> }


override fun createSettingsPage ( settings : CodeStyleSettings , originalSettings : CodeStyleSettings ) : Configurable

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


@ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldPublishCorrectlyWithOmittedVersion ( gradleVersion : GradleVersion )

{ <EOL> project ( "<STR_LIT>" . fullProjectName , gradleVersion ) { <EOL> build ( "<STR_LIT>" ) <EOL> } <EOL> }


@ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> fun testKotlinJvmProjectPublishesKotlinApiDependenciesAsCompile ( gradleVersion : GradleVersion )

{ <EOL> project ( "<STR_LIT:simpleProject>" , gradleVersion ) { <EOL> buildGradle . appendText ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT>" ) { <EOL> val pomText = projectPath <EOL> . resolve ( "<STR_LIT>" ) <EOL> . readText ( ) <EOL> . replace ( "<STR_LIT>" . toRegex ( ) , "<STR_LIT>" ) <EOL> assertTrue { <EOL> pomText . contains ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> }


@ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> fun testOmittedStdlibVersion ( gradleVersion : GradleVersion )

{ <EOL> project ( "<STR_LIT>" , gradleVersion ) { <EOL> buildGradle . appendText ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT:build>" , "<STR_LIT>" , ) { <EOL> assertTasksExecuted ( "<STR_LIT::compileKotlin>" , "<STR_LIT>" ) <EOL> val pomLines = projectPath . resolve ( "<STR_LIT>" ) . readLines ( ) <EOL> val stdlibVersionLineNumber = pomLines . indexOfFirst { "<STR_LIT>" in it } + <NUM_LIT:1> <EOL> val versionLine = pomLines [ stdlibVersionLineNumber ] <EOL> assertTrue { "<STR_LIT>" in versionLine } <EOL> } <EOL> } <EOL> }


@ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> @ GradleTestVersions ( maxVersion = TestVersions . Gradle . G_6_9 ) <EOL> @ DisabledOnOs ( OS . WINDOWS ) <EOL> fun testOldMavenPublishing ( gradleVersion : GradleVersion , @ TempDir localRepoDir : Path )

{ <EOL> project ( projectName = "<STR_LIT>" , gradleVersion = gradleVersion , localRepoDir = localRepoDir , buildOptions = defaultBuildOptions . copy ( warningMode = WarningMode . Summary ) ) { <EOL> build ( "<STR_LIT>" ) { <EOL> val publishingDir = localRepoDir . resolve ( "<STR_LIT>" ) . resolve ( "<STR_LIT>" ) <EOL> assertDirectoryExists ( publishingDir ) <EOL> assertFileExists ( publishingDir . resolve ( "<STR_LIT>" ) ) <EOL> val pomFile = publishingDir . resolve ( "<STR_LIT>" ) <EOL> assertFileExists ( pomFile ) <EOL> assertFileContains ( pomFile , """<STR_LIT>""" . trimMargin ( ) ) <EOL> } <EOL> } <EOL> }


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

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


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

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


fun replaceContractDescription ( newContractDescription : FirContractDescription ? )


fun < D > transformContractDescription ( transformer : FirTransformer < D > , data : D ) : FirContractDescriptionOwner


= x . foo ( )


= "<STR_LIT:OK>"


{ <EOL> c . startCoroutine ( Continuation ( EmptyCoroutineContext ) { <EOL> it . getOrThrow ( ) <EOL> } ) <EOL> }


{ <EOL> var res = "<STR_LIT:FAIL>" <EOL> builder { <EOL> res = A ( ) . nextBuffer ( ) <EOL> } <EOL> return res <EOL> }


fun fromPropertyValue ( value : String ) : KotlinCompilerArgumentsLogLevel

= <EOL> values ( ) . single { it . value == value }


{ <EOL> PANIC_OPTIONS . mode = mode <EOL> }


{ <EOL> return PANIC_OPTIONS . mode <EOL> }


{ <EOL> if ( System . getProperty ( "<STR_LIT>" ) == "<STR_LIT:true>" ) { <EOL> setPanicMode ( PanicMode . ALWAYS_FAIL ) <EOL> } <EOL> logger . debug ( "<STR_LIT>" ) <EOL> }


@ JvmStatic <EOL> fun get ( ) : Application

= error ( )


@ JvmStatic <EOL> fun getPreferencesDataStore ( )

= get ( ) . _preferencesDataStore


protected open fun getDeclarationOriginFor ( file : KtFile ) : FirDeclarationOrigin

{ <EOL> val virtualFile = file . virtualFile <EOL> return if ( virtualFile . extension == BuiltInSerializerProtocol . BUILTINS_FILE_EXTENSION ) { <EOL> FirDeclarationOrigin . BuiltIns <EOL> } else { <EOL> FirDeclarationOrigin . Library <EOL> } <EOL> }

/**
 * Computes the origin for the declarations coming from [file].
 *
 * We assume that a stub Kotlin declaration might come only from Library or from BuiltIns.
 * We do the decision based upon the extension of the [file].
 *
 * This method is left open so the inheritors can provide more optimal/strict implementations.
 */


private fun findAndDeserializeTypeAlias ( classId : ClassId , context : StubBasedFirDeserializationContext ? , ) : Pair < FirTypeAliasSymbol ? , DeserializedTypeAliasPostProcessor ? >

{ <EOL> val classLikeDeclaration = <EOL> ( context ? . classLikeDeclaration ? : declarationProvider . getClassLikeDeclarationByClassId ( classId ) ) <EOL> if ( classLikeDeclaration is KtTypeAlias ) { <EOL> val symbol = FirTypeAliasSymbol ( classId ) <EOL> val postProcessor : DeserializedTypeAliasPostProcessor = { <EOL> val rootContext = context ? : StubBasedFirDeserializationContext . createRootContext ( moduleData , StubBasedAnnotationDeserializer ( session ) , classId . packageFqName , classId . relativeClassName , classLikeDeclaration , null , null , symbol , initialOrigin = getDeclarationOriginFor ( classLikeDeclaration . containingKtFile ) ) <EOL> rootContext . memberDeserializer . loadTypeAlias ( classLikeDeclaration , symbol ) <EOL> } <EOL> return symbol to postProcessor <EOL> } <EOL> return null to null <EOL> }


private fun findAndDeserializeClass ( classId : ClassId , parentContext : StubBasedFirDeserializationContext ? , ) : FirRegularClassSymbol ?

{ <EOL> val classLikeDeclaration = parentContext ? . classLikeDeclaration <EOL> ? : declarationProvider . getClassLikeDeclarationByClassId ( classId ) <EOL> ? : return null <EOL> val symbol = FirRegularClassSymbol ( classId ) <EOL> if ( classLikeDeclaration is KtClassOrObject ) { <EOL> deserializeClassToSymbol ( classId , classLikeDeclaration , symbol , session , moduleData , StubBasedAnnotationDeserializer ( session ) , kotlinScopeProvider , parentContext = parentContext , containerSource = JvmStubDeserializedContainerSource ( classId ) , deserializeNestedClass = this :: getClass , initialOrigin = parentContext ? . initialOrigin ? : getDeclarationOriginFor ( classLikeDeclaration . containingKtFile ) ) <EOL> return symbol <EOL> } <EOL> return null <EOL> }


private fun loadFunctionsByCallableId ( callableId : CallableId , foundFunctions : Collection < KtNamedFunction > ? , ) : List < FirNamedFunctionSymbol >

{ <EOL> val topLevelFunctions = foundFunctions ? : declarationProvider . getTopLevelFunctions ( callableId ) <EOL> return ArrayList < FirNamedFunctionSymbol > ( topLevelFunctions . size ) . apply { <EOL> for ( function in topLevelFunctions ) { <EOL> val functionStub = function . stub as? KotlinFunctionStubImpl ? : loadStubByElement ( function ) <EOL> val functionFile = function . containingKtFile <EOL> val containerSource = getContainerSource ( functionFile , functionStub ? . origin ) <EOL> val functionOrigin = getDeclarationOriginFor ( functionFile ) <EOL> if ( functionOrigin != FirDeclarationOrigin . BuiltIns && containerSource is FacadeClassSource && containerSource . className . internalName in KotlinBuiltins ) { <EOL> continue <EOL> } <EOL> val symbol = FirNamedFunctionSymbol ( callableId ) <EOL> val rootContext = StubBasedFirDeserializationContext <EOL> . createRootContext ( session , moduleData , callableId , function , symbol , functionOrigin , containerSource ) <EOL> add ( rootContext . memberDeserializer . loadFunction ( function , null , session , symbol ) . symbol ) <EOL> } <EOL> } <EOL> }


private fun loadPropertiesByCallableId ( callableId : CallableId , foundProperties : Collection < KtProperty > ? ) : List < FirPropertySymbol >

{ <EOL> val topLevelProperties = foundProperties ? : declarationProvider . getTopLevelProperties ( callableId ) <EOL> return buildList { <EOL> for ( property in topLevelProperties ) { <EOL> val propertyStub = property . stub as? KotlinPropertyStubImpl ? : loadStubByElement ( property ) <EOL> val propertyFile = property . containingKtFile <EOL> val containerSource = getContainerSource ( propertyFile , propertyStub ? . origin ) <EOL> val propertyOrigin = getDeclarationOriginFor ( propertyFile ) <EOL> val symbol = FirPropertySymbol ( callableId ) <EOL> val rootContext = StubBasedFirDeserializationContext <EOL> . createRootContext ( session , moduleData , callableId , property , symbol , propertyOrigin , containerSource ) <EOL> add ( rootContext . memberDeserializer . loadProperty ( property , null , symbol ) . symbol ) <EOL> } <EOL> } <EOL> }


private fun getContainerSource ( file : KtFile , origin : KotlinStubOrigin ? ) : DeserializedContainerSource

{ <EOL> if ( getDeclarationOriginFor ( file ) == FirDeclarationOrigin . BuiltIns ) { <EOL> require ( origin is KotlinStubOrigin . Facade ) { <EOL> "<STR_LIT>" <EOL> } <EOL> return JvmStubDeserializedBuiltInsContainerSource ( facadeClassName = JvmClassName . byInternalName ( origin . className ) ) <EOL> } <EOL> return when ( origin ) { <EOL> is KotlinStubOrigin . Facade -> { <EOL> val className = JvmClassName . byInternalName ( origin . className ) <EOL> JvmStubDeserializedFacadeContainerSource ( className , facadeClassName = null ) <EOL> } <EOL> is KotlinStubOrigin . MultiFileFacade -> { <EOL> val className = JvmClassName . byInternalName ( origin . className ) <EOL> val facadeClassName = JvmClassName . byInternalName ( origin . facadeClassName ) <EOL> JvmStubDeserializedFacadeContainerSource ( className , facadeClassName ) <EOL> } <EOL> else -> { <EOL> val virtualFile = file . virtualFile <EOL> val classId = ClassId ( file . packageFqName , Name . identifier ( virtualFile . nameWithoutExtension ) ) <EOL> val className = JvmClassName . byClassId ( classId ) <EOL> JvmStubDeserializedFacadeContainerSource ( className , facadeClassName = null ) <EOL> } <EOL> } <EOL> }


private fun getClass ( classId : ClassId , parentContext : StubBasedFirDeserializationContext ? = null ) : FirRegularClassSymbol ?

= <EOL> if ( parentContext ? . classLikeDeclaration != null ) { <EOL> classCache . getNotNullValueForNotNullContext ( classId , parentContext ) <EOL> } else { <EOL> classCache . getValue ( classId , parentContext ) <EOL> }


private fun getTypeAlias ( classId : ClassId , context : StubBasedFirDeserializationContext ? = null ) : FirTypeAliasSymbol ?

{ <EOL> if ( ! classId . relativeClassName . isOneSegmentFQN ( ) ) return null <EOL> return typeAliasCache . getValue ( classId , context ) <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelCallableSymbolsTo ( destination : MutableList < FirCallableSymbol < * > > , packageFqName : FqName , name : Name )

{ <EOL> val callableId = CallableId ( packageFqName , name ) <EOL> destination += functionCache . getCallablesWithoutContext ( callableId ) <EOL> destination += propertyCache . getCallablesWithoutContext ( callableId ) <EOL> }


private fun < C : FirCallableSymbol < * > , CONTEXT > FirCache < CallableId , List < C > , CONTEXT ? > . getCallablesWithoutContext ( id : CallableId , ) : List < C >

{ <EOL> if ( ! symbolNamesProvider . mayHaveTopLevelCallable ( id . packageName , id . callableName ) ) return emptyList ( ) <EOL> return getValue ( id , null ) <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelCallableSymbolsTo ( destination : MutableList < FirCallableSymbol < * > > , callableId : CallableId , callables : Collection < KtCallableDeclaration > , )

{ <EOL> callables . filterIsInstance < KtNamedFunction > ( ) . ifNotEmpty { <EOL> destination += functionCache . getValue ( callableId , this ) <EOL> } <EOL> callables . filterIsInstance < KtProperty > ( ) . ifNotEmpty { <EOL> destination += propertyCache . getValue ( callableId , this ) <EOL> } <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelFunctionSymbolsTo ( destination : MutableList < FirNamedFunctionSymbol > , packageFqName : FqName , name : Name )

{ <EOL> destination += functionCache . getCallablesWithoutContext ( CallableId ( packageFqName , name ) ) <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelFunctionSymbolsTo ( destination : MutableList < FirNamedFunctionSymbol > , callableId : CallableId , functions : Collection < KtNamedFunction > , )

{ <EOL> destination += functionCache . getValue ( callableId , functions ) <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelPropertySymbolsTo ( destination : MutableList < FirPropertySymbol > , packageFqName : FqName , name : Name )

{ <EOL> destination += propertyCache . getCallablesWithoutContext ( CallableId ( packageFqName , name ) ) <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getTopLevelPropertySymbolsTo ( destination : MutableList < FirPropertySymbol > , callableId : CallableId , properties : Collection < KtProperty > , )

{ <EOL> destination += propertyCache . getValue ( callableId , properties ) <EOL> }


override fun getPackage ( fqName : FqName ) : FqName ?

= <EOL> fqName . takeIf { packageProvider . doesKotlinOnlyPackageExist ( fqName ) }


override fun getClassLikeSymbolByClassId ( classId : ClassId ) : FirClassLikeSymbol < * > ?

{ <EOL> if ( ! symbolNamesProvider . mayHaveTopLevelClassifier ( classId ) ) return null <EOL> classId . takeIf ( ClassId :: isNestedClass ) ? . outermostClassId ? . let { outermostClassId -> <EOL> getClassLikeSymbolByClassId ( outermostClassId ) <EOL> val computedValue = classCache . getValueIfComputed ( classId ) ? : typeAliasCache . getValueIfComputed ( classId ) <EOL> computedValue ? . let { return it } <EOL> } <EOL> return getClass ( classId ) ? : getTypeAlias ( classId ) <EOL> }


@ FirSymbolProviderInternals <EOL> override fun getClassLikeSymbolByClassId ( classId : ClassId , classLikeDeclaration : KtClassLikeDeclaration ) : FirClassLikeSymbol < * > ?

{ <EOL> val topmostClassLikeDeclaration = classLikeDeclaration . takeIf { <EOL> classId . isNestedClass <EOL> } ? . getTopmostParentOfType < KtClassLikeDeclaration > ( ) <EOL> val outermostClassId = topmostClassLikeDeclaration ? . getClassId ( ) <EOL> val cache = if ( classLikeDeclaration is KtClassOrObject ) classCache else typeAliasCache <EOL> if ( outermostClassId != null ) { <EOL> getClassLikeSymbolByClassId ( outermostClassId , topmostClassLikeDeclaration ) <EOL> cache . getValueIfComputed ( classId ) ? . let { return it } <EOL> } <EOL> val annotationDeserializer = StubBasedAnnotationDeserializer ( session ) <EOL> val classOrigin = getDeclarationOriginFor ( classLikeDeclaration . containingKtFile ) <EOL> val deserializationContext = StubBasedFirDeserializationContext ( moduleData , classId . packageFqName , classId . relativeClassName , StubBasedFirTypeDeserializer ( moduleData , annotationDeserializer , parent = null , containingSymbol = null , owner = null , classOrigin ) , annotationDeserializer , containerSource = null , outerClassSymbol = null , outerTypeParameters = emptyList ( ) , classOrigin , classLikeDeclaration , ) <EOL> return cache . getNotNullValueForNotNullContext ( classId , deserializationContext ) <EOL> }


fun getTopLevelCallableSymbol ( packageFqName : FqName , shortName : Name , callableDeclaration : KtCallableDeclaration , ) : FirCallableSymbol < * > ?

{ <EOL> val callableId = CallableId ( packageFqName , shortName ) <EOL> val callableSymbols = when ( callableDeclaration ) { <EOL> is KtNamedFunction -> functionCache . getValue ( callableId ) <EOL> is KtProperty -> propertyCache . getValue ( callableId ) <EOL> else -> null <EOL> } <EOL> return callableSymbols ? . singleOrNull { it . fir . realPsi == callableDeclaration } <EOL> }


@ Disabled ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> override fun testMppAndroidKapt ( gradleVersion : GradleVersion , agpVersion : String , jdkVersion : JdkVersions . ProvidedJdk , )


override fun TestProject . customizeProject ( )

{ <EOL> forceKapt4 ( ) <EOL> }


= runBlocking { <EOL> val myDeferredInt : Deferred < Int > = async { <EOL> throw UnsupportedOperationException ( "<STR_LIT>" ) <EOL> } <EOL> try { <EOL> val i : Int = myDeferredInt . await ( ) <EOL> println ( i ) <EOL> } catch ( u : UnsupportedOperationException ) { <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }


override fun getAnnotationsContainer ( binaryClass : KotlinJvmBinaryClass ) : AnnotationsContainerWithConstants < A , C >

= storage ( binaryClass )


protected abstract fun loadConstant ( desc : String , initializer : Any ) : C ?


protected abstract fun transformToUnsignedConstant ( constant : C ) : C ?


protected abstract fun loadAnnotationMethodDefaultValue ( annotationClass : KotlinJvmBinaryClass , methodSignature : MemberSignature , visitResult : ( C ) -> Unit ) : KotlinJvmBinaryClass . AnnotationArgumentVisitor ?


override fun loadAnnotationDefaultValue ( container : ProtoContainer , proto : ProtoBuf . Property , expectedType : KotlinType ) : C ?

{ <EOL> return loadConstantFromProperty ( container , proto , AnnotatedCallableKind . PROPERTY_GETTER , expectedType ) { annotationParametersDefaultValues [ it ] } <EOL> }


override fun loadPropertyConstant ( container : ProtoContainer , proto : ProtoBuf . Property , expectedType : KotlinType ) : C ?

{ <EOL> return loadConstantFromProperty ( container , proto , AnnotatedCallableKind . PROPERTY , expectedType ) { propertyConstants [ it ] } <EOL> }


private fun loadConstantFromProperty ( container : ProtoContainer , proto : ProtoBuf . Property , annotatedCallableKind : AnnotatedCallableKind , expectedType : KotlinType , loader : AnnotationsContainerWithConstants < A , C > . ( MemberSignature ) -> C ? <EOL> ) : C ?

{ <EOL> val specialCase = getSpecialCaseContainerClass ( container , property = true , field = true , isConst = Flags . IS_CONST . get ( proto . flags ) , isMovedFromInterfaceCompanion = JvmProtoBufUtil . isMovedFromInterfaceCompanion ( proto ) , kotlinClassFinder = kotlinClassFinder , jvmMetadataVersion = jvmMetadataVersion ) <EOL> val kotlinClass = findClassWithAnnotationsAndInitializers ( container , specialCase ) ? : return null <EOL> val requireHasFieldFlag = kotlinClass . classHeader . metadataVersion . isAtLeast ( DeserializedDescriptorResolver . KOTLIN_1_3_RC_METADATA_VERSION ) <EOL> val signature = <EOL> getCallableSignature ( proto , container . nameResolver , container . typeTable , annotatedCallableKind , requireHasFieldFlag ) ? : return null <EOL> val result = storage ( kotlinClass ) . loader ( signature ) ? : return null <EOL> return if ( UnsignedTypes . isUnsignedType ( expectedType ) ) transformToUnsignedConstant ( result ) else result <EOL> }


private fun loadAnnotationsAndInitializers ( kotlinClass : KotlinJvmBinaryClass ) : AnnotationsContainerWithConstants < A , C >

{ <EOL> val memberAnnotations = HashMap < MemberSignature , MutableList < A > > ( ) <EOL> val propertyConstants = HashMap < MemberSignature , C > ( ) <EOL> val annotationParametersDefaultValues = HashMap < MemberSignature , C > ( ) <EOL> kotlinClass . visitMembers ( object : KotlinJvmBinaryClass . MemberVisitor { <EOL> override fun visitMethod ( name : Name , desc : String ) : KotlinJvmBinaryClass . MethodAnnotationVisitor ? { <EOL> return AnnotationVisitorForMethod ( MemberSignature . fromMethodNameAndDesc ( name . asString ( ) , desc ) ) <EOL> } <EOL> override fun visitField ( name : Name , desc : String , initializer : Any ? ) : KotlinJvmBinaryClass . AnnotationVisitor ? { <EOL> val signature = MemberSignature . fromFieldNameAndDesc ( name . asString ( ) , desc ) <EOL> if ( initializer != null ) { <EOL> val constant = loadConstant ( desc , initializer ) <EOL> if ( constant != null ) { <EOL> propertyConstants [ signature ] = constant <EOL> } <EOL> } <EOL> return MemberAnnotationVisitor ( signature ) <EOL> } <EOL> inner class AnnotationVisitorForMethod ( signature : MemberSignature ) : MemberAnnotationVisitor ( signature ) , <EOL> KotlinJvmBinaryClass . MethodAnnotationVisitor { <EOL> override fun visitParameterAnnotation ( index : Int , classId : ClassId , source : SourceElement ) : KotlinJvmBinaryClass . AnnotationArgumentVisitor ? { <EOL> val paramSignature = MemberSignature . fromMethodSignatureAndParameterIndex ( signature , index ) <EOL> var result = memberAnnotations [ paramSignature ] <EOL> if ( result == null ) { <EOL> result = ArrayList ( ) <EOL> memberAnnotations [ paramSignature ] = result <EOL> } <EOL> return loadAnnotationIfNotSpecial ( classId , source , result ) <EOL> } <EOL> override fun visitAnnotationMemberDefaultValue ( ) : KotlinJvmBinaryClass . AnnotationArgumentVisitor ? { <EOL> return loadAnnotationMethodDefaultValue ( kotlinClass , signature ) { <EOL> annotationParametersDefaultValues [ signature ] = it <EOL> } <EOL> } <EOL> } <EOL> open inner class MemberAnnotationVisitor ( protected val signature : MemberSignature ) : KotlinJvmBinaryClass . AnnotationVisitor { <EOL> private val result = ArrayList < A > ( ) <EOL> override fun visitAnnotation ( classId : ClassId , source : SourceElement ) : KotlinJvmBinaryClass . AnnotationArgumentVisitor ? { <EOL> return loadAnnotationIfNotSpecial ( classId , source , result ) <EOL> } <EOL> override fun visitEnd ( ) { <EOL> if ( result . isNotEmpty ( ) ) { <EOL> memberAnnotations [ signature ] = result <EOL> } <EOL> } <EOL> } <EOL> } , getCachedFileContent ( kotlinClass ) ) <EOL> return AnnotationsContainerWithConstants ( memberAnnotations , propertyConstants , annotationParametersDefaultValues ) <EOL> }


protected fun isRepeatableWithImplicitContainer ( annotationClassId : ClassId , arguments : Map < Name , ConstantValue < * > > ) : Boolean

{ <EOL> if ( annotationClassId != SpecialJvmAnnotations . JAVA_LANG_ANNOTATION_REPEATABLE ) return false <EOL> val containerKClassValue = arguments [ Name . identifier ( "<STR_LIT:value>" ) ] as? KClassValue ? : return false <EOL> val normalClass = containerKClassValue . value as? KClassValue . Value . NormalClass ? : return false <EOL> return isImplicitRepeatableContainer ( normalClass . classId ) <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldFailIfJavaAndKotlinJvmTargetsAreDifferent ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion , buildOptions = defaultBuildOptions . copy ( logLevel = LogLevel . WARN ) ) { <EOL> setJavaCompilationCompatibility ( JavaVersion . VERSION_1_8 ) <EOL> useToolchainToCompile ( <NUM_LIT:11> ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> buildAndFail ( "<STR_LIT:assemble>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun overrideModeForTask ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion , buildOptions = defaultBuildOptions . copy ( logLevel = LogLevel . WARN ) ) { <EOL> setJavaCompilationCompatibility ( JavaVersion . VERSION_1_8 ) <EOL> useToolchainToCompile ( <NUM_LIT:11> ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> buildGradle . appendText ( """<STR_LIT>""" . trimMargin ( ) ) <EOL> build ( "<STR_LIT:assemble>" ) { <EOL> assertNoDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldWarnBuildIfJavaAndKotlinJvmTargetsAreDifferent ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion ) { <EOL> setJavaCompilationCompatibility ( JavaVersion . VERSION_1_8 ) <EOL> useToolchainToCompile ( <NUM_LIT:11> ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT:assemble>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldNotPrintAnythingIfJavaAndKotlinJvmTargetsAreDifferent ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion ) { <EOL> setJavaCompilationCompatibility ( JavaVersion . VERSION_1_8 ) <EOL> useToolchainToCompile ( <NUM_LIT:11> ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT:assemble>" ) { <EOL> assertNoDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldNotWarnOnJavaAndKotlinSameJvmTargets ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion ) { <EOL> useToolchainToCompile ( <NUM_LIT:11> ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT:build>" ) { <EOL> assertNoDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldProduceJavaKotlinJvmTargetDifferenceWarningOnlyForRelatedTasks ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion ) { <EOL> useToolchainToCompile ( <NUM_LIT:11> ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> buildGradle . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT:build>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks , withSubstring = "<STR_LIT>" ) <EOL> assertNoDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks , withSubstring = "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun oldJdkMixedJavaKotlinTargetVerification ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion ) { <EOL> buildGradle . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT:build>" ) <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldSkipJvmTargetValidationNoKotlinSources ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" . fullProjectName , gradleVersion = gradleVersion ) { <EOL> setJavaCompilationCompatibility ( JavaVersion . VERSION_1_8 ) <EOL> useToolchainToCompile ( <NUM_LIT:11> ) <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> kotlinSourcesDir ( ) . toFile ( ) . deleteRecursively ( ) <EOL> javaSourcesDir ( ) . resolve ( "<STR_LIT>" ) . deleteExisting ( ) <EOL> build ( "<STR_LIT:assemble>" ) { <EOL> assertNoDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> javaSourcesDir ( ) . resolve ( "<STR_LIT>" ) . modify { <EOL> it . replace ( "<STR_LIT>" , """<STR_LIT>""" ) <EOL> } <EOL> build ( "<STR_LIT:assemble>" ) { <EOL> assertNoDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldDoJvmTargetValidationOnNoJavaSources ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT:simple>" . fullProjectName , gradleVersion = gradleVersion , ) { <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> buildGradle . appendText ( """<STR_LIT>""" . trimMargin ( ) ) <EOL> build ( "<STR_LIT::compileKotlin>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun shouldDoJvmTargetValidationOnNewJavaSourcesAndConfigurationCacheReuse ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT:simple>" . fullProjectName , gradleVersion = gradleVersion , buildOptions = defaultBuildOptions . withConfigurationCache ) { <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> buildGradle . appendText ( """<STR_LIT>""" . trimMargin ( ) ) <EOL> build ( "<STR_LIT::compileKotlin>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> javaSourcesDir ( ) . resolve ( "<STR_LIT>" ) . run { <EOL> createDirectories ( ) <EOL> resolve ( "<STR_LIT>" ) . writeText ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> } <EOL> build ( "<STR_LIT::compileKotlin>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ OtherGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun kaptGenerateStubsValidateCorrect ( gradleVersion : GradleVersion )

{ <EOL> project ( projectName = "<STR_LIT>" , gradleVersion = gradleVersion , ) { <EOL> val toolchainJavaVersion = if ( gradleVersion < GradleVersion . version ( "<STR_LIT>" ) ) <NUM_LIT:11> else <NUM_LIT> <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> buildGradle . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> build ( "<STR_LIT>" ) <EOL> } <EOL> }


@ JvmGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTestVersions ( maxVersion = TestVersions . Gradle . G_8_0 ) <EOL> @ GradleTest <EOL> internal fun errorByDefaultWithGradle8 ( gradleVersion : GradleVersion )

{ <EOL> project ( "<STR_LIT:simple>" . fullProjectName , gradleVersion ) { <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> buildGradle . appendText ( """<STR_LIT>""" . trimMargin ( ) ) <EOL> if ( gradleVersion . baseVersion >= GradleVersion . version ( "<STR_LIT>" ) ) { <EOL> buildAndFail ( "<STR_LIT:assemble>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } else { <EOL> build ( "<STR_LIT:assemble>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> } <EOL> }


@ MppGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun mppWithJavaFailValidation ( gradleVersion : GradleVersion )

{ <EOL> project ( "<STR_LIT>" , gradleVersion ) { <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> subProject ( "<STR_LIT:lib>" ) . buildGradleKts . appendText ( """<STR_LIT>""" . trimMargin ( ) ) <EOL> buildAndFail ( "<STR_LIT>" ) { <EOL> assertHasDiagnostic ( KotlinToolingDiagnostics . InconsistentTargetCompatibilityForKotlinAndJavaTasks ) <EOL> } <EOL> } <EOL> }


@ MppGradlePluginTests <EOL> @ DisplayName ( "<STR_LIT>" ) <EOL> @ GradleTest <EOL> internal fun mppJvmNotFailValidation ( gradleVersion : GradleVersion )

{ <EOL> project ( "<STR_LIT>" , gradleVersion ) { <EOL> gradleProperties . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> subProject ( "<STR_LIT:lib>" ) . buildGradleKts . appendText ( """<STR_LIT>""" . trimMargin ( ) ) <EOL> build ( "<STR_LIT>" ) <EOL> } <EOL> }


private fun TestProject . setJavaCompilationCompatibility ( target : JavaVersion )

{ <EOL> buildGradle . append ( """<STR_LIT>""" . trimIndent ( ) ) <EOL> }


private fun TestProject . useToolchainToCompile ( jdkVersion : Int )


= Jvm . forHome ( File ( System . getProperty ( "<STR_LIT>" ) ) )


= a


{ <EOL> use ( use ( A , null ) . toString ( ) ) <EOL> }


private fun primitiveClassProperty ( name : String )

= <EOL> primitiveClassProperties . singleOrNull { it . name == Name . identifier ( name ) } ? . getter <EOL> ? : primitiveClassesObject . owner . declarations <EOL> . filterIsInstance < IrSimpleFunction > ( ) <EOL> . single { it . name == Name . special ( "<STR_LIT>" ) }


private fun getPrimitiveClass ( target : IrSimpleFunction , returnType : IrType )

= <EOL> JsIrBuilder . buildCall ( target . symbol , returnType ) . apply { <EOL> dispatchReceiver = JsIrBuilder . buildGetObjectValue ( type = primitiveClassesObject . defaultType , classSymbol = primitiveClassesObject ) <EOL> }


override fun getFinalPrimitiveKClass ( returnType : IrType , typeArgument : IrType ) : IrCall ?

{ <EOL> for ( ( typePredicate , v ) in finalPrimitiveClasses ) { <EOL> if ( typePredicate ( typeArgument ) ) <EOL> return getPrimitiveClass ( v , returnType ) <EOL> } <EOL> return null <EOL> }


override fun getOpenPrimitiveKClass ( returnType : IrType , typeArgument : IrType ) : IrCall ?

{ <EOL> for ( ( typePredicate , v ) in openPrimitiveClasses ) { <EOL> if ( typePredicate ( typeArgument ) ) <EOL> return getPrimitiveClass ( v , returnType ) <EOL> } <EOL> if ( typeArgument . isFunction ( ) ) { <EOL> val functionInterface = typeArgument . getClass ( ) ! ! <EOL> val arity = functionInterface . typeParameters . size - <NUM_LIT:1> <EOL> return getPrimitiveClass ( primitiveClassFunctionClass , returnType ) . apply { <EOL> putValueArgument ( <NUM_LIT:0> , JsIrBuilder . buildInt ( context . irBuiltIns . intType , arity ) ) <EOL> } <EOL> } <EOL> return null <EOL> }


override fun callGetKClass ( returnType : IrType , typeArgument : IrType ) : IrCall

{ <EOL> val primitiveKClass = <EOL> getFinalPrimitiveKClass ( returnType , typeArgument ) ? : getOpenPrimitiveKClass ( returnType , typeArgument ) <EOL> if ( primitiveKClass != null ) <EOL> return primitiveKClass <EOL> return JsIrBuilder . buildCall ( reflectionSymbols . getKClass , returnType , listOf ( typeArgument ) ) <EOL> . apply { <EOL> putValueArgument ( <NUM_LIT:0> , callGetClassByType ( typeArgument ) ) <EOL> } <EOL> }


private fun callGetClassByType ( type : IrType )

= <EOL> JsIrBuilder . buildCall ( getClassData , typeArguments = listOf ( type ) , origin = JsStatementOrigins . CLASS_REFERENCE )


protected open fun getFinalPrimitiveKClass ( returnType : IrType , typeArgument : IrType ) : IrCall ?

= null


protected open fun getOpenPrimitiveKClass ( returnType : IrType , typeArgument : IrType ) : IrCall ?

= null


private fun callGetKClassFromExpression ( returnType : IrType , typeArgument : IrType , argument : IrExpression ) : IrExpression

{ <EOL> val primitiveKClass = getFinalPrimitiveKClass ( returnType , typeArgument ) <EOL> if ( primitiveKClass != null ) <EOL> return JsIrBuilder . buildBlock ( returnType , listOf ( argument , primitiveKClass ) ) <EOL> return JsIrBuilder . buildCall ( reflectionSymbols . getKClassFromExpression , returnType , listOf ( typeArgument ) ) . apply { <EOL> putValueArgument ( <NUM_LIT:0> , argument ) <EOL> } <EOL> }


abstract fun callGetKClass ( returnType : IrType = reflectionSymbols . getKClass . owner . returnType , typeArgument : IrType ) : IrCall


private fun buildCall ( name : IrSimpleFunctionSymbol , vararg args : IrExpression ) : IrExpression

= <EOL> JsIrBuilder . buildCall ( name ) . apply { <EOL> args . forEachIndexed { index , irExpression -> <EOL> putValueArgument ( index , irExpression ) <EOL> } <EOL> }


private fun createKType ( type : IrType , visitedTypeParams : MutableSet < IrTypeParameter > ) : IrExpression

{ <EOL> if ( type is IrSimpleType ) <EOL> return createSimpleKType ( type , visitedTypeParams ) <EOL> if ( type is IrDynamicType ) <EOL> return createDynamicType ( ) <EOL> compilationException ( "<STR_LIT>" , type ) <EOL> }


private fun createDynamicType ( ) : IrExpression

{ <EOL> return buildCall ( reflectionSymbols . createDynamicKType ! ! ) <EOL> }


private fun createSimpleKType ( type : IrSimpleType , visitedTypeParams : MutableSet < IrTypeParameter > ) : IrExpression

{ <EOL> val classifier : IrClassifierSymbol = type . classifier <EOL> val kClassifier = createKClassifier ( classifier , visitedTypeParams ) <EOL> val arguments = context . createArrayOfExpression ( startOffset = UNDEFINED_OFFSET , endOffset = UNDEFINED_OFFSET , arrayElementType = context . reflectionSymbols . kTypeClass . defaultType , arrayElements = type . arguments . memoryOptimizedMap { createKTypeProjection ( it , visitedTypeParams ) } ) <EOL> val isMarkedNullable = JsIrBuilder . buildBoolean ( context . irBuiltIns . booleanType , type . isMarkedNullable ( ) ) <EOL> return buildCall ( reflectionSymbols . createKType ! ! , kClassifier , arguments , isMarkedNullable ) <EOL> }


private fun createKTypeProjection ( tp : IrTypeArgument , visitedTypeParams : MutableSet < IrTypeParameter > ) : IrExpression

{ <EOL> if ( tp !is IrTypeProjection ) { <EOL> return buildCall ( reflectionSymbols . getStarKTypeProjection ! ! ) <EOL> } <EOL> val factoryName = when ( tp . variance ) { <EOL> Variance . INVARIANT -> reflectionSymbols . createInvariantKTypeProjection ! ! <EOL> Variance . IN_VARIANCE -> reflectionSymbols . createContravariantKTypeProjection ! ! <EOL> Variance . OUT_VARIANCE -> reflectionSymbols . createCovariantKTypeProjection ! ! <EOL> } <EOL> val kType = createKType ( tp . type , visitedTypeParams ) <EOL> return buildCall ( factoryName , kType ) <EOL> }


private fun createKClassifier ( classifier : IrClassifierSymbol , visitedTypeParams : MutableSet < IrTypeParameter > ) : IrExpression

= <EOL> when ( classifier ) { <EOL> is IrTypeParameterSymbol -> createKTypeParameter ( classifier . owner , visitedTypeParams ) <EOL> else -> callGetKClass ( typeArgument = classifier . defaultType ) <EOL> }


private fun createKTypeParameter ( typeParameter : IrTypeParameter , visitedTypeParams : MutableSet < IrTypeParameter > ) : IrExpression

{ <EOL> if ( typeParameter in visitedTypeParams ) TODO ( "<STR_LIT>" ) <EOL> visitedTypeParams . add ( typeParameter ) <EOL> val name = JsIrBuilder . buildString ( context . irBuiltIns . stringType , typeParameter . name . asString ( ) ) <EOL> val upperBounds = context . createArrayOfExpression ( startOffset = UNDEFINED_OFFSET , endOffset = UNDEFINED_OFFSET , arrayElementType = context . reflectionSymbols . kTypeClass . defaultType , arrayElements = typeParameter . superTypes . memoryOptimizedMap { createKType ( it , visitedTypeParams ) } ) <EOL> val variance = when ( typeParameter . variance ) { <EOL> Variance . INVARIANT -> JsIrBuilder . buildString ( context . irBuiltIns . stringType , "<STR_LIT>" ) <EOL> Variance . IN_VARIANCE -> JsIrBuilder . buildString ( context . irBuiltIns . stringType , "<STR_LIT>" ) <EOL> Variance . OUT_VARIANCE -> JsIrBuilder . buildString ( context . irBuiltIns . stringType , "<STR_LIT>" ) <EOL> } <EOL> return buildCall ( reflectionSymbols . createKTypeParameter ! ! , name , upperBounds , variance , typeParameter . isReified . toIrConst ( context . irBuiltIns . booleanType ) , ) . also { <EOL> visitedTypeParams . remove ( typeParameter ) <EOL> } <EOL> }


override fun lower ( irBody : IrBody , container : IrDeclaration )

{ <EOL> irBody . transformChildrenVoid ( object : IrElementTransformerVoidWithContext ( ) { <EOL> override fun visitGetClass ( expression : IrGetClass ) = <EOL> callGetKClassFromExpression ( returnType = expression . type , typeArgument = expression . argument . type , argument = expression . argument . transform ( this , null ) ) <EOL> override fun visitClassReference ( expression : IrClassReference ) = <EOL> callGetKClass ( returnType = expression . type , typeArgument = expression . classType . makeNotNull ( ) ) <EOL> override fun visitCall ( expression : IrCall ) : IrExpression = <EOL> if ( Symbols . isTypeOfIntrinsic ( expression . symbol ) ) { <EOL> createKType ( expression . getTypeArgument ( <NUM_LIT:0> ) ! ! , hashSetOf ( ) ) <EOL> } else { <EOL> super . visitCall ( expression ) <EOL> } <EOL> } ) <EOL> }


= membersDiffList . isEmpty ( )


override fun writeAsHtml ( output : PrintWriter )

{ <EOL> if ( isEmpty ( ) ) return <EOL> output . tag ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> output . listDiff ( header1 , header2 , membersDiffList ) <EOL> }


fun addMembersListDiffs ( diffs : List < ListEntryDiff > )

{ <EOL> for ( diff in diffs ) { <EOL> membersDiffList . add ( diff . toDiffEntry ( ) ) <EOL> } <EOL> }


fun TextTreeBuilderContext . appendMultiFileClassFacadeReport ( )

{ <EOL> if ( isNotEmpty ( ) ) { <EOL> node ( "<STR_LIT>" ) { <EOL> appendDiffEntries ( header1 , header2 , membersDiffList ) <EOL> } <EOL> } <EOL> }


operator fun invoke ( usedDeprecatedProperties : List < String > )

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


operator fun invoke ( podName : String )

= build ( """<STR_LIT>""" . trimIndent ( ) )


= build ( "<STR_LIT>" )


operator fun invoke ( podName : String , dependencyName : String )

= build ( "<STR_LIT>" )


@ DisplayName ( "<STR_LIT>" ) <EOL> @ ParameterizedTest ( name = "<STR_LIT>" ) <EOL> @ MethodSource ( "<STR_LIT>" ) <EOL> fun withValueSource ( name : String , tsPath : String , ktPath : String )

{ <EOL> assertContentEquals ( name , tsPath , ktPath ) <EOL> }


override fun getTranslator ( ) : InputTranslator < String >

= translator


@ JvmStatic <EOL> fun idl2ktSet ( ) : Array < Array < String > >

{ <EOL> return MethodSourceSourceFiles ( "<STR_LIT>" , WEBIDL_DECLARATION_EXTENSION ) . fileSetWithDescriptors ( ) <EOL> }


= <NUM_LIT:10>


override fun findInnerClass ( name : Name )

= klass . declaredClasses <EOL> . asSequence ( ) <EOL> . firstOrNull { <EOL> it . simpleName == name . asString ( ) <EOL> } ? . let ( :: ReflectJavaClass )


private fun isEnumValuesOrValueOf ( method : Method ) : Boolean

{ <EOL> return when ( method . name ) { <EOL> "<STR_LIT>" -> method . parameterTypes . isEmpty ( ) <EOL> "<STR_LIT>" -> Arrays . equals ( method . parameterTypes , arrayOf ( String :: class . java ) ) <EOL> else -> false <EOL> } <EOL> }


= false


= other is ReflectJavaClass && klass == other . klass


= klass . hashCode ( )


= this :: class . java . name + "<STR_LIT::U+0020>" + klass


{ <EOL> val clazz = Class :: class . java <EOL> return try { <EOL> Cache ( clazz . getMethod ( "<STR_LIT>" ) , clazz . getMethod ( "<STR_LIT>" ) , clazz . getMethod ( "<STR_LIT>" ) , clazz . getMethod ( "<STR_LIT>" ) ) <EOL> } catch ( e : NoSuchMethodException ) { <EOL> Cache ( null , null , null , null ) <EOL> } <EOL> }


{ <EOL> var cache = this . _cache <EOL> if ( cache == null ) { <EOL> cache = buildCache ( ) <EOL> this . _cache = cache <EOL> } <EOL> return cache <EOL> }


fun loadIsSealed ( clazz : Class < * > ) : Boolean ?

{ <EOL> val cache = initCache ( ) <EOL> val isSealed = cache . isSealed ? : return null <EOL> return isSealed . invoke ( clazz ) as Boolean <EOL> }


fun loadGetPermittedSubclasses ( clazz : Class < * > ) : Array < Class < * > > ?

{ <EOL> val cache = initCache ( ) <EOL> val getPermittedSubclasses = cache . getPermittedSubclasses ? : return null <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return getPermittedSubclasses . invoke ( clazz ) as Array < Class < * > > <EOL> }


fun loadIsRecord ( clazz : Class < * > ) : Boolean ?

{ <EOL> val cache = initCache ( ) <EOL> val isRecord = cache . isRecord ? : return null <EOL> return isRecord . invoke ( clazz ) as Boolean <EOL> }


fun loadGetRecordComponents ( clazz : Class < * > ) : Array < Any > ?

{ <EOL> val cache = initCache ( ) <EOL> val getRecordComponents = cache . getRecordComponents ? : return null <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return getRecordComponents . invoke ( clazz ) as Array < Any > ? <EOL> }


{ <EOL> val data : Any = OwnedProject ( "<STR_LIT>" , "<STR_LIT:kotlin>" ) <EOL> println ( format . encodeToString ( PolymorphicSerializer ( Any :: class ) , data ) ) <EOL> }


{ <EOL> val c = CalculatorConstants ( ) <EOL> return c . status <EOL> }


override fun compareTo ( other : LookupSymbolKey ) : Int

{ <EOL> val nameCmp = nameHash . compareTo ( other . nameHash ) <EOL> if ( nameCmp != <NUM_LIT:0> ) return nameCmp <EOL> return scopeHash . compareTo ( other . scopeHash ) <EOL> }


{ <EOL> var result = nameHash <EOL> result = <NUM_LIT:31> * result + scopeHash <EOL> return result <EOL> }


override fun equals ( other : Any ? ) : Boolean

{ <EOL> if ( this === other ) return true <EOL> if ( javaClass != other ? . javaClass ) return false <EOL> other as LookupSymbolKey <EOL> if ( nameHash != other . nameHash ) return false <EOL> if ( scopeHash != other . scopeHash ) return false <EOL> return true <EOL> }


{ <EOL> OUTER @ while ( true ) { <EOL> var x = "<STR_LIT>" <EOL> try { <EOL> do { <EOL> x = x + break@OUTER <EOL> } while ( true ) <EOL> } finally { <EOL> return "<STR_LIT:OK>" <EOL> } <EOL> } <EOL> }


private fun internal ( className : String , packageFragment : PackageFragmentDescriptor = kotlinJvmInternalPackage ) : Lazy < ClassDescriptor >

= <EOL> lazy { createClass ( packageFragment , className ) }


private fun coroutinesInternal ( name : String ) : Lazy < ClassDescriptor >

= <EOL> lazy { createCoroutineSuperClass ( name ) }


private fun propertyClasses ( prefix : String , suffix : String ) : Lazy < List < ClassDescriptor > >

= <EOL> lazy { ( <NUM_LIT:0> .. <NUM_LIT:2> ) . map { i -> createClass ( kotlinJvmInternalPackage , prefix + i + suffix ) } }


private fun createCoroutineSuperClass ( className : String ) : ClassDescriptor

= createClass ( kotlinCoroutinesJvmInternalPackage , className )


private fun createClass ( packageFragment : PackageFragmentDescriptor , name : String , classKind : ClassKind = ClassKind . CLASS ) : ClassDescriptor

= <EOL> MutableClassDescriptor ( packageFragment , classKind , false , false , Name . identifier ( name ) , SourceElement . NO_SOURCE , LockBasedStorageManager . NO_LOCKS ) . apply { <EOL> modality = Modality . FINAL <EOL> visibility = DescriptorVisibilities . PUBLIC <EOL> setTypeParameterDescriptors ( emptyList ( ) ) <EOL> createTypeConstructor ( ) <EOL> }


fun getSupertypesForClosure ( descriptor : FunctionDescriptor ) : Collection < KotlinType >

{ <EOL> val actualFunctionDescriptor = <EOL> if ( descriptor . isSuspend ) <EOL> getOrCreateJvmSuspendFunctionView ( descriptor ) <EOL> else <EOL> descriptor <EOL> if ( actualFunctionDescriptor . returnType == null ) <EOL> throw KotlinExceptionWithAttachments ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> val functionType = createFunctionType ( descriptor . builtIns , Annotations . EMPTY , actualFunctionDescriptor . extensionReceiverParameter ? . type , actualFunctionDescriptor . contextReceiverParameters . map { it . type } , actualFunctionDescriptor . valueParameters . map { it . type } , null , actualFunctionDescriptor . returnType ! ! <EOL> ) <EOL> if ( descriptor . isSuspend ) { <EOL> return mutableListOf < KotlinType > ( ) . apply { <EOL> if ( actualFunctionDescriptor . isRestrictedSuspendFunction ( ) ) { <EOL> if ( descriptor . isSuspendLambdaOrLocalFunction ( ) ) { <EOL> add ( restrictedSuspendLambda . defaultType ) <EOL> } else { <EOL> add ( restrictedContinuationImpl . defaultType ) <EOL> } <EOL> } else { <EOL> if ( descriptor . isSuspendLambdaOrLocalFunction ( ) ) { <EOL> add ( suspendLambda . defaultType ) <EOL> } else { <EOL> add ( continuationImpl . defaultType ) <EOL> } <EOL> } <EOL> if ( descriptor . isSuspendLambdaOrLocalFunction ( ) ) { <EOL> add ( functionType ) <EOL> } <EOL> } <EOL> } <EOL> return listOf ( lambda . defaultType , functionType ) <EOL> }


fun getSupertypesForFunctionReference ( referencedFunction : FunctionDescriptor , anonymousFunctionDescriptor : AnonymousFunctionDescriptor , isBound : Boolean , isAdaptedCallableReference : Boolean , isSuspendConversion : Boolean ) : Collection < KotlinType >

{ <EOL> val receivers = computeExpectedNumberOfReceivers ( referencedFunction , isBound ) <EOL> val functionType = createFunctionType ( referencedFunction . builtIns , Annotations . EMPTY , if ( isBound ) null else referencedFunction . extensionReceiverParameter ? . type ? : referencedFunction . dispatchReceiverParameter ? . type , referencedFunction . contextReceiverParameters . map { it . type } , anonymousFunctionDescriptor . valueParameters . drop ( receivers ) . map { it . type } , null , anonymousFunctionDescriptor . returnType ! ! , referencedFunction . isSuspend || isSuspendConversion ) <EOL> val suspendFunctionType = if ( referencedFunction . isSuspend || isSuspendConversion ) suspendFunctionInterface ? . defaultType else null <EOL> val superClass = when { <EOL> generateOptimizedCallableReferenceSuperClasses -> when { <EOL> isAdaptedCallableReference || isSuspendConversion -> adaptedFunctionReference <EOL> else -> functionReferenceImpl <EOL> } <EOL> else -> functionReference <EOL> } <EOL> return listOfNotNull ( superClass . defaultType , functionType , suspendFunctionType ) <EOL> }


fun getSupertypeForPropertyReference ( descriptor : VariableDescriptorWithAccessors , isMutable : Boolean , isBound : Boolean ) : KotlinType

{ <EOL> if ( descriptor is LocalVariableDescriptor ) { <EOL> return ( if ( isMutable ) mutableLocalVariableReference else localVariableReference ) . defaultType <EOL> } <EOL> val arity = <EOL> ( if ( descriptor . extensionReceiverParameter != null ) <NUM_LIT:1> else <NUM_LIT:0> ) + <EOL> ( if ( descriptor . dispatchReceiverParameter != null ) <NUM_LIT:1> else <NUM_LIT:0> ) - <EOL> if ( isBound ) <NUM_LIT:1> else <NUM_LIT:0> <EOL> val classes = when { <EOL> generateOptimizedCallableReferenceSuperClasses -> if ( isMutable ) mutablePropertyReferenceImpls else propertyReferenceImpls <EOL> else -> if ( isMutable ) mutablePropertyReferences else propertyReferences <EOL> } <EOL> return if ( arity >= <NUM_LIT:0> ) { <EOL> classes [ arity ] . defaultType <EOL> } else { <EOL> classes [ <NUM_LIT:0> ] . defaultType <EOL> } <EOL> }


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

{ <EOL> val descriptor = resolvedCall . candidateDescriptor <EOL> if ( descriptor !is PropertyDescriptor ) return <EOL> val propertyName = descriptor . name <EOL> val containingDescriptor = descriptor . containingDeclaration <EOL> if ( containingDescriptor !is ClassDescriptor || ! containingDescriptor . isCompanionObject ) return <EOL> val grandParent = containingDescriptor . containingDeclaration <EOL> if ( grandParent is ClassDescriptor && grandParent . kind == ClassKind . ENUM_CLASS && grandParent . containsEntryWithName ( propertyName ) && resolvedCall . dispatchReceiver . isQualifierFor ( grandParent ) ) { <EOL> context . resolutionContext . trace . report ( Errors . DEPRECATED_ACCESS_TO_ENUM_COMPANION_PROPERTY . on ( reportOn , descriptor ) ) <EOL> } <EOL> }


private fun ClassDescriptor . containsEntryWithName ( name : Name ) : Boolean

{ <EOL> val foundDescriptor = unsubstitutedMemberScope . getContributedClassifier ( name , NoLookupLocation . FOR_ALREADY_TRACKED ) <EOL> return foundDescriptor is ClassDescriptor && foundDescriptor . kind == ClassKind . ENUM_ENTRY <EOL> }


internal fun ReceiverValue ? . isQualifierFor ( classDescriptor : ClassDescriptor ) : Boolean

{ <EOL> if ( this !is ClassValueReceiver ) return false <EOL> val thisClass = this . classQualifier . descriptor as? ClassDescriptor ? : return false <EOL> return thisClass . typeConstructor == classDescriptor . typeConstructor <EOL> }


{ <EOL> val result = mutableListOf < Int > ( ) <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> result += ( a . list as List < Int > ) . filter { it > <NUM_LIT:0> } <EOL> }