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:
Alexander Udalov
2014-02-04 19:39:16 +04:00
parent 3e33473c1a
commit 304129f9c9
5 changed files with 12 additions and 18 deletions
@@ -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();