From 9ecd04f6289247711135837b48f4ab09e089f4d0 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 18 Jul 2017 17:28:33 +0300 Subject: [PATCH] Improve diagnostics on header/impl classes when scopes don't match Try to report most of the errors on the actual members of the impl class. In many cases, there's a 1:1 mapping of header to impl class members, so the error "some members are not implemented" on the class declaration itself is redundant. Exceptions include functions/properties from supertypes (there may be no other place to report a signature mismatch error in this case), functions/properties not marked with 'impl' (the checker is only run for declarations explicitly marked with 'impl') and default constructors (the checker is not run for them) #KT-18447 Fixed --- .../jetbrains/kotlin/diagnostics/Errors.java | 9 +- .../rendering/DefaultErrorMessages.java | 3 + ...atformIncompatibilityDiagnosticRenderer.kt | 108 +++++++++++------- .../checkers/HeaderImplDeclarationChecker.kt | 59 ++++++++-- .../headerClass/noImplKeywordOnMember.kt | 15 +++ .../headerClass/noImplKeywordOnMember.txt | 22 ++++ .../constructorIncorrectSignature/output.txt | 13 +-- .../functionIncorrectSignature/output.txt | 13 +-- .../common.kt | 3 + .../jvm.kt | 5 + .../output.txt | 16 +++ .../classScopes/missingConstructor/output.txt | 5 +- .../classScopes/missingFunction/output.txt | 5 +- .../multiplatform/missingOverload/output.txt | 2 +- .../checkers/DiagnosticsTestGenerated.java | 6 + ...MultiPlatformIntegrationTestGenerated.java | 6 + .../headerPartiallyImplemented/jvm/jvm.kt | 6 +- 17 files changed, 207 insertions(+), 89 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.kt create mode 100644 compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.txt create mode 100644 compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/common.kt create mode 100644 compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/jvm.kt create mode 100644 compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/output.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index b23cb35a328..27646fe4d4e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.tower.WrongResolutionToClassifier; import org.jetbrains.kotlin.resolve.checkers.HeaderImplDeclarationChecker; +import org.jetbrains.kotlin.resolve.checkers.HeaderImplDeclarationChecker.Compatibility.Incompatible; import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData; import org.jetbrains.kotlin.serialization.deserialization.descriptors.SinceKotlinInfo; import org.jetbrains.kotlin.types.KotlinType; @@ -560,10 +561,14 @@ public interface Errors { DiagnosticFactory0 IMPL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory3>> HEADER_WITHOUT_IMPLEMENTATION = + Map>> HEADER_WITHOUT_IMPLEMENTATION = DiagnosticFactory3.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory2>> IMPLEMENTATION_WITHOUT_HEADER = + Map>> IMPLEMENTATION_WITHOUT_HEADER = + DiagnosticFactory2.create(ERROR, DECLARATION_SIGNATURE); + + DiagnosticFactory2>>>> HEADER_CLASS_MEMBERS_ARE_NOT_IMPLEMENTED = DiagnosticFactory2.create(ERROR, DECLARATION_SIGNATURE); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index e666fba2c3a..853d756a130 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -275,6 +275,9 @@ public class DefaultErrorMessages { MAP.put(IMPLEMENTATION_WITHOUT_HEADER, "''impl'' {0} has no corresponding ''header'' declaration{1}", DECLARATION_NAME_WITH_KIND, PlatformIncompatibilityDiagnosticRenderer.INSTANCE); + MAP.put(HEADER_CLASS_MEMBERS_ARE_NOT_IMPLEMENTED, "''impl'' class ''{0}'' has no implementation of ''header'' class members:{1}", + NAME, IncompatibleHeaderImplClassScopesRenderer.INSTANCE); + MAP.put(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, "Projections are not allowed on type arguments of functions and properties"); MAP.put(SUPERTYPE_NOT_INITIALIZED, "This type has a constructor, and thus must be initialized here"); MAP.put(NOTHING_TO_OVERRIDE, "''{0}'' overrides nothing", NAME); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt index af3e01b77ed..47d5d0d8c19 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt @@ -16,58 +16,82 @@ package org.jetbrains.kotlin.diagnostics.rendering +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.MemberDescriptor -import org.jetbrains.kotlin.resolve.checkers.HeaderImplDeclarationChecker - -object PlatformIncompatibilityDiagnosticRenderer : - DiagnosticParameterRenderer>> { - private val INDENTATION_UNIT = " " +import org.jetbrains.kotlin.resolve.checkers.HeaderImplDeclarationChecker.Compatibility.Incompatible +object PlatformIncompatibilityDiagnosticRenderer : DiagnosticParameterRenderer>> { override fun render( - obj: Map>, + obj: Map>, renderingContext: RenderingContext ): String { if (obj.isEmpty()) return "" - val renderDescriptor: (DeclarationDescriptor) -> String = { Renderers.COMPACT_WITH_MODIFIERS.render(it, renderingContext) } - return buildString { appendln() - render(obj, "", renderDescriptor) - } - } - - private fun StringBuilder.render( - map: Map>, - indent: String, - renderDescriptor: (DeclarationDescriptor) -> String - ) { - for ((incompatibility, descriptors) in map) { - append(indent) - append("The following declaration") - if (descriptors.size == 1) append(" is") else append("s are") - append(" incompatible") - incompatibility.reason?.let { appendln(" because $it:") } - - for (descriptor in descriptors) { - append(indent + " ") - appendln(renderDescriptor(descriptor)) - } - - incompatibility.unimplemented?.let { unimplemented -> - append(indent) - appendln("No implementations are found for members listed below:") - for ((descriptor, mapping) in unimplemented) { - appendln() - append(indent + " ") - appendln(renderDescriptor(descriptor)) - if (mapping.isNotEmpty()) { - appendln() - } - render(mapping, indent + INDENTATION_UNIT, renderDescriptor) - } - } + renderIncompatibilityInformation(obj, "", renderingContext) } } } + +object IncompatibleHeaderImplClassScopesRenderer : + DiagnosticParameterRenderer>>>> { + override fun render( + obj: List>>>, + renderingContext: RenderingContext): String { + if (obj.isEmpty()) return "" + + return buildString { + appendln() + renderIncompatibleClassScopes(obj, "", renderingContext) + } + } +} + +private fun StringBuilder.renderIncompatibilityInformation( + map: Map>, + indent: String, + context: RenderingContext +) { + for ((incompatibility, descriptors) in map) { + append(indent) + append("The following declaration") + if (descriptors.size == 1) append(" is") else append("s are") + append(" incompatible") + incompatibility.reason?.let { appendln(" because $it:") } + + for (descriptor in descriptors) { + append(indent + " ") + appendln(descriptor.render(context)) + } + + if (incompatibility is Incompatible.ClassScopes) { + append(indent) + appendln("No implementations are found for members listed below:") + renderIncompatibleClassScopes(incompatibility.unimplemented, indent, context) + } + } +} + +private fun StringBuilder.renderIncompatibleClassScopes( + unimplemented: List>>>, + indent: String, + context: RenderingContext +) { + for ((descriptor, mapping) in unimplemented) { + appendln() + append(indent + " ") + appendln(descriptor.render(context)) + if (mapping.isNotEmpty()) { + appendln() + } + renderIncompatibilityInformation(mapping, indent + INDENTATION_UNIT, context) + } +} + +private const val INDENTATION_UNIT = " " + +private fun DeclarationDescriptor.render(context: RenderingContext): String { + return Renderers.COMPACT_WITH_MODIFIERS.render(this, context) +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/HeaderImplDeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/HeaderImplDeclarationChecker.kt index e3e6b4716d0..2204a208ebb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/HeaderImplDeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/HeaderImplDeclarationChecker.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtConstructor import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.BindingContext @@ -102,7 +103,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker { return when (header) { is CallableMemberDescriptor -> { header.findNamesakesFromModule(platformModule).filter { impl -> - header != impl && + header != impl && !impl.isHeader && // TODO: support non-source definitions (e.g. from Java) DescriptorToSourceUtils.getSourceFromDescriptor(impl) is KtElement }.groupBy { impl -> @@ -111,7 +112,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker { } is ClassDescriptor -> { header.findClassifiersFromModule(platformModule).filter { impl -> - header != impl && + header != impl && !impl.isHeader && DescriptorToSourceUtils.getSourceFromDescriptor(impl) is KtElement }.groupBy { impl -> areCompatibleClassifiers(header, impl, checkImpl) @@ -129,7 +130,35 @@ object HeaderImplDeclarationChecker : DeclarationChecker { // TODO: use common module here val compatibility = findHeaderForImpl(descriptor, descriptor.module) ?: return - if (Compatible !in compatibility) { + // 'firstOrNull' is needed because in diagnostic tests, common sources appear twice, so the same class is duplicated + // TODO: replace with 'singleOrNull' as soon as multi-module diagnostic tests are refactored + val singleIncompatibility = compatibility.keys.firstOrNull() + if (singleIncompatibility is Incompatible.ClassScopes) { + assert(descriptor is ClassDescriptor) { "Incompatible.ClassScopes is only possible for a class: $descriptor" } + + // Do not report "header members are not implemented" for those header members, for which there's a clear + // (albeit maybe incompatible) single implementation suspect, declared in the impl class. + // This is needed only to reduce the number of errors. Incompatibility errors for those members will be reported + // later when this checker is called for them + fun hasSingleImplSuspect( + headerWithIncompatibility: Pair>> + ): Boolean { + val (headerMember, incompatibility) = headerWithIncompatibility + val implMember = incompatibility.values.singleOrNull()?.singleOrNull() + return implMember != null && + implMember.isExplicitImplDeclaration() && + findHeaderForImpl(implMember, headerMember.module)?.values?.singleOrNull()?.singleOrNull() == headerMember + } + + val nonTrivialUnimplemented = singleIncompatibility.unimplemented.filterNot(::hasSingleImplSuspect) + + if (nonTrivialUnimplemented.isNotEmpty()) { + diagnosticHolder.report(Errors.HEADER_CLASS_MEMBERS_ARE_NOT_IMPLEMENTED.on( + reportOn, descriptor as ClassDescriptor, nonTrivialUnimplemented + )) + } + } + else if (Compatible !in compatibility) { assert(compatibility.keys.all { it is Incompatible }) @Suppress("UNCHECKED_CAST") val incompatibility = compatibility as Map> @@ -137,13 +166,24 @@ object HeaderImplDeclarationChecker : DeclarationChecker { } } + // This should ideally be handled by CallableMemberDescriptor.Kind, but default constructors have kind DECLARATION and non-empty source. + // Their source is the containing KtClass instance though, as opposed to explicit constructors, whose source is KtConstructor + private fun CallableMemberDescriptor.isExplicitImplDeclaration(): Boolean = + if (this is ConstructorDescriptor) { + DescriptorToSourceUtils.getSourceFromDescriptor(this) is KtConstructor<*> + } + else { + isImpl && kind == CallableMemberDescriptor.Kind.DECLARATION + } + private fun findHeaderForImpl(impl: MemberDescriptor, commonModule: ModuleDescriptor): Map>? { return when (impl) { is CallableMemberDescriptor -> { val container = impl.containingDeclaration val candidates = when (container) { is ClassDescriptor -> { - val headerClass = findHeaderForImpl(container, commonModule)?.get(Compatible)?.firstOrNull() as? ClassDescriptor + // TODO: replace with 'singleOrNull' as soon as multi-module diagnostic tests are refactored + val headerClass = findHeaderForImpl(container, commonModule)?.values?.firstOrNull()?.firstOrNull() as? ClassDescriptor headerClass?.getMembers(impl.name).orEmpty() } is PackageFragmentDescriptor -> impl.findNamesakesFromModule(commonModule) @@ -169,7 +209,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker { impl != declaration && declaration is ClassDescriptor && declaration.isHeader }.groupBy { header -> - areCompatibleClassifiers(header as ClassDescriptor, impl, checkImpl = false) + areCompatibleClassifiers(header as ClassDescriptor, impl, checkImpl = true) } } else -> null @@ -229,10 +269,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker { sealed class Compatibility { // Note that the reason is used in the diagnostic output, see PlatformIncompatibilityDiagnosticRenderer - sealed class Incompatible( - val reason: String?, - val unimplemented: List>>>? = null - ) : Compatibility() { + sealed class Incompatible(val reason: String?) : Compatibility() { // Callables object ParameterShape : Incompatible("parameter shapes are different (extension vs non-extension)") @@ -268,8 +305,8 @@ object HeaderImplDeclarationChecker : DeclarationChecker { object Supertypes : Incompatible("some supertypes are missing in the implementation") class ClassScopes( - unimplemented: List>>> - ) : Incompatible("some members are not implemented", unimplemented) + val unimplemented: List>>> + ) : Incompatible("some members are not implemented") object EnumEntries : Incompatible("some entries from header enum are missing in the impl enum") diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.kt new file mode 100644 index 00000000000..9045851d132 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.kt @@ -0,0 +1,15 @@ +// !LANGUAGE: +MultiPlatformProjects +// MODULE: m1-common +// FILE: common.kt + +header class Foo { + fun bar(): String +} + +// MODULE: m2-jvm(m1-common) +// FILE: jvm.kt + +// TODO: run HeaderImplDeclarationChecker on non-impl members of impl classes, and report something like "impl expected" on 'bar' instead +impl class Foo { + fun bar(): String = "bar" +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.txt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.txt new file mode 100644 index 00000000000..23118c90290 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.txt @@ -0,0 +1,22 @@ +// -- Module: -- +package + +public final header class Foo { + public constructor Foo() + public final header fun bar(): kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + + +// -- Module: -- +package + +public final impl class Foo { + public constructor Foo() + public final fun bar(): kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/output.txt b/compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/output.txt index 2560cbc2841..385366cb0a7 100644 --- a/compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/output.txt +++ b/compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/output.txt @@ -5,18 +5,9 @@ Output: -- JVM -- Exit code: COMPILATION_ERROR Output: -compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/jvm.kt:1:12: error: 'impl' class 'Foo' has no corresponding 'header' declaration -The following declaration is incompatible because some members are not implemented: - public final header class Foo -No implementations are found for members listed below: - +compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/jvm.kt:2:10: error: 'impl' constructor of 'Foo' has no corresponding 'header' declaration +The following declaration is incompatible because parameter types are different: public constructor Foo(s: String) - The following declaration is incompatible because parameter types are different: - public constructor Foo(s: Array) - -impl class Foo { - ^ -compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/jvm.kt:2:10: error: 'impl' constructor of 'Foo' has no corresponding 'header' declaration impl constructor(s: Array) ^ diff --git a/compiler/testData/multiplatform/classScopes/functionIncorrectSignature/output.txt b/compiler/testData/multiplatform/classScopes/functionIncorrectSignature/output.txt index 7d949766f82..94d5186e16d 100644 --- a/compiler/testData/multiplatform/classScopes/functionIncorrectSignature/output.txt +++ b/compiler/testData/multiplatform/classScopes/functionIncorrectSignature/output.txt @@ -5,18 +5,9 @@ Output: -- JVM -- Exit code: COMPILATION_ERROR Output: -compiler/testData/multiplatform/classScopes/functionIncorrectSignature/jvm.kt:1:12: error: 'impl' class 'Foo' has no corresponding 'header' declaration -The following declaration is incompatible because some members are not implemented: - public final header class Foo -No implementations are found for members listed below: - +compiler/testData/multiplatform/classScopes/functionIncorrectSignature/jvm.kt:2:5: error: 'impl' function 'function' has no corresponding 'header' declaration +The following declaration is incompatible because return type is different: public final header fun function(b: ByteArray): Int - The following declaration is incompatible because return type is different: - public final impl fun function(b: ByteArray): Long - -impl class Foo { - ^ -compiler/testData/multiplatform/classScopes/functionIncorrectSignature/jvm.kt:2:5: error: 'impl' function 'function' has no corresponding 'header' declaration impl fun function(b: ByteArray): Long = b.size.toLong() ^ diff --git a/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/common.kt b/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/common.kt new file mode 100644 index 00000000000..a9481f243b0 --- /dev/null +++ b/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/common.kt @@ -0,0 +1,3 @@ +header class Foo { + fun function(b: ByteArray): Int +} diff --git a/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/jvm.kt b/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/jvm.kt new file mode 100644 index 00000000000..d66d369b64a --- /dev/null +++ b/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/jvm.kt @@ -0,0 +1,5 @@ +open class Base { + fun function(b: ByteArray): Long = b.size.toLong() +} + +impl class Foo : Base() diff --git a/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/output.txt b/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/output.txt new file mode 100644 index 00000000000..00da8e6c2ea --- /dev/null +++ b/compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/output.txt @@ -0,0 +1,16 @@ +-- Common -- +Exit code: OK +Output: + +-- JVM -- +Exit code: COMPILATION_ERROR +Output: +compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/jvm.kt:5:12: error: 'impl' class 'Foo' has no implementation of 'header' class members: + + public final header fun function(b: ByteArray): Int + + The following declaration is incompatible because return type is different: + public final fun function(b: ByteArray): Long + +impl class Foo : Base() + ^ diff --git a/compiler/testData/multiplatform/classScopes/missingConstructor/output.txt b/compiler/testData/multiplatform/classScopes/missingConstructor/output.txt index 538781331dd..b3454c1b6a5 100644 --- a/compiler/testData/multiplatform/classScopes/missingConstructor/output.txt +++ b/compiler/testData/multiplatform/classScopes/missingConstructor/output.txt @@ -5,10 +5,7 @@ Output: -- JVM -- Exit code: COMPILATION_ERROR Output: -compiler/testData/multiplatform/classScopes/missingConstructor/jvm.kt:1:12: error: 'impl' class 'Foo' has no corresponding 'header' declaration -The following declaration is incompatible because some members are not implemented: - public final header class Foo -No implementations are found for members listed below: +compiler/testData/multiplatform/classScopes/missingConstructor/jvm.kt:1:12: error: 'impl' class 'Foo' has no implementation of 'header' class members: public constructor Foo(s: String) diff --git a/compiler/testData/multiplatform/classScopes/missingFunction/output.txt b/compiler/testData/multiplatform/classScopes/missingFunction/output.txt index a5535d68e67..d1f2d2fa0e5 100644 --- a/compiler/testData/multiplatform/classScopes/missingFunction/output.txt +++ b/compiler/testData/multiplatform/classScopes/missingFunction/output.txt @@ -5,10 +5,7 @@ Output: -- JVM -- Exit code: COMPILATION_ERROR Output: -compiler/testData/multiplatform/classScopes/missingFunction/jvm.kt:1:12: error: 'impl' class 'Foo' has no corresponding 'header' declaration -The following declaration is incompatible because some members are not implemented: - public final header class Foo -No implementations are found for members listed below: +compiler/testData/multiplatform/classScopes/missingFunction/jvm.kt:1:12: error: 'impl' class 'Foo' has no implementation of 'header' class members: public final header fun function(s: String): Unit diff --git a/compiler/testData/multiplatform/missingOverload/output.txt b/compiler/testData/multiplatform/missingOverload/output.txt index b2132c859e2..e7d87757674 100644 --- a/compiler/testData/multiplatform/missingOverload/output.txt +++ b/compiler/testData/multiplatform/missingOverload/output.txt @@ -11,7 +11,7 @@ The following declaration is incompatible because parameter types are different: header fun g(s: String) ^ -compiler/testData/multiplatform/missingOverload/jvm.kt:1:12: error: 'impl' class 'Foo' has no implementations of 'header' class members: +compiler/testData/multiplatform/missingOverload/jvm.kt:1:12: error: 'impl' class 'Foo' has no implementation of 'header' class members: public final header fun f(a: Any): Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index fb45d247049..85fe7885351 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -13770,6 +13770,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("noImplKeywordOnMember.kt") + public void testNoImplKeywordOnMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/noImplKeywordOnMember.kt"); + doTest(fileName); + } + @TestMetadata("simpleHeaderClass.kt") public void testSimpleHeaderClass() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/simpleHeaderClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java index 8e7f51c640f..24b5ac8a27d 100644 --- a/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java @@ -140,6 +140,12 @@ public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatform doTest(fileName); } + @TestMetadata("functionIncorrectSignatureFromSuperclass") + public void testFunctionIncorrectSignatureFromSuperclass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/classScopes/functionIncorrectSignatureFromSuperclass/"); + doTest(fileName); + } + @TestMetadata("missingConstructor") public void testMissingConstructor() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/classScopes/missingConstructor/"); diff --git a/idea/testData/multiModuleHighlighting/multiplatform/headerPartiallyImplemented/jvm/jvm.kt b/idea/testData/multiModuleHighlighting/multiplatform/headerPartiallyImplemented/jvm/jvm.kt index 2090d790adf..814c97b38a0 100644 --- a/idea/testData/multiModuleHighlighting/multiplatform/headerPartiallyImplemented/jvm/jvm.kt +++ b/idea/testData/multiModuleHighlighting/multiplatform/headerPartiallyImplemented/jvm/jvm.kt @@ -1,11 +1,11 @@ impl class My { - impl fun foo() = 42 + impl fun foo() = 42 } -impl class Your { +impl class Your { - impl fun foo() = 13 + impl fun foo() = 13 impl fun bar(arg: Int) = arg