Do not annotate Kotlin members returning platform types as @Nullable
This leads to pointless warning in Java code
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user