Search in sources :

Example 1 with DeferredType

use of org.jetbrains.kotlin.types.DeferredType in project kotlin by JetBrains.

the class QuickFixUtil method getDeclarationReturnType.

@Nullable
public static KotlinType getDeclarationReturnType(KtNamedDeclaration declaration) {
    PsiFile file = declaration.getContainingFile();
    if (!(file instanceof KtFile))
        return null;
    DeclarationDescriptor descriptor = ResolutionUtils.resolveToDescriptor(declaration, BodyResolveMode.FULL);
    if (!(descriptor instanceof CallableDescriptor))
        return null;
    KotlinType type = ((CallableDescriptor) descriptor).getReturnType();
    if (type instanceof DeferredType) {
        type = ((DeferredType) type).getDelegate();
    }
    return type;
}
Also used : DeferredType(org.jetbrains.kotlin.types.DeferredType) DeclarationDescriptor(org.jetbrains.kotlin.descriptors.DeclarationDescriptor) KotlinType(org.jetbrains.kotlin.types.KotlinType) PsiFile(com.intellij.psi.PsiFile) CallableDescriptor(org.jetbrains.kotlin.descriptors.CallableDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiFile (com.intellij.psi.PsiFile)1 Nullable (org.jetbrains.annotations.Nullable)1 CallableDescriptor (org.jetbrains.kotlin.descriptors.CallableDescriptor)1 DeclarationDescriptor (org.jetbrains.kotlin.descriptors.DeclarationDescriptor)1 DeferredType (org.jetbrains.kotlin.types.DeferredType)1 KotlinType (org.jetbrains.kotlin.types.KotlinType)1