Skip to content

Commit

Permalink
[Analysis API] add test on contract with dispatch receiver cast
Browse files Browse the repository at this point in the history
^KT-75123
  • Loading branch information
dimonchik0036 authored and Space Team committed Feb 18, 2025
1 parent 5c09cae commit fd275e9
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
KaNamedFunctionSymbol:
annotations: [
kotlin/OptIn(markerClass = [kotlin.contracts.ExperimentalContracts::class])
psi: KtAnnotationEntry
]
callableId: /Result.isFailure
compilerVisibility: Public
contextParameters: []
contextReceivers: []
contractEffects: [
KaContractConditionalContractEffectDeclaration:
effect:
KaContractReturnsSuccessfullyEffectDeclaration:
condition:
KaContractIsInstancePredicateExpression:
argument:
KaContractParameterValue:
parameterSymbol:
KaReceiverParameterSymbol:
annotations: []
callableId: null
compilerVisibility: Local
contextReceivers: []
isActual: false
isExpect: false
isExtension: false
isVal: true
location: LOCAL
modality: FINAL
name: <receiver>
origin: SOURCE
owningCallableSymbol: Could not render due to java.lang.ClassCastException: org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.KaFe10DescNamedClassSymbol cannot be cast to org.jetbrains.kotlin.analysis.api.symbols.KaCallableSymbol

receiverParameter: null
returnType: KaUsualClassType:
annotations: []
typeArguments: []
type: Result
visibility: LOCAL
getContainingFileSymbol: KaFileSymbol(castForDispatchReceiver.kt)
getContainingJvmClassName: null
getContainingModule: KaSourceModule "Sources of main"
deprecationStatus: null
type:
KaUsualClassType:
annotations: []
typeArguments: []
type: Result.Failure
isNegated: false
]
hasStableParameterNames: true
isActual: false
isBuiltinFunctionInvoke: false
isExpect: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
isTailRec: false
location: CLASS
modality: FINAL
name: isFailure
origin: SOURCE
receiverParameter: null
returnType: KaUsualClassType:
annotations: []
typeArguments: []
type: kotlin/Boolean
typeParameters: []
valueParameters: []
visibility: PUBLIC
getDispatchReceiver(): KaUsualClassType:
annotations: []
typeArguments: []
type: Result
getContainingFileSymbol: KaFileSymbol(castForDispatchReceiver.kt)
getContainingJvmClassName: Result
canBeOperator: false
getContainingModule: KaSourceModule "Sources of main"
deprecationStatus: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE_K1
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract

sealed class Result {
class Success : Result()
class Failure : Result()

@OptIn(ExperimentalContracts::class)
fun isFail<caret>ure(): Boolean {
contract {
returns() implies (this@Result is Failure)
}

return this is Failure
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@kotlin.OptIn(markerClass = [kotlin.contracts.ExperimentalContracts::class])
fun isFailure(): kotlin.Boolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
KaNamedFunctionSymbol:
annotations: [
kotlin/OptIn(markerClass = [kotlin.contracts.ExperimentalContracts::class])
psi: KtAnnotationEntry
]
callableId: /Result.isFailure
compilerVisibility: Public
contextParameters: []
contextReceivers: []
contractEffects: Could not render due to org.jetbrains.kotlin.utils.exceptions.KotlinIllegalArgumentExceptionWithAttachments: class org.jetbrains.kotlin.analysis.api.fir.symbols.KaFirNamedFunctionSymbol should contain a receiver

hasStableParameterNames: true
isActual: false
isBuiltinFunctionInvoke: false
isExpect: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
isTailRec: false
location: CLASS
modality: FINAL
name: isFailure
origin: SOURCE
receiverParameter: null
returnType: KaUsualClassType:
annotations: []
typeArguments: []
type: kotlin/Boolean
typeParameters: []
valueParameters: []
visibility: PUBLIC
getDispatchReceiver(): KaUsualClassType:
annotations: []
typeArguments: []
type: Result
getContainingFileSymbol: KaFileSymbol(castForDispatchReceiver.kt)
getContainingJvmClassName: Result
canBeOperator: false
getContainingModule: KaSourceModule "Sources of main"
deprecationStatus: null

0 comments on commit fd275e9

Please sign in to comment.