Analysis API: fix constructor return type for FE1.0 implementation
This commit is contained in:
+8
-4
@@ -18,10 +18,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypes
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
||||
import org.jetbrains.kotlin.psi.psiUtil.unwrapParenthesesLabelsAndAnnotations
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.returnTypeOrNothing
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.MultipleSmartCasts
|
||||
@@ -115,6 +112,13 @@ class KtFe10ExpressionTypeProvider(
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration is KtConstructor<*>) {
|
||||
val bindingContext = analysisContext.analyze(declaration)
|
||||
val kotlinType = bindingContext[BindingContext.CONSTRUCTOR, declaration]?.returnType
|
||||
?: ErrorUtils.createErrorType("Return type for constructor \"${declaration.containingClass()?.name}\" cannot be resolved")
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
}
|
||||
|
||||
return analysisContext.builtIns.unitType.toKtType(analysisContext)
|
||||
}
|
||||
|
||||
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
Foo@(1,1)
|
||||
Foo@(1,13) : kotlin.Unit
|
||||
t@(1,14) : T
|
||||
i@(1,24) : kotlin.Int
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
lazy@(3,1) : Lazy<T>
|
||||
initializer@(3,14) : () -> T
|
||||
Lazy@(5,1)
|
||||
Lazy@(5,14) : kotlin.Unit
|
||||
value@(5,15) : T
|
||||
getValue@(7,1) : T
|
||||
thisRef@(7,42) : kotlin.Any?
|
||||
property@(7,57) : kotlin.reflect.KProperty<*>
|
||||
A@(9,1)
|
||||
i@(10,5) : kotlin.Int
|
||||
Reference in New Issue
Block a user