KT-4107 Data objects
This commit is contained in:
+5
-2
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.backend.common
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
@@ -33,8 +34,10 @@ abstract class DataClassMethodGenerator(
|
||||
) : FunctionsFromAnyGenerator(declaration, bindingContext) {
|
||||
|
||||
override fun generate() {
|
||||
generateComponentFunctionsForDataClasses()
|
||||
generateCopyFunctionForDataClasses(primaryConstructorParameters)
|
||||
if (declaration !is KtObjectDeclaration) {
|
||||
generateComponentFunctionsForDataClasses()
|
||||
generateCopyFunctionForDataClasses(primaryConstructorParameters)
|
||||
}
|
||||
|
||||
super.generate()
|
||||
}
|
||||
|
||||
+3
-5
@@ -21,11 +21,9 @@ abstract class FunctionsFromAnyGenerator(protected val declaration: KtClassOrObj
|
||||
|
||||
open fun generate() {
|
||||
val properties = primaryConstructorProperties
|
||||
if (properties.isNotEmpty()) {
|
||||
generateToStringIfNeeded(properties)
|
||||
generateHashCodeIfNeeded(properties)
|
||||
generateEqualsIfNeeded(properties)
|
||||
}
|
||||
generateToStringIfNeeded(properties)
|
||||
generateHashCodeIfNeeded(properties)
|
||||
generateEqualsIfNeeded(properties)
|
||||
}
|
||||
|
||||
protected abstract fun generateToStringMethod(function: FunctionDescriptor, properties: List<PropertyDescriptor>)
|
||||
|
||||
Reference in New Issue
Block a user