Add nullability annotations to data class equals and toString.
KT-22201
This commit is contained in:
committed by
Nicolay Mitropolsky
parent
8d24ca65a3
commit
2e4f3ced9b
@@ -537,6 +537,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
public void generateEqualsMethod(@NotNull FunctionDescriptor function, @NotNull List<? extends PropertyDescriptor> properties) {
|
public void generateEqualsMethod(@NotNull FunctionDescriptor function, @NotNull List<? extends PropertyDescriptor> properties) {
|
||||||
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(function);
|
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(function);
|
||||||
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(function), ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null);
|
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);
|
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||||
|
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
@@ -644,6 +645,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
public void generateToStringMethod(@NotNull FunctionDescriptor function, @NotNull List<? extends PropertyDescriptor> properties) {
|
public void generateToStringMethod(@NotNull FunctionDescriptor function, @NotNull List<? extends PropertyDescriptor> properties) {
|
||||||
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(function);
|
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(function);
|
||||||
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(function), ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
|
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);
|
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||||
|
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
|
|||||||
+4
-2
@@ -18,6 +18,7 @@ public final class Wrapper {
|
|||||||
@org.jetbrains.annotations.NotNull
|
@org.jetbrains.annotations.NotNull
|
||||||
public final p.Wrapper.Equals copy(@org.jetbrains.annotations.NotNull p.G code) { /* compiled code */ }
|
public final p.Wrapper.Equals copy(@org.jetbrains.annotations.NotNull p.G code) { /* compiled code */ }
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull
|
||||||
public java.lang.String toString() { /* compiled code */ }
|
public java.lang.String toString() { /* compiled code */ }
|
||||||
|
|
||||||
public int hashCode() { /* compiled code */ }
|
public int hashCode() { /* compiled code */ }
|
||||||
@@ -40,9 +41,10 @@ public final class Wrapper {
|
|||||||
@org.jetbrains.annotations.NotNull
|
@org.jetbrains.annotations.NotNull
|
||||||
public final p.Wrapper.HashCode copy(@org.jetbrains.annotations.NotNull p.G code) { /* compiled code */ }
|
public final p.Wrapper.HashCode copy(@org.jetbrains.annotations.NotNull p.G code) { /* compiled code */ }
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull
|
||||||
public java.lang.String toString() { /* compiled code */ }
|
public java.lang.String toString() { /* compiled code */ }
|
||||||
|
|
||||||
public boolean equals(java.lang.Object p) { /* compiled code */ }
|
public boolean equals(@org.jetbrains.annotations.Nullable java.lang.Object p) { /* compiled code */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ToString {
|
public static final class ToString {
|
||||||
@@ -65,6 +67,6 @@ public final class Wrapper {
|
|||||||
|
|
||||||
public int hashCode() { /* compiled code */ }
|
public int hashCode() { /* compiled code */ }
|
||||||
|
|
||||||
public boolean equals(java.lang.Object p) { /* compiled code */ }
|
public boolean equals(@org.jetbrains.annotations.Nullable java.lang.Object p) { /* compiled code */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -7,9 +7,9 @@ public final class User {
|
|||||||
public final method component2(): int
|
public final method component2(): int
|
||||||
public synthetic static @org.jetbrains.annotations.NotNull method copy$default(p0: User, p1: java.lang.String, p2: int, p3: int, p4: java.lang.Object): User
|
public synthetic static @org.jetbrains.annotations.NotNull method copy$default(p0: User, p1: java.lang.String, p2: int, p3: int, p4: java.lang.Object): User
|
||||||
public final @org.jetbrains.annotations.NotNull method copy(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: int): User
|
public final @org.jetbrains.annotations.NotNull method copy(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: int): User
|
||||||
public method equals(p0: java.lang.Object): boolean
|
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||||
public final method getAge(): int
|
public final method getAge(): int
|
||||||
public final @org.jetbrains.annotations.NotNull method getName(): java.lang.String
|
public final @org.jetbrains.annotations.NotNull method getName(): java.lang.String
|
||||||
public method hashCode(): int
|
public method hashCode(): int
|
||||||
public method toString(): java.lang.String
|
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user