FIR: implement checker for open members
Specifically, 1. NON_FINAL_MEMBER_IN_FINAL_CLASS 2. NON_FINAL_MEMBER_IN_OBJECT
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3e9ff3ecda
commit
6b453d9b23
+1
-1
@@ -10,7 +10,7 @@ inline class A4(var x: Int)
|
||||
inline class A5(val x: Int, val y: Int)
|
||||
inline class A6(x: Int, val y: Int)
|
||||
inline class A7(vararg val x: Int)
|
||||
inline class A8(open val x: Int)
|
||||
inline class A8(<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> val x: Int)
|
||||
inline class A9(final val x: Int)
|
||||
|
||||
class B1 {
|
||||
|
||||
@@ -7,14 +7,14 @@ abstract class A() {
|
||||
<!INCOMPATIBLE_MODIFIERS!>final<!> <!INCOMPATIBLE_MODIFIERS!>open<!> fun h() {}
|
||||
|
||||
open var r: String
|
||||
get
|
||||
abstract protected set
|
||||
get
|
||||
abstract protected set
|
||||
}
|
||||
|
||||
final interface T {}
|
||||
|
||||
class FinalClass() {
|
||||
open fun foo() {}
|
||||
<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> fun foo() {}
|
||||
val i: Int = 1
|
||||
open get(): Int = field
|
||||
var j: Int = 1
|
||||
@@ -32,13 +32,13 @@ class LegalModifier(val a: Int, @annotated private var b: String, @annotated var
|
||||
|
||||
//Check illegal modifier in constructor parameters
|
||||
class IllegalModifiers1(
|
||||
<!INCOMPATIBLE_MODIFIERS!>in<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>out<!>
|
||||
reified
|
||||
enum
|
||||
private
|
||||
const
|
||||
a: Int)
|
||||
<!INCOMPATIBLE_MODIFIERS!>in<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>out<!>
|
||||
reified
|
||||
enum
|
||||
private
|
||||
const
|
||||
a: Int)
|
||||
|
||||
//Check multiple illegal modifiers in constructor
|
||||
class IllegalModifiers2(<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>abstract<!> a: Int)
|
||||
@@ -53,26 +53,26 @@ class IllegalModifiers4(val a: Int, @annotated("a text") protected vararg v: Int
|
||||
//Check illegal modifiers for functions and catch block
|
||||
abstract class IllegalModifiers5() {
|
||||
|
||||
//Check illegal modifier in function parameter
|
||||
abstract fun foo(public a: Int, vararg v: String)
|
||||
//Check illegal modifier in function parameter
|
||||
abstract fun foo(public a: Int, vararg v: String)
|
||||
|
||||
//Check multiple illegal modifiers in function parameter
|
||||
abstract fun bar(public abstract a: Int, vararg v: String)
|
||||
|
||||
//Check annotations with illegal modifiers
|
||||
abstract fun baz(@annotated("a text") public abstract a: Int)
|
||||
|
||||
private fun qux() {
|
||||
|
||||
//Check illegal modifier in catch block
|
||||
try {} catch (<!INCOMPATIBLE_MODIFIERS!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> reified enum public e: Exception) {}
|
||||
|
||||
//Check multiple illegal modifiers in catch block
|
||||
try {} catch (<!INCOMPATIBLE_MODIFIERS!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> reified enum abstract public e: Exception) {}
|
||||
//Check multiple illegal modifiers in function parameter
|
||||
abstract fun bar(public abstract a: Int, vararg v: String)
|
||||
|
||||
//Check annotations with illegal modifiers
|
||||
try {} catch (@annotated("a text") abstract public e: Exception) {}
|
||||
}
|
||||
abstract fun baz(@annotated("a text") public abstract a: Int)
|
||||
|
||||
private fun qux() {
|
||||
|
||||
//Check illegal modifier in catch block
|
||||
try {} catch (<!INCOMPATIBLE_MODIFIERS!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> reified enum public e: Exception) {}
|
||||
|
||||
//Check multiple illegal modifiers in catch block
|
||||
try {} catch (<!INCOMPATIBLE_MODIFIERS!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> reified enum abstract public e: Exception) {}
|
||||
|
||||
//Check annotations with illegal modifiers
|
||||
try {} catch (@annotated("a text") abstract public e: Exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
//Check illegal modifiers on anonymous initializers
|
||||
|
||||
@@ -7,8 +7,8 @@ abstract class A() {
|
||||
<!INCOMPATIBLE_MODIFIERS!>final<!> <!INCOMPATIBLE_MODIFIERS!>open<!> fun h() {}
|
||||
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>open var r: String<!>
|
||||
get
|
||||
<!WRONG_MODIFIER_TARGET!>abstract<!> protected set
|
||||
get
|
||||
<!WRONG_MODIFIER_TARGET!>abstract<!> protected set
|
||||
}
|
||||
|
||||
<!WRONG_MODIFIER_TARGET!>final<!> interface T {}
|
||||
@@ -32,13 +32,13 @@ class LegalModifier(val a: Int, @annotated private var b: String, @annotated var
|
||||
|
||||
//Check illegal modifier in constructor parameters
|
||||
class IllegalModifiers1(
|
||||
<!WRONG_MODIFIER_TARGET!>in<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>out<!>
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!>
|
||||
<!WRONG_MODIFIER_TARGET!>enum<!>
|
||||
<!WRONG_MODIFIER_TARGET!>private<!>
|
||||
<!WRONG_MODIFIER_TARGET!>const<!>
|
||||
<!UNUSED_PARAMETER!>a<!>: Int)
|
||||
<!WRONG_MODIFIER_TARGET!>in<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>out<!>
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!>
|
||||
<!WRONG_MODIFIER_TARGET!>enum<!>
|
||||
<!WRONG_MODIFIER_TARGET!>private<!>
|
||||
<!WRONG_MODIFIER_TARGET!>const<!>
|
||||
<!UNUSED_PARAMETER!>a<!>: Int)
|
||||
|
||||
//Check multiple illegal modifiers in constructor
|
||||
class IllegalModifiers2(<!WRONG_MODIFIER_TARGET!>private<!> <!INCOMPATIBLE_MODIFIERS!>abstract<!> <!UNUSED_PARAMETER!>a<!>: Int)
|
||||
@@ -53,26 +53,26 @@ class IllegalModifiers4(val a: Int, @annotated("a text") <!WRONG_MODIFIER_TARGET
|
||||
//Check illegal modifiers for functions and catch block
|
||||
abstract class IllegalModifiers5() {
|
||||
|
||||
//Check illegal modifier in function parameter
|
||||
abstract fun foo(<!WRONG_MODIFIER_TARGET!>public<!> a: Int, vararg v: String)
|
||||
//Check illegal modifier in function parameter
|
||||
abstract fun foo(<!WRONG_MODIFIER_TARGET!>public<!> a: Int, vararg v: String)
|
||||
|
||||
//Check multiple illegal modifiers in function parameter
|
||||
abstract fun bar(<!WRONG_MODIFIER_TARGET!>public<!> <!WRONG_MODIFIER_TARGET!>abstract<!> a: Int, vararg v: String)
|
||||
|
||||
//Check annotations with illegal modifiers
|
||||
abstract fun baz(@annotated("a text") <!WRONG_MODIFIER_TARGET!>public<!> <!WRONG_MODIFIER_TARGET!>abstract<!> a: Int)
|
||||
|
||||
private fun qux() {
|
||||
|
||||
//Check illegal modifier in catch block
|
||||
try {} catch (<!WRONG_MODIFIER_TARGET!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> <!WRONG_MODIFIER_TARGET!>reified<!> <!WRONG_MODIFIER_TARGET!>enum<!> <!WRONG_MODIFIER_TARGET!>public<!> e: Exception) {}
|
||||
|
||||
//Check multiple illegal modifiers in catch block
|
||||
try {} catch (<!WRONG_MODIFIER_TARGET!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> <!WRONG_MODIFIER_TARGET!>reified<!> <!WRONG_MODIFIER_TARGET!>enum<!> <!WRONG_MODIFIER_TARGET!>abstract<!> <!WRONG_MODIFIER_TARGET!>public<!> e: Exception) {}
|
||||
//Check multiple illegal modifiers in function parameter
|
||||
abstract fun bar(<!WRONG_MODIFIER_TARGET!>public<!> <!WRONG_MODIFIER_TARGET!>abstract<!> a: Int, vararg v: String)
|
||||
|
||||
//Check annotations with illegal modifiers
|
||||
try {} catch (@annotated("a text") <!WRONG_MODIFIER_TARGET!>abstract<!> <!WRONG_MODIFIER_TARGET!>public<!> e: Exception) {}
|
||||
}
|
||||
abstract fun baz(@annotated("a text") <!WRONG_MODIFIER_TARGET!>public<!> <!WRONG_MODIFIER_TARGET!>abstract<!> a: Int)
|
||||
|
||||
private fun qux() {
|
||||
|
||||
//Check illegal modifier in catch block
|
||||
try {} catch (<!WRONG_MODIFIER_TARGET!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> <!WRONG_MODIFIER_TARGET!>reified<!> <!WRONG_MODIFIER_TARGET!>enum<!> <!WRONG_MODIFIER_TARGET!>public<!> e: Exception) {}
|
||||
|
||||
//Check multiple illegal modifiers in catch block
|
||||
try {} catch (<!WRONG_MODIFIER_TARGET!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> <!WRONG_MODIFIER_TARGET!>reified<!> <!WRONG_MODIFIER_TARGET!>enum<!> <!WRONG_MODIFIER_TARGET!>abstract<!> <!WRONG_MODIFIER_TARGET!>public<!> e: Exception) {}
|
||||
|
||||
//Check annotations with illegal modifiers
|
||||
try {} catch (@annotated("a text") <!WRONG_MODIFIER_TARGET!>abstract<!> <!WRONG_MODIFIER_TARGET!>public<!> e: Exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
//Check illegal modifiers on anonymous initializers
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
object Obj {
|
||||
fun foo() {}
|
||||
|
||||
open fun bar() {}
|
||||
|
||||
var x: Int = 0
|
||||
|
||||
open var y: Int = 1
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
object Obj {
|
||||
fun foo() {}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
open fun openFoo() {}
|
||||
<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> fun openFoo() {}
|
||||
fun finalFoo() {}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ abstract class A2 {
|
||||
class B2 : A2()
|
||||
class C2 : B2() {
|
||||
override fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ value class A6(x: Int, val y: Int)
|
||||
@JvmInline
|
||||
value class A7(vararg val x: Int)
|
||||
@JvmInline
|
||||
value class A8(open val x: Int)
|
||||
value class A8(<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> val x: Int)
|
||||
@JvmInline
|
||||
value class A9(final val x: Int)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user