Report illegal modifiers on secondary constructors

This commit is contained in:
Denis Zharkov
2015-03-17 13:39:21 +03:00
parent 66023e6f31
commit 29b03e8175
3 changed files with 48 additions and 1 deletions
@@ -105,6 +105,14 @@ public class DeclarationsChecker {
modifiersChecker.checkModifiersForDeclaration(property, propertyDescriptor);
}
for (Map.Entry<JetSecondaryConstructor, ConstructorDescriptor> entry : bodiesResolveContext.getSecondaryConstructors().entrySet()) {
ConstructorDescriptor constructorDescriptor = entry.getValue();
JetSecondaryConstructor declaration = entry.getKey();
modifiersChecker.reportIllegalModalityModifiers(declaration);
reportErrorIfHasIllegalModifier(declaration);
modifiersChecker.checkModifiersForDeclaration(declaration, constructorDescriptor);
}
}
private void reportErrorIfHasIllegalModifier(JetModifierListOwner declaration) {
@@ -88,7 +88,7 @@ abstract class IllegalModifiers6() {
<!ILLEGAL_MODIFIER!>private<!> <!NOT_AN_ANNOTATION_CLASS!>IllegalModifiers6()<!> init {}
}
// strange Check inappropriate modifiers
// strange inappropriate modifiers usages
<!ILLEGAL_MODIFIER!>override<!>
<!ILLEGAL_MODIFIER!>out<!>
<!ILLEGAL_MODIFIER!>in<!>
@@ -112,3 +112,26 @@ class IllegalModifiers7() {
<!ILLEGAL_MODIFIER!>reified<!>
fun foo() {}
}
// Secondary constructors
class IllegalModifiers8 {
<!ILLEGAL_MODIFIER, INCOMPATIBLE_MODIFIERS!>abstract<!>
<!ILLEGAL_ENUM_ANNOTATION!>enum<!>
<!ILLEGAL_MODIFIER, REDUNDANT_MODIFIER, REDUNDANT_MODIFIER, INCOMPATIBLE_MODIFIERS!>open<!>
<!ILLEGAL_MODIFIER!>inner<!>
<!ILLEGAL_ANNOTATION_KEYWORD!>annotation<!>
<!ILLEGAL_MODIFIER!>override<!>
<!ILLEGAL_MODIFIER!>out<!>
<!ILLEGAL_MODIFIER!>in<!>
<!ILLEGAL_MODIFIER, INCOMPATIBLE_MODIFIERS!>final<!>
<!ILLEGAL_MODIFIER!>vararg<!>
<!ILLEGAL_MODIFIER!>reified<!>
constructor() {}
constructor(<!ILLEGAL_MODIFIER!>private<!> <!ILLEGAL_MODIFIER!>enum<!> <!ILLEGAL_MODIFIER!>abstract<!> <!UNUSED_PARAMETER!>x<!>: Int) {}
}
class IllegalModifiers9 {
<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>protected<!> constructor() {}
<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>internal<!> constructor(<!UNUSED_PARAMETER!>x<!>: Int) {}
}
@@ -93,6 +93,22 @@ package illegal_modifiers {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class IllegalModifiers8 {
public constructor IllegalModifiers8()
public constructor IllegalModifiers8(/*0*/ x: kotlin.Int)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class IllegalModifiers9 {
private constructor IllegalModifiers9()
private constructor IllegalModifiers9(/*0*/ x: kotlin.Int)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
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