diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java index df2af34a135..04887664bb4 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java @@ -31,7 +31,6 @@ import org.jetbrains.jet.lang.psi.JetModifierListOwner; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; 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.types.JetType; import org.jetbrains.jet.lang.types.TypeUtils; @@ -174,7 +173,7 @@ public abstract class AnnotationCodegen { return; } - boolean isNullableType = JvmCodegenUtil.isNullableType(type); + boolean isNullableType = TypeUtils.isNullableType(type); Class annotationClass = isNullableType ? Nullable.class : NotNull.class; diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java index 9a5f4c39e2e..badbff196fc 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java @@ -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.KotlinSyntheticClass; 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.*; public class AsmUtil { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 60cbe9f7dcc..8e9f9862f95 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -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.scopes.receivers.*; 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.lang.KotlinBuiltIns; 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); if (opToken != JetTokens.AS_SAFE) { - if (!JvmCodegenUtil.isNullableType(rightType)) { + if (!TypeUtils.isNullableType(rightType)) { v.dup(); Label nonnull = new Label(); v.ifnonnull(nonnull); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java index 98dea4fa31b..65d0eaf897b 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java @@ -16,8 +16,6 @@ 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 kotlin.Function1; 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.name.Name; import org.jetbrains.jet.lang.types.JetType; -import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; 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( @NotNull PropertyDescriptor propertyDescriptor, boolean forGetter, diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java index ecebe07b469..ee8d1386ed6 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -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