Report error for inappropriate modifiers usages
This commit is contained in:
@@ -30,7 +30,13 @@ annotation class annotated(val text: String = "not given")
|
||||
class LegalModifier(val a: Int, annotated private var b: String, annotated vararg <!UNUSED_PARAMETER!>v<!>: Int)
|
||||
|
||||
//Check illegal modifier in constructor parameters
|
||||
class IllegalModifiers1(<!ILLEGAL_MODIFIER!>private<!> <!UNUSED_PARAMETER!>a<!>: Int)
|
||||
class IllegalModifiers1(
|
||||
<!ILLEGAL_MODIFIER!>in<!>
|
||||
<!ILLEGAL_MODIFIER!>out<!>
|
||||
<!ILLEGAL_MODIFIER!>reified<!>
|
||||
<!ILLEGAL_MODIFIER!>enum<!>
|
||||
<!ILLEGAL_MODIFIER!>private<!>
|
||||
<!UNUSED_PARAMETER!>a<!>: Int)
|
||||
|
||||
//Check multiple illegal modifiers in constructor
|
||||
class IllegalModifiers2(<!ILLEGAL_MODIFIER!>private<!> <!ILLEGAL_MODIFIER!>abstract<!> <!UNUSED_PARAMETER!>a<!>: Int)
|
||||
@@ -57,10 +63,10 @@ abstract class IllegalModifiers5() {
|
||||
private fun qux() {
|
||||
|
||||
//Check illegal modifier in catch block
|
||||
try {} catch (<!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
|
||||
try {} catch (<!ILLEGAL_MODIFIER!>in<!> <!ILLEGAL_MODIFIER!>out<!> <!ILLEGAL_MODIFIER!>reified<!> <!ILLEGAL_MODIFIER!>enum<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
|
||||
|
||||
//Check multiple illegal modifiers in catch block
|
||||
try {} catch (<!ILLEGAL_MODIFIER!>abstract<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
|
||||
try {} catch (<!ILLEGAL_MODIFIER!>in<!> <!ILLEGAL_MODIFIER!>out<!> <!ILLEGAL_MODIFIER!>reified<!> <!ILLEGAL_MODIFIER!>enum<!> <!ILLEGAL_MODIFIER!>abstract<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
|
||||
|
||||
//Check annotations with illegal modifiers
|
||||
try {} catch (annotated("a text") <!ILLEGAL_MODIFIER!>abstract<!> <!ILLEGAL_MODIFIER!>public<!> e: Exception) {}
|
||||
@@ -80,4 +86,29 @@ abstract class IllegalModifiers6() {
|
||||
<!ILLEGAL_MODIFIER!>public<!> annotated init {}
|
||||
|
||||
<!ILLEGAL_MODIFIER!>private<!> <!NOT_AN_ANNOTATION_CLASS!>IllegalModifiers6()<!> init {}
|
||||
}
|
||||
}
|
||||
|
||||
// strange Check inappropriate modifiers
|
||||
<!ILLEGAL_MODIFIER!>override<!>
|
||||
<!ILLEGAL_MODIFIER!>out<!>
|
||||
<!ILLEGAL_MODIFIER!>in<!>
|
||||
<!ILLEGAL_MODIFIER!>vararg<!>
|
||||
<!ILLEGAL_MODIFIER!>reified<!>
|
||||
class IllegalModifiers7() {
|
||||
<!ILLEGAL_ENUM_ANNOTATION!>enum<!>
|
||||
<!ILLEGAL_MODIFIER!>inner<!>
|
||||
<!ILLEGAL_ANNOTATION_KEYWORD!>annotation<!>
|
||||
<!ILLEGAL_MODIFIER!>out<!>
|
||||
<!ILLEGAL_MODIFIER!>in<!>
|
||||
<!ILLEGAL_MODIFIER!>vararg<!>
|
||||
<!ILLEGAL_MODIFIER!>reified<!>
|
||||
val x = 1
|
||||
<!ILLEGAL_ENUM_ANNOTATION!>enum<!>
|
||||
<!ILLEGAL_MODIFIER!>inner<!>
|
||||
<!ILLEGAL_ANNOTATION_KEYWORD!>annotation<!>
|
||||
<!ILLEGAL_MODIFIER!>out<!>
|
||||
<!ILLEGAL_MODIFIER!>in<!>
|
||||
<!ILLEGAL_MODIFIER!>vararg<!>
|
||||
<!ILLEGAL_MODIFIER!>reified<!>
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,15 @@ package illegal_modifiers {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal open class IllegalModifiers7 {
|
||||
public constructor IllegalModifiers7()
|
||||
internal final val x: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
internal final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final class LegalModifier {
|
||||
public constructor LegalModifier(/*0*/ a: kotlin.Int, /*1*/ illegal_modifiers.annotated() b: kotlin.String, /*2*/ illegal_modifiers.annotated() vararg v: kotlin.Int /*kotlin.IntArray*/)
|
||||
internal final val a: kotlin.Int
|
||||
|
||||
Reference in New Issue
Block a user