From 06cd19dd0dee0d9299701f5ea26d8903d523b3b2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 5 Oct 2015 14:34:44 +0300 Subject: [PATCH] Open / data forbidden: AnalysisResult fix --- .../kotlin/analyzer/AnalysisResult.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt index 05e4bbdb7d9..1fa62d80c78 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt @@ -20,12 +20,32 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.ErrorUtils -public data open class AnalysisResult protected constructor( +public open class AnalysisResult protected constructor( public val bindingContext: BindingContext, public val moduleDescriptor: ModuleDescriptor, public val shouldGenerateCode: Boolean = true ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + return (other is AnalysisResult && bindingContext == other.bindingContext && + moduleDescriptor == other.moduleDescriptor && shouldGenerateCode == other.shouldGenerateCode) + } + + override fun hashCode(): Int { + var result = 17 + result = 29 * result + bindingContext.hashCode() + result = 29 * result + moduleDescriptor.hashCode() + result = 29 * result + shouldGenerateCode.hashCode() + return result + } + + operator fun component1() = bindingContext + + operator fun component2() = moduleDescriptor + + operator fun component3() = shouldGenerateCode + public val error: Throwable get() = if (this is Error) this.exception else throw IllegalStateException("Should only be called for error analysis result")