AA: expected type for expression passed to vararg
This commit is contained in:
committed by
Yan Zhulanow
parent
4f8dad3e4b
commit
4beb55179b
+8
-2
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.components.isVararg
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.returnTypeOrNothing
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.MultipleSmartCasts
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.SingleSmartCast
|
||||
@@ -210,9 +211,14 @@ class KtFe10ExpressionTypeProvider(
|
||||
if (parameterDescriptor != null) {
|
||||
val kotlinType = when (val originalCallableDescriptor = parameterDescriptor.containingDeclaration) {
|
||||
is SamConstructorDescriptor -> originalCallableDescriptor.returnTypeOrNothing
|
||||
else -> parameterDescriptor.type
|
||||
else -> {
|
||||
if (parameterDescriptor.isVararg)
|
||||
parameterDescriptor.varargElementType
|
||||
else
|
||||
parameterDescriptor.type
|
||||
}
|
||||
}
|
||||
return kotlinType.toKtType(analysisContext)
|
||||
return kotlinType?.toKtType(analysisContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -232,6 +232,24 @@ public class Fe10IdeNormalAnalysisSourceModuleExpectedExpressionTypeTestGenerate
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samAsReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samReferenceAsArgument.kt")
|
||||
public void testSamReferenceAsArgument() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceAsArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samReferenceAsVararg.kt")
|
||||
public void testSamReferenceAsVararg() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceAsVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samReferenceWithTypeCast.kt")
|
||||
public void testSamReferenceWithTypeCast() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceWithTypeCast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samWithExplicitTypeFromProperty.kt")
|
||||
public void testSamWithExplicitTypeFromProperty() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user