From b0ec3cb831a5b3c440909bdee2dd2603572bab40 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 27 Oct 2021 09:07:01 +0300 Subject: [PATCH] Switch off FIR version off REDUNDANT_LABEL_WARNING (performance-related) This reverts commit 363b2550 (partially) --- .../checkers/CommonDeclarationCheckers.kt | 1 - .../diagnostics/tests/BreakContinue.fir.kt | 4 +- .../testData/diagnostics/tests/Casts.fir.kt | 23 +++++++++++ compiler/testData/diagnostics/tests/Casts.kt | 1 - .../tests/FunctionCalleeExpressions.fir.kt | 2 +- .../diagnostics/tests/LValueAssignment.fir.kt | 36 ++++++++--------- .../tests/PackageInExpressionPosition.fir.kt | 2 +- .../diagnostics/tests/ReserveYield2.fir.kt | 4 +- .../diagnostics/tests/Underscore.fir.kt | 2 +- .../deadCode/commentsInDeadCode.fir.kt | 2 +- .../referenceToPropertyInitializer.fir.kt | 2 +- ...ueAndBreakLabelWithSameFunctionName.fir.kt | 2 +- .../notAFunctionLabel_after.fir.kt | 4 +- .../notAFunctionLabel_before.fir.kt | 4 +- .../controlStructures/redundantLabel.fir.kt | 39 ++++++++++++++++++ .../tests/controlStructures/redundantLabel.kt | 1 - .../labeledDelegatedExpression.fir.kt | 11 +++++ .../inference/labeledDelegatedExpression.kt | 1 - .../ParenthesizedVariable.fir.kt | 4 +- .../checkDeparenthesizedType.fir.kt | 10 ++--- .../deparenthesize/labeledSafeCall.fir.kt | 3 ++ .../tests/deparenthesize/labeledSafeCall.kt | 1 - .../functionAsExpression/WithoutBody.fir.kt | 2 +- .../return/IfWithoutElse.fir.kt | 2 +- .../expectedTypeFromCastParenthesized.fir.kt | 22 ++++++++++ .../expectedTypeFromCastParenthesized.kt | 1 - .../diagnostics/tests/inline/labeled.fir.kt | 40 +++++++++++++++++++ .../diagnostics/tests/inline/labeled.kt | 1 - .../tests/inline/parenthesized.fir.kt | 27 +++++++++++++ .../diagnostics/tests/inline/parenthesized.kt | 1 - .../QualifiedExpressionNullability.fir.kt | 2 +- .../TypeMismatchOnUnaryOperations.fir.kt | 4 +- .../nestedCalls/argumentsInParentheses.fir.kt | 20 ++++++++++ .../nestedCalls/argumentsInParentheses.kt | 1 - .../senselessComparison/parenthesized.fir.kt | 23 +++++++++++ .../senselessComparison/parenthesized.kt | 1 - .../flowInlining/labeledReturns.fir.kt | 2 +- .../suspensionPointInMonitorNewInf.kt | 2 +- .../contractBuilder/common/neg/14.fir.kt | 2 +- 39 files changed, 255 insertions(+), 57 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/Casts.fir.kt create mode 100644 compiler/testData/diagnostics/tests/controlStructures/redundantLabel.fir.kt create mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.fir.kt create mode 100644 compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.fir.kt create mode 100644 compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.fir.kt create mode 100644 compiler/testData/diagnostics/tests/inline/labeled.fir.kt create mode 100644 compiler/testData/diagnostics/tests/inline/parenthesized.fir.kt create mode 100644 compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.fir.kt create mode 100644 compiler/testData/diagnostics/tests/senselessComparison/parenthesized.fir.kt diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt index c53b93cca35..e708abca6f8 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt @@ -30,7 +30,6 @@ object CommonDeclarationCheckers : DeclarationCheckers() { FirInvalidAndDangerousCharactersChecker, FirAmbiguousAnonymousTypeChecker, FirExplicitApiDeclarationChecker, - FirRedundantLabelChecker, ) override val functionCheckers: Set diff --git a/compiler/testData/diagnostics/tests/BreakContinue.fir.kt b/compiler/testData/diagnostics/tests/BreakContinue.fir.kt index 4a2a4abb85c..469ac667bd4 100644 --- a/compiler/testData/diagnostics/tests/BreakContinue.fir.kt +++ b/compiler/testData/diagnostics/tests/BreakContinue.fir.kt @@ -2,7 +2,7 @@ class C { fun f (a : Boolean, b : Boolean) { b@ while (true) - a@ { + a@ { break@f break break@b @@ -12,7 +12,7 @@ class C { continue b@ while (true) - a@ { + a@ { continue@f continue continue@b diff --git a/compiler/testData/diagnostics/tests/Casts.fir.kt b/compiler/testData/diagnostics/tests/Casts.fir.kt new file mode 100644 index 00000000000..9c1a5774b9a --- /dev/null +++ b/compiler/testData/diagnostics/tests/Casts.fir.kt @@ -0,0 +1,23 @@ +// !CHECK_TYPE + +fun test() : Unit { + var x : Int? = 0 + var y : Int = 0 + + checkSubtype(x) + checkSubtype(y) + checkSubtype(x as Int) + checkSubtype(y as Int) + checkSubtype(x as Int?) + checkSubtype(y as Int?) + checkSubtype(x as? Int) + checkSubtype(y as? Int) + checkSubtype(x as? Int?) + checkSubtype(y as? Int?) + + val s = "" as Any + ("" as String?)?.length + (data@("" as String?))?.length + (@MustBeDocumented()( "" as String?))?.length + Unit +} diff --git a/compiler/testData/diagnostics/tests/Casts.kt b/compiler/testData/diagnostics/tests/Casts.kt index 68bafad7f3c..4c2b4a990f0 100644 --- a/compiler/testData/diagnostics/tests/Casts.kt +++ b/compiler/testData/diagnostics/tests/Casts.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !CHECK_TYPE fun test() : Unit { diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt index 1f1812d686f..353483534e4 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt @@ -62,7 +62,7 @@ fun main1() { {1}(); (fun (x : Int) = x)(1) 1.(fun Int.(x : Int) = x)(1); - l@{1}() + l@{1}() 1.((fun Int.() = 1))() 1.(f())() 1.if(true){f()}else{f()}() diff --git a/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt b/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt index 78850380657..66d2a62cf01 100644 --- a/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt +++ b/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt @@ -57,19 +57,19 @@ annotation class Ann fun canBe(i0: Int, j: Int) { var i = i0 - (label@ i) = 34 + (label@ i) = 34 - (label@ j) = 34 //repeat for j + (label@ j) = 34 //repeat for j val a = A() - (l@ a.a) = 3894 + (l@ a.a) = 3894 @Ann - l@ (i) = 123 + l@ (i) = 123 } fun canBe2(j: Int) { - (label@ j) = 34 + (label@ j) = 34 } class A() { @@ -79,29 +79,29 @@ class A() { class Test() { fun testIllegalValues() { 1 += 23 - (l@ 1) += 23 + (l@ 1) += 23 getInt() += 343 - (f@ getInt()) += 343 + (f@ getInt()) += 343 1++ - (r@ 1)-- + (r@ 1)-- getInt()++ - (m@ getInt())-- + (m@ getInt())-- ++2 - --(r@ 2) + --(r@ 2) this++ var s : String = "r" s += "ss" s += this - s += (a@ 2) + s += (a@ 2) @Ann - l@ (1) = 123 + l@ (1) = 123 } fun testIncompleteSyntax() { @@ -114,22 +114,22 @@ class Test() { val b: Int = 34 a += 34 - (l@ a) += 34 + (l@ a) += 34 b += 34 a++ - (@Ann l@ a)-- + (@Ann l@ a)-- (a)++ --a - ++(@Ann l@ a) + ++(@Ann l@ a) --(a) } fun testVariables1() { val b: Int = 34 - (l@ b) += 34 + (l@ b) += 34 //repeat for b (b) += 3 } @@ -140,12 +140,12 @@ class Test() { a[6] += 43 @Ann a[7] = 7 - (@Ann l@ (a))[8] = 8 + (@Ann l@ (a))[8] = 8 ab.getArray()[54] = 23 ab.getArray()[54]++ - (f@ a)[3] = 4 + (f@ a)[3] = 4 this[54] = 34 } diff --git a/compiler/testData/diagnostics/tests/PackageInExpressionPosition.fir.kt b/compiler/testData/diagnostics/tests/PackageInExpressionPosition.fir.kt index 1d339cd44cb..11456837617 100644 --- a/compiler/testData/diagnostics/tests/PackageInExpressionPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/PackageInExpressionPosition.fir.kt @@ -22,6 +22,6 @@ fun main() { System is Int System() (System) - foo@ System + foo@ System null in System } diff --git a/compiler/testData/diagnostics/tests/ReserveYield2.fir.kt b/compiler/testData/diagnostics/tests/ReserveYield2.fir.kt index e9547cd0637..aab3b906def 100644 --- a/compiler/testData/diagnostics/tests/ReserveYield2.fir.kt +++ b/compiler/testData/diagnostics/tests/ReserveYield2.fir.kt @@ -5,8 +5,8 @@ annotation class yield fun bar(p: Int) { - yield@ p - `yield`@ p + yield@ p + `yield`@ p @yield() p @`yield`() p diff --git a/compiler/testData/diagnostics/tests/Underscore.fir.kt b/compiler/testData/diagnostics/tests/Underscore.fir.kt index 6edbde47123..1e961ffffc7 100644 --- a/compiler/testData/diagnostics/tests/Underscore.fir.kt +++ b/compiler/testData/diagnostics/tests/Underscore.fir.kt @@ -21,7 +21,7 @@ fun __(___: Int, y: _: String) = 1 - __@ return if (y != null) __(____, y) else __(`_`, ______) + __@ return if (y != null) __(____, y) else __(`_`, ______) } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/commentsInDeadCode.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/commentsInDeadCode.fir.kt index 8f44fcbe1e8..7e3230febec 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/commentsInDeadCode.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/commentsInDeadCode.fir.kt @@ -12,7 +12,7 @@ fun test2() { bar(11, todo()/*comment1*/, ""/*comment2*/) } fun test3() { - bar(11, l@(todo()/*comment*/), "") + bar(11, l@(todo()/*comment*/), "") } fun todo(): Nothing = throw Exception() diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.fir.kt index 9662d4c4982..293091f3571 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.fir.kt @@ -19,7 +19,7 @@ class TestObjectLiteral { val y = obj } } - val obj1: A = l@ ( object: A(obj1) { + val obj1: A = l@ ( object: A(obj1) { init { val x = obj1 } diff --git a/compiler/testData/diagnostics/tests/controlStructures/continueAndBreakLabelWithSameFunctionName.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/continueAndBreakLabelWithSameFunctionName.fir.kt index 2d1eeacf1d6..b2d5f04a659 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/continueAndBreakLabelWithSameFunctionName.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/continueAndBreakLabelWithSameFunctionName.fir.kt @@ -50,4 +50,4 @@ class Test7 { break@Test8 } } -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_after.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_after.fir.kt index f966a8b3c6b..c5e6fe20f02 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_after.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_after.fir.kt @@ -51,12 +51,12 @@ fun testLoopLabelInReturn(xs: List) { } fun testValLabelInReturn() { - L@ val fn = { return@L } + L@ val fn = { return@L } fn() } fun testHighOrderFunctionCallLabelInReturn() { - L@ run { + L@ run { return@L } } diff --git a/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_before.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_before.fir.kt index ca00dc6c1f1..237beb97d69 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_before.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/notAFunctionLabel_before.fir.kt @@ -51,12 +51,12 @@ fun testLoopLabelInReturn(xs: List) { } fun testValLabelInReturn() { - L@ val fn = { return@L } + L@ val fn = { return@L } fn() } fun testHighOrderFunctionCallLabelInReturn() { - L@ run { + L@ run { return@L } } diff --git a/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.fir.kt new file mode 100644 index 00000000000..1b23784d271 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.fir.kt @@ -0,0 +1,39 @@ +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) +annotation class Ann + +fun testLambdaLabel() = l@ { 42 } + +fun testAnonymousFunctionLabel() = l@ fun() {} + +fun testAnnotatedLambdaLabel() = lambda@ @Ann {} + +fun testParenthesizedLambdaLabel() = lambda@ ( {} ) + +fun testLabelBoundToInvokeOperatorExpression() = l@ { 42 }() + +fun testLabelBoundToLambda() = (l@ { 42 })() + +fun testWhileLoopLabel() { + L@ while (true) {} +} + +fun testDoWhileLoopLabel() { + L@ do {} while (true) +} + +fun testForLoopLabel(xs: List) { + L@ for (x in xs) {} +} + +fun testValLabel() { + L@ val fn = {} + fn() +} + +fun testHighOrderFunctionCallLabel() { + L@ run {} +} + +fun testAnonymousObjectLabel() = + L@ object {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.kt b/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.kt index 7d7aeb6c6c8..06267698864 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL @Target(AnnotationTarget.EXPRESSION) @Retention(AnnotationRetention.SOURCE) annotation class Ann diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.fir.kt new file mode 100644 index 00000000000..f8290772eae --- /dev/null +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.fir.kt @@ -0,0 +1,11 @@ +import kotlin.reflect.KProperty + +class A3 { + val a: String by l@ MyProperty() + + class MyProperty {} + + operator fun MyProperty.getValue(thisRef: Any?, desc: KProperty<*>): T { + throw Exception("$thisRef $desc") + } +} diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.kt index 975a9b4d92f..e5b1e6b3584 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL import kotlin.reflect.KProperty class A3 { diff --git a/compiler/testData/diagnostics/tests/deparenthesize/ParenthesizedVariable.fir.kt b/compiler/testData/diagnostics/tests/deparenthesize/ParenthesizedVariable.fir.kt index c0535e51ccb..f8950a03263 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/ParenthesizedVariable.fir.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/ParenthesizedVariable.fir.kt @@ -1,3 +1,3 @@ fun test() { - (d@ val bar = 2) -} + (d@ val bar = 2) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt index 8e760dfae71..7c9c6f68318 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt @@ -6,19 +6,19 @@ import checkSubtype fun test(i: Int?) { if (i != null) { - foo(l1@ i) + foo(l1@ i) foo((i)) - foo(l2@ (i)) - foo((l3@ i)) + foo(l2@ (i)) + foo((l3@ i)) } - val a: Int = l4@ "" + val a: Int = l4@ "" val b: Int = ("") val c: Int = checkSubtype("") val d: Int = checkSubtype("") - foo(l4@ "") + foo(l4@ "") foo(("")) foo(checkSubtype("")) foo(checkSubtype("")) diff --git a/compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.fir.kt b/compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.fir.kt new file mode 100644 index 00000000000..e270df0ec1d --- /dev/null +++ b/compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.fir.kt @@ -0,0 +1,3 @@ +fun f(s : String?) : Boolean { + return foo@(s?.equals("a"))!! +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.kt b/compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.kt index 40fe7628a75..a9e8b9255bc 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/labeledSafeCall.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL fun f(s : String?) : Boolean { return foo@(s?.equals("a"))!! } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.fir.kt b/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.fir.kt index d8a201054d3..ccb1f2408b2 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.fir.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.fir.kt @@ -9,4 +9,4 @@ fun outer() { bar(fun ()) bar(l@ fun ()) bar(@ann fun ()) -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElse.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElse.fir.kt index c24cb24c35b..cf5888dab3d 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElse.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElse.fir.kt @@ -12,4 +12,4 @@ val b/*: () -> Int */ = l@ { val c/*: () -> Unit */ = l@ { if (flag) 4 -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.fir.kt b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.fir.kt new file mode 100644 index 00000000000..2fcb8d78216 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.fir.kt @@ -0,0 +1,22 @@ +// !LANGUAGE: +ExpectedTypeFromCast + +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) +annotation class bar + +fun foo(): T = TODO() + +fun id(value: V) = value + +val par1 = (foo()) as String +val par2 = ((foo())) as String + +val par3 = (dd@ (foo())) as String + +val par4 = ( @bar() (foo())) as String + +object X { + fun foo(): T = TODO() +} + +val par5 = ( @bar() X.foo()) as String diff --git a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt index 50782e4a3e7..471612aaaf8 100644 --- a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt +++ b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !LANGUAGE: +ExpectedTypeFromCast @Target(AnnotationTarget.EXPRESSION) diff --git a/compiler/testData/diagnostics/tests/inline/labeled.fir.kt b/compiler/testData/diagnostics/tests/inline/labeled.fir.kt new file mode 100644 index 00000000000..15f37ccad45 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inline/labeled.fir.kt @@ -0,0 +1,40 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +inline fun foo(bar1: (String.() -> Int) -> Int, bar2: (()->Int) -> Int) { + bar1 label@ { + this@label.length + } + + bar1 { + this.length + } + //unmute after KT-4247 fix + //bar1 { + // this@bar1.length + //} + + bar2 l@ { + 11 + } + + bar2 { + 12 + } + +} + +inline fun foo2(bar1: (String.() -> Int) -> Int) { + l1@ bar1 + + l2@ bar1 { + 11 + } + + (l3@ bar1) { + 11 + } + + (l5@ (l4@ bar1)) { + 11 + } +} diff --git a/compiler/testData/diagnostics/tests/inline/labeled.kt b/compiler/testData/diagnostics/tests/inline/labeled.kt index 986f5921a04..fa36e7540bd 100644 --- a/compiler/testData/diagnostics/tests/inline/labeled.kt +++ b/compiler/testData/diagnostics/tests/inline/labeled.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE inline fun foo(bar1: (String.() -> Int) -> Int, bar2: (()->Int) -> Int) { diff --git a/compiler/testData/diagnostics/tests/inline/parenthesized.fir.kt b/compiler/testData/diagnostics/tests/inline/parenthesized.fir.kt new file mode 100644 index 00000000000..49451133b4c --- /dev/null +++ b/compiler/testData/diagnostics/tests/inline/parenthesized.fir.kt @@ -0,0 +1,27 @@ +// !CHECK_TYPE + +inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) { + (s)(11) + (s).invoke(11) + (s) invoke 11 + (s) +} + +inline fun Function1.inlineExt() { + (this).invoke(11) + (this) invoke 11 + (this)(11) + (this) +} + +inline fun inlineFunWithInvoke2(s: (p: Int) -> Unit) { + (((s)))(11) + (((s))).invoke(11) + (((s))) invoke 11 + (((s))) +} + +inline fun propagation(s: (p: Int) -> Unit) { + inlineFunWithInvoke((label@ s)) + inlineFunWithInvoke((label2@ label@ s)) +} diff --git a/compiler/testData/diagnostics/tests/inline/parenthesized.kt b/compiler/testData/diagnostics/tests/inline/parenthesized.kt index e42d2a33402..b12d7d414d0 100644 --- a/compiler/testData/diagnostics/tests/inline/parenthesized.kt +++ b/compiler/testData/diagnostics/tests/inline/parenthesized.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !CHECK_TYPE inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) { diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.fir.kt index 16dc3de9483..6916a5d33c3 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/QualifiedExpressionNullability.fir.kt @@ -32,7 +32,7 @@ fun main() { val w: Foo? = null w.f = z (w.f) = z - (label@ w.f) = z + (label@ w.f) = z w!!.f = z w.f = z w!!.f = z diff --git a/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt b/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt index b03d15a42fd..d9cbd608db7 100644 --- a/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt @@ -8,8 +8,8 @@ fun main() { val h : String = v--; val h1 : String = --v; val i : String = !true; - val j : String = foo@ true; - val k : String = foo@ bar@ true; + val j : String = foo@ true; + val k : String = foo@ bar@ true; val l : String = -1; val m : String = +1; } diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.fir.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.fir.kt new file mode 100644 index 00000000000..1ffa3472243 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.fir.kt @@ -0,0 +1,20 @@ +interface Foo + +class Bar { + operator fun invoke(): Foo = throw Exception() +} + +class A { + val bar = Bar() +} + +fun fooInt(l: Foo) = l + +fun test(bar: Bar, a: A) { + // no elements with error types + fooInt((bar())) + fooInt(if (true) bar() else bar()) + fooInt(label@ bar()) + fooInt(a.bar()) + fooInt(((label@ if (true) (a.bar()) else bar()))) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.kt index 74973e41072..aab2243f1d5 100644 --- a/compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.kt +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/argumentsInParentheses.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL interface Foo class Bar { diff --git a/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.fir.kt b/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.fir.kt new file mode 100644 index 00000000000..15c100df48d --- /dev/null +++ b/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.fir.kt @@ -0,0 +1,23 @@ +fun testEquals(x: Int) { + if (x == null) {} + if (x == (null)) {} + if (x == foo@ null) {} +} + +fun testEqualsFlipped(x: Int) { + if (null == x) {} + if ((null) == x) {} + if (foo@ null == x) {} +} + +fun testNotEquals(x: Int) { + if (x != null) {} + if (x != (null)) {} + if (x != foo@ null) {} +} + +fun testNotEqualsFlipped(x: Int) { + if (null != x) {} + if ((null) != x) {} + if (foo@ null != x) {} +} diff --git a/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt b/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt index 838097ad29d..1c8ae0da59f 100644 --- a/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt +++ b/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL fun testEquals(x: Int) { if (x == null) {} if (x == (null)) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt index 5b8d61163d1..883aa5c5f62 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt @@ -83,4 +83,4 @@ fun threeLevelsReturnWithUnknown(x: Int?): Int? { } } return y.inc() -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspensionPointInMonitorNewInf.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspensionPointInMonitorNewInf.kt index 1a893309818..5f91bdbd2fb 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspensionPointInMonitorNewInf.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspensionPointInMonitorNewInf.kt @@ -59,4 +59,4 @@ suspend fun ifWhenAndOtherNonsence() { } } -suspend fun returnsInt(): Int = 0 +suspend fun returnsInt(): Int = 0 \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.fir.kt index 7c53cd6a78f..78c15773f00 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.fir.kt @@ -31,7 +31,7 @@ inline fun case_4(block: () -> Unit) { // TESTCASE NUMBER: 5 inline fun case_5(block: () -> Unit) { - test@ contract { + test@ contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block()