FIR checker: report UNINITIALIZED_PARAMETER

This commit is contained in:
Jinseong Jeon
2021-04-22 23:48:15 -07:00
committed by TeamCityServer
parent d2f831b635
commit bdfc879f00
21 changed files with 146 additions and 39 deletions
@@ -1,9 +0,0 @@
interface Inter {
fun foo(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int = x)
}
abstract class Abst {
abstract fun foo(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int = x)
}
<!NON_MEMBER_FUNCTION_NO_BODY!>fun extraDiagnostics(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int)<!>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface Inter {
fun foo(x: Int = <!UNINITIALIZED_PARAMETER!>y<!>, y: Int = x)
}
@@ -7,10 +7,33 @@ fun bar(x : Int = "", y : Int = x, z : String = y) {
// KT-371 Resolve default parameters for constructors
class A(x : Int = <!UNRESOLVED_REFERENCE!>y<!>, y : Int = x) { // None of the references is resolved, no types checked
fun foo(bool: Boolean, a: Int = <!UNRESOLVED_REFERENCE!>b<!>, b: String = a) {}
class A(x : Int = <!UNINITIALIZED_PARAMETER!>y<!>, y : Int = x) { // None of the references is resolved, no types checked
constructor(x : Int = <!UNINITIALIZED_PARAMETER!>x<!>) : this(x, x)
fun foo(bool: Boolean, a: Int = <!UNINITIALIZED_PARAMETER!>b<!>, b: String = a) {}
}
val z = 3
fun foo(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int = x, i : Int = z): Int = x + y
fun foo(x: Int = <!UNINITIALIZED_PARAMETER!>y<!>, y: Int = x, i : Int = z): Int = x + y
fun foo(x: () -> Int = { <!UNINITIALIZED_PARAMETER!>y<!> }, y: Int = x(), i : Int = z): Int = x() + y
fun bar(x: () -> Int = { <!UNINITIALIZED_PARAMETER!>y<!>; 1 }, y: Int) {}
fun baz(
x: () -> Int = {
fun bar(xx: () -> Int = { <!UNINITIALIZED_PARAMETER!>y<!>; 1 }) = xx
bar()()
},
y: Int
) {
}
fun boo(
x: () -> Int = {
fun bar(): Int = <!UNINITIALIZED_PARAMETER!>y<!>
bar()
},
y: Int
) {
}
@@ -8,9 +8,32 @@ fun bar(x : Int = <!TYPE_MISMATCH!>""<!>, y : Int = x, z : String = <!TYPE_MISMA
// KT-371 Resolve default parameters for constructors
class A(x : Int = <!UNINITIALIZED_PARAMETER!>y<!>, y : Int = x) { // None of the references is resolved, no types checked
constructor(x : Int = <!UNINITIALIZED_PARAMETER!>x<!>) : this(x, x)
fun foo(bool: Boolean, a: Int = <!TYPE_MISMATCH, UNINITIALIZED_PARAMETER!>b<!>, b: String = <!TYPE_MISMATCH!>a<!>) {}
}
val z = 3
fun foo(x: Int = <!UNINITIALIZED_PARAMETER!>y<!>, y: Int = x, i : Int = z): Int = x + y
fun foo(x: () -> Int = { <!UNINITIALIZED_PARAMETER{OI}!>y<!> }, y: Int = x(), i : Int = z): Int = x() + y
fun bar(x: () -> Int = { <!UNINITIALIZED_PARAMETER{OI}!>y<!>; 1 }, y: Int) {}
fun baz(
x: () -> Int = {
fun bar(xx: () -> Int = { <!UNINITIALIZED_PARAMETER{OI}!>y<!>; 1 }) = xx
bar()()
},
y: Int
) {
}
fun boo(
x: () -> Int = {
fun bar(): Int = <!UNINITIALIZED_PARAMETER{OI}!>y<!>
bar()
},
y: Int
) {
}
@@ -2,10 +2,15 @@ package
public val x: kotlin.String = ""
public val z: kotlin.Int = 3
public fun bar(/*0*/ x: () -> kotlin.Int = ..., /*1*/ y: kotlin.Int): kotlin.Unit
public fun bar(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ..., /*2*/ z: kotlin.String = ...): kotlin.Unit
public fun baz(/*0*/ x: () -> kotlin.Int = ..., /*1*/ y: kotlin.Int): kotlin.Unit
public fun boo(/*0*/ x: () -> kotlin.Int = ..., /*1*/ y: kotlin.Int): kotlin.Unit
public fun foo(/*0*/ x: () -> kotlin.Int = ..., /*1*/ y: kotlin.Int = ..., /*2*/ i: kotlin.Int = ...): kotlin.Int
public fun foo(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ..., /*2*/ i: kotlin.Int = ...): kotlin.Int
public final class A {
public constructor A(/*0*/ x: kotlin.Int = ...)
public constructor A(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ...)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ bool: kotlin.Boolean, /*1*/ a: kotlin.Int = ..., /*2*/ b: kotlin.String = ...): kotlin.Unit
@@ -1,6 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo() {
fun bar(x: String, y: String = x) {}
fun baz(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int) {}
}
@@ -1,6 +1,8 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo() {
fun foo(x: Int = <!UNINITIALIZED_PARAMETER!>x<!>) {}
fun bar(x: String, y: String = x) {}
fun baz(x: Int = <!UNINITIALIZED_PARAMETER!>y<!>, y: Int) {}
}
}
@@ -23,7 +23,7 @@ fun foo() {
10
}
fun bar(x: Exception = `_`) {}
class Bar(`_`: Exception = `_`) {
class Bar(`_`: Exception = <!UNINITIALIZED_PARAMETER!>`_`<!>) {
inner class Bar2(x: Exception = `_`) { }
}
}
@@ -23,7 +23,7 @@ fun foo() {
10
}
fun bar(x: Exception = `_`) {}
class Bar(`_`: Exception = `_`) {
class Bar(`_`: Exception = <!UNINITIALIZED_PARAMETER!>`_`<!>) {
inner class Bar2(x: Exception = `_`) { }
}
}