Add nullability annotations to data class equals and toString.

KT-22201
This commit is contained in:
Jake Wharton
2018-05-30 11:38:05 -04:00
committed by Nicolay Mitropolsky
parent 8d24ca65a3
commit 2e4f3ced9b
3 changed files with 8 additions and 4 deletions
@@ -537,6 +537,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
public void generateEqualsMethod(@NotNull FunctionDescriptor function, @NotNull List<? extends PropertyDescriptor> properties) {
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(function);
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(function), ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null);
mv.visitParameterAnnotation(0, Type.getDescriptor(Nullable.class), true);
InstructionAdapter iv = new InstructionAdapter(mv);
mv.visitCode();
@@ -644,6 +645,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
public void generateToStringMethod(@NotNull FunctionDescriptor function, @NotNull List<? extends PropertyDescriptor> properties) {
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(function);
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(function), ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
mv.visitAnnotation(Type.getDescriptor(NotNull.class), true);
InstructionAdapter iv = new InstructionAdapter(mv);
mv.visitCode();