Do not annotate Kotlin members returning platform types as @Nullable

This leads to pointless warning in Java code
This commit is contained in:
Andrey Breslav
2014-11-04 10:36:29 +02:00
parent 19afb2fcb8
commit f16dcdd8a9
4 changed files with 36 additions and 0 deletions
@@ -34,8 +34,10 @@ 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.Flexibility;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.TypesPackage;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.org.objectweb.asm.*;
@@ -184,6 +186,14 @@ public abstract class AnnotationCodegen {
return;
}
if (TypesPackage.isFlexible(type)) {
// A flexible type whose lower bound in not-null and upper bound is nullable, should not be annotated
Flexibility flexibility = TypesPackage.flexibility(type);
if (!TypeUtils.isNullableType(flexibility.getLowerBound()) && TypeUtils.isNullableType(flexibility.getUpperBound())) {
return;
}
}
boolean isNullableType = TypeUtils.isNullableType(type);
Class<?> annotationClass = isNullableType ? Nullable.class : NotNull.class;