From e7e162c7eb6a78b8451a0888f73066495f1e2963 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 17 Nov 2020 18:52:28 +0300 Subject: [PATCH] [FIR TEST] Filter some particular tokens during createDebugInfo --- .../postponedArgumentsAnalysis/basic.fir.kt | 20 +++++++++---------- .../testsWithStdLib/coroutines/kt41430.fir.kt | 2 +- .../callableReferences.fir.kt | 2 +- .../kotlin/fir/AbstractFirDiagnosticTest.kt | 4 ++++ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt index a8516c5a43e..06588262147 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt @@ -142,13 +142,13 @@ fun main() { val x18: (C) -> Unit = select(id { it }, { it }, id<(B) -> Unit> { x -> x }) // Resolution of extension/non-extension functions combination - val x19: String.() -> Unit = select(")!>id { this }, ")!>id(fun(x: String) {})) - val x20: String.() -> Unit = select(")!>{ this }, (fun(x: String) {})) + val x19: String.() -> Unit = select(")!>id { this }, ")!>id(fun(x: String) {})) + val x20: String.() -> Unit = select(")!>{ this }, (fun(x: String) {})) val x21: String.() -> Unit = select(")!>id(fun(x: String) {}), ")!>id(fun(x: String) {})) select(id Unit>(fun(x: String) {}), ")!>id(fun(x: String) {})) select(")!>id(fun String.(x: String) {}), ")!>id(fun(x: String, y: String) {})) - select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String -> this }) - select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x -> this }) + select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String -> this }) + select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x -> this }) select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String, y: String -> x }) // Convert to extension lambda is impossible because the lambda parameter types aren't specified explicitly select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x, y -> x }) @@ -180,16 +180,16 @@ fun main() { takeLambdasWithInverselyDependentTypeParameters({ it }, { x: Number -> x }, { x: Int -> x }) // Inferring lambda parameter types by subtypes of functional type - ")!>select(A2(), { a, b, c -> a; b; c }) + ")!>select(A2(), { a, b, c -> a; b; c }) ")!>select(A3(), { it }, { a -> a }) ")!>select(A3(), ")!>A3::foo1) // Should be error as `A3::foo1` is `KFunction2`, but the remaining arguments are `KFuncion1` or `Function1` ")!>select(A3(), ")!>A3::foo1, { a -> a }, { it -> it }) // It's OK because `A3::foo2` is from companion of `A3` - ")!>select(A3(), ")!>A3::foo2, { a -> a }, { it -> it }) + ")!>select(A3(), ")!>A3::foo2, { a -> a }, { it -> it }) & java.io.Serializable>")!>select(A4(), { x: Number -> "" }) & java.io.Serializable>")!>select(A5(), { x: Number, y: Int -> "" }) - ")!>select(A2(), id { a, b, c -> a; b; c }) + ")!>select(A2(), id { a, b, c -> a; b; c }) ")!>select(id(A3()), { it }, { a -> a }) ")!>select(A3(), id(")!>A3::foo1)) ")!>select(A3(), ")!>A3::foo1, id { a -> a }, { it -> it }) @@ -201,7 +201,7 @@ fun main() { ")!>select(id(A3()), id(")!>A3::foo1), id { a: Number -> a }) ")!>select(A4(), id { x: Number -> x }) >")!>select(id(A5()), id { x: Number, y: Int -> x;y }) - >")!>select(id(A5()), id { x, y -> x;y }) + >")!>select(id(A5()), id { x, y -> x;y }) >")!>select(id(")!>A5()), id { x: Number, y: Int -> x;y }) val x55: Function2 = select(id(A5()), id { x, y -> x;y; 1f }) @@ -228,8 +228,8 @@ fun main() { val x70: (Int) -> Unit = selectNumber(id(fun (it) { }), id {}, id {}) val x71: String.() -> Unit = select(")!>id(fun String.() { }), ")!>id(fun(x: String) {})) val x72: String.() -> Unit = select(fun String.() { }, fun(x: String) {}) // must be error - select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), fun (x, y) { x;y }) + select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), fun (x, y) { x;y }) select(id Unit>(fun (x, y) {}), { x: Int, y: String -> x }) // receiver of anonymous function must be specified explicitly select(id Unit>(fun Int.(y) {}), { x: Int, y: String -> x }) - ")!>select(A3(), fun (x) = "", { a -> a }) + ")!>select(A3(), fun (x) = "", { a -> a }) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.fir.kt index a0cf6c2b5e9..30277dd24e7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt41430.fir.kt @@ -8,7 +8,7 @@ fun test_1(list: List>) { fun test_2(list: List>) { sequence { - ")!>list.flatMapTo(mutableSetOf()) { it } + list.flatMapTo(mutableSetOf()) { it } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt index 621c01262cd..9edfb2eded2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt @@ -53,5 +53,5 @@ fun main() { select(id(::foo5), id { x: A -> }, id { x: B -> }, id { it }) - val x2: (Int) -> Unit = selectNumber(id(")!>::foo6), id { x -> x }, id { ")!>it }) + val x2: (Int) -> Unit = selectNumber(id(")!>::foo6), id { x -> ")!>x }, id { ")!>it }) } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt index 9d71824715d..f3de6c66efe 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir import com.intellij.psi.PsiElement import junit.framework.TestCase +import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1 import org.jetbrains.kotlin.checkers.utils.TypeOfCall import org.jetbrains.kotlin.diagnostics.rendering.Renderers @@ -204,6 +205,9 @@ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { ): FirDiagnosticWithParameters1? { val sourceElement = element.source ?: return null if (sourceElement.kind != FirRealSourceElementKind) return null + // Lambda argument is always (?) duplicated by function literal + // Block expression is always (?) duplicated by single block expression + if (sourceElement.elementType == KtNodeTypes.LAMBDA_ARGUMENT || sourceElement.elementType == KtNodeTypes.BLOCK) return null val name = name ?: return null if (diagnosedRangesToDiagnosticNames[sourceElement.startOffset..sourceElement.endOffset]?.contains(name) != true) return null