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