Atul Gupta
08/07/2025, 5:53 AManalyze
apis?
Earlier using bindingContext
below code was working
val property = this?.parent as? KtProperty ?: return false
val propertyDescriptor =
bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, property] as? PropertyDescriptor
return propertyDescriptor?.getter?.let {
bindingContext[BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, it]
?.resultingDescriptor
?.returnType
closest I could get is below
val delegate = this ?: return true
return analyze(delegate) {
val functionSymbol = delegate
.mainReference
?.resolveToSymbols()
?.filterIsInstance<KaFunctionSymbol>()
?.firstOrNull {
it.callableId?.callableName == OperatorNameConventions.GET_VALUE
}
functionSymbol?.returnType?.nullability == KaTypeNullability.NULLABLE
but this gives the type of the actual implementation not the runtime resolved type(few examples in the đź§µ)Atul Gupta
08/07/2025, 5:57 AM// example 1
class A {
val a: Int? by lazy {
5
}
}
// using bindingContext it returns `Int`
// using analyze api it returns `V`(this is generic type by which lazy is implemented not the actual type)
// example 2
class A(private var aDelegate: Int?) {
private var a: Int? by this::aDelegate
}
// using bindingContext it returns `Int?`
// using the analyze api it returns `V`
Atul Gupta
08/08/2025, 7:12 AMBindingContext.DELEGATED_PROPERTY_RESOLVED_CALL
in analyze
apiRoman Golyshev
08/14/2025, 9:28 AMRoman Golyshev
08/14/2025, 9:29 AMgetter
of the delegated property? Are you talking about getValue
operator specifically?
Wouldn’t it be enough to simply know the type of the property itself in that case?Atul Gupta
08/14/2025, 9:40 AMCanBeNonNullable
It warns you for some property which is declared as nullable(maybe by mistake) but can be declared as non null
For this usecase, I need to know the type of getter body of delegated property.
In my migration PR I was able to pass all the TCs except the above mentioned cases