Minor: JvmCodegenUtil#isNullableType -> TypeUtils#isNullableType
This commit is contained in:
@@ -31,7 +31,6 @@ import org.jetbrains.jet.lang.psi.JetModifierListOwner;
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.*;
|
import org.jetbrains.jet.lang.resolve.constants.*;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||||
@@ -174,7 +173,7 @@ public abstract class AnnotationCodegen {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isNullableType = JvmCodegenUtil.isNullableType(type);
|
boolean isNullableType = TypeUtils.isNullableType(type);
|
||||||
|
|
||||||
Class<?> annotationClass = isNullableType ? Nullable.class : NotNull.class;
|
Class<?> annotationClass = isNullableType ? Nullable.class : NotNull.class;
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.getType;
|
|||||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.ABI_VERSION_FIELD_NAME;
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.ABI_VERSION_FIELD_NAME;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.mapping.PrimitiveTypesUtil.asmTypeForPrimitive;
|
import static org.jetbrains.jet.lang.resolve.java.mapping.PrimitiveTypesUtil.asmTypeForPrimitive;
|
||||||
|
import static org.jetbrains.jet.lang.types.TypeUtils.isNullableType;
|
||||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
public class AsmUtil {
|
public class AsmUtil {
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
|||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
|
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
@@ -3506,7 +3507,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
value.put(boxType(value.type), v);
|
value.put(boxType(value.type), v);
|
||||||
|
|
||||||
if (opToken != JetTokens.AS_SAFE) {
|
if (opToken != JetTokens.AS_SAFE) {
|
||||||
if (!JvmCodegenUtil.isNullableType(rightType)) {
|
if (!TypeUtils.isNullableType(rightType)) {
|
||||||
v.dup();
|
v.dup();
|
||||||
Label nonnull = new Label();
|
Label nonnull = new Label();
|
||||||
v.ifnonnull(nonnull);
|
v.ifnonnull(nonnull);
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen;
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
|
||||||
import com.intellij.util.containers.Stack;
|
import com.intellij.util.containers.Stack;
|
||||||
import kotlin.Function1;
|
import kotlin.Function1;
|
||||||
import kotlin.KotlinPackage;
|
import kotlin.KotlinPackage;
|
||||||
@@ -37,7 +35,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
|||||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -193,20 +190,6 @@ public class JvmCodegenUtil {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 TypeUtils.hasNullableSuperType(type);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean couldUseDirectAccessToProperty(
|
public static boolean couldUseDirectAccessToProperty(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
boolean forGetter,
|
boolean forGetter,
|
||||||
|
|||||||
@@ -420,6 +420,20 @@ public class TypeUtils {
|
|||||||
return false;
|
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) {
|
public static boolean hasNullableSuperType(@NotNull JetType type) {
|
||||||
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
||||||
// A class/trait cannot have a nullable supertype
|
// A class/trait cannot have a nullable supertype
|
||||||
|
|||||||
Reference in New Issue
Block a user