Minor: JvmCodegenUtil#isNullableType -> TypeUtils#isNullableType

This commit is contained in:
Zalim Bashorov
2014-06-23 20:09:37 +04:00
parent e73ee4bbd6
commit 0d0751c3f9
5 changed files with 18 additions and 20 deletions
@@ -420,6 +420,20 @@ public class TypeUtils {
return false;
}
/**
* A work-around of the generic nullability problem in the type checker
* @return true if a value of this type can be null
*/
public static boolean isNullableType(@NotNull JetType type) {
if (type.isNullable()) {
return true;
}
if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
return hasNullableSuperType(type);
}
return false;
}
public static boolean hasNullableSuperType(@NotNull JetType type) {
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
// A class/trait cannot have a nullable supertype