Fix AssertionError on incompatible scopes with impl typealias
This has been introduced in 9ecd04f628
This commit is contained in:
+7
-2
@@ -143,7 +143,9 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
|||||||
// TODO: replace with 'singleOrNull' as soon as multi-module diagnostic tests are refactored
|
// TODO: replace with 'singleOrNull' as soon as multi-module diagnostic tests are refactored
|
||||||
val singleIncompatibility = compatibility.keys.firstOrNull()
|
val singleIncompatibility = compatibility.keys.firstOrNull()
|
||||||
if (singleIncompatibility is Incompatible.ClassScopes) {
|
if (singleIncompatibility is Incompatible.ClassScopes) {
|
||||||
assert(descriptor is ClassDescriptor) { "Incompatible.ClassScopes is only possible for a class: $descriptor" }
|
assert(descriptor is ClassDescriptor || descriptor is TypeAliasDescriptor) {
|
||||||
|
"Incompatible.ClassScopes is only possible for a class or a typealias: $descriptor"
|
||||||
|
}
|
||||||
|
|
||||||
// Do not report "header members are not implemented" for those header members, for which there's a clear
|
// 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.
|
// (albeit maybe incompatible) single implementation suspect, declared in the impl class.
|
||||||
@@ -162,8 +164,11 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
|||||||
val nonTrivialUnimplemented = singleIncompatibility.unimplemented.filterNot(::hasSingleImplSuspect)
|
val nonTrivialUnimplemented = singleIncompatibility.unimplemented.filterNot(::hasSingleImplSuspect)
|
||||||
|
|
||||||
if (nonTrivialUnimplemented.isNotEmpty()) {
|
if (nonTrivialUnimplemented.isNotEmpty()) {
|
||||||
|
val classDescriptor =
|
||||||
|
(descriptor as? TypeAliasDescriptor)?.expandedType?.constructor?.declarationDescriptor as? ClassDescriptor
|
||||||
|
?: (descriptor as ClassDescriptor)
|
||||||
diagnosticHolder.report(Errors.HEADER_CLASS_MEMBERS_ARE_NOT_IMPLEMENTED.on(
|
diagnosticHolder.report(Errors.HEADER_CLASS_MEMBERS_ARE_NOT_IMPLEMENTED.on(
|
||||||
reportOn, descriptor as ClassDescriptor, nonTrivialUnimplemented
|
reportOn, classDescriptor, nonTrivialUnimplemented
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
header abstract class Writer protected constructor()
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
impl typealias Writer = java.io.Writer
|
||||||
Vendored
+18
@@ -0,0 +1,18 @@
|
|||||||
|
-- Common --
|
||||||
|
Exit code: OK
|
||||||
|
Output:
|
||||||
|
|
||||||
|
-- JVM --
|
||||||
|
Exit code: COMPILATION_ERROR
|
||||||
|
Output:
|
||||||
|
compiler/testData/multiplatform/regressions/incompatibleClassScopesWithImplTypeAlias/jvm.kt:3:1: error: 'impl' class 'Writer' has no implementation of 'header' class members:
|
||||||
|
|
||||||
|
protected constructor Writer()
|
||||||
|
|
||||||
|
The following declaration is incompatible because visibility is different:
|
||||||
|
protected/*protected and package*/ constructor Writer()
|
||||||
|
The following declaration is incompatible because number of value parameters is different:
|
||||||
|
protected/*protected and package*/ constructor Writer(p0: Any!)
|
||||||
|
|
||||||
|
impl typealias Writer = java.io.Writer
|
||||||
|
^
|
||||||
+6
@@ -206,6 +206,12 @@ public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatform
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/multiplatform/regressions"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/multiplatform/regressions"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("incompatibleClassScopesWithImplTypeAlias")
|
||||||
|
public void testIncompatibleClassScopesWithImplTypeAlias() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/regressions/incompatibleClassScopesWithImplTypeAlias/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt17001")
|
@TestMetadata("kt17001")
|
||||||
public void testKt17001() throws Exception {
|
public void testKt17001() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/regressions/kt17001/");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/regressions/kt17001/");
|
||||||
|
|||||||
Reference in New Issue
Block a user