isNothing() made static

This commit is contained in:
Andrey Breslav
2014-12-02 15:53:39 +03:00
parent ea4f0ab214
commit 7a41e37655
20 changed files with 29 additions and 29 deletions
@@ -118,7 +118,7 @@ public class CommonSupertypes {
JetType type = iterator.next();
assert type != null;
assert !TypesPackage.isFlexible(type) : "Flexible type " + type + " passed to commonSuperTypeForInflexible";
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type)) {
if (KotlinBuiltIns.isNothingOrNullableNothing(type)) {
iterator.remove();
}
if (type.isError()) {
@@ -169,7 +169,7 @@ public class TypeSubstitutor {
);
}
if (KotlinBuiltIns.getInstance().isNothing(type) || type.isError()) return originalProjection;
if (KotlinBuiltIns.isNothing(type) || type.isError()) return originalProjection;
TypeProjection replacement = substitution.get(type.getConstructor());
@@ -171,7 +171,7 @@ public class TypeUtils {
boolean nothingTypePresent = false;
List<JetType> nullabilityStripped = new ArrayList<JetType>(types.size());
for (JetType type : types) {
nothingTypePresent |= KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type);
nothingTypePresent |= KotlinBuiltIns.isNothingOrNullableNothing(type);
allNullable &= type.isNullable();
nullabilityStripped.add(makeNotNullable(type));
}
@@ -194,7 +194,7 @@ public class TypeCheckingProcedure {
}
subtype = TypeUtils.makeNotNullable(subtype);
supertype = TypeUtils.makeNotNullable(supertype);
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(subtype)) {
if (KotlinBuiltIns.isNothingOrNullableNothing(subtype)) {
return true;
}
@Nullable JetType closestSupertype = findCorrespondingSupertype(subtype, supertype, constraints);
@@ -835,18 +835,19 @@ public class KotlinBuiltIns {
return FQ_NAMES.any.equals(DescriptorUtils.getFqName(descriptor));
}
public boolean isNothing(@NotNull JetType type) {
public static boolean isNothing(@NotNull JetType type) {
return isNothingOrNullableNothing(type)
&& !type.isNullable();
}
public boolean isNullableNothing(@NotNull JetType type) {
public static boolean isNullableNothing(@NotNull JetType type) {
return isNothingOrNullableNothing(type)
&& type.isNullable();
}
public boolean isNothingOrNullableNothing(@NotNull JetType type) {
return type.getConstructor() == getNothing().getTypeConstructor();
public static boolean isNothingOrNullableNothing(@NotNull JetType type) {
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
return descriptor != null && FQ_NAMES.nothing.equals(DescriptorUtils.getFqName(descriptor));
}
public boolean isAnyOrNullableAny(@NotNull JetType type) {