From 9b440345a142eeacf96bbc8314fcdc4254c8e490 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 16 Oct 2015 13:36:49 +0300 Subject: [PATCH] Do not render @NoInfer, @Exact annotations For now they are always not rendered, but later they should be rendered in descriptors, but omitted in error messages --- .../annotationsForResolve/exactAnnotation.txt | 2 +- .../annotationsForResolve/noInferAnnotation.txt | 10 +++++----- .../kotlin/renderer/DescriptorRendererOptionsImpl.kt | 4 +++- .../diagnosticMessage/annotationsForResolve.kt | 10 ++++++++++ .../diagnosticMessage/annotationsForResolve1.txt | 2 ++ .../highlighter/AbstractDiagnosticMessageTest.java | 2 +- .../highlighter/DiagnosticMessageTestGenerated.java | 6 ++++++ 7 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 idea/testData/diagnosticMessage/annotationsForResolve.kt create mode 100644 idea/testData/diagnosticMessage/annotationsForResolve1.txt diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.txt index 712abf2c627..afbd811f459 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.txt @@ -1,4 +1,4 @@ package public fun test1(/*0*/ l: kotlin.List): kotlin.Unit -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.List<@kotlin.Exact() T>.firstTyped(): U +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.List.firstTyped(): U diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.txt index 8740379d18a..6d3aef8c670 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.txt @@ -1,10 +1,10 @@ package -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun assertEquals1(/*0*/ e1: T, /*1*/ e2: @kotlin.NoInfer() T): kotlin.Boolean +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun assertEquals1(/*0*/ e1: T, /*1*/ e2: T): kotlin.Boolean public fun test(/*0*/ l: kotlin.List): kotlin.Unit public fun test(/*0*/ s: kotlin.String): kotlin.Unit -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun test1(/*0*/ t1: T, /*1*/ t2: @kotlin.NoInfer() T): T -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun test3(/*0*/ t1: @kotlin.NoInfer() T): T +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun test1(/*0*/ t1: T, /*1*/ t2: T): T +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun test3(/*0*/ t1: T): T public fun usage(): kotlin.Unit -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.List.contains1(/*0*/ e: @kotlin.NoInfer() T): kotlin.Boolean -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun @kotlin.NoInfer() T.test2(/*0*/ t1: T): T +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.List.contains1(/*0*/ e: T): kotlin.Boolean +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun T.test2(/*0*/ t1: T): T diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt index 3c124bbde56..0c66f846c4a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt @@ -111,6 +111,8 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions { FqName("org.jetbrains.annotations.ReadOnly"), FqName("org.jetbrains.annotations.Mutable"), FqName("org.jetbrains.annotations.NotNull"), - FqName("org.jetbrains.annotations.Nullable") + FqName("org.jetbrains.annotations.Nullable"), + FqName("kotlin.internal.NoInfer"), + FqName("kotlin.internal.Exact") )) } \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/annotationsForResolve.kt b/idea/testData/diagnosticMessage/annotationsForResolve.kt new file mode 100644 index 00000000000..79da60309bf --- /dev/null +++ b/idea/testData/diagnosticMessage/annotationsForResolve.kt @@ -0,0 +1,10 @@ +// !DIAGNOSTICS_NUMBER: 1 +// !DIAGNOSTICS: TYPE_MISMATCH +// !MESSAGE_TYPE: TEXT + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun test1(t1: T, t2: @kotlin.internal.NoInfer T): T = t1 + +fun usage() { + test1(1, "a") +} \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/annotationsForResolve1.txt b/idea/testData/diagnosticMessage/annotationsForResolve1.txt new file mode 100644 index 00000000000..9a22d7fcfcc --- /dev/null +++ b/idea/testData/diagnosticMessage/annotationsForResolve1.txt @@ -0,0 +1,2 @@ + +Type mismatch: inferred type is kotlin.String but kotlin.Int was expected \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractDiagnosticMessageTest.java b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractDiagnosticMessageTest.java index 7b15da4b0e3..ed1d41f477b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractDiagnosticMessageTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractDiagnosticMessageTest.java @@ -64,7 +64,7 @@ public abstract class AbstractDiagnosticMessageTest extends JetLiteFixture { @NotNull @Override protected KotlinCoreEnvironment createEnvironment() { - return createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY); + return createEnvironmentWithMockJdk(ConfigurationKind.ALL); } @NotNull diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/DiagnosticMessageTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/highlighter/DiagnosticMessageTestGenerated.java index 731c114df4e..d1f8fa31517 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/DiagnosticMessageTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/DiagnosticMessageTestGenerated.java @@ -41,6 +41,12 @@ public class DiagnosticMessageTestGenerated extends AbstractDiagnosticMessageTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/diagnosticMessage"), Pattern.compile("^(.+)\\.kt$"), false); } + @TestMetadata("annotationsForResolve.kt") + public void testAnnotationsForResolve() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/diagnosticMessage/annotationsForResolve.kt"); + doTest(fileName); + } + @TestMetadata("assignedButNeverAccessedVariable.kt") public void testAssignedButNeverAccessedVariable() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/diagnosticMessage/assignedButNeverAccessedVariable.kt");