Object literals are now classes and expressions simultaneously for the purposes of annotation target checking
This commit is contained in:
@@ -173,6 +173,7 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
|
||||
is JetClassInitializer -> TargetLists.T_INITIALIZER
|
||||
is JetMultiDeclaration -> TargetLists.T_MULTI_DECLARATION
|
||||
is JetFunctionLiteralExpression -> TargetLists.T_FUNCTION_LITERAL
|
||||
is JetObjectLiteralExpression -> TargetLists.T_OBJECT_LITERAL
|
||||
is JetExpression -> TargetLists.T_EXPRESSION
|
||||
else -> TargetLists.EMPTY
|
||||
}
|
||||
@@ -229,6 +230,8 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
|
||||
|
||||
val T_FUNCTION_LITERAL = targetList(FUNCTION_LITERAL, FUNCTION, EXPRESSION)
|
||||
|
||||
val T_OBJECT_LITERAL = targetList(OBJECT_LITERAL, CLASS, EXPRESSION)
|
||||
|
||||
val T_TYPE_REFERENCE = targetList(TYPE) {
|
||||
onlyWithUseSiteTarget(VALUE_PARAMETER)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
annotation class Ann
|
||||
|
||||
open class My
|
||||
|
||||
fun foo(): My {
|
||||
return (@Ann object: My() {})
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package
|
||||
|
||||
public fun foo(): My
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS}) @kotlin.annotation.annotation() public final class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 open class My {
|
||||
public constructor My()
|
||||
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
|
||||
}
|
||||
@@ -1064,6 +1064,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectLiteral.kt")
|
||||
public void testObjectLiteral() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/objectLiteral.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("repeatable.kt")
|
||||
public void testRepeatable() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/repeatable.kt");
|
||||
|
||||
Reference in New Issue
Block a user