diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 14c7aa0e286..385b8501e8d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -327,6 +327,7 @@ public interface Errors { DiagnosticFactory1 LOCAL_OBJECT_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME); DiagnosticFactory1 LOCAL_INTERFACE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME); + DiagnosticFactory0 TYPE_PARAMETERS_IN_OBJECT = DiagnosticFactory0.create(ERROR); // Type parameter declarations diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index edb39ee3771..2ff04b8f5ad 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -23,7 +23,6 @@ import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; -import org.jetbrains.kotlin.config.LanguageFeature; import org.jetbrains.kotlin.config.LanguageVersion; import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.diagnostics.DiagnosticFactory; @@ -373,6 +372,7 @@ public class DefaultErrorMessages { MAP.put(LOCAL_OBJECT_NOT_ALLOWED, "Named object ''{0}'' is a singleton and cannot be local. Try to use anonymous object instead", NAME); MAP.put(LOCAL_INTERFACE_NOT_ALLOWED, "''{0}'' is an interface so it cannot be local. Try to use anonymous object or abstract class instead", NAME); + MAP.put(TYPE_PARAMETERS_IN_OBJECT, "Type parameters are not allowed for objects"); MAP.put(ENUM_CLASS_CONSTRUCTOR_CALL, "Enum types cannot be instantiated"); MAP.put(SEALED_CLASS_CONSTRUCTOR_CALL, "Sealed types cannot be instantiated"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java index feaf2b9a919..a9827dc8d66 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -823,9 +823,7 @@ public class KotlinParsing extends AbstractKotlinParsing { } } - OptionalMarker typeParamsMarker = new OptionalMarker(object); boolean typeParametersDeclared = parseTypeParameterList(TYPE_PARAMETER_GT_RECOVERY_SET); - typeParamsMarker.error("Type parameters are not allowed for objects"); PsiBuilder.Marker beforeConstructorModifiers = mark(); PsiBuilder.Marker primaryConstructorMarker = mark(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/KtObjectInfo.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/KtObjectInfo.java index bcd2b787284..954be26746d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/KtObjectInfo.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/KtObjectInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class KtObjectInfo extends KtClassOrObjectInfo { @Nullable @Override public KtTypeParameterList getTypeParameterList() { - return null; + return element.getTypeParameterList(); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index f5abb6f2334..d7bc2df3d91 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,8 +68,7 @@ import java.util.List; import static kotlin.collections.CollectionsKt.firstOrNull; import static org.jetbrains.kotlin.descriptors.Visibilities.PUBLIC; -import static org.jetbrains.kotlin.diagnostics.Errors.CYCLIC_INHERITANCE_HIERARCHY; -import static org.jetbrains.kotlin.diagnostics.Errors.TYPE_PARAMETERS_IN_ENUM; +import static org.jetbrains.kotlin.diagnostics.Errors.*; import static org.jetbrains.kotlin.resolve.BindingContext.TYPE; import static org.jetbrains.kotlin.resolve.ModifiersChecker.*; @@ -270,6 +269,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes if (classInfo.getClassKind() == ClassKind.ENUM_CLASS) { c.getTrace().report(TYPE_PARAMETERS_IN_ENUM.on(typeParameterList)); } + if (classInfo.getClassKind() == ClassKind.OBJECT) { + c.getTrace().report(TYPE_PARAMETERS_IN_OBJECT.on(typeParameterList)); + } List typeParameters = typeParameterList.getParameters(); if (typeParameters.isEmpty()) return Collections.emptyList(); diff --git a/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.kt b/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.kt new file mode 100644 index 00000000000..fb6cb213662 --- /dev/null +++ b/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.kt @@ -0,0 +1,21 @@ +object A +object B +object C> + +class D { + companion object +} + +class E { + companion object +} + +class F { + companion object C> +} + +class G { + companion object F +} + +object H() diff --git a/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.txt b/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.txt new file mode 100644 index 00000000000..20fee8f46b8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.txt @@ -0,0 +1,85 @@ +package + +public 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 +} + +public object B { + private constructor 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 +} + +public object C> { + private 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 +} + +public final class D { + public constructor D() + 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 + + public 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 + } +} + +public final class E { + public constructor E() + 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 + + public 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 + } +} + +public final class F { + public constructor F() + 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 + + public companion object C> { + private 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 + } +} + +public final class G { + public constructor 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 + + public companion object F { + private constructor F() + 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 + } +} + +public object H { + private constructor H() + 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 +} diff --git a/compiler/testData/psi/recovery/objects/declarations/Everything.txt b/compiler/testData/psi/recovery/objects/declarations/Everything.txt index de80f55755e..fe3e97a1253 100644 --- a/compiler/testData/psi/recovery/objects/declarations/Everything.txt +++ b/compiler/testData/psi/recovery/objects/declarations/Everything.txt @@ -7,16 +7,15 @@ JetFile: Everything.kt PsiElement(object)('object') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('Foo') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PsiWhiteSpace(' ') PRIMARY_CONSTRUCTOR MODIFIER_LIST diff --git a/compiler/testData/psi/recovery/objects/declarations/TypeParametersAndParentheses.txt b/compiler/testData/psi/recovery/objects/declarations/TypeParametersAndParentheses.txt index 0740b1f2183..42fe84ddaad 100644 --- a/compiler/testData/psi/recovery/objects/declarations/TypeParametersAndParentheses.txt +++ b/compiler/testData/psi/recovery/objects/declarations/TypeParametersAndParentheses.txt @@ -7,16 +7,15 @@ JetFile: TypeParametersAndParentheses.kt PsiElement(object)('object') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('Foo') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PRIMARY_CONSTRUCTOR VALUE_PARAMETER_LIST PsiElement(LPAR)('(') @@ -26,16 +25,15 @@ JetFile: TypeParametersAndParentheses.kt PsiElement(object)('object') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('Foo') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PRIMARY_CONSTRUCTOR VALUE_PARAMETER_LIST PsiElement(LPAR)('(') @@ -57,16 +55,15 @@ JetFile: TypeParametersAndParentheses.kt PsiElement(object)('object') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('Foo') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PRIMARY_CONSTRUCTOR VALUE_PARAMETER_LIST PsiElement(LPAR)('(') diff --git a/compiler/testData/psi/recovery/objects/declarations/TypeParameterss.txt b/compiler/testData/psi/recovery/objects/declarations/TypeParameterss.txt index 6970291e5a9..e69402f1507 100644 --- a/compiler/testData/psi/recovery/objects/declarations/TypeParameterss.txt +++ b/compiler/testData/psi/recovery/objects/declarations/TypeParameterss.txt @@ -7,31 +7,29 @@ JetFile: TypeParameterss.kt PsiElement(object)('object') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('Foo') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PsiWhiteSpace('\n\n') OBJECT_DECLARATION PsiElement(object)('object') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('Foo') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PsiWhiteSpace(' ') CLASS_BODY PsiElement(LBRACE)('{') @@ -41,16 +39,15 @@ JetFile: TypeParameterss.kt PsiElement(object)('object') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('Foo') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(COLON)(':') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/recovery/objects/expressions/Everything.txt b/compiler/testData/psi/recovery/objects/expressions/Everything.txt index 9df352f6322..5a96f5b6a58 100644 --- a/compiler/testData/psi/recovery/objects/expressions/Everything.txt +++ b/compiler/testData/psi/recovery/objects/expressions/Everything.txt @@ -13,16 +13,15 @@ JetFile: Everything.kt OBJECT_LITERAL OBJECT_DECLARATION PsiElement(object)('object') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PsiWhiteSpace(' ') PRIMARY_CONSTRUCTOR MODIFIER_LIST @@ -81,4 +80,4 @@ JetFile: Everything.kt PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/objects/expressions/TypeParametersAndParentheses.txt b/compiler/testData/psi/recovery/objects/expressions/TypeParametersAndParentheses.txt index 55241eb92b9..252ba8a872f 100644 --- a/compiler/testData/psi/recovery/objects/expressions/TypeParametersAndParentheses.txt +++ b/compiler/testData/psi/recovery/objects/expressions/TypeParametersAndParentheses.txt @@ -13,16 +13,15 @@ JetFile: TypeParametersAndParentheses.kt OBJECT_LITERAL OBJECT_DECLARATION PsiElement(object)('object') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PRIMARY_CONSTRUCTOR VALUE_PARAMETER_LIST PsiElement(LPAR)('(') @@ -50,16 +49,15 @@ JetFile: TypeParametersAndParentheses.kt OBJECT_LITERAL OBJECT_DECLARATION PsiElement(object)('object') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PRIMARY_CONSTRUCTOR VALUE_PARAMETER_LIST PsiElement(LPAR)('(') @@ -89,20 +87,19 @@ JetFile: TypeParametersAndParentheses.kt OBJECT_LITERAL OBJECT_DECLARATION PsiElement(object)('object') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PRIMARY_CONSTRUCTOR VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') CLASS_BODY PsiErrorElement:Expecting a class body - + \ No newline at end of file diff --git a/compiler/testData/psi/recovery/objects/expressions/TypeParameterss.txt b/compiler/testData/psi/recovery/objects/expressions/TypeParameterss.txt index 1ff9475e663..e86eed4d8ef 100644 --- a/compiler/testData/psi/recovery/objects/expressions/TypeParameterss.txt +++ b/compiler/testData/psi/recovery/objects/expressions/TypeParameterss.txt @@ -13,16 +13,15 @@ JetFile: TypeParameterss.kt OBJECT_LITERAL OBJECT_DECLARATION PsiElement(object)('object') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PsiWhiteSpace(' ') CLASS_BODY PsiElement(LBRACE)('{') @@ -38,16 +37,15 @@ JetFile: TypeParameterss.kt OBJECT_LITERAL OBJECT_DECLARATION PsiElement(object)('object') - PsiErrorElement:Type parameters are not allowed for objects - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('T') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(COLON)(':') PsiWhiteSpace(' ') @@ -97,4 +95,4 @@ JetFile: TypeParameterss.kt PsiElement(RPAR)(')') CLASS_BODY PsiErrorElement:Expecting a class body - + \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index e9c6058ec8b..50998042cb3 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -3324,6 +3324,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/classObjects/resolveFunctionInsideClassObject.kt"); doTest(fileName); } + + @TestMetadata("typeParametersInObject.kt") + public void testTypeParametersInObject() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/tests/constructorConsistency")