Switch off FIR version off REDUNDANT_LABEL_WARNING (performance-related)

This reverts commit 363b2550 (partially)
This commit is contained in:
Mikhail Glukhikh
2021-10-27 09:07:01 +03:00
committed by TeamCityServer
parent 36c4938172
commit b0ec3cb831
39 changed files with 255 additions and 57 deletions
@@ -30,7 +30,6 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
FirInvalidAndDangerousCharactersChecker,
FirAmbiguousAnonymousTypeChecker,
FirExplicitApiDeclarationChecker,
FirRedundantLabelChecker,
)
override val functionCheckers: Set<FirFunctionChecker>
+2 -2
View File
@@ -2,7 +2,7 @@ class C {
fun f (a : Boolean, b : Boolean) {
b@ while (true)
<!REDUNDANT_LABEL_WARNING!>a@<!> {
a@ {
<!NOT_A_LOOP_LABEL!>break@f<!>
break
break@b
@@ -12,7 +12,7 @@ class C {
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>
b@ while (true)
<!REDUNDANT_LABEL_WARNING!>a@<!> {
a@ {
<!NOT_A_LOOP_LABEL!>continue@f<!>
continue
continue@b
+23
View File
@@ -0,0 +1,23 @@
// !CHECK_TYPE
fun test() : Unit {
var x : Int? = 0
var y : Int = 0
checkSubtype<Int?>(x)
checkSubtype<Int>(y)
checkSubtype<Int>(x as Int)
checkSubtype<Int>(y <!USELESS_CAST!>as Int<!>)
checkSubtype<Int?>(x as Int?)
checkSubtype<Int?>(y as Int?)
checkSubtype<Int?>(x as? Int)
checkSubtype<Int?>(y as? Int)
checkSubtype<Int?>(x as? Int?)
checkSubtype<Int?>(y as? Int?)
val s = "" as Any
("" as String?)?.length
(data@("" as String?))?.length
(<!WRONG_ANNOTATION_TARGET!>@MustBeDocumented()<!>( "" as String?))?.length
Unit
}
-1
View File
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !CHECK_TYPE
fun test() : Unit {
@@ -62,7 +62,7 @@ fun main1() {
{1}();
(fun (x : Int) = x)(1)
1.(<!FUNCTION_EXPECTED!>fun Int.(x : Int) = x<!>)(1);
<!REDUNDANT_LABEL_WARNING!>l@<!>{1}()
l@{1}()
1.((<!FUNCTION_EXPECTED!>fun Int.() = 1<!>))()
1.(<!FUNCTION_EXPECTED!>f()<!>)()
1.<!FUNCTION_EXPECTED!>if(true){f()}else{f()}<!>()
+18 -18
View File
@@ -57,19 +57,19 @@ annotation class Ann
fun canBe(i0: Int, j: Int) {
var i = i0
(<!REDUNDANT_LABEL_WARNING!>label@<!> i) = 34
(label@ i) = 34
(<!REDUNDANT_LABEL_WARNING!>label@<!> <!VAL_REASSIGNMENT!>j<!>) = 34 //repeat for j
(label@ <!VAL_REASSIGNMENT!>j<!>) = 34 //repeat for j
val a = A()
(<!REDUNDANT_LABEL_WARNING!>l@<!> a.a) = 3894
(l@ a.a) = 3894
@Ann
<!REDUNDANT_LABEL_WARNING!>l@<!> (i) = 123
l@ (i) = 123
}
fun canBe2(j: Int) {
(<!REDUNDANT_LABEL_WARNING!>label@<!> <!VAL_REASSIGNMENT!>j<!>) = 34
(label@ <!VAL_REASSIGNMENT!>j<!>) = 34
}
class A() {
@@ -79,29 +79,29 @@ class A() {
class Test() {
fun testIllegalValues() {
<!VARIABLE_EXPECTED!>1<!> += 23
(<!REDUNDANT_LABEL_WARNING!>l@<!> <!VARIABLE_EXPECTED!>1<!>) += 23
(l@ <!VARIABLE_EXPECTED!>1<!>) += 23
<!VARIABLE_EXPECTED!>getInt()<!> += 343
(<!REDUNDANT_LABEL_WARNING!>f@<!> <!VARIABLE_EXPECTED!>getInt()<!>) += 343
(f@ <!VARIABLE_EXPECTED!>getInt()<!>) += 343
<!VARIABLE_EXPECTED!>1<!>++
(<!REDUNDANT_LABEL_WARNING!>r@<!> <!VARIABLE_EXPECTED!>1<!>)--
(r@ <!VARIABLE_EXPECTED!>1<!>)--
<!VARIABLE_EXPECTED!>getInt()<!>++
(<!REDUNDANT_LABEL_WARNING!>m@<!> <!VARIABLE_EXPECTED!>getInt()<!>)--
(m@ <!VARIABLE_EXPECTED!>getInt()<!>)--
++<!VARIABLE_EXPECTED!>2<!>
--(<!REDUNDANT_LABEL_WARNING!>r@<!> <!VARIABLE_EXPECTED!>2<!>)
--(r@ <!VARIABLE_EXPECTED!>2<!>)
this<!UNRESOLVED_REFERENCE!>++<!>
var s : String = "r"
s += "ss"
s += this
s += (<!REDUNDANT_LABEL_WARNING!>a@<!> 2)
s += (a@ 2)
@Ann
<!REDUNDANT_LABEL_WARNING!>l@<!> (<!VARIABLE_EXPECTED!>1<!>) = 123
l@ (<!VARIABLE_EXPECTED!>1<!>) = 123
}
fun testIncompleteSyntax() {
@@ -114,22 +114,22 @@ class Test() {
val b: Int = 34
a += 34
(<!REDUNDANT_LABEL_WARNING!>l@<!> a) += 34
(l@ a) += 34
<!VAL_REASSIGNMENT!>b<!> += 34
a++
(@Ann <!REDUNDANT_LABEL_WARNING!>l@<!> a)--
(@Ann l@ a)--
(a)++
--a
++(@Ann <!REDUNDANT_LABEL_WARNING!>l@<!> a)
++(@Ann l@ a)
--(a)
}
fun testVariables1() {
val b: Int = 34
(<!REDUNDANT_LABEL_WARNING!>l@<!> <!VAL_REASSIGNMENT!>b<!>) += 34
(l@ <!VAL_REASSIGNMENT!>b<!>) += 34
//repeat for b
(<!VAL_REASSIGNMENT!>b<!>) += 3
}
@@ -140,12 +140,12 @@ class Test() {
a[6] += 43
@Ann
a[7] = 7
(@Ann <!REDUNDANT_LABEL_WARNING!>l@<!> (a))[8] = 8
(@Ann l@ (a))[8] = 8
ab.getArray()[54] = 23
ab.getArray()[54]++
(<!REDUNDANT_LABEL_WARNING!>f@<!> a)[3] = 4
(f@ a)[3] = 4
this<!NO_SET_METHOD!>[54]<!> = 34
}
@@ -22,6 +22,6 @@ fun main() {
<!NO_COMPANION_OBJECT!>System<!> is Int
<!INVISIBLE_REFERENCE!>System<!>()
(<!NO_COMPANION_OBJECT!>System<!>)
<!REDUNDANT_LABEL_WARNING!>foo@<!> <!NO_COMPANION_OBJECT!>System<!>
foo@ <!NO_COMPANION_OBJECT!>System<!>
null <!UNRESOLVED_REFERENCE!>in<!> System
}
+2 -2
View File
@@ -5,8 +5,8 @@
annotation class yield
fun bar(p: Int) {
<!REDUNDANT_LABEL_WARNING!>yield@<!> p
<!REDUNDANT_LABEL_WARNING!>`yield`@<!> p
yield@ p
`yield`@ p
@yield() p
@`yield`() p
+1 -1
View File
@@ -21,7 +21,7 @@ fun <!UNDERSCORE_IS_RESERVED!>__<!>(<!UNDERSCORE_IS_RESERVED!>___<!>: Int, y: <!
fun localFun(<!UNDERSCORE_IS_RESERVED!>_<!>: String) = 1
<!REDUNDANT_LABEL_WARNING!><!UNDERSCORE_IS_RESERVED!>__<!>@<!> return if (y != null) <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>(<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>____<!>, y) else <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>(`_`, <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>______<!>)
<!UNDERSCORE_IS_RESERVED!>__<!>@ return if (y != null) <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>(<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>____<!>, y) else <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>(`_`, <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>______<!>)
}
@@ -12,7 +12,7 @@ fun test2() {
<!UNREACHABLE_CODE!>bar(<!>11, todo()/*comment1*/, <!UNREACHABLE_CODE!>""/*comment2*/)<!>
}
fun test3() {
<!UNREACHABLE_CODE!>bar(<!>11, <!UNREACHABLE_CODE!><!REDUNDANT_LABEL_WARNING!>l@<!>(<!>todo()/*comment*/<!UNREACHABLE_CODE!>), "")<!>
<!UNREACHABLE_CODE!>bar(<!>11, <!UNREACHABLE_CODE!>l@(<!>todo()/*comment*/<!UNREACHABLE_CODE!>), "")<!>
}
fun todo(): Nothing = throw Exception()
@@ -19,7 +19,7 @@ class TestObjectLiteral {
val y = obj
}
}
val obj1: A = <!REDUNDANT_LABEL_WARNING!>l@<!> ( object: A(obj1) {
val obj1: A = l@ ( object: A(obj1) {
init {
val x = obj1
}
@@ -50,4 +50,4 @@ class Test7 {
<!NOT_A_LOOP_LABEL!>break@Test8<!>
}
}
}
}
@@ -51,12 +51,12 @@ fun testLoopLabelInReturn(xs: List<Int>) {
}
fun testValLabelInReturn() {
<!REDUNDANT_LABEL_WARNING!>L@<!> val fn = { <!NOT_A_FUNCTION_LABEL!>return@L<!> }
L@ val fn = { <!NOT_A_FUNCTION_LABEL!>return@L<!> }
fn()
}
fun testHighOrderFunctionCallLabelInReturn() {
<!REDUNDANT_LABEL_WARNING!>L@<!> run {
L@ run {
<!NOT_A_FUNCTION_LABEL!>return@L<!>
}
}
@@ -51,12 +51,12 @@ fun testLoopLabelInReturn(xs: List<Int>) {
}
fun testValLabelInReturn() {
<!REDUNDANT_LABEL_WARNING!>L@<!> val fn = { <!NOT_A_FUNCTION_LABEL!>return@L<!> }
L@ val fn = { <!NOT_A_FUNCTION_LABEL!>return@L<!> }
fn()
}
fun testHighOrderFunctionCallLabelInReturn() {
<!REDUNDANT_LABEL_WARNING!>L@<!> run {
L@ run {
<!NOT_A_FUNCTION_LABEL!>return@L<!>
}
}
@@ -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<Any>) {
L@ for (x in xs) {}
}
fun testValLabel() {
L@ val fn = {}
fn()
}
fun testHighOrderFunctionCallLabel() {
L@ run {}
}
fun testAnonymousObjectLabel() =
L@ object {}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class Ann
@@ -0,0 +1,11 @@
import kotlin.reflect.KProperty
class A3 {
val a: String by l@ MyProperty()
class MyProperty<T> {}
operator fun <T> MyProperty<T>.getValue(thisRef: Any?, desc: KProperty<*>): T {
throw Exception("$thisRef $desc")
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
import kotlin.reflect.KProperty
class A3 {
@@ -1,3 +1,3 @@
fun test() {
(<!REDUNDANT_LABEL_WARNING!>d@<!> val bar = 2)
}
(d@ val bar = 2)
}
@@ -6,19 +6,19 @@ import checkSubtype
fun test(i: Int?) {
if (i != null) {
foo(<!REDUNDANT_LABEL_WARNING!>l1@<!> i)
foo(l1@ i)
foo((i))
foo(<!REDUNDANT_LABEL_WARNING!>l2@<!> (i))
foo((<!REDUNDANT_LABEL_WARNING!>l3@<!> i))
foo(l2@ (i))
foo((l3@ i))
}
val a: Int = <!INITIALIZER_TYPE_MISMATCH!><!REDUNDANT_LABEL_WARNING!>l4@<!> ""<!>
val a: Int = <!INITIALIZER_TYPE_MISMATCH!>l4@ ""<!>
val b: Int = <!INITIALIZER_TYPE_MISMATCH!>("")<!>
val c: Int = checkSubtype<Int>(<!ARGUMENT_TYPE_MISMATCH!>""<!>)
val d: Int = <!INITIALIZER_TYPE_MISMATCH!>checkSubtype<Long>(<!ARGUMENT_TYPE_MISMATCH!>""<!>)<!>
foo(<!REDUNDANT_LABEL_WARNING!>l4@<!> <!ARGUMENT_TYPE_MISMATCH!>""<!>)
foo(l4@ <!ARGUMENT_TYPE_MISMATCH!>""<!>)
foo((<!ARGUMENT_TYPE_MISMATCH!>""<!>))
foo(checkSubtype<Int>(<!ARGUMENT_TYPE_MISMATCH!>""<!>))
foo(<!ARGUMENT_TYPE_MISMATCH!>checkSubtype<Long>(<!ARGUMENT_TYPE_MISMATCH!>""<!>)<!>)
@@ -0,0 +1,3 @@
fun f(s : String?) : Boolean {
return foo@(s?.equals("a"))!!
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
fun f(s : String?) : Boolean {
return <!REDUNDANT_LABEL_WARNING!>foo@<!>(s?.equals("a"))!!
}
@@ -9,4 +9,4 @@ fun outer() {
bar(fun ())
bar(l@ fun ())
bar(@ann fun ())
}
}
@@ -12,4 +12,4 @@ val b/*: () -> Int */ = l@ {
val c/*: () -> Unit */ = l@ {
if (flag) 4
}
}
@@ -0,0 +1,22 @@
// !LANGUAGE: +ExpectedTypeFromCast
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class bar
fun <T> foo(): T = TODO()
fun <V> 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 <T> foo(): T = TODO()
}
val par5 = ( @bar() X.foo()) as String
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !LANGUAGE: +ExpectedTypeFromCast
@Target(AnnotationTarget.EXPRESSION)
@@ -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@ <!USAGE_IS_NOT_INLINABLE!>bar1<!>
l2@ bar1 {
11
}
(l3@ bar1) {
11
}
(l5@ (l4@ bar1)) {
11
}
}
-1
View File
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
inline fun foo(bar1: (String.() -> Int) -> Int, bar2: (()->Int) -> Int) {
@@ -0,0 +1,27 @@
// !CHECK_TYPE
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) {
(s)(11)
(s).invoke(11)
(s) <!INFIX_MODIFIER_REQUIRED!>invoke<!> 11
(<!USAGE_IS_NOT_INLINABLE!>s<!>)
}
<!NOTHING_TO_INLINE!>inline<!> fun Function1<Int, Unit>.inlineExt() {
(this).invoke(11)
(this) <!INFIX_MODIFIER_REQUIRED!>invoke<!> 11
(this)(11)
(this)
}
inline fun inlineFunWithInvoke2(s: (p: Int) -> Unit) {
(((s)))(11)
(((s))).invoke(11)
(((s))) <!INFIX_MODIFIER_REQUIRED!>invoke<!> 11
(((<!USAGE_IS_NOT_INLINABLE!>s<!>)))
}
inline fun propagation(s: (p: Int) -> Unit) {
inlineFunWithInvoke((label@ s))
inlineFunWithInvoke((label2@ label@ s))
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !CHECK_TYPE
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) {
@@ -32,7 +32,7 @@ fun main() {
val w: Foo? = null
w<!UNSAFE_CALL!>.<!>f = z
(w<!UNSAFE_CALL!>.<!>f) = z
(<!REDUNDANT_LABEL_WARNING!>label@<!> w<!UNSAFE_CALL!>.<!>f) = z
(label@ w<!UNSAFE_CALL!>.<!>f) = z
w!!.f = z
w.f = z
w<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.f = z
@@ -8,8 +8,8 @@ fun main() {
val h : String = v--;
val h1 : String = --v;
val i : String = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>!true<!>;
val j : String = <!INITIALIZER_TYPE_MISMATCH!><!REDUNDANT_LABEL_WARNING!>foo@<!> true<!>;
val k : String = <!INITIALIZER_TYPE_MISMATCH!><!REDUNDANT_LABEL_WARNING!>foo@<!> <!REDUNDANT_LABEL_WARNING!>bar@<!> true<!>;
val j : String = <!INITIALIZER_TYPE_MISMATCH!>foo@ true<!>;
val k : String = <!INITIALIZER_TYPE_MISMATCH!>foo@ bar@ true<!>;
val l : String = <!INITIALIZER_TYPE_MISMATCH!>-1<!>;
val m : String = <!INITIALIZER_TYPE_MISMATCH!>+1<!>;
}
@@ -0,0 +1,20 @@
interface Foo<T>
class Bar {
operator fun <T> invoke(): Foo<T> = throw Exception()
}
class A {
val bar = Bar()
}
fun fooInt(l: Foo<Int>) = 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())))
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
interface Foo<T>
class Bar {
@@ -0,0 +1,23 @@
fun testEquals(x: Int) {
if (<!SENSELESS_COMPARISON!>x == null<!>) {}
if (<!SENSELESS_COMPARISON!>x == (null)<!>) {}
if (<!SENSELESS_COMPARISON!>x == foo@ null<!>) {}
}
fun testEqualsFlipped(x: Int) {
if (<!SENSELESS_COMPARISON!>null == x<!>) {}
if (<!SENSELESS_COMPARISON!>(null) == x<!>) {}
if (<!SENSELESS_COMPARISON!>foo@ null == x<!>) {}
}
fun testNotEquals(x: Int) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
if (<!SENSELESS_COMPARISON!>x != (null)<!>) {}
if (<!SENSELESS_COMPARISON!>x != foo@ null<!>) {}
}
fun testNotEqualsFlipped(x: Int) {
if (<!SENSELESS_COMPARISON!>null != x<!>) {}
if (<!SENSELESS_COMPARISON!>(null) != x<!>) {}
if (<!SENSELESS_COMPARISON!>foo@ null != x<!>) {}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
fun testEquals(x: Int) {
if (<!SENSELESS_COMPARISON!>x == null<!>) {}
if (<!SENSELESS_COMPARISON!>x == (null)<!>) {}
@@ -83,4 +83,4 @@ fun threeLevelsReturnWithUnknown(x: Int?): Int? {
}
}
return <!UNINITIALIZED_VARIABLE!>y<!>.inc()
}
}
@@ -59,4 +59,4 @@ suspend fun ifWhenAndOtherNonsence() {
}
}
suspend fun returnsInt(): Int = 0
suspend fun returnsInt(): Int = 0
@@ -31,7 +31,7 @@ inline fun case_4(block: () -> Unit) {
// TESTCASE NUMBER: 5
inline fun case_5(block: () -> Unit) {
<!REDUNDANT_LABEL_WARNING!>test@<!> contract {
test@ contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()