diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt index ffc6e6b3d09..2fea37d0c3b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt @@ -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. @@ -312,7 +312,7 @@ class AnnotationChecker(private val additionalCheckers: Iterable@receiver:Ann - constructor(@receiver:Ann a: String) + constructor(@receiver:Ann a: String) - @receiver:Ann + @receiver:Ann protected val simpleProperty: String = "text" - @receiver:Ann + @receiver:Ann fun anotherFun() { - @receiver:Ann + @receiver:Ann val localVariable = 5 } diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.kt new file mode 100644 index 00000000000..c42fe12dcb6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.kt @@ -0,0 +1,15 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun test1(i: @setparam:Suppress Int) {} +fun test2(i: @param:Suppress Int) {} +fun test3(i: @receiver:Suppress Int) {} +fun test4(i: @field:Suppress Int) {} +fun test5(i: @set:Suppress Int) {} + +fun test6(): @setparam:Suppress Int = TODO() +fun test7(i: (@setparam:Suppress Int) -> Unit) {} + +fun @setparam:Suppress Int.test8() {} +fun ((@setparam:Suppress Int) -> Unit).test9() {} + +fun test10(): ((@setparam:Suppress Int) -> Unit) = TODO() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.txt new file mode 100644 index 00000000000..628c159de21 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.txt @@ -0,0 +1,12 @@ +package + +public fun test1(/*0*/ i: @setparam:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit +public fun test10(): (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit +public fun test2(/*0*/ i: @param:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit +public fun test3(/*0*/ i: @receiver:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit +public fun test4(/*0*/ i: @field:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit +public fun test5(/*0*/ i: @set:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit +public fun test6(): @setparam:kotlin.Suppress(names = {}) kotlin.Int +public fun test7(/*0*/ i: (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit): kotlin.Unit +public fun @setparam:kotlin.Suppress(names = {}) kotlin.Int.test8(): kotlin.Unit +public fun ((@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit).test9(): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 8937cafb7a2..61ebe5e9f50 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1682,6 +1682,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.kt"); doTest(fileName); } + + @TestMetadata("wrongParamAnnotationsOnTypes.kt") + public void testWrongParamAnnotationsOnTypes() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.kt"); + doTest(fileName); + } } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index a683568dca4..c8002830643 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -1682,6 +1682,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.kt"); doTest(fileName); } + + @TestMetadata("wrongParamAnnotationsOnTypes.kt") + public void testWrongParamAnnotationsOnTypes() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/wrongParamAnnotationsOnTypes.kt"); + doTest(fileName); + } } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt index c05851931ca..c8f8c5c697a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt @@ -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. @@ -40,6 +40,8 @@ enum class KotlinTarget(val description: String, val isDefault: Boolean = true) FILE("file", false), TYPEALIAS("typealias", false), + RECEIVER("receiver", true), + TYPE_PROJECTION("type projection", false), STAR_PROJECTION("star projection", false), PROPERTY_PARAMETER("property constructor parameter", false), @@ -124,7 +126,7 @@ enum class KotlinTarget(val description: String, val isDefault: Boolean = true) AnnotationUseSiteTarget.FILE to FILE, AnnotationUseSiteTarget.PROPERTY_GETTER to PROPERTY_GETTER, AnnotationUseSiteTarget.PROPERTY_SETTER to PROPERTY_SETTER, - AnnotationUseSiteTarget.RECEIVER to VALUE_PARAMETER, + AnnotationUseSiteTarget.RECEIVER to RECEIVER, AnnotationUseSiteTarget.SETTER_PARAMETER to VALUE_PARAMETER, AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD to FIELD)