[NI] Remove lambda coersion to Unit in case of error return type(s)
Coersion to Unit from error type leads to misleading type mismatches: "expected <expected lambda return type> found Unit", despite no user-provided Unit / empty lambda. These diagnostics were collected, but not reported before, and that had been disguising the issue for a while. KT-34729 Fixed
This commit is contained in:
Generated
+5
@@ -10371,6 +10371,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coersionWithAnonymousFunctionsAndUnresolved.kt")
|
||||||
|
public void testCoersionWithAnonymousFunctionsAndUnresolved() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coersionWithAnonymousFunctionsAndUnresolved.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("indirectCoercionWithExpectedType.kt")
|
@TestMetadata("indirectCoercionWithExpectedType.kt")
|
||||||
public void testIndirectCoercionWithExpectedType() throws Exception {
|
public void testIndirectCoercionWithExpectedType() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt");
|
||||||
|
|||||||
+6
-6
@@ -23,10 +23,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getBinaryWithTypeParent
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.lastBlockStatementOrThis
|
import org.jetbrains.kotlin.psi.psiUtil.lastBlockStatementOrThis
|
||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
|
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
|
||||||
import org.jetbrains.kotlin.resolve.calls.SPECIAL_FUNCTION_NAMES
|
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.CoroutineInferenceSession
|
import org.jetbrains.kotlin.resolve.calls.inference.CoroutineInferenceSession
|
||||||
@@ -95,7 +92,7 @@ class KotlinResolutionCallbacksImpl(
|
|||||||
expectedReturnType: UnwrappedType?,
|
expectedReturnType: UnwrappedType?,
|
||||||
annotations: Annotations,
|
annotations: Annotations,
|
||||||
stubsForPostponedVariables: Map<NewTypeVariable, StubType>
|
stubsForPostponedVariables: Map<NewTypeVariable, StubType>
|
||||||
): Pair<List<KotlinCallArgument>, InferenceSession?> {
|
): ReturnArgumentsAnalysisResult {
|
||||||
val psiCallArgument = lambdaArgument.psiCallArgument as PSIFunctionKotlinCallArgument
|
val psiCallArgument = lambdaArgument.psiCallArgument as PSIFunctionKotlinCallArgument
|
||||||
val outerCallContext = psiCallArgument.outerCallContext
|
val outerCallContext = psiCallArgument.outerCallContext
|
||||||
|
|
||||||
@@ -191,7 +188,9 @@ class KotlinResolutionCallbacksImpl(
|
|||||||
trace.record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, psiCallArgument.ktFunction, LambdaInfo.STUB_EMPTY)
|
trace.record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, psiCallArgument.ktFunction, LambdaInfo.STUB_EMPTY)
|
||||||
|
|
||||||
var hasReturnWithoutExpression = false
|
var hasReturnWithoutExpression = false
|
||||||
|
var returnArgumentFound = false
|
||||||
val returnArguments = lambdaInfo.returnStatements.mapNotNullTo(ArrayList()) { (expression, contextInfo) ->
|
val returnArguments = lambdaInfo.returnStatements.mapNotNullTo(ArrayList()) { (expression, contextInfo) ->
|
||||||
|
returnArgumentFound = true
|
||||||
val returnedExpression = expression.returnedExpression
|
val returnedExpression = expression.returnedExpression
|
||||||
if (returnedExpression != null) {
|
if (returnedExpression != null) {
|
||||||
createCallArgument(
|
createCallArgument(
|
||||||
@@ -210,6 +209,7 @@ class KotlinResolutionCallbacksImpl(
|
|||||||
if (expectedReturnType?.isUnit() == true || hasReturnWithoutExpression) return@let null // coercion to Unit
|
if (expectedReturnType?.isUnit() == true || hasReturnWithoutExpression) return@let null // coercion to Unit
|
||||||
|
|
||||||
// todo lastExpression can be if without else
|
// todo lastExpression can be if without else
|
||||||
|
returnArgumentFound = true
|
||||||
val lastExpressionType = trace.getType(lastExpression)
|
val lastExpressionType = trace.getType(lastExpression)
|
||||||
val contextInfo = lambdaInfo.lastExpressionInfo
|
val contextInfo = lambdaInfo.lastExpressionInfo
|
||||||
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, contextInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
|
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, contextInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
|
||||||
@@ -218,7 +218,7 @@ class KotlinResolutionCallbacksImpl(
|
|||||||
|
|
||||||
returnArguments.addIfNotNull(lastExpressionArgument)
|
returnArguments.addIfNotNull(lastExpressionArgument)
|
||||||
|
|
||||||
return Pair(returnArguments, coroutineSession)
|
return ReturnArgumentsAnalysisResult(ReturnArgumentsInfo(returnArguments, returnArgumentFound), coroutineSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLastDeparentesizedExpression(psiCallArgument: PSIKotlinCallArgument): KtExpression? {
|
private fun getLastDeparentesizedExpression(psiCallArgument: PSIKotlinCallArgument): KtExpression? {
|
||||||
|
|||||||
+3
-3
@@ -153,7 +153,7 @@ class ResolvedAtomCompleter(
|
|||||||
private val ResolvedLambdaAtom.isCoercedToUnit: Boolean
|
private val ResolvedLambdaAtom.isCoercedToUnit: Boolean
|
||||||
get() {
|
get() {
|
||||||
val returnTypes =
|
val returnTypes =
|
||||||
resultArguments.map {
|
resultArgumentsInfo.nonErrorArguments.map {
|
||||||
val type = it.safeAs<SimpleKotlinCallArgument>()?.receiver?.receiverValue?.type ?: return@map null
|
val type = it.safeAs<SimpleKotlinCallArgument>()?.receiver?.receiverValue?.type ?: return@map null
|
||||||
val unwrappedType = when (type) {
|
val unwrappedType = when (type) {
|
||||||
is WrappedType -> type.unwrap()
|
is WrappedType -> type.unwrap()
|
||||||
@@ -161,7 +161,7 @@ class ResolvedAtomCompleter(
|
|||||||
}
|
}
|
||||||
resultSubstitutor.safeSubstitute(unwrappedType)
|
resultSubstitutor.safeSubstitute(unwrappedType)
|
||||||
}
|
}
|
||||||
if (returnTypes.isEmpty()) return true
|
if (returnTypes.isEmpty() && !resultArgumentsInfo.returnArgumentsExist) return true
|
||||||
val substitutedTypes = returnTypes.filterNotNull()
|
val substitutedTypes = returnTypes.filterNotNull()
|
||||||
// we have some unsubstituted types
|
// we have some unsubstituted types
|
||||||
if (substitutedTypes.isEmpty()) return false
|
if (substitutedTypes.isEmpty()) return false
|
||||||
@@ -184,7 +184,7 @@ class ResolvedAtomCompleter(
|
|||||||
)
|
)
|
||||||
updateTraceForLambda(lambda, topLevelTrace, approximatedReturnType)
|
updateTraceForLambda(lambda, topLevelTrace, approximatedReturnType)
|
||||||
|
|
||||||
for (lambdaResult in lambda.resultArguments) {
|
for (lambdaResult in lambda.resultArgumentsInfo.nonErrorArguments) {
|
||||||
val resultValueArgument = lambdaResult as? PSIKotlinCallArgument ?: continue
|
val resultValueArgument = lambdaResult as? PSIKotlinCallArgument ?: continue
|
||||||
val newContext =
|
val newContext =
|
||||||
topLevelCallContext.replaceDataFlowInfo(resultValueArgument.dataFlowInfoAfterThisArgument)
|
topLevelCallContext.replaceDataFlowInfo(resultValueArgument.dataFlowInfoAfterThisArgument)
|
||||||
|
|||||||
+11
-2
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
|
import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
@@ -42,6 +41,16 @@ interface KotlinResolutionStatelessCallbacks {
|
|||||||
): SimpleConstraintSystem
|
): SimpleConstraintSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class ReturnArgumentsInfo(
|
||||||
|
val nonErrorArguments: List<KotlinCallArgument>,
|
||||||
|
val returnArgumentsExist: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
|
data class ReturnArgumentsAnalysisResult(
|
||||||
|
val returnArgumentsInfo: ReturnArgumentsInfo,
|
||||||
|
val inferenceSession: InferenceSession?
|
||||||
|
)
|
||||||
|
|
||||||
// This components hold state (trace). Work with this carefully.
|
// This components hold state (trace). Work with this carefully.
|
||||||
interface KotlinResolutionCallbacks {
|
interface KotlinResolutionCallbacks {
|
||||||
fun analyzeAndGetLambdaReturnArguments(
|
fun analyzeAndGetLambdaReturnArguments(
|
||||||
@@ -52,7 +61,7 @@ interface KotlinResolutionCallbacks {
|
|||||||
expectedReturnType: UnwrappedType?, // null means, that return type is not proper i.e. it depends on some type variables
|
expectedReturnType: UnwrappedType?, // null means, that return type is not proper i.e. it depends on some type variables
|
||||||
annotations: Annotations,
|
annotations: Annotations,
|
||||||
stubsForPostponedVariables: Map<NewTypeVariable, StubType>
|
stubsForPostponedVariables: Map<NewTypeVariable, StubType>
|
||||||
): Pair<List<KotlinCallArgument>, InferenceSession?>
|
): ReturnArgumentsAnalysisResult
|
||||||
|
|
||||||
fun bindStubResolvedCallForCandidate(candidate: ResolvedCallAtom)
|
fun bindStubResolvedCallForCandidate(candidate: ResolvedCallAtom)
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -118,7 +118,7 @@ class PostponedArgumentsAnalyzer(
|
|||||||
else FilteredAnnotations(annotations, true) { it != KotlinBuiltIns.FQ_NAMES.extensionFunctionType }
|
else FilteredAnnotations(annotations, true) { it != KotlinBuiltIns.FQ_NAMES.extensionFunctionType }
|
||||||
}
|
}
|
||||||
|
|
||||||
val (returnArguments, inferenceSession) = resolutionCallbacks.analyzeAndGetLambdaReturnArguments(
|
val (returnArgumentsInfo, inferenceSession) = resolutionCallbacks.analyzeAndGetLambdaReturnArguments(
|
||||||
lambda.atom,
|
lambda.atom,
|
||||||
lambda.isSuspend,
|
lambda.isSuspend,
|
||||||
receiver,
|
receiver,
|
||||||
@@ -128,21 +128,21 @@ class PostponedArgumentsAnalyzer(
|
|||||||
stubsForPostponedVariables.cast()
|
stubsForPostponedVariables.cast()
|
||||||
)
|
)
|
||||||
|
|
||||||
returnArguments.forEach { c.addSubsystemFromArgument(it) }
|
returnArgumentsInfo.nonErrorArguments.forEach { c.addSubsystemFromArgument(it) }
|
||||||
|
|
||||||
val subResolvedKtPrimitives = returnArguments.map {
|
val subResolvedKtPrimitives = returnArgumentsInfo.nonErrorArguments.map {
|
||||||
resolveKtPrimitive(
|
resolveKtPrimitive(
|
||||||
c.getBuilder(), it, lambda.returnType.let(::substitute), diagnosticHolder, isReceiver = false
|
c.getBuilder(), it, lambda.returnType.let(::substitute), diagnosticHolder, isReceiver = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnArguments.isEmpty()) {
|
if (!returnArgumentsInfo.returnArgumentsExist) {
|
||||||
val unitType = lambda.returnType.builtIns.unitType
|
val unitType = lambda.returnType.builtIns.unitType
|
||||||
val lambdaReturnType = lambda.returnType.let(::substitute)
|
val lambdaReturnType = lambda.returnType.let(::substitute)
|
||||||
c.getBuilder().addSubtypeConstraint(unitType, lambdaReturnType, LambdaArgumentConstraintPosition(lambda))
|
c.getBuilder().addSubtypeConstraint(unitType, lambdaReturnType, LambdaArgumentConstraintPosition(lambda))
|
||||||
}
|
}
|
||||||
|
|
||||||
lambda.setAnalyzedResults(returnArguments, subResolvedKtPrimitives)
|
lambda.setAnalyzedResults(returnArgumentsInfo, subResolvedKtPrimitives)
|
||||||
|
|
||||||
if (inferenceSession != null) {
|
if (inferenceSession != null) {
|
||||||
val storageSnapshot = c.getBuilder().currentStorage()
|
val storageSnapshot = c.getBuilder().currentStorage()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.resolve.calls.model
|
|||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceCandidate
|
import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceCandidate
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.components.ReturnArgumentsInfo
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper
|
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.extractInputOutputTypesFromCallableReferenceExpectedType
|
import org.jetbrains.kotlin.resolve.calls.components.extractInputOutputTypesFromCallableReferenceExpectedType
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
|
||||||
@@ -115,14 +116,14 @@ class ResolvedLambdaAtom(
|
|||||||
val typeVariableForLambdaReturnType: TypeVariableForLambdaReturnType?,
|
val typeVariableForLambdaReturnType: TypeVariableForLambdaReturnType?,
|
||||||
override val expectedType: UnwrappedType?
|
override val expectedType: UnwrappedType?
|
||||||
) : PostponedResolvedAtom() {
|
) : PostponedResolvedAtom() {
|
||||||
lateinit var resultArguments: List<KotlinCallArgument>
|
lateinit var resultArgumentsInfo: ReturnArgumentsInfo
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setAnalyzedResults(
|
fun setAnalyzedResults(
|
||||||
resultArguments: List<KotlinCallArgument>,
|
resultArguments: ReturnArgumentsInfo,
|
||||||
subResolvedAtoms: List<ResolvedAtom>
|
subResolvedAtoms: List<ResolvedAtom>
|
||||||
) {
|
) {
|
||||||
this.resultArguments = resultArguments
|
this.resultArgumentsInfo = resultArguments
|
||||||
setAnalyzedResults(subResolvedAtoms)
|
setAnalyzedResults(subResolvedAtoms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ fun text() {
|
|||||||
bar1 {1}
|
bar1 {1}
|
||||||
bar1 {it + 1}
|
bar1 {it + 1}
|
||||||
|
|
||||||
bar2 {<!TYPE_MISMATCH!><!>}
|
bar2 <!NI;TYPE_MISMATCH!>{<!TYPE_MISMATCH!><!>}<!>
|
||||||
bar2 {1}
|
bar2 {1}
|
||||||
bar2 {<!UNRESOLVED_REFERENCE!>it<!>}
|
bar2 {<!UNRESOLVED_REFERENCE!>it<!>}
|
||||||
bar2 <!NI;TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE, EXPECTED_PARAMETERS_NUMBER_MISMATCH!>it<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!>}<!>
|
bar2 <!NI;TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE, EXPECTED_PARAMETERS_NUMBER_MISMATCH!>it<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!>}<!>
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
interface JPAEntityClass<D> {
|
interface JPAEntityClass<D> {
|
||||||
fun <T> T.findByName(s: String): D {null!!}
|
fun <T> T.findByName(s: String): D {null!!}
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
interface JPAEntityClass<D> {
|
interface JPAEntityClass<D> {
|
||||||
fun <T> T.findByName(s: String): D {null!!}
|
fun <T> T.findByName(s: String): D {null!!}
|
||||||
@@ -9,7 +10,7 @@ class Foo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
with("", {
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>("", {
|
||||||
Foo.<!UNRESOLVED_REFERENCE!>findByName<!>("")
|
Foo.<!UNRESOLVED_REFERENCE!>findByName<!>("")
|
||||||
})
|
})
|
||||||
with(Foo) {
|
with(Foo) {
|
||||||
|
|||||||
Vendored
+2
-2
@@ -6,12 +6,12 @@ class A<T> {
|
|||||||
class Out<out E>
|
class Out<out E>
|
||||||
|
|
||||||
fun test(x: A<out CharSequence>, y: Out<CharSequence>) {
|
fun test(x: A<out CharSequence>, y: Out<CharSequence>) {
|
||||||
with(x) {
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(x) {
|
||||||
// TODO: this diagnostic could be replaced with TYPE_MISMATCH_DUE_TO_TYPE_PROJECTION
|
// TODO: this diagnostic could be replaced with TYPE_MISMATCH_DUE_TO_TYPE_PROJECTION
|
||||||
"".<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foo<!>()
|
"".<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foo<!>()
|
||||||
<!OI;TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS!>y<!>.<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>bar<!>()
|
<!OI;TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS!>y<!>.<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>bar<!>()
|
||||||
|
|
||||||
with(y) {
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(y) {
|
||||||
<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS!>bar<!>()
|
<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS!>bar<!>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
|
fun takeFnToAny(fn: () -> Any) {}
|
||||||
|
fun takeFnToUnit(fn: () -> Unit) {}
|
||||||
|
fun <P> takeFnToParameter(fn: () -> P) {}
|
||||||
|
|
||||||
|
fun testAny() {
|
||||||
|
takeFnToAny { }
|
||||||
|
takeFnToAny { Unit }
|
||||||
|
takeFnToAny { <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToAny { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToAny { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() else <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToAny(fun() = Unit)
|
||||||
|
takeFnToAny(fun() {})
|
||||||
|
takeFnToAny(fun() { return })
|
||||||
|
takeFnToAny(fun() { return Unit })
|
||||||
|
takeFnToAny(fun(): Unit {})
|
||||||
|
takeFnToAny(fun(): Unit { return })
|
||||||
|
takeFnToAny(fun(): Unit { return Unit })
|
||||||
|
takeFnToAny(fun() { if (true) return })
|
||||||
|
takeFnToAny(fun() { if (true) return Unit })
|
||||||
|
takeFnToAny(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||||
|
takeFnToAny(fun() { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToAny(fun(): Unit { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToAny(fun() { return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToAny(fun() { if (true ) return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testUnit() {
|
||||||
|
takeFnToUnit { }
|
||||||
|
takeFnToUnit { Unit }
|
||||||
|
takeFnToUnit { <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToUnit { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToUnit { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() else <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToUnit(fun() = Unit)
|
||||||
|
takeFnToUnit(fun() {})
|
||||||
|
takeFnToUnit(fun() { return })
|
||||||
|
takeFnToUnit(fun() { return Unit })
|
||||||
|
takeFnToUnit(fun(): Unit {})
|
||||||
|
takeFnToUnit(fun(): Unit { return })
|
||||||
|
takeFnToUnit(fun(): Unit { return Unit })
|
||||||
|
takeFnToUnit(fun() { if (true) return })
|
||||||
|
takeFnToUnit(fun() { if (true) return Unit })
|
||||||
|
takeFnToUnit(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||||
|
takeFnToUnit(fun() { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToUnit(fun(): Unit { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToUnit(fun() { return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToUnit(fun() { if (true ) return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testParameter() {
|
||||||
|
takeFnToParameter { }
|
||||||
|
takeFnToParameter { Unit }
|
||||||
|
takeFnToParameter { <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToParameter { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToParameter {
|
||||||
|
if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() else <!UNRESOLVED_REFERENCE!>unresolved<!>()
|
||||||
|
}
|
||||||
|
takeFnToParameter(fun() = Unit)
|
||||||
|
takeFnToParameter(fun() {})
|
||||||
|
takeFnToParameter(fun() { return })
|
||||||
|
takeFnToParameter(fun() { return Unit })
|
||||||
|
takeFnToParameter(fun(): Unit {})
|
||||||
|
takeFnToParameter(fun(): Unit { return })
|
||||||
|
takeFnToParameter(fun(): Unit { return Unit })
|
||||||
|
takeFnToParameter(fun() { if (true) return })
|
||||||
|
takeFnToParameter(fun() { if (true) return Unit })
|
||||||
|
takeFnToParameter(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||||
|
takeFnToParameter(fun() { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToParameter(fun(): Unit { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToParameter(fun() { return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToParameter(fun() { if (true ) return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
}
|
||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
|
fun takeFnToAny(fn: () -> Any) {}
|
||||||
|
fun takeFnToUnit(fn: () -> Unit) {}
|
||||||
|
fun <P> takeFnToParameter(fn: () -> P) {}
|
||||||
|
|
||||||
|
fun testAny() {
|
||||||
|
takeFnToAny { }
|
||||||
|
takeFnToAny { Unit }
|
||||||
|
takeFnToAny { <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToAny { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToAny { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() else <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToAny(fun() = Unit)
|
||||||
|
takeFnToAny(fun() {})
|
||||||
|
takeFnToAny(fun() { return })
|
||||||
|
takeFnToAny(fun() { return Unit })
|
||||||
|
takeFnToAny(fun(): Unit {})
|
||||||
|
takeFnToAny(fun(): Unit { return })
|
||||||
|
takeFnToAny(fun(): Unit { return Unit })
|
||||||
|
takeFnToAny(fun() { if (true) return })
|
||||||
|
takeFnToAny(fun() { if (true) return Unit })
|
||||||
|
takeFnToAny(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||||
|
takeFnToAny(fun() { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToAny(fun(): Unit { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToAny(fun() { return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToAny(fun() { if (true ) return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testUnit() {
|
||||||
|
takeFnToUnit { }
|
||||||
|
takeFnToUnit { Unit }
|
||||||
|
takeFnToUnit { <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToUnit { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToUnit { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() else <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToUnit(fun() = Unit)
|
||||||
|
takeFnToUnit(fun() {})
|
||||||
|
takeFnToUnit(fun() { return })
|
||||||
|
takeFnToUnit(fun() { return Unit })
|
||||||
|
takeFnToUnit(fun(): Unit {})
|
||||||
|
takeFnToUnit(fun(): Unit { return })
|
||||||
|
takeFnToUnit(fun(): Unit { return Unit })
|
||||||
|
takeFnToUnit(fun() { if (true) return })
|
||||||
|
takeFnToUnit(fun() { if (true) return Unit })
|
||||||
|
takeFnToUnit(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||||
|
takeFnToUnit(fun() { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToUnit(fun(): Unit { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToUnit(fun() { return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToUnit(fun() { if (true ) return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testParameter() {
|
||||||
|
takeFnToParameter { }
|
||||||
|
takeFnToParameter { Unit }
|
||||||
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>takeFnToParameter<!> { <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
takeFnToParameter { if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() }
|
||||||
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>takeFnToParameter<!> {
|
||||||
|
if (true) <!UNRESOLVED_REFERENCE!>unresolved<!>() else <!UNRESOLVED_REFERENCE!>unresolved<!>()
|
||||||
|
}
|
||||||
|
takeFnToParameter(fun() = Unit)
|
||||||
|
takeFnToParameter(fun() {})
|
||||||
|
takeFnToParameter(fun() { return })
|
||||||
|
takeFnToParameter(fun() { return Unit })
|
||||||
|
takeFnToParameter(fun(): Unit {})
|
||||||
|
takeFnToParameter(fun(): Unit { return })
|
||||||
|
takeFnToParameter(fun(): Unit { return Unit })
|
||||||
|
takeFnToParameter(fun() { if (true) return })
|
||||||
|
takeFnToParameter(fun() { if (true) return Unit })
|
||||||
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>takeFnToParameter<!>(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||||
|
takeFnToParameter(fun() { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToParameter(fun(): Unit { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToParameter(fun() { return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
takeFnToParameter(fun() { if (true ) return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun takeFnToAny(/*0*/ fn: () -> kotlin.Any): kotlin.Unit
|
||||||
|
public fun </*0*/ P> takeFnToParameter(/*0*/ fn: () -> P): kotlin.Unit
|
||||||
|
public fun takeFnToUnit(/*0*/ fn: () -> kotlin.Unit): kotlin.Unit
|
||||||
|
public fun testAny(): kotlin.Unit
|
||||||
|
public fun testParameter(): kotlin.Unit
|
||||||
|
public fun testUnit(): kotlin.Unit
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
// Related issue: KT-28654
|
// Related issue: KT-28654
|
||||||
|
|
||||||
fun <K> select(): K = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>run { <!OI;TYPE_MISMATCH!><!>}<!>
|
fun <K> select(): K = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>run <!NI;TYPE_MISMATCH!>{ <!OI;TYPE_MISMATCH!><!>}<!><!>
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val x: Int = select()
|
val x: Int = select()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ fun insideJob1() = doTheJob1()
|
|||||||
suspend fun insideJob2() = doTheJob2()
|
suspend fun insideJob2() = doTheJob2()
|
||||||
suspend fun insideJob3() = doTheJob3()
|
suspend fun insideJob3() = doTheJob3()
|
||||||
|
|
||||||
fun doTheJob0() = simpleAsync0 { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob0<!>()<!> }
|
fun doTheJob0() = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>simpleAsync0<!> { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob0<!>()<!> }
|
||||||
fun doTheJob1() = simpleAsync1 { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob1<!>()<!> }
|
fun doTheJob1() = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>simpleAsync1<!> { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob1<!>()<!> }
|
||||||
suspend fun doTheJob2() = simpleAsync2 { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob2<!>()<!> }
|
suspend fun doTheJob2() = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>simpleAsync2<!> { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob2<!>()<!> }
|
||||||
suspend fun doTheJob3() = simpleAsync3 { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob3<!>()<!> }
|
suspend fun doTheJob3() = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>simpleAsync3<!> { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>insideJob3<!>()<!> }
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
//KT-2741 Compiler can't infer a type of a function literal parameter when its body contains errors
|
//KT-2741 Compiler can't infer a type of a function literal parameter when its body contains errors
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
fun <T, R: Comparable<R>> Iterable<T>._sortBy(f: (T) -> R): List<T> = throw Exception()
|
fun <T, R: Comparable<R>> Iterable<T>._sortBy(f: (T) -> R): List<T> = throw Exception()
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
//KT-2741 Compiler can't infer a type of a function literal parameter when its body contains errors
|
//KT-2741 Compiler can't infer a type of a function literal parameter when its body contains errors
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
fun <T, R: Comparable<R>> Iterable<T>._sortBy(<!UNUSED_PARAMETER!>f<!>: (T) -> R): List<T> = throw Exception()
|
fun <T, R: Comparable<R>> Iterable<T>._sortBy(<!UNUSED_PARAMETER!>f<!>: (T) -> R): List<T> = throw Exception()
|
||||||
@@ -7,5 +9,5 @@ fun <T> _arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : List<T> = throw Ex
|
|||||||
class _Pair<A>(val a: A)
|
class _Pair<A>(val a: A)
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
_arrayList(_Pair(1))._sortBy { <!UNUSED_ANONYMOUS_PARAMETER!>it<!> -> <!UNRESOLVED_REFERENCE!>xxx<!> }
|
_arrayList(_Pair(1)).<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>_sortBy<!> { <!UNUSED_ANONYMOUS_PARAMETER!>it<!> -> <!UNRESOLVED_REFERENCE!>xxx<!> }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {}
|
interface Closeable {}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {}
|
interface Closeable {}
|
||||||
@@ -8,7 +10,7 @@ public inline fun <T: Closeable, R> T.use1(block: (T)-> R) : R {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
C().use1 {
|
C().<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use1<!> {
|
||||||
<!UNUSED_ANONYMOUS_PARAMETER!>w<!> -> // ERROR here
|
<!UNUSED_ANONYMOUS_PARAMETER!>w<!> -> // ERROR here
|
||||||
<!UNRESOLVED_REFERENCE!>x<!>
|
<!UNRESOLVED_REFERENCE!>x<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {
|
interface Closeable {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {
|
interface Closeable {
|
||||||
@@ -11,7 +13,7 @@ public inline fun <T: Closeable, R> T.use(block: (t: T)-> R) : R {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
C().use {
|
C().<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use<!> {
|
||||||
it.close()
|
it.close()
|
||||||
<!UNRESOLVED_REFERENCE!>x<!>
|
<!UNRESOLVED_REFERENCE!>x<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {
|
interface Closeable {
|
||||||
|
|||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {
|
interface Closeable {
|
||||||
@@ -11,7 +13,7 @@ public inline fun <T: Closeable, R> use(t: T, block: T.(T)-> R) : R {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
use(C()) {
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use<!>(C()) {
|
||||||
this.close()
|
this.close()
|
||||||
it.close()
|
it.close()
|
||||||
<!UNRESOLVED_REFERENCE!>xx<!>
|
<!UNRESOLVED_REFERENCE!>xx<!>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {
|
interface Closeable {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {
|
interface Closeable {
|
||||||
@@ -11,7 +13,7 @@ public inline fun <T: Closeable, R> T.use(block: T.()-> R) : R {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
C().use {
|
C().<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use<!> {
|
||||||
this.close()
|
this.close()
|
||||||
<!UNRESOLVED_REFERENCE!>x<!>
|
<!UNRESOLVED_REFERENCE!>x<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {}
|
interface Closeable {}
|
||||||
|
|||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
interface Closeable {}
|
interface Closeable {}
|
||||||
@@ -8,7 +10,7 @@ fun <T: Closeable, R> T.foo(block: (T)-> R) = block
|
|||||||
fun <T: Closeable, R> T.foo(block: (T, T)-> R) = block
|
fun <T: Closeable, R> T.foo(block: (T, T)-> R) = block
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
C().foo { // no ambiguity here
|
C().<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!> { // no ambiguity here
|
||||||
<!UNUSED_ANONYMOUS_PARAMETER!>www<!> ->
|
<!UNUSED_ANONYMOUS_PARAMETER!>www<!> ->
|
||||||
<!UNRESOLVED_REFERENCE!>xs<!>
|
<!UNRESOLVED_REFERENCE!>xs<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ fun test2() { // to extension lambda 1
|
|||||||
// val i27: E1 = id { i, s: String -> i + s.length } // overload oi- ni-
|
// val i27: E1 = id { i, s: String -> i + s.length } // overload oi- ni-
|
||||||
|
|
||||||
val w28 = W2 <!TYPE_MISMATCH!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!EXPECTED_PARAMETER_TYPE_MISMATCH!>i: Int<!>, <!CANNOT_INFER_PARAMETER_TYPE!>s<!><!> -> i <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>s<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>length<!> }<!> // oi- ni-
|
val w28 = W2 <!TYPE_MISMATCH!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!EXPECTED_PARAMETER_TYPE_MISMATCH!>i: Int<!>, <!CANNOT_INFER_PARAMETER_TYPE!>s<!><!> -> i <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>s<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>length<!> }<!> // oi- ni-
|
||||||
val i28: E1 = <!TYPE_MISMATCH!>id <!TYPE_MISMATCH!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!EXPECTED_PARAMETER_TYPE_MISMATCH!>i: Int<!>, <!CANNOT_INFER_PARAMETER_TYPE!>s<!><!> -> i <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>s<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>length<!> }<!><!> // oi- ni-
|
val i28: E1 = id <!TYPE_MISMATCH!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!EXPECTED_PARAMETER_TYPE_MISMATCH!>i: Int<!>, <!CANNOT_INFER_PARAMETER_TYPE!>s<!><!> -> i <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>s<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>length<!> }<!> // oi- ni-
|
||||||
val w29 = W2 <!TYPE_MISMATCH!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!EXPECTED_PARAMETER_TYPE_MISMATCH!>i: Int<!>, s: String<!> -> i + s.length }<!> // oi- ni-
|
val w29 = W2 <!TYPE_MISMATCH!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!EXPECTED_PARAMETER_TYPE_MISMATCH!>i: Int<!>, s: String<!> -> i + s.length }<!> // oi- ni-
|
||||||
val i29: E1 = id { i: Int, s: String -> i + s.length } // oi+ ni+
|
val i29: E1 = id { i: Int, s: String -> i + s.length } // oi+ ni+
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
class B
|
class B
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
class B
|
class B
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
@@ -11,7 +13,7 @@ fun test(a: A, b: B) {
|
|||||||
|
|
||||||
b.<!FUNCTION_EXPECTED!>(a)<!>()
|
b.<!FUNCTION_EXPECTED!>(a)<!>()
|
||||||
|
|
||||||
with(b) {
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(b) {
|
||||||
val <!UNUSED_VARIABLE!>y<!>: Int = a()
|
val <!UNUSED_VARIABLE!>y<!>: Int = a()
|
||||||
<!FUNCTION_EXPECTED!>(a)<!>()
|
<!FUNCTION_EXPECTED!>(a)<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ fun testTwoLambdas() {
|
|||||||
<!OI;TYPE_MISMATCH!>twoLambdaArgs({})
|
<!OI;TYPE_MISMATCH!>twoLambdaArgs({})
|
||||||
{}
|
{}
|
||||||
<!MANY_LAMBDA_EXPRESSION_ARGUMENTS, UNEXPECTED_TRAILING_LAMBDA_ON_A_NEW_LINE!>{}<!><!>
|
<!MANY_LAMBDA_EXPRESSION_ARGUMENTS, UNEXPECTED_TRAILING_LAMBDA_ON_A_NEW_LINE!>{}<!><!>
|
||||||
} else {
|
} else <!NI;TYPE_MISMATCH!>{
|
||||||
{}
|
{}
|
||||||
}<!>
|
}<!><!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// !CHECK_TYPE
|
// !CHECK_TYPE
|
||||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
// FILE: 2.kt
|
// FILE: 2.kt
|
||||||
package b
|
package b
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// !CHECK_TYPE
|
// !CHECK_TYPE
|
||||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
// FILE: 2.kt
|
// FILE: 2.kt
|
||||||
package b
|
package b
|
||||||
@@ -41,7 +42,7 @@ fun test(a: A) {
|
|||||||
|
|
||||||
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>("")
|
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>("")
|
||||||
|
|
||||||
with(a) {
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
|
||||||
forEach() checkType { _<String>() }
|
forEach() checkType { _<String>() }
|
||||||
|
|
||||||
forEach(1) checkType { _<Int>() }
|
forEach(1) checkType { _<Int>() }
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// !CHECK_TYPE
|
// !CHECK_TYPE
|
||||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
fun forEach() = this
|
fun forEach() = this
|
||||||
fun forEach(i: Int) = this
|
fun forEach(i: Int) = this
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// !CHECK_TYPE
|
// !CHECK_TYPE
|
||||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
fun forEach() = this
|
fun forEach() = this
|
||||||
fun forEach(i: Int) = this
|
fun forEach(i: Int) = this
|
||||||
@@ -35,7 +37,7 @@ fun test2(a: A) {
|
|||||||
a.forEach() checkType { _<String>() }
|
a.forEach() checkType { _<String>() }
|
||||||
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
||||||
|
|
||||||
with(a) {
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
|
||||||
forEach() checkType { _<String>() }
|
forEach() checkType { _<String>() }
|
||||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach<!>(1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10378,6 +10378,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coersionWithAnonymousFunctionsAndUnresolved.kt")
|
||||||
|
public void testCoersionWithAnonymousFunctionsAndUnresolved() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coersionWithAnonymousFunctionsAndUnresolved.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("indirectCoercionWithExpectedType.kt")
|
@TestMetadata("indirectCoercionWithExpectedType.kt")
|
||||||
public void testIndirectCoercionWithExpectedType() throws Exception {
|
public void testIndirectCoercionWithExpectedType() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10373,6 +10373,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coersionWithAnonymousFunctionsAndUnresolved.kt")
|
||||||
|
public void testCoersionWithAnonymousFunctionsAndUnresolved() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coersionWithAnonymousFunctionsAndUnresolved.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("indirectCoercionWithExpectedType.kt")
|
@TestMetadata("indirectCoercionWithExpectedType.kt")
|
||||||
public void testIndirectCoercionWithExpectedType() throws Exception {
|
public void testIndirectCoercionWithExpectedType() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt");
|
||||||
|
|||||||
+5
-5
@@ -14715,11 +14715,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class NotNullAssertions extends AbstractLightAnalysisModeTest {
|
public static class NotNullAssertions extends AbstractLightAnalysisModeTest {
|
||||||
@TestMetadata("paramAssertionMessage.kt")
|
|
||||||
public void ignoreParamAssertionMessage() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
}
|
}
|
||||||
@@ -14808,6 +14803,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("paramAssertionMessage.kt")
|
||||||
|
public void testParamAssertionMessage() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("staticCallErrorMessage.kt")
|
@TestMetadata("staticCallErrorMessage.kt")
|
||||||
public void testStaticCallErrorMessage() throws Exception {
|
public void testStaticCallErrorMessage() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/staticCallErrorMessage.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/staticCallErrorMessage.kt");
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ fun ResolvedCall<*>.hasLastFunctionalParameterWithResult(context: BindingContext
|
|||||||
if (this is NewResolvedCallImpl<*>) {
|
if (this is NewResolvedCallImpl<*>) {
|
||||||
// TODO: looks like hack
|
// TODO: looks like hack
|
||||||
resolvedCallAtom.subResolvedAtoms?.firstOrNull { it is ResolvedLambdaAtom }.safeAs<ResolvedLambdaAtom>()?.let { lambdaAtom ->
|
resolvedCallAtom.subResolvedAtoms?.firstOrNull { it is ResolvedLambdaAtom }.safeAs<ResolvedLambdaAtom>()?.let { lambdaAtom ->
|
||||||
return lambdaAtom.resultArguments.filterIsInstance<ReceiverKotlinCallArgument>().all {
|
return lambdaAtom.resultArgumentsInfo.nonErrorArguments.filterIsInstance<ReceiverKotlinCallArgument>().all {
|
||||||
val type = it.receiverValue?.type ?: return@all false
|
val type = it.receiverValue?.type ?: return@all false
|
||||||
predicate(type)
|
predicate(type)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user