Improve diagnostic for non-actual declaration with weak incompatibility
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
+1
-1
@@ -284,7 +284,7 @@ public class DefaultErrorMessages {
|
|||||||
|
|
||||||
MAP.put(NO_ACTUAL_FOR_EXPECT, "Expected {0} has no actual declaration in module{1}{2}", DECLARATION_NAME_WITH_KIND,
|
MAP.put(NO_ACTUAL_FOR_EXPECT, "Expected {0} has no actual declaration in module{1}{2}", DECLARATION_NAME_WITH_KIND,
|
||||||
PLATFORM, PlatformIncompatibilityDiagnosticRenderer.TEXT);
|
PLATFORM, PlatformIncompatibilityDiagnosticRenderer.TEXT);
|
||||||
MAP.put(ACTUAL_WITHOUT_EXPECT, "Actual {0} has no corresponding expected declaration{1}", DECLARATION_NAME_WITH_KIND,
|
MAP.put(ACTUAL_WITHOUT_EXPECT, "{0} has no corresponding expected declaration{1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM,
|
||||||
PlatformIncompatibilityDiagnosticRenderer.TEXT);
|
PlatformIncompatibilityDiagnosticRenderer.TEXT);
|
||||||
|
|
||||||
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}",
|
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}",
|
||||||
|
|||||||
@@ -108,6 +108,17 @@ object Renderers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmField val CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM = ContextDependentRenderer<DeclarationDescriptor> { descriptor, context ->
|
||||||
|
val declarationWithNameAndKind = DECLARATION_NAME_WITH_KIND.render(descriptor, context)
|
||||||
|
val withPlatform = if (descriptor is MemberDescriptor && descriptor.isActual)
|
||||||
|
"actual $declarationWithNameAndKind"
|
||||||
|
else
|
||||||
|
declarationWithNameAndKind
|
||||||
|
|
||||||
|
withPlatform.capitalize()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@JvmField val NAME_OF_CONTAINING_DECLARATION_OR_FILE = Renderer<DeclarationDescriptor> {
|
@JvmField val NAME_OF_CONTAINING_DECLARATION_OR_FILE = Renderer<DeclarationDescriptor> {
|
||||||
if (DescriptorUtils.isTopLevelDeclaration(it) && it is DeclarationDescriptorWithVisibility && it.visibility == Visibilities.PRIVATE) {
|
if (DescriptorUtils.isTopLevelDeclaration(it) && it is DeclarationDescriptorWithVisibility && it.visibility == Visibilities.PRIVATE) {
|
||||||
"file"
|
"file"
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ expect fun foo3<!JVM:NO_ACTUAL_FOR_EXPECT!>()<!>: Int
|
|||||||
|
|
||||||
// FILE: jvm.kt
|
// FILE: jvm.kt
|
||||||
|
|
||||||
<!ACTUAL_WITHOUT_EXPECT!>interface<!> Foo1
|
<!DECLARATION_WITH_INCOMPATIBLE_EXPECT!>interface<!> Foo1
|
||||||
actual <!ACTUAL_WITHOUT_EXPECT!>interface<!> Foo2
|
actual <!ACTUAL_WITHOUT_EXPECT!>interface<!> Foo2
|
||||||
|
|
||||||
actual fun foo1(): <!ACTUAL_WITHOUT_EXPECT!>String<!> = ""
|
actual fun foo1(): <!ACTUAL_WITHOUT_EXPECT!>String<!> = ""
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
expect class Foo
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
interface Foo
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
-- Common --
|
||||||
|
Exit code: OK
|
||||||
|
Output:
|
||||||
|
|
||||||
|
-- JVM --
|
||||||
|
Exit code: COMPILATION_ERROR
|
||||||
|
Output:
|
||||||
|
compiler/testData/multiplatform/weakIncompatibilityWithoutActualModifier/jvm.kt:1:1: error: interface 'Foo' has no corresponding expected declaration
|
||||||
|
The following declaration is incompatible because class kinds are different (class, interface, object, enum, annotation):
|
||||||
|
public final expect class Foo
|
||||||
|
|
||||||
|
interface Foo
|
||||||
|
^
|
||||||
+6
@@ -132,6 +132,12 @@ public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatform
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("weakIncompatibilityWithoutActualModifier")
|
||||||
|
public void testWeakIncompatibilityWithoutActualModifier() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/weakIncompatibilityWithoutActualModifier/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/multiplatform/classScopes")
|
@TestMetadata("compiler/testData/multiplatform/classScopes")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -177,7 +177,7 @@ public class IdeErrorMessages {
|
|||||||
|
|
||||||
MAP.put(NO_ACTUAL_FOR_EXPECT, "<html>Expected {0} has no actual declaration in module{1}{2}</html>", DECLARATION_NAME_WITH_KIND,
|
MAP.put(NO_ACTUAL_FOR_EXPECT, "<html>Expected {0} has no actual declaration in module{1}{2}</html>", DECLARATION_NAME_WITH_KIND,
|
||||||
PLATFORM, new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE));
|
PLATFORM, new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE));
|
||||||
MAP.put(ACTUAL_WITHOUT_EXPECT, "<html>Actual {0} has no corresponding expected declaration{1}</html>", DECLARATION_NAME_WITH_KIND,
|
MAP.put(ACTUAL_WITHOUT_EXPECT, "<html>{0} has no corresponding expected declaration{1}</html>", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM,
|
||||||
new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE));
|
new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE));
|
||||||
|
|
||||||
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "<html>Actual class ''{0}'' has no corresponding members for expected class members:{1}</html>",
|
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "<html>Actual class ''{0}'' has no corresponding members for expected class members:{1}</html>",
|
||||||
|
|||||||
Reference in New Issue
Block a user