Check if the class is special by FQ name
This is needed because our built-ins can be loaded with two different mechanisms (deserialization and lazy resolve) and, when that happens, corresponding descriptors aren't equal to each other, so one of two resolved descriptors for Any (or the same with Nothing) was never considered to be a "special class" with no supertypes
This commit is contained in:
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -893,6 +894,12 @@ public class KotlinBuiltIns {
|
||||
|
||||
// Recognized & special
|
||||
|
||||
public static boolean isSpecialClassWithNoSupertypes(@NotNull ClassDescriptor descriptor) {
|
||||
FqNameUnsafe fqName = DescriptorUtils.getFqName(descriptor);
|
||||
return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("Any")).toUnsafe().equals(fqName) ||
|
||||
BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("Nothing")).toUnsafe().equals(fqName);
|
||||
}
|
||||
|
||||
public boolean isNothing(@NotNull JetType type) {
|
||||
return isNothingOrNullableNothing(type)
|
||||
&& !type.isNullable();
|
||||
|
||||
Reference in New Issue
Block a user