Do not consider 'expect' class type constructors final
Because even a final expected class can be actualized with an open actual class and thus have subtypes in the platform code
This commit is contained in:
-1
@@ -114,7 +114,6 @@ class SyntheticClassOrObjectDescriptor(
|
||||
|
||||
private inner class SyntheticTypeConstructor(storageManager: StorageManager) : AbstractClassTypeConstructor(storageManager) {
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
override fun isFinal(): Boolean = true
|
||||
override fun isDenotable(): Boolean = true
|
||||
override fun getDeclarationDescriptor(): ClassDescriptor = thisDescriptor
|
||||
override fun computeSupertypes(): Collection<KotlinType> = syntheticSupertypes
|
||||
|
||||
-5
@@ -650,11 +650,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return parameters.invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return getModality() == Modality.FINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDenotable() {
|
||||
return true;
|
||||
|
||||
+2
@@ -6,6 +6,8 @@ expect class Foo
|
||||
|
||||
expect fun getFoo(): Foo
|
||||
|
||||
fun <T : Foo> bar() {} // no "Foo is final" warning should be here
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
|
||||
+2
@@ -1,6 +1,7 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public fun </*0*/ T : Foo> bar(): kotlin.Unit
|
||||
public expect fun getFoo(): Foo
|
||||
|
||||
public final expect class Foo {
|
||||
@@ -13,6 +14,7 @@ public final expect class Foo {
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public fun </*0*/ T : Foo> bar(): kotlin.Unit
|
||||
public actual fun getFoo(): Foo
|
||||
|
||||
public final class Bar : Foo {
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class Foo { // also, it's important that Foo doesn't override equals
|
||||
fun foo()
|
||||
}
|
||||
|
||||
fun check(x1: Foo, x: Any) {
|
||||
if (x1 == x) {
|
||||
x.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public fun check(/*0*/ x1: Foo, /*1*/ x: kotlin.Any): kotlin.Unit
|
||||
|
||||
public final expect class Foo {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final expect fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -14241,6 +14241,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastOnExpectClass.kt")
|
||||
public void testSmartCastOnExpectClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/smartCastOnExpectClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("superClass.kt")
|
||||
public void testSuperClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt");
|
||||
|
||||
+6
@@ -14241,6 +14241,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastOnExpectClass.kt")
|
||||
public void testSmartCastOnExpectClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/smartCastOnExpectClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("superClass.kt")
|
||||
public void testSuperClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt");
|
||||
|
||||
-2
@@ -255,8 +255,6 @@ class LazyJavaClassDescriptor(
|
||||
override val supertypeLoopChecker: SupertypeLoopChecker
|
||||
get() = c.components.supertypeLoopChecker
|
||||
|
||||
override fun isFinal(): Boolean = isFinalClass
|
||||
|
||||
override fun isDenotable(): Boolean = true
|
||||
|
||||
override fun getDeclarationDescriptor(): ClassDescriptor = this@LazyJavaClassDescriptor
|
||||
|
||||
-1
@@ -152,7 +152,6 @@ class FunctionClassDescriptor(
|
||||
|
||||
override fun getDeclarationDescriptor() = this@FunctionClassDescriptor
|
||||
override fun isDenotable() = true
|
||||
override fun isFinal() = false
|
||||
|
||||
override fun toString() = declarationDescriptor.toString()
|
||||
|
||||
|
||||
@@ -53,6 +53,12 @@ public abstract class AbstractClassTypeConstructor extends AbstractTypeConstruct
|
||||
@Override
|
||||
public abstract ClassDescriptor getDeclarationDescriptor();
|
||||
|
||||
@Override
|
||||
public final boolean isFinal() {
|
||||
ClassDescriptor descriptor = getDeclarationDescriptor();
|
||||
return descriptor.getModality() == Modality.FINAL && !descriptor.isExpect();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinBuiltIns getBuiltIns() {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.types;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.Modality;
|
||||
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
@@ -56,11 +55,6 @@ public class ClassTypeConstructorImpl extends AbstractClassTypeConstructor imple
|
||||
return DescriptorUtils.getFqName(classDescriptor).asString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return classDescriptor.getModality() == Modality.FINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDenotable() {
|
||||
return true;
|
||||
|
||||
-2
@@ -195,8 +195,6 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun getParameters() = parameters()
|
||||
|
||||
override fun isFinal(): Boolean = isFinalClass
|
||||
|
||||
override fun isDenotable() = true
|
||||
|
||||
override fun getDeclarationDescriptor() = this@DeserializedClassDescriptor
|
||||
|
||||
Reference in New Issue
Block a user