Sealed class: handle the case with actual type alias #KT-26141 Fixed
Before this commit, class super-type could be sealed only in the case it's the class we are inside or in the same file with. However, it's quite possible for the expect sealed class to be implemented by typealias. So in this commit we allow class super-type to be sealed if it's typealias expansion we are inside.
This commit is contained in:
@@ -40,7 +40,9 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
@@ -497,6 +499,16 @@ public class BodyResolver {
|
||||
parentEnumOrSealed = new HashSet<>();
|
||||
}
|
||||
parentEnumOrSealed.add(currentDescriptor.getTypeConstructor());
|
||||
if (currentDescriptor.isExpect()) {
|
||||
List<MemberDescriptor> actualDescriptors = ExpectedActualResolver.INSTANCE.findCompatibleActualForExpected(
|
||||
currentDescriptor, DescriptorUtilsKt.getModule( currentDescriptor)
|
||||
);
|
||||
for (MemberDescriptor actualDescriptor: actualDescriptors) {
|
||||
if (actualDescriptor instanceof TypeAliasDescriptor) {
|
||||
parentEnumOrSealed.add(((TypeAliasDescriptor) actualDescriptor).getExpandedType().getConstructor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// FILE: common.kt
|
||||
|
||||
expect sealed class Presence {
|
||||
object Online: <!JVM:SEALED_SUPERTYPE!>Presence<!>
|
||||
object Offline: <!JVM:SEALED_SUPERTYPE!>Presence<!>
|
||||
object Online: Presence
|
||||
object Offline: Presence
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
|
||||
Reference in New Issue
Block a user