Refactoring: make parameters not-null
This commit is contained in:
@@ -825,12 +825,12 @@ public class FunctionCodegen {
|
||||
endVisit(mv, "bridge method", origin);
|
||||
}
|
||||
|
||||
public void genDelegate(FunctionDescriptor functionDescriptor, FunctionDescriptor overriddenDescriptor, StackValue field) {
|
||||
public void genDelegate(@NotNull FunctionDescriptor functionDescriptor, FunctionDescriptor overriddenDescriptor, StackValue field) {
|
||||
genDelegate(functionDescriptor, overriddenDescriptor.getOriginal(), (ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field);
|
||||
}
|
||||
|
||||
public void genDelegate(
|
||||
final FunctionDescriptor delegateFunction,
|
||||
@NotNull final FunctionDescriptor delegateFunction,
|
||||
final FunctionDescriptor delegatedTo,
|
||||
final ClassDescriptor toClass,
|
||||
final StackValue field
|
||||
|
||||
@@ -496,6 +496,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
KotlinBuiltIns.getInstance().getBoolean(),
|
||||
KotlinBuiltIns.getInstance().getAny()
|
||||
);
|
||||
|
||||
assert equalsFunction != null : String.format("Should be called only for classes with non-trivial '%s'. In %s, %s",
|
||||
CodegenUtil.EQUALS_METHOD_NAME, descriptor.getName(), descriptor);
|
||||
|
||||
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(equalsFunction);
|
||||
MethodVisitor mv = v.newMethod(OtherOrigin(equalsFunction), ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null);
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
@@ -565,6 +569,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
descriptor, Name.identifier(CodegenUtil.HASH_CODE_METHOD_NAME),
|
||||
KotlinBuiltIns.getInstance().getInt()
|
||||
);
|
||||
|
||||
assert hashCodeFunction != null : String.format("Should be called only for classes with non-trivial '%s'. In %s, %s",
|
||||
CodegenUtil.HASH_CODE_METHOD_NAME, descriptor.getName(), descriptor);
|
||||
|
||||
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(hashCodeFunction);
|
||||
MethodVisitor mv = v.newMethod(OtherOrigin(hashCodeFunction), ACC_PUBLIC, "hashCode", "()I", null, null);
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
@@ -617,6 +625,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
descriptor, Name.identifier(CodegenUtil.TO_STRING_METHOD_NAME),
|
||||
KotlinBuiltIns.getInstance().getString()
|
||||
);
|
||||
|
||||
assert toString != null : String.format("Should be called only for classes with non-trivial '%s'. In %s, %s",
|
||||
CodegenUtil.TO_STRING_METHOD_NAME, descriptor.getName(), descriptor);
|
||||
|
||||
MethodContext context = ImplementationBodyCodegen.this.context.intoFunction(toString);
|
||||
MethodVisitor mv = v.newMethod(OtherOrigin(toString), ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
@@ -1603,7 +1615,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
public void addClassObjectPropertyToCopy(PropertyDescriptor descriptor, Object defaultValue) {
|
||||
public void addClassObjectPropertyToCopy(@NotNull PropertyDescriptor descriptor, Object defaultValue) {
|
||||
if (classObjectPropertiesToCopy == null) {
|
||||
classObjectPropertiesToCopy = new ArrayList<PropertyAndDefaultValue>();
|
||||
}
|
||||
@@ -1623,7 +1635,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
public final PropertyDescriptor descriptor;
|
||||
public final Object defaultValue;
|
||||
|
||||
public PropertyAndDefaultValue(PropertyDescriptor descriptor, Object defaultValue) {
|
||||
public PropertyAndDefaultValue(@NotNull PropertyDescriptor descriptor, Object defaultValue) {
|
||||
this.descriptor = descriptor;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
+2
-2
@@ -54,9 +54,9 @@ public fun OtherOrigin(element: PsiElement?, descriptor: DeclarationDescriptor?)
|
||||
JvmDeclarationOrigin.NO_ORIGIN
|
||||
else JvmDeclarationOrigin(OTHER, element, descriptor)
|
||||
|
||||
public fun OtherOrigin(element: PsiElement?): JvmDeclarationOrigin = OtherOrigin(element, null)
|
||||
public fun OtherOrigin(element: PsiElement): JvmDeclarationOrigin = OtherOrigin(element, null)
|
||||
|
||||
public fun OtherOrigin(descriptor: DeclarationDescriptor?): JvmDeclarationOrigin = OtherOrigin(null, descriptor)
|
||||
public fun OtherOrigin(descriptor: DeclarationDescriptor): JvmDeclarationOrigin = OtherOrigin(null, descriptor)
|
||||
|
||||
public fun PackageFacade(descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_FACADE, null, descriptor)
|
||||
public fun PackagePart(file: JetFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_PART, file, descriptor)
|
||||
|
||||
Reference in New Issue
Block a user