diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java index 1303636dc02..df29767ccd2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java @@ -455,7 +455,7 @@ public class JetParsing extends AbstractJetParsing { if ((annotationParsingMode == PRIMARY_CONSTRUCTOR_MODIFIER_LIST || annotationParsingMode == PRIMARY_CONSTRUCTOR_MODIFIER_LIST_LOCAL) && atSet(CONSTRUCTOR_KEYWORD, WHERE_KEYWORD)) break; - if (at(AT)) { + if (at(AT) && annotationParsingMode.allowAnnotations) { parseAnnotationOrList(annotationParsingMode); } else if (tryParseModifier(tokenConsumer)) { @@ -2082,7 +2082,7 @@ public class JetParsing extends AbstractJetParsing { // TokenSet stopAt = TokenSet.create(COMMA, COLON, GT); // parseModifierListWithUnescapedAnnotations(MODIFIER_LIST, lookFor, stopAt); // Currently we do not allow annotations - parseModifierList(ONLY_ESCAPED_REGULAR_ANNOTATIONS); + parseModifierList(NO_ANNOTATIONS); if (at(MUL)) { advance(); // MUL @@ -2331,26 +2331,31 @@ public class JetParsing extends AbstractJetParsing { } enum AnnotationParsingMode { - FILE_ANNOTATIONS_BEFORE_PACKAGE(false, true, false), - FILE_ANNOTATIONS_WHEN_PACKAGE_OMITTED(false, true, false), - ONLY_ESCAPED_REGULAR_ANNOTATIONS(false, false, false), - ALLOW_UNESCAPED_REGULAR_ANNOTATIONS(true, false, false), - ALLOW_UNESCAPED_REGULAR_ANNOTATIONS_AT_MEMBER_MODIFIER_LIST(true, false, true), - PRIMARY_CONSTRUCTOR_MODIFIER_LIST(true, false, false), - PRIMARY_CONSTRUCTOR_MODIFIER_LIST_LOCAL(false, false, false); + FILE_ANNOTATIONS_BEFORE_PACKAGE(false, true, false, true), + FILE_ANNOTATIONS_WHEN_PACKAGE_OMITTED(false, true, false, true), + ONLY_ESCAPED_REGULAR_ANNOTATIONS(false, false, false, true), + ALLOW_UNESCAPED_REGULAR_ANNOTATIONS(true, false, false, true), + ALLOW_UNESCAPED_REGULAR_ANNOTATIONS_AT_MEMBER_MODIFIER_LIST(true, false, true, true), + PRIMARY_CONSTRUCTOR_MODIFIER_LIST(true, false, false, true), + PRIMARY_CONSTRUCTOR_MODIFIER_LIST_LOCAL(false, false, false, true), + NO_ANNOTATIONS(false, false, false, false); + boolean allowShortAnnotations; boolean isFileAnnotationParsingMode; boolean atMemberStart; + boolean allowAnnotations; AnnotationParsingMode( boolean allowShortAnnotations, boolean isFileAnnotationParsingMode, - boolean atMemberStart + boolean atMemberStart, + boolean allowAnnotations ) { this.allowShortAnnotations = allowShortAnnotations; this.isFileAnnotationParsingMode = isFileAnnotationParsingMode; this.atMemberStart = atMemberStart; + this.allowAnnotations = allowAnnotations; } } } diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt index 88b3aee5f26..ba58167ad7c 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt @@ -1,3 +1,5 @@ annotation class base -val x: List<@base String>? = null +val x: List<@base String>? = null + +val y: List<@[base] String>? = null \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt index 9b5caee7925..6b709622e96 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt @@ -1,6 +1,7 @@ package -public val x: kotlin.List? = null +public val x: kotlin.List<@base() kotlin.String>? = null +public val y: kotlin.List<@base() kotlin.String>? = null @kotlin.annotation.annotation() public final class base : kotlin.Annotation { public constructor base() diff --git a/compiler/testData/psi/annotation/TypeAnnotations.txt b/compiler/testData/psi/annotation/TypeAnnotations.txt index 538d5ddfe9a..61bdb4e78c7 100644 --- a/compiler/testData/psi/annotation/TypeAnnotations.txt +++ b/compiler/testData/psi/annotation/TypeAnnotations.txt @@ -79,7 +79,7 @@ JetFile: TypeAnnotations.kt TYPE_ARGUMENT_LIST PsiElement(LT)('<') TYPE_PROJECTION - MODIFIER_LIST + TYPE_REFERENCE ANNOTATION PsiElement(AT)('@') PsiElement(LBRACKET)('[') @@ -90,8 +90,7 @@ JetFile: TypeAnnotations.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') - TYPE_REFERENCE + PsiWhiteSpace(' ') USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('A') diff --git a/idea/testData/decompiler/decompiledText/FunctionTypes.expected.kt b/idea/testData/decompiler/decompiledText/FunctionTypes.expected.kt index 921bef98414..c4a07d88f6a 100644 --- a/idea/testData/decompiler/decompiledText/FunctionTypes.expected.kt +++ b/idea/testData/decompiler/decompiledText/FunctionTypes.expected.kt @@ -10,7 +10,7 @@ public final class FunctionTypes public constructor() { public final fun f3(f: kotlin.Int.(kotlin.Int) -> kotlin.Unit): kotlin.Unit { /* compiled code */ } - public final fun f4(f: kotlin.List>): kotlin.Unit { /* compiled code */ } + public final fun f4(f: kotlin.List<@kotlin.Extension kotlin.Function1<*, *>>): kotlin.Unit { /* compiled code */ } public final fun (A.(A) -> A)?.bar(): kotlin.Unit { /* compiled code */ } diff --git a/idea/testData/decompiler/stubBuilder/Types/Types.txt b/idea/testData/decompiler/stubBuilder/Types/Types.txt index 2fddc99b0cf..b3b7f3fac0f 100644 --- a/idea/testData/decompiler/stubBuilder/Types/Types.txt +++ b/idea/testData/decompiler/stubBuilder/Types/Types.txt @@ -252,6 +252,13 @@ PsiJetFileStubImpl[package=test] TYPE_ARGUMENT_LIST: TYPE_PROJECTION:[projectionKind=NONE] TYPE_REFERENCE: + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=Extension] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=Extension] USER_TYPE:[isAbsoluteInRootPackage=false] USER_TYPE:[isAbsoluteInRootPackage=false] REFERENCE_EXPRESSION:[referencedName=kotlin]