KotlinType (KtNamedDeclaration declaration) { PsiFile file = declaration.getContainingFile(); if (!(file instanceof KtFile)) return null; DeclarationDescriptor descriptor = ResolutionUtils.unsafeResolveToDescriptor(declaration, BodyResolveMode.FULL); if (!(descriptor instanceof CallableDescriptor)) return null; KotlinType type = ((CallableDescriptor) descriptor).getReturnType(); if (type instanceof DeferredType) { type = ((DeferredType) type).getDelegate(); } return type; }