Support non-parenthesized annotations on functional types without receiver
^KT-31734 Fixed
This commit is contained in:
+28
@@ -1159,6 +1159,34 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/annotations/functionalTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class FunctionalTypes extends AbstractFirDiagnosticsSmokeTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInFunctionalTypes() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/annotations/functionalTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("nonParenthesizedAnnotationsWithError.kt")
|
||||
public void testNonParenthesizedAnnotationsWithError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithError.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonParenthesizedAnnotationsWithoutError.kt")
|
||||
public void testNonParenthesizedAnnotationsWithoutError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithoutError.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parenthesizedAnnotations.kt")
|
||||
public void testParenthesizedAnnotations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/parenthesizedAnnotations.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/annotations/options")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -268,6 +268,8 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, FqName> EXPERIMENTAL_UNSIGNED_LITERALS = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, FqName> EXPERIMENTAL_UNSIGNED_LITERALS_ERROR = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Const
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
+2
@@ -159,6 +159,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(EXPERIMENTAL_UNSIGNED_LITERALS, "Unsigned literals are experimental and their usages should be marked with ''@{0}'' or ''@UseExperimental({0}::class)''", TO_STRING);
|
||||
MAP.put(EXPERIMENTAL_UNSIGNED_LITERALS_ERROR, "Unsigned literals are experimental and their usages must be marked with ''@{0}'' or ''@UseExperimental({0}::class)''", TO_STRING);
|
||||
|
||||
MAP.put(NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES, "Non parenthesized annotations on function types without receiver isn't yet supported (see KT-31734 for details)");
|
||||
|
||||
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
|
||||
MAP.put(REDUNDANT_OPEN_IN_INTERFACE, "Modifier 'open' is redundant for abstract interface members");
|
||||
MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter");
|
||||
|
||||
@@ -34,6 +34,9 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
|
||||
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
||||
import org.jetbrains.kotlin.psi.psiUtil.checkReservedYield
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComments
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getPrevSiblingIgnoringWhitespaceAndComments
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasSuspendModifier
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.resolve.PossiblyBareType.bare
|
||||
import org.jetbrains.kotlin.resolve.PossiblyBareType.type
|
||||
@@ -69,6 +72,9 @@ class TypeResolver(
|
||||
private val platformToKotlinClassMap: PlatformToKotlinClassMap,
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
private val isNonParenthesizedAnnotationsOnFunctionalTypesEnabled =
|
||||
languageVersionSettings.getFeatureSupport(LanguageFeature.NonParenthesizedAnnotationsOnFunctionalTypes) == LanguageFeature.State.ENABLED
|
||||
|
||||
open class TypeTransformerForTests {
|
||||
open fun transformType(kotlinType: KotlinType): KotlinType? = null
|
||||
}
|
||||
@@ -129,12 +135,53 @@ class TypeResolver(
|
||||
internal fun KtElementImplStub<*>.getAllModifierLists(): Array<out KtDeclarationModifierList> =
|
||||
getStubOrPsiChildren(KtStubElementTypes.MODIFIER_LIST, KtStubElementTypes.MODIFIER_LIST.arrayFactory)
|
||||
|
||||
// TODO: remove this method and its usages in 1.4
|
||||
private fun checkNonParenthesizedAnnotationsOnFunctionalType(
|
||||
typeElement: KtFunctionType,
|
||||
annotationEntries: List<KtAnnotationEntry>,
|
||||
trace: BindingTrace
|
||||
) {
|
||||
val lastAnnotationEntry = annotationEntries.lastOrNull()
|
||||
val isAnnotationsGroupedUsingBrackets =
|
||||
lastAnnotationEntry?.getNextSiblingIgnoringWhitespaceAndComments()?.node?.elementType == KtTokens.RBRACKET
|
||||
val hasAnnotationParentheses = lastAnnotationEntry?.valueArgumentList != null
|
||||
val isFunctionalTypeStartingWithParentheses = typeElement.firstChild is KtParameterList
|
||||
val hasSuspendModifierBeforeParentheses =
|
||||
typeElement.getPrevSiblingIgnoringWhitespaceAndComments().run { this is KtDeclarationModifierList && hasSuspendModifier() }
|
||||
|
||||
if (lastAnnotationEntry != null &&
|
||||
isFunctionalTypeStartingWithParentheses &&
|
||||
!hasAnnotationParentheses &&
|
||||
!isAnnotationsGroupedUsingBrackets &&
|
||||
!hasSuspendModifierBeforeParentheses
|
||||
) {
|
||||
trace.report(Errors.NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES.on(lastAnnotationEntry))
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveTypeAnnotations(c: TypeResolutionContext, modifierListsOwner: KtElementImplStub<*>): Annotations {
|
||||
val modifierLists = modifierListsOwner.getAllModifierLists()
|
||||
|
||||
var result = Annotations.EMPTY
|
||||
var isSplitModifierList = false
|
||||
|
||||
if (!isNonParenthesizedAnnotationsOnFunctionalTypesEnabled) {
|
||||
val targetType = when (modifierListsOwner) {
|
||||
is KtNullableType -> modifierListsOwner.innerType
|
||||
is KtTypeReference -> modifierListsOwner.typeElement
|
||||
else -> null
|
||||
}
|
||||
val annotationEntries = when (modifierListsOwner) {
|
||||
is KtNullableType -> modifierListsOwner.modifierList?.annotationEntries
|
||||
is KtTypeReference -> modifierListsOwner.annotationEntries
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (targetType is KtFunctionType && annotationEntries != null) {
|
||||
checkNonParenthesizedAnnotationsOnFunctionalType(targetType, annotationEntries, c.trace)
|
||||
}
|
||||
}
|
||||
|
||||
for (modifierList in modifierLists) {
|
||||
if (isSplitModifierList) {
|
||||
c.trace.report(MODIFIER_LIST_NOT_ALLOWED.on(modifierList))
|
||||
|
||||
@@ -509,24 +509,36 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
}
|
||||
|
||||
private boolean parseTypeModifierList() {
|
||||
return doParseModifierList(null, TYPE_MODIFIER_KEYWORDS, DEFAULT, TokenSet.EMPTY);
|
||||
return doParseModifierList(null, TYPE_MODIFIER_KEYWORDS, TYPE_CONTEXT, TokenSet.EMPTY);
|
||||
}
|
||||
|
||||
private boolean parseTypeArgumentModifierList() {
|
||||
return doParseModifierList(null, TYPE_ARGUMENT_MODIFIER_KEYWORDS, NO_ANNOTATIONS, TokenSet.create(COMMA, COLON, GT));
|
||||
}
|
||||
|
||||
private boolean doParseModifierList(
|
||||
private boolean doParseModifierListBody(
|
||||
@Nullable Consumer<IElementType> tokenConsumer,
|
||||
@NotNull TokenSet modifierKeywords,
|
||||
@NotNull AnnotationParsingMode annotationParsingMode,
|
||||
@NotNull TokenSet noModifiersBefore
|
||||
) {
|
||||
PsiBuilder.Marker list = mark();
|
||||
boolean empty = true;
|
||||
PsiBuilder.Marker beforeAnnotationMarker;
|
||||
while (!eof()) {
|
||||
if (at(AT) && annotationParsingMode.allowAnnotations) {
|
||||
parseAnnotationOrList(annotationParsingMode);
|
||||
beforeAnnotationMarker = mark();
|
||||
|
||||
boolean isAnnotationParsed = parseAnnotationOrList(annotationParsingMode);
|
||||
|
||||
if (!isAnnotationParsed && !annotationParsingMode.withSignificantWhitespaceBeforeArguments) {
|
||||
beforeAnnotationMarker.rollbackTo();
|
||||
// try parse again, but with significant whitespace
|
||||
doParseModifierListBody(tokenConsumer, modifierKeywords, WITH_SIGNIFICANT_WHITESPACE_BEFORE_ARGUMENTS, noModifiersBefore);
|
||||
empty = false;
|
||||
break;
|
||||
} else {
|
||||
beforeAnnotationMarker.drop();
|
||||
}
|
||||
}
|
||||
else if (tryParseModifier(tokenConsumer, noModifiersBefore, modifierKeywords)) {
|
||||
// modifier advanced
|
||||
@@ -536,6 +548,25 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
}
|
||||
empty = false;
|
||||
}
|
||||
|
||||
return empty;
|
||||
}
|
||||
|
||||
private boolean doParseModifierList(
|
||||
@Nullable Consumer<IElementType> tokenConsumer,
|
||||
@NotNull TokenSet modifierKeywords,
|
||||
@NotNull AnnotationParsingMode annotationParsingMode,
|
||||
@NotNull TokenSet noModifiersBefore
|
||||
) {
|
||||
PsiBuilder.Marker list = mark();
|
||||
|
||||
boolean empty = doParseModifierListBody(
|
||||
tokenConsumer,
|
||||
modifierKeywords,
|
||||
annotationParsingMode,
|
||||
noModifiersBefore
|
||||
);
|
||||
|
||||
if (empty) {
|
||||
list.drop();
|
||||
}
|
||||
@@ -796,8 +827,27 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
|
||||
parseTypeArgumentList();
|
||||
|
||||
if (at(LPAR)) {
|
||||
boolean whitespaceAfterAnnotation = WHITE_SPACE_OR_COMMENT_BIT_SET.contains(myBuilder.rawLookup(-1));
|
||||
boolean shouldBeParsedNextAsFunctionalType = at(LPAR) && whitespaceAfterAnnotation && mode.withSignificantWhitespaceBeforeArguments;
|
||||
|
||||
if (at(LPAR) && !shouldBeParsedNextAsFunctionalType) {
|
||||
myExpressionParsing.parseValueArgumentList();
|
||||
|
||||
/*
|
||||
* There are two problem cases relating to parsing of annotations on a functional type:
|
||||
* - Annotation on a functional type was parsed correctly with the capture parentheses of the functional type,
|
||||
* e.g. @Anno () -> Unit
|
||||
* ^ Parse error only here: Type expected
|
||||
* - It wasn't parsed, e.g. @Anno (x: kotlin.Any) -> Unit
|
||||
* ^ Parse error: Expecting ')'
|
||||
*
|
||||
* In both cases, parser should rollback to start parsing of annotation and tries parse it with significant whitespace.
|
||||
* A marker is set here which means that we must to rollback.
|
||||
*/
|
||||
if (mode.typeContext && (getLastToken() != RPAR || at(ARROW))) {
|
||||
annotation.done(ANNOTATION_ENTRY);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
annotation.done(ANNOTATION_ENTRY);
|
||||
|
||||
@@ -1995,7 +2045,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
else if (at(LPAR)) {
|
||||
PsiBuilder.Marker functionOrParenthesizedType = mark();
|
||||
|
||||
// This may be a function parameter list or just a prenthesized type
|
||||
// This may be a function parameter list or just a parenthesized type
|
||||
advance(); // LPAR
|
||||
parseTypeRefContents(TokenSet.EMPTY).drop(); // parenthesized types, no reference element around it is needed
|
||||
|
||||
@@ -2423,20 +2473,28 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
}
|
||||
|
||||
enum AnnotationParsingMode {
|
||||
DEFAULT(false, true),
|
||||
FILE_ANNOTATIONS_BEFORE_PACKAGE(true, true),
|
||||
FILE_ANNOTATIONS_WHEN_PACKAGE_OMITTED(true, true),
|
||||
NO_ANNOTATIONS(false, false);
|
||||
DEFAULT(false, true, false, false),
|
||||
FILE_ANNOTATIONS_BEFORE_PACKAGE(true, true, false, false),
|
||||
FILE_ANNOTATIONS_WHEN_PACKAGE_OMITTED(true, true, false, false),
|
||||
TYPE_CONTEXT(false, true, true, false),
|
||||
WITH_SIGNIFICANT_WHITESPACE_BEFORE_ARGUMENTS(false, true, true, true),
|
||||
NO_ANNOTATIONS(false, false, false, false);
|
||||
|
||||
boolean isFileAnnotationParsingMode;
|
||||
boolean allowAnnotations;
|
||||
boolean withSignificantWhitespaceBeforeArguments;
|
||||
boolean typeContext;
|
||||
|
||||
AnnotationParsingMode(
|
||||
boolean isFileAnnotationParsingMode,
|
||||
boolean allowAnnotations
|
||||
boolean allowAnnotations,
|
||||
boolean typeContext,
|
||||
boolean withSignificantWhitespaceBeforeArguments
|
||||
) {
|
||||
this.isFileAnnotationParsingMode = isFileAnnotationParsingMode;
|
||||
this.allowAnnotations = allowAnnotations;
|
||||
this.typeContext = typeContext;
|
||||
this.withSignificantWhitespaceBeforeArguments = withSignificantWhitespaceBeforeArguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -CAST_NEVER_SUCCEEDS -CANNOT_CHECK_FOR_ERASED -UNCHECKED_CAST -UNUSED_ANONYMOUS_PARAMETER
|
||||
// SKIP_TXT
|
||||
// Issue: KT-31734
|
||||
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Repeatable
|
||||
annotation class Foo
|
||||
|
||||
fun foo1(x: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit) = x as Iterable<<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit>?
|
||||
|
||||
fun foo2() = null as <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit
|
||||
|
||||
fun foo3(x: Any?) {
|
||||
if (x is (<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@<!DEBUG_INFO_MISSING_UNRESOLVED!>Foo<!><!> () -> Unit)?) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun foo4(x: Any) = x is <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> (() -> Unit?)
|
||||
|
||||
fun foo5(x: Any): <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit = x as @Foo() @[Foo Foo()] <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit
|
||||
|
||||
fun foo6() {
|
||||
val x: @Foo() @[Foo Foo()] <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo7() {
|
||||
val x: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> (<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit) -> Unit = { x: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit -> }
|
||||
}
|
||||
|
||||
fun foo8(<!UNUSED_PARAMETER!>x<!>: Any?) {
|
||||
val <!NAME_SHADOWING!>x<!>: (<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit)? = {}
|
||||
}
|
||||
|
||||
fun foo9(x: (<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit)?) = x as Iterable<(<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit?)?>?
|
||||
|
||||
fun foo10(x: @[Foo] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo11(x: @[Foo ] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo12(x: @[Foo/**/] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
val foo13: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> (x: @Foo Any) -> Unit get() = {}
|
||||
|
||||
val foo14: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> (x: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit) -> Unit get() = {}
|
||||
|
||||
val foo15: @Foo () <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit get() = {}
|
||||
|
||||
val foo16: @Foo @Foo () <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit get() = {}
|
||||
|
||||
val foo17: @Foo() @Foo () <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit get() = {}
|
||||
|
||||
val foo18: @Foo()@Foo () <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit get() = {}
|
||||
|
||||
val foo19: @Foo@Foo () <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit get() = {}
|
||||
|
||||
val foo20: @Foo<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit get() = {}
|
||||
|
||||
val foo21: @Foo()<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit get() = {}
|
||||
|
||||
val foo22: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> (x: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit) -> Unit get() = {}
|
||||
|
||||
val foo23: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> (<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit) -> Unit get() = {}
|
||||
|
||||
val foo24: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> (<!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit, <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> () -> Unit) -> Unit get() = {x, y -> }
|
||||
|
||||
val foo25: <!NON_PARENTHESIZED_ANNOTATIONS_ON_FUNCTIONAL_TYPES!>@Foo<!> (x: @Foo Any, @Foo Any) -> Unit get() = {x, y -> }
|
||||
|
||||
val foo26: @Foo suspend () -> Unit = {}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
// !LANGUAGE: +NonParenthesizedAnnotationsOnFunctionalTypes
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -CAST_NEVER_SUCCEEDS -CANNOT_CHECK_FOR_ERASED -UNCHECKED_CAST -UNUSED_ANONYMOUS_PARAMETER
|
||||
// SKIP_TXT
|
||||
// Issue: KT-31734
|
||||
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Repeatable
|
||||
annotation class Foo
|
||||
|
||||
class MyClass
|
||||
|
||||
fun foo1(x: @Foo () -> Unit) = x as Iterable<@Foo () -> Unit>?
|
||||
|
||||
fun foo2() = null as @Foo () -> Unit
|
||||
|
||||
fun foo3(x: Any?) {
|
||||
if (x is (@<!DEBUG_INFO_MISSING_UNRESOLVED!>Foo<!> () -> Unit)?) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun foo4(x: Any) = x is @Foo () -> (() -> Unit?)
|
||||
|
||||
fun foo5(x: Any): @Foo () -> Unit = x as @Foo() @[Foo Foo()] @Foo () -> Unit
|
||||
|
||||
fun foo6() {
|
||||
val x: @Foo() @[Foo Foo()] @Foo () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo7() {
|
||||
val x: @Foo (@Foo () -> Unit) -> Unit = { x: @Foo () -> Unit -> }
|
||||
}
|
||||
|
||||
fun foo10(x: @[Foo()] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo11(x: @[Foo] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo12(x: @[Foo ] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo13(x: @[Foo/**/] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
val foo14: @Foo (x: @Foo () -> Unit) -> Unit get() = {}
|
||||
|
||||
val foo15: @Foo () @Foo () -> Unit get() = {}
|
||||
|
||||
val foo16: @Foo @Foo () @Foo () -> Unit get() = {}
|
||||
|
||||
val foo17: @Foo() @Foo () @Foo () -> Unit get() = {}
|
||||
|
||||
val foo18: @Foo()@Foo () @Foo () -> Unit get() = {}
|
||||
|
||||
val foo19: @Foo@Foo () @Foo () -> Unit get() = {}
|
||||
|
||||
val foo20: @Foo@Foo () -> Unit get() = {}
|
||||
|
||||
val foo21: @Foo()@Foo () -> Unit get() = {}
|
||||
|
||||
val foo22: @Foo (x: @Foo () -> Unit) -> Unit get() = {}
|
||||
|
||||
val foo23: @Foo (@Foo () -> Unit) -> Unit get() = {}
|
||||
|
||||
val foo24: @Foo (@Foo () -> Unit, @Foo () -> Unit) -> Unit get() = {x, y -> }
|
||||
|
||||
val foo25: @Foo (x: @Foo Any, @Foo Any) -> Unit get() = {x, y -> }
|
||||
|
||||
val foo26: @Foo suspend () -> Unit = {}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -CAST_NEVER_SUCCEEDS -CANNOT_CHECK_FOR_ERASED -UNCHECKED_CAST -UNUSED_ANONYMOUS_PARAMETER
|
||||
// SKIP_TXT
|
||||
// Issue: KT-31734
|
||||
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Repeatable
|
||||
annotation class Foo
|
||||
|
||||
fun foo1(x: @Foo() () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo2() = null as @Foo() () -> Unit
|
||||
|
||||
fun foo3(x: Any?) {
|
||||
if (x is (@<!DEBUG_INFO_MISSING_UNRESOLVED!>Foo<!>() () -> Unit)?) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun foo4(x: Any) = x is @Foo() () -> (() -> Unit?)
|
||||
|
||||
fun foo5(x: Any): @Foo() () -> Unit = x as @Foo () @[Foo Foo ()] @Foo() () -> Unit
|
||||
|
||||
fun foo6() {
|
||||
val x: @Foo() @[Foo Foo()] @Foo() () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo7() {
|
||||
val x: @Foo() (@Foo() () -> Unit) -> Unit = { x: @Foo() () -> Unit -> }
|
||||
}
|
||||
|
||||
fun foo8(x: @[Foo() ] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo9(x: @[Foo()] () -> Unit) = x as Iterable<@Foo() () -> Unit>?
|
||||
|
||||
fun foo10() {
|
||||
val x: @Foo () @Foo () () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo11() {
|
||||
val x: @Foo @Foo () () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo12() {
|
||||
val x: @Foo() @Foo () () -> Unit = {}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
fun foo() {
|
||||
for (@Foo (i: Int) in y) {}
|
||||
for (@Foo (i: () -> Unit) in y) {}
|
||||
for (@Foo (i) in y) {}
|
||||
for (@Foo (i, j) in y) {}
|
||||
for (@Foo (i, j: Int) in y) {}
|
||||
for (@Foo i: Int in y) {}
|
||||
for (@Foo i in y) {}
|
||||
}
|
||||
Vendored
+282
@@ -0,0 +1,282 @@
|
||||
KtFile: forDestructuring.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
PsiComment(EOL_COMMENT)('// Issue: KT-31734')
|
||||
PsiWhiteSpace('\n\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiErrorElement:Unexpected type specification
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiErrorElement:Expecting 'in'
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiErrorElement:Expecting ')'
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
DESTRUCTURING_DECLARATION
|
||||
PsiElement(LPAR)('(')
|
||||
PsiErrorElement:Expecting a name
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Expecting 'in'
|
||||
PsiElement(ARROW)('->')
|
||||
PsiErrorElement:Expecting ')'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Unit')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
BLOCK
|
||||
<empty list>
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiErrorElement:Expecting 'in'
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('j')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiErrorElement:Expecting 'in'
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('j')
|
||||
PsiErrorElement:Unexpected type specification
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiErrorElement:Expecting 'in'
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
LOOP_RANGE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
LOOP_RANGE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
fun foo() {
|
||||
val x = { @Foo (foo, bar) -> }
|
||||
val x = { @Foo (foo: kotlin.Any, bar) -> }
|
||||
val x = { @Foo (foo, bar: Any) -> }
|
||||
val x = { @Foo ((foo, bar: Any)) -> }
|
||||
val x = { @Foo () -> Unit }
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
KtFile: lambdaParameterDeclaration.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
PsiComment(EOL_COMMENT)('// Issue: KT-31734')
|
||||
PsiWhiteSpace('\n\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
ANNOTATED_EXPRESSION
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting an element
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
ANNOTATED_EXPRESSION
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiErrorElement:Unexpected type specification
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('kotlin')
|
||||
PsiErrorElement:Expecting ')'
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Any')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
ANNOTATED_EXPRESSION
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
PsiErrorElement:Unexpected type specification
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Any')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting an element
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
ANNOTATED_EXPRESSION
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
PARENTHESIZED
|
||||
PsiElement(LPAR)('(')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiErrorElement:Expecting ')'
|
||||
<empty list>
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
PsiErrorElement:Unexpected type specification
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Any')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting an element
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
ANNOTATED_EXPRESSION
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting an element
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Unit')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
compiler/testData/psi/annotation/functionalTypes/regressionForSimilarSyntax/variableDestructuring.kt
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
fun foo() {
|
||||
val @Foo (i) = Pair(1, 2)
|
||||
var @Foo (i: () -> Unit) = Pair(1, 2)
|
||||
var @Foo (i: Int) = Pair(1, 2)
|
||||
val @Foo (i, j) = Pair(1, 2)
|
||||
val @Foo (i, j: Int) = Pair(1, 2)
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
KtFile: variableDestructuring.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
PsiComment(EOL_COMMENT)('// Issue: KT-31734')
|
||||
PsiWhiteSpace('\n\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Annotations are not allowed in this position
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Pair')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
DESTRUCTURING_DECLARATION
|
||||
PsiElement(var)('var')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Annotations are not allowed in this position
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiErrorElement:Expecting ')'
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
PsiErrorElement:Expecting a name
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Unit')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Pair')
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(var)('var')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Annotations are not allowed in this position
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiErrorElement:Unexpected type specification
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Pair')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Annotations are not allowed in this position
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('j')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Pair')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Annotations are not allowed in this position
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Foo')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('j')
|
||||
PsiErrorElement:Unexpected type specification
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Pair')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_ARGUMENT
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
val x: (@Foo(10) suspend (Int) -> Unit) get() = {}
|
||||
|
||||
val x: @Foo({}) ((x: @Foo(10) (@Foo(11) () -> Int) -> Int) -> Unit) get() = {}
|
||||
|
||||
val x: suspend @Foo(10) (x: @Foo(10) (@Foo("") (x: kotlin.Any) -> Int) -> Int) -> Unit get() = {}
|
||||
|
||||
val x: Comparable<@Foo(10) @Bar(10) @Foo(listOf(10)) (x: kotlin.Any = {}) -> Unit> get() = {}
|
||||
|
||||
val x: Any = {} as @Foo({ x: Int -> 10}) suspend (x: @Foo(10) Foo) -> (y: @Foo(10) Bar) -> Unit
|
||||
|
||||
fun foo(x: (@Foo(10) (@Foo({ x: Int -> 10}) kotlin.Any)->()->Unit)) = x
|
||||
|
||||
fun foo(x: suspend @Foo(10) @Bar(10 + @Foo 3) (kotlin.Any) -> Unit = { x: Int -> x }) {}
|
||||
|
||||
fun foo() {
|
||||
val x: @Foo(10) suspend @Bar(throw Exception()) (Coomparable<kotlin.Any>) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val x = { x: suspend @Foo(null) (Coomparable<@Foo(10) @Bar(10) @Foo(10) () -> Unit>) -> () -> Unit -> x }
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract var x: @Foo(10 as @Foo suspend (Int) -> ((Int) -> Unit)) suspend (suspend (Int) -> ((Int) -> Unit)) -> Int
|
||||
}
|
||||
|
||||
fun foo(vararg x: @Foo(10) @Bar(10) @Foo(Any) (Any) -> Unit) = 10
|
||||
|
||||
fun foo(): @Foo.Bar(@Foo x) suspend (Nothing) -> Unit = {}
|
||||
|
||||
fun foo(): () -> @Foo.Bar('1') suspend (Bar) -> Unit = {}
|
||||
|
||||
val x: Any get() = fun(): @Foo("") (Coomparable<Nothing>) -> Unit {}
|
||||
|
||||
fun foo() {
|
||||
var x: (@Foo(object {}) (()->Unit)-> ()->Unit) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo(x: Any) {
|
||||
if (x as @Foo({}) @Bar(10) @Foo(10) (()->Unit) -> Unit is suspend @Foo(10) @Bar(10) @Foo(10) (()->Unit) -> Unit) {}
|
||||
}
|
||||
|
||||
fun foo(y: Any) {
|
||||
var x = y as (@Foo({}) suspend (()->Unit) -> (()->Unit) -> Unit) -> Unit
|
||||
}
|
||||
+1774
File diff suppressed because it is too large
Load Diff
+47
@@ -0,0 +1,47 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
val x: (@Foo() () -> Unit) get() = {}
|
||||
|
||||
val x: @Foo() (() -> Unit) get() = {}
|
||||
|
||||
val x: @Foo() () -> Unit get() = {}
|
||||
|
||||
val x: Comparable<@Fo() @Bar(10) @Foo() () -> Unit> get() = {}
|
||||
|
||||
val x: Any = {} as @Foo() () -> Unit
|
||||
|
||||
fun foo(x: (@Foo() () -> Unit)) = x
|
||||
|
||||
fun foo(x: @Foo(10) @Bar() () -> Unit = { x: Int -> x }) {}
|
||||
|
||||
fun foo() {
|
||||
val x: @Foo() @Bar() () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val x = { x: @Foo() () -> () -> Unit -> x }
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract var x: @Foo() (() -> (() -> Unit)) -> Int
|
||||
}
|
||||
|
||||
fun foo(vararg x: @Foo() @Bar(10) @Foo() () -> Unit) = 10
|
||||
|
||||
fun foo(): @Foo.Bar() () -> Unit = {}
|
||||
|
||||
fun foo(): () -> @Foo.Bar() () -> Unit = {}
|
||||
|
||||
val x: Any get() = fun(): @Foo() () -> Unit {}
|
||||
|
||||
fun foo() {
|
||||
var x: (@Foo() ()->()->Unit) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo(x: Any) {
|
||||
if (x as @Foo() @Bar(10) @Foo() () -> Unit is @Foo() @Bar(10) @Foo() () -> Unit) {}
|
||||
}
|
||||
|
||||
fun foo(y: Any) {
|
||||
var x = y as (@Foo() () -> () -> Unit) -> Unit
|
||||
}
|
||||
+1116
File diff suppressed because it is too large
Load Diff
+51
@@ -0,0 +1,51 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
val x: (@[Foo] suspend (Int) -> Unit) get() = {}
|
||||
|
||||
val x: (@[Foo] () -> Unit) get() = {}
|
||||
|
||||
val x: (@[Foo] suspend () -> Unit) get() = {}
|
||||
|
||||
val x: @[Foo] ((x: @[Foo] (@[Foo Foo] () -> Int) -> Int) -> Unit) get() = {}
|
||||
|
||||
val x: suspend @[Foo] (x: @[Foo Foo] (@[Foo Foo] (x: kotlin.Any) -> Int) -> Int) -> Unit get() = {}
|
||||
|
||||
val x: Comparable<@[Foo] @[Bar(10)] @[Foo] () -> Unit> get() = {}
|
||||
|
||||
val x: Any = {} as @[Foo Foo] suspend (x: @[Foo] Foo) -> (y: @[Foo] Bar) -> Unit
|
||||
|
||||
fun foo(x: (@Foo ()->()->Unit)) = x
|
||||
|
||||
fun foo(x: suspend @[Foo Foo(10)] @[Bar] (kotlin.Any) -> Unit = { x: Int -> x }) {}
|
||||
|
||||
fun foo() {
|
||||
val x: @[Foo(10)] @[Bar] (Coomparable<kotlin.Any>) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val x = { x: suspend @[Foo Bar] (Coomparable<@[Foo Bar Bar Bar Bar Bar] @[Bar(10)] @[Foo Bar] () -> Unit>) -> () -> Unit -> x }
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract var x: @[Foo Bar] suspend (() -> ((Int) -> Unit)) -> Int
|
||||
}
|
||||
|
||||
fun foo(vararg x: @[Foo Bar] @[Bar(10)] @[Foo Bar] () -> Unit) = 10
|
||||
|
||||
fun foo(): @[Foo.Bar Foo.Bar(1)] suspend () -> Unit = {}
|
||||
|
||||
fun foo(): () -> @[Foo.Bar] () -> Unit = {}
|
||||
|
||||
val x: Any get() = fun(): @[Foo()] (Coomparable<Nothing>) -> Unit {}
|
||||
|
||||
fun foo() {
|
||||
var x: (@[Foo Bar] (()->Unit)-> ()->Unit) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo(x: Any) {
|
||||
if (x as @[Foo] @[Bar(10) Bar] @[Foo Bar] (()->Unit) -> Unit is suspend @[Foo] @[Bar (10)] @[Foo Bar (10)] (()->Unit) -> Unit) {}
|
||||
}
|
||||
|
||||
fun foo(y: Any) {
|
||||
var x = y as (@[Foo Bar] suspend (()->Unit) -> (()->Unit) -> Unit) -> Unit
|
||||
}
|
||||
+1752
File diff suppressed because it is too large
Load Diff
+47
@@ -0,0 +1,47 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
val x: (@Foo suspend (Int) -> Unit) get() = {}
|
||||
|
||||
val x: @Foo ((x: @Foo (@Foo () -> Int) -> Int) -> Unit) get() = {}
|
||||
|
||||
val x: suspend @Foo (x: @Foo (@Foo (x: kotlin.Any) -> Int) -> Int) -> Unit get() = {}
|
||||
|
||||
val x: Comparable<@Foo @Bar(10) @Foo (x: kotlin.Any = {}) -> Unit> get() = {}
|
||||
|
||||
val x: Any = {} as @Foo suspend (x: @Foo Foo) -> (y: @Foo Bar) -> Unit
|
||||
|
||||
fun foo(x: (@Foo (@Foo kotlin.Any)->()->Unit)) = x
|
||||
|
||||
fun foo(x: suspend @Foo(10) @Bar (kotlin.Any) -> Unit = { x: Int -> x }) {}
|
||||
|
||||
fun foo() {
|
||||
val x: @Foo suspend @Bar (Coomparable<kotlin.Any>) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val x = { x: suspend @Foo (Coomparable<@Foo @Bar(10) @Foo () -> Unit>) -> () -> Unit -> x }
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract var x: @Foo suspend (suspend (Int) -> ((Int) -> Unit)) -> Int
|
||||
}
|
||||
|
||||
fun foo(vararg x: @Foo @Bar(10) @Foo (Any) -> Unit) = 10
|
||||
|
||||
fun foo(): @Foo.Bar suspend (Nothing) -> Unit = {}
|
||||
|
||||
fun foo(): () -> @Foo.Bar suspend (Bar) -> Unit = {}
|
||||
|
||||
val x: Any get() = fun(): @Foo (Coomparable<Nothing>) -> Unit {}
|
||||
|
||||
fun foo() {
|
||||
var x: (@Foo (()->Unit)-> ()->Unit) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo(x: Any) {
|
||||
if (x as @Foo @Bar(10) @Foo (()->Unit) -> Unit is suspend @Foo @Bar(10) @Foo (()->Unit) -> Unit) {}
|
||||
}
|
||||
|
||||
fun foo(y: Any) {
|
||||
var x = y as (@Foo suspend (()->Unit) -> (()->Unit) -> Unit) -> Unit
|
||||
}
|
||||
+1440
File diff suppressed because it is too large
Load Diff
+51
@@ -0,0 +1,51 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
val x: (@Foo suspend Int.() -> Unit) get() = {}
|
||||
|
||||
val x: @Foo Int.() -> Unit get() = {}
|
||||
|
||||
val x: @Foo Int.(x: kotlin.Int) -> Unit get() = {}
|
||||
|
||||
val x: @Foo ((x: @Foo (@Foo () -> Int) -> Int.(@Foo () -> Int) -> Int) -> Unit) get() = {}
|
||||
|
||||
val x: suspend @Foo (x: @Foo (@Foo ((x: kotlin.Any) -> Int).(x: kotlin.Any) -> Int) -> Int) -> Unit get() = {}
|
||||
|
||||
val x: Comparable<@Foo @Bar(10) @Foo Unit.(x: kotlin.Any = {}) -> Unit> get() = {}
|
||||
|
||||
val x: Any = {} as @Foo suspend Int.(x: @Foo Foo) -> (y: @Foo Bar) -> Unit
|
||||
|
||||
fun foo(x: (@Foo ((@Foo kotlin.Any)->(Int)).(@Foo kotlin.Any)->()->Unit)) = x
|
||||
|
||||
fun foo(x: suspend @Foo(10) @Bar Comparable<T>.(kotlin.Any) -> Unit = { x: Int -> x }) {}
|
||||
|
||||
fun foo() {
|
||||
val x: @Foo suspend @Bar (Coomparable<kotlin.Any>) -> Unit.(Coomparable<kotlin.Any>) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val x = { x: suspend @Foo @Foo () -> Unit.(Coomparable<@Foo @Bar(10) @Foo () -> Unit>) -> () -> Unit -> x }
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract var x: @Foo suspend (@Foo () -> Unit).(suspend (Int) -> ((Int) -> Unit)) -> Int
|
||||
}
|
||||
|
||||
fun foo(vararg x: @Foo @Bar(10) @Foo Any.(Any) -> Unit) = 10
|
||||
|
||||
fun foo(): @Foo.Bar suspend Nothing.(Nothing) -> Unit = {}
|
||||
|
||||
fun foo(): () -> @Foo.Bar suspend Iterable<@Foo.Bar Int.(Bar) -> Unit>.(Bar) -> Unit = {}
|
||||
|
||||
val x: Any get() = fun(): @Foo (@Foo (Coomparable<Nothing>) -> Unit).(Coomparable<Nothing>) -> Unit {}
|
||||
|
||||
fun foo() {
|
||||
var x: (@Foo (()->Unit)-> @Foo Int.()->Unit) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo(x: Any) {
|
||||
if (x as @Foo @Bar(10) @Foo ()->Unit.(()->Unit) -> Unit is suspend @Foo @Bar(10) @Foo ((()->Unit).()->Unit) -> Unit) {}
|
||||
}
|
||||
|
||||
fun foo(y: Any) {
|
||||
var x = y as (@Foo suspend (suspend (()->Unit)->Int).(()->Unit) -> (Float.()->Unit) -> Unit) -> Unit
|
||||
}
|
||||
+1922
File diff suppressed because it is too large
Load Diff
+47
@@ -0,0 +1,47 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
val x: (@Foo () -> Unit) get() = {}
|
||||
|
||||
val x: @Foo (() -> Unit) get() = {}
|
||||
|
||||
val x: @Foo () -> Unit get() = {}
|
||||
|
||||
val x: Comparable<@Foo @Bar(10) @Foo () -> Unit> get() = {}
|
||||
|
||||
val x: Any = {} as @Foo () -> Unit
|
||||
|
||||
fun foo(x: (@Foo () -> Unit)) = x
|
||||
|
||||
fun foo(x: @Foo(10) @Bar () -> Unit = { x: Int -> x }) {}
|
||||
|
||||
fun foo() {
|
||||
val x: @Foo @Bar () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val x = { x: @Foo () -> () -> Unit -> x }
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract var x: @Foo (() -> (() -> Unit)) -> Int
|
||||
}
|
||||
|
||||
fun foo(vararg x: @Foo @Bar(10) @Foo () -> Unit) = 10
|
||||
|
||||
fun foo(): @Foo.Bar () -> Unit = {}
|
||||
|
||||
fun foo(): () -> @Foo.Bar () -> Unit = {}
|
||||
|
||||
val x: Any get() = fun(): @Foo () -> Unit {}
|
||||
|
||||
fun foo() {
|
||||
var x: (@Foo ()->()->Unit) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo(x: Any) {
|
||||
if (x as @Foo @Bar(10) @Foo () -> Unit is @Foo @Bar(10) @Foo () -> Unit) {}
|
||||
}
|
||||
|
||||
fun foo(y: Any) {
|
||||
var x = y as (@Foo () -> () -> Unit) -> Unit
|
||||
}
|
||||
+1047
File diff suppressed because it is too large
Load Diff
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Issue: KT-31734
|
||||
|
||||
val x: (@Foo suspend () -> Unit) get() = {}
|
||||
|
||||
val x: @Foo (suspend () -> Unit) get() = {}
|
||||
|
||||
val x: suspend @Foo () -> Unit get() = {}
|
||||
|
||||
val x: Comparable<@Foo suspend @Bar(10) @Foo () -> Unit> get() = {}
|
||||
|
||||
val x: Any = {} as @Foo suspend () -> Unit
|
||||
|
||||
fun foo(x: (suspend @Foo () -> Unit)) = x
|
||||
|
||||
fun foo(x: suspend @Foo(10) @Bar () -> Unit = { x: Int -> x }) {}
|
||||
|
||||
fun foo() {
|
||||
val x: @Foo suspend @Bar () -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val x = { x: suspend @Foo () -> () -> Unit -> x }
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract var x: @Foo suspend (suspend () -> (() -> Unit)) -> Int
|
||||
}
|
||||
|
||||
fun foo(vararg x: @Foo @Bar(10) @Foo () -> Unit) = 10
|
||||
|
||||
fun foo(): @Foo.Bar suspend () -> Unit = {}
|
||||
|
||||
fun foo(): () -> @Foo.Bar suspend () -> Unit = {}
|
||||
|
||||
val x: Any get() = fun(): @Foo suspend () -> Unit {}
|
||||
|
||||
fun foo() {
|
||||
var x: (@Foo ()->suspend ()->Unit) -> Unit = {}
|
||||
}
|
||||
|
||||
fun foo(x: Any) {
|
||||
if (x as @Foo @Bar(10) suspend @Foo () -> Unit is suspend @Foo @Bar(10) @Foo () -> Unit) {}
|
||||
}
|
||||
|
||||
fun foo(y: Any) {
|
||||
var x = y as (@Foo suspend () -> () -> Unit) -> Unit
|
||||
}
|
||||
Vendored
+1086
File diff suppressed because it is too large
Load Diff
@@ -1166,6 +1166,34 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/annotations/functionalTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class FunctionalTypes extends AbstractDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInFunctionalTypes() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/annotations/functionalTypes"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("nonParenthesizedAnnotationsWithError.kt")
|
||||
public void testNonParenthesizedAnnotationsWithError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithError.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonParenthesizedAnnotationsWithoutError.kt")
|
||||
public void testNonParenthesizedAnnotationsWithoutError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithoutError.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parenthesizedAnnotations.kt")
|
||||
public void testParenthesizedAnnotations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/parenthesizedAnnotations.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/annotations/options")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Generated
+28
@@ -1161,6 +1161,34 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/annotations/functionalTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class FunctionalTypes extends AbstractDiagnosticsUsingJavacTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInFunctionalTypes() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/annotations/functionalTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("nonParenthesizedAnnotationsWithError.kt")
|
||||
public void testNonParenthesizedAnnotationsWithError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithError.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonParenthesizedAnnotationsWithoutError.kt")
|
||||
public void testNonParenthesizedAnnotationsWithoutError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithoutError.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parenthesizedAnnotations.kt")
|
||||
public void testParenthesizedAnnotations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/parenthesizedAnnotations.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/annotations/options")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -901,6 +901,108 @@ public class ParsingTestGenerated extends AbstractParsingTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/psi/annotation/functionalTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class FunctionalTypes extends AbstractParsingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doParsingTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInFunctionalTypes() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/psi/annotation/functionalTypes"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/psi/annotation/functionalTypes/regressionForSimilarSyntax")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class RegressionForSimilarSyntax extends AbstractParsingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doParsingTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInRegressionForSimilarSyntax() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/psi/annotation/functionalTypes/regressionForSimilarSyntax"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("forDestructuring.kt")
|
||||
public void testForDestructuring() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/regressionForSimilarSyntax/forDestructuring.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaParameterDeclaration.kt")
|
||||
public void testLambdaParameterDeclaration() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/regressionForSimilarSyntax/lambdaParameterDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("variableDestructuring.kt")
|
||||
public void testVariableDestructuring() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/regressionForSimilarSyntax/variableDestructuring.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/psi/annotation/functionalTypes/withParentheses")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class WithParentheses extends AbstractParsingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doParsingTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInWithParentheses() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/psi/annotation/functionalTypes/withParentheses"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("withParameter.kt")
|
||||
public void testWithParameter() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/withParentheses/withParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withoutParameter.kt")
|
||||
public void testWithoutParameter() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/withParentheses/withoutParameter.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/psi/annotation/functionalTypes/withoutParentheses")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class WithoutParentheses extends AbstractParsingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doParsingTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInWithoutParentheses() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/psi/annotation/functionalTypes/withoutParentheses"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationList.kt")
|
||||
public void testAnnotationList() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/withoutParentheses/annotationList.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withParameter.kt")
|
||||
public void testWithParameter() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/withoutParentheses/withParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withReveiver.kt")
|
||||
public void testWithReveiver() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/withoutParentheses/withReveiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withoutParameter.kt")
|
||||
public void testWithoutParameter() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/withoutParentheses/withoutParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withoutParameterOnSuspend.kt")
|
||||
public void testWithoutParameterOnSuspend() throws Exception {
|
||||
runTest("compiler/testData/psi/annotation/functionalTypes/withoutParentheses/withoutParameterOnSuspend.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/psi/annotation/list")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -104,6 +104,7 @@ enum class LanguageFeature(
|
||||
ProhibitComparisonOfIncompatibleEnums(KOTLIN_1_4, kind = BUG_FIX),
|
||||
BareArrayClassLiteral(KOTLIN_1_4),
|
||||
ProhibitGenericArrayClassLiteral(KOTLIN_1_4),
|
||||
NonParenthesizedAnnotationsOnFunctionalTypes(KOTLIN_1_4),
|
||||
|
||||
ProperVisibilityForCompanionObjectInstanceField(sinceVersion = null, kind = BUG_FIX),
|
||||
// Temporarily disabled, see KT-27084/KT-22379
|
||||
|
||||
Reference in New Issue
Block a user