drop deprecated syntax for class objects

This commit is contained in:
Dmitry Jemerov
2015-04-24 17:17:18 +02:00
parent 2bc4dde959
commit 683d727c72
23 changed files with 3 additions and 339 deletions
@@ -215,8 +215,6 @@ public interface Errors {
DiagnosticFactory0<JetObjectDeclaration> MANY_COMPANION_OBJECTS = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
DiagnosticFactory0<JetObjectDeclaration> COMPANION_OBJECT_NOT_ALLOWED = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
DiagnosticFactory0<JetObjectDeclaration> DEPRECATED_CLASS_OBJECT_SYNTAX = DiagnosticFactory0.create(WARNING);
DiagnosticFactory1<PsiElement, DeclarationDescriptor> DEPRECATED_SYMBOL = DiagnosticFactory1.create(WARNING);
DiagnosticFactory2<PsiElement, DeclarationDescriptor, String> DEPRECATED_SYMBOL_WITH_MESSAGE = DiagnosticFactory2.create(WARNING);
@@ -58,7 +58,7 @@ public object PositioningStrategies {
}
is JetObjectDeclaration -> {
return markRange(
element.getClassKeyword() ?: element.getObjectKeyword(),
element.getObjectKeyword(),
element.getNameIdentifier() ?: element.getObjectKeyword()
)
}
@@ -251,7 +251,6 @@ public class DefaultErrorMessages {
MAP.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class");
MAP.put(COMPANION_OBJECT_NOT_ALLOWED, "A companion object is not allowed here");
MAP.put(DEPRECATED_CLASS_OBJECT_SYNTAX, "'class object' syntax for companion objects was deprecated. Use 'companion' modifier instead");
MAP.put(DEPRECATED_SYMBOL, "''{0}'' is deprecated.", DEPRECATION);
MAP.put(DEPRECATED_SYMBOL_WITH_MESSAGE, "''{0}'' is deprecated. {1}", DEPRECATION, STRING);
@@ -821,12 +821,7 @@ public class JetParsing extends AbstractJetParsing {
IElementType keywordToken = tt();
IElementType declType = null;
if (keywordToken == CLASS_KEYWORD) {
if (lookahead(1) == OBJECT_KEYWORD) {
declType = parseDeprecatedClassObject();
}
else {
declType = parseClass(isEnum);
}
declType = parseClass(isEnum);
}
else if (keywordToken == TRAIT_KEYWORD) {
declType = parseClass(isEnum);
@@ -977,18 +972,6 @@ public class JetParsing extends AbstractJetParsing {
initializer.done(type);
}
/*
* companionObject
* : modifiers "class" object
* ;
*/
private IElementType parseDeprecatedClassObject() {
assert _at(CLASS_KEYWORD) && lookahead(1) == OBJECT_KEYWORD;
advance(); // CLASS_KEYWORD
parseObject(NameParsingMode.ALLOWED, true);
return OBJECT_DECLARATION;
}
/*
* typeAlias
* : modifiers "typealias" SimpleName (typeParameters typeConstraints)? "=" type
@@ -99,7 +99,7 @@ public class JetObjectDeclaration extends JetNamedDeclarationStub<KotlinObjectSt
if (stub != null) {
return stub.isCompanion();
}
return getClassKeyword() != null || hasModifier(JetTokens.COMPANION_KEYWORD);
return hasModifier(JetTokens.COMPANION_KEYWORD);
}
@Override
@@ -182,11 +182,6 @@ public class JetObjectDeclaration extends JetNamedDeclarationStub<KotlinObjectSt
return findChildByType(JetTokens.OBJECT_KEYWORD);
}
@Nullable
public PsiElement getClassKeyword() {
return findChildByType(JetTokens.CLASS_KEYWORD);
}
@Override
public void delete() throws IncorrectOperationException {
JetPsiUtil.deleteClass(this);
@@ -230,19 +230,12 @@ public class DeclarationsChecker {
}
}
private void checkObject(JetObjectDeclaration declaration, ClassDescriptor classDescriptor) {
checkDeprecatedClassObjectSyntax(declaration);
reportErrorIfHasIllegalModifier(declaration);
if (declaration.isLocal() && !declaration.isCompanion() && !declaration.isObjectLiteral()) {
trace.report(LOCAL_OBJECT_NOT_ALLOWED.on(declaration, classDescriptor));
}
}
private void checkDeprecatedClassObjectSyntax(@NotNull JetObjectDeclaration declaration) {
if (declaration.getClassKeyword() != null) {
trace.report(DEPRECATED_CLASS_OBJECT_SYNTAX.on(declaration));
}
}
private void checkClass(BodiesResolveContext c, JetClass aClass, ClassDescriptorWithResolutionScopes classDescriptor) {
checkOpenMembers(classDescriptor);
checkPrimaryConstructor(aClass, classDescriptor);
@@ -1,32 +0,0 @@
trait G
class A {
<!DEPRECATED_CLASS_OBJECT_SYNTAX!>class object A<!> {
}
}
trait B {
<!DEPRECATED_CLASS_OBJECT_SYNTAX!>class object<!> : G {
}
}
class C {
companion <!DEPRECATED_CLASS_OBJECT_SYNTAX!>class object<!>
}
fun main() {
A
A.A
g(B.Companion)
g(B)
A.ext()
A.A.ext()
}
fun g(g: G) { <!UNUSED_EXPRESSION!>g<!> }
fun A.A.ext() {
}
@@ -1,52 +0,0 @@
package
internal fun g(/*0*/ g: G): kotlin.Unit
internal fun main(): kotlin.Unit
internal fun A.A.ext(): kotlin.Unit
internal final class A {
public constructor A()
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 companion object A {
private constructor A()
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 trait B {
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 companion object Companion : G {
private constructor Companion()
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 C {
public constructor C()
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 companion object Companion {
private constructor Companion()
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 trait G {
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
}
@@ -1482,12 +1482,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("deprecatedClassObjectSyntax.kt")
public void testDeprecatedClassObjectSyntax() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/classObjects/deprecatedClassObjectSyntax.kt");
doTest(fileName);
}
@TestMetadata("importClassInClassObject.kt")
public void testImportClassInClassObject() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/classObjects/importClassInClassObject.kt");