diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index b3bc155dcc4..739e8126337 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -27,10 +27,7 @@ import org.jetbrains.kotlin.resolve.BindingContext.CALL import org.jetbrains.kotlin.resolve.BindingContext.RESOLVED_CALL import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext -import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch -import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatchStatus -import org.jetbrains.kotlin.resolve.calls.model.ArgumentUnmapped -import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.calls.model.* import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.utils.sure @@ -67,12 +64,15 @@ public fun ResolvedCall.getParameterForArgument(valu public fun > Call.hasUnresolvedArguments(context: ResolutionContext): Boolean { val arguments = getValueArguments().map { it.getArgumentExpression() } - return arguments.any { - argument -> - val expressionType = argument?.let { context.trace.getBindingContext().getType(it) } - argument != null && !ArgumentTypeResolver.isFunctionLiteralArgument(argument, context) - && (expressionType == null || expressionType.isError()) - } + return arguments.any (fun (argument: JetExpression?): Boolean { + if (argument == null || ArgumentTypeResolver.isFunctionLiteralArgument(argument, context)) return false + + val resolvedCall = argument.getResolvedCall(context.trace.getBindingContext()) as MutableResolvedCall<*>? + if (resolvedCall != null && !resolvedCall.hasInferredReturnType()) return false + + val expressionType = context.trace.getBindingContext().getType(argument) + return expressionType == null || expressionType.isError() + }) } public fun Call.getValueArgumentsInParentheses(): List = getValueArguments().filterArgsInParentheses() diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt new file mode 100644 index 00000000000..de99dbeab71 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt @@ -0,0 +1,10 @@ +// !CHECK_TYPE + +trait Inv + +fun Inv.reduce2(): S = null!! + +fun test(a: Inv): Int { + val b = 1 + a.reduce2() + return b +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.txt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.txt new file mode 100644 index 00000000000..020040884dd --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.txt @@ -0,0 +1,10 @@ +package + +internal fun test(/*0*/ a: Inv): kotlin.Int +internal fun Inv.reduce2(): S + +internal trait Inv { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt new file mode 100644 index 00000000000..ab81fa1efc1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt @@ -0,0 +1,12 @@ +class ResolutionCandidate + +class ResolutionTask(val candidate: ResolutionCandidate) + +fun List>.bar(t: ResolutionTask) = t + +public class ResolutionTaskHolder { + fun test(candidate: ResolutionCandidate, tasks: MutableList>) { + tasks.bar(ResolutionTask(candidate)) + } +} + diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.txt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.txt new file mode 100644 index 00000000000..28219ef34b4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.txt @@ -0,0 +1,26 @@ +package + +internal fun kotlin.List>.bar(/*0*/ t: ResolutionTask): ResolutionTask + +internal final class ResolutionCandidate { + public constructor ResolutionCandidate() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class ResolutionTask { + public constructor ResolutionTask(/*0*/ candidate: ResolutionCandidate) + internal final val candidate: ResolutionCandidate + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class ResolutionTaskHolder { + public constructor ResolutionTaskHolder() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal final fun test(/*0*/ candidate: ResolutionCandidate, /*1*/ tasks: kotlin.MutableList>): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt index eb84b493a3e..0a14b59baa4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt @@ -6,7 +6,7 @@ fun main(args:Array) { val startTimeNanos = System.nanoTime() // the problem sits on the next line: - val pi = 4.0.toDouble() * delta * (1..n).reduce( + val pi = 4.0.toDouble() * delta * (1..n).reduce( {t, i -> val x = (i - 0.5) * delta t + 1.0 / (1.0 + x * x) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 357faf49e47..e225b3f4b1f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -10231,6 +10231,18 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/nestedCalls/kt5971NestedSafeCall.kt"); doTest(fileName); } + + @TestMetadata("kt7597.kt") + public void testKt7597() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt"); + doTest(fileName); + } + + @TestMetadata("twoTypeParameters.kt") + public void testTwoTypeParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/tests/resolve/specialConstructions")