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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user