From e500093c4345c5adfc6aa95dc504b2ed288e80bf Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Wed, 6 Feb 2019 17:22:57 +0300 Subject: [PATCH] [groovy] #equals and #hashCode for DefaultConstructor as per CachedValue documentation --- .../psi/impl/synthetic/DefaultConstructor.kt | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/DefaultConstructor.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/DefaultConstructor.kt index fc345eec6fb6..e67c4e48958e 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/DefaultConstructor.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/DefaultConstructor.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic import com.intellij.psi.* @@ -65,7 +65,9 @@ class DefaultConstructor( override fun isVarArgs(): Boolean = false - override fun getSignature(substitutor: PsiSubstitutor): MethodSignatureBackedByPsiMethod = MethodSignatureBackedByPsiMethod.create(this, substitutor) + override fun getSignature(substitutor: PsiSubstitutor): MethodSignatureBackedByPsiMethod { + return MethodSignatureBackedByPsiMethod.create(this, substitutor) + } override fun getHierarchicalMethodSignature(): HierarchicalMethodSignature = getHierarchicalMethodSignature(this) @@ -81,7 +83,7 @@ class DefaultConstructor( override fun findSuperMethods(parentClass: PsiClass?): Array = PsiMethod.EMPTY_ARRAY - override fun findSuperMethodSignaturesIncludingStatic(checkAccess: Boolean): List = emptyList() + override fun findSuperMethodSignaturesIncludingStatic(checkAccess: Boolean): List = emptyList() override fun findDeepestSuperMethods(): Array = PsiMethod.EMPTY_ARRAY @@ -91,4 +93,19 @@ class DefaultConstructor( override fun findDeepestSuperMethod(): PsiMethod? = null override fun setName(name: String): PsiElement = throw IncorrectOperationException("setName() isn't supported") -} \ No newline at end of file + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as DefaultConstructor + + if (myConstructedClass != other.myConstructedClass) return false + + return true + } + + override fun hashCode(): Int { + return myConstructedClass.hashCode() + } +}