From 3afd4a2f4a43bb45764a3722f87fc5a6604b76b4 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 14 Feb 2018 05:42:14 +0300 Subject: [PATCH] [NI] Record all diagnostics from subcalls resolution results --- .../calls/tower/ResolvedAtomCompleter.kt | 20 +++++++------------ .../controlFlowAnalysis/elvisNotProcessed.kt | 2 +- .../kt770.kt351.kt735_StatementType.kt | 2 +- .../lambdasInExclExclAndElvis.kt | 4 ++-- .../dataFlowInfoTraversal/BinaryExpression.kt | 2 +- .../tests/generics/tpAsReified/InFunction.kt | 2 +- ...ortAboutUnresolvedReferenceAsUnresolved.kt | 7 +++++++ ...rtAboutUnresolvedReferenceAsUnresolved.txt | 5 +++++ .../tests/nullabilityAndSmartCasts/kt2216.kt | 2 +- 9 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt create mode 100644 compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt index 4d87bae927d..eee735d7ea7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.resolve.calls.tower @@ -65,6 +54,11 @@ class ResolvedAtomCompleter( is ResolvedCallableReferenceAtom -> completeCallableReference(resolvedAtom) is ResolvedLambdaAtom -> completeLambda(resolvedAtom) is ResolvedCallAtom -> completeResolvedCall(resolvedAtom, emptyList()) + is CallResolutionResult -> { + if (resolvedAtom.type == CallResolutionResult.Type.PARTIAL) { + resolvedAtom.resultCallAtom?.let { completeResolvedCall(it, resolvedAtom.diagnostics) } + } + } } } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt index afd8c205883..29e48a8d119 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt @@ -34,6 +34,6 @@ val bbb = null ?: ( l() ?: null) val bbbb = ( l() ?: null) ?: ( l() ?: null) fun f(x : Long?): Long { - var a = x ?: (fun() {} ?: fun() {}) + var a = x ?: (fun() {} ?: fun() {}) return a } diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt index bdcbf94e711..5833d9c5480 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt @@ -108,7 +108,7 @@ fun testImplicitCoercion() { val h = if (false) 4 else {} bar(if (true) { - 4 + 4 } else { z = 342 diff --git a/compiler/testData/diagnostics/tests/controlStructures/lambdasInExclExclAndElvis.kt b/compiler/testData/diagnostics/tests/controlStructures/lambdasInExclExclAndElvis.kt index 4885f22e845..9de1bf0c298 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/lambdasInExclExclAndElvis.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/lambdasInExclExclAndElvis.kt @@ -9,8 +9,8 @@ fun test() { // KT-KT-9070 { } ?: 1 - use({ 2 } ?: 1); + use({ 2 } ?: 1); 1 ?: { } - use(1 ?: { }) + use(1 ?: { }) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt index 06f3e506011..a7e3fc3535d 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt @@ -6,6 +6,6 @@ fun foo() { val x: Int? = null bar(1 + (if (x == null) 0 else x)) - bar(if (x == null) x else x) + bar(if (x == null) x else x) if (x != null) bar(x + x/(x-x*x)) } diff --git a/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt b/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt index 52425e95571..13c63d50eb8 100644 --- a/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt +++ b/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt @@ -14,5 +14,5 @@ fun main() { val b: Int = f() f() - val с: A = id(f()) + val с: A = id(f()) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt new file mode 100644 index 00000000000..27540748926 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt @@ -0,0 +1,7 @@ +fun T.map(f: (T) -> U) = f(this) + +fun consume(s: String) {} + +fun test() { + consume(1.map(::foo)) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.txt b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.txt new file mode 100644 index 00000000000..5aeb44dcc9b --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.txt @@ -0,0 +1,5 @@ +package + +public fun consume(/*0*/ s: kotlin.String): kotlin.Unit +public fun test(): kotlin.Unit +public fun T.map(/*0*/ f: (T) -> U): U diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt index d5cbe11a26d..382667b652a 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2216.kt @@ -15,7 +15,7 @@ fun foo() { val y: Int? = 0 val z: Int? = 0 - bar(if (y != null) y else z, y) + bar(if (y != null) y else z, y) y + 2 baz(y, y, if (y == null) return else y, y) baz(y, z!!, z, y)