From db3e0798c80f4e42f0ec1c82f4a879b56df3f697 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 9 Jun 2016 16:38:47 +0300 Subject: [PATCH] Minor, move the Lombok hack a bit higher --- .../kotlin/load/java/structure/impl/JavaClassImpl.java | 6 ++++-- .../impl/JavaElementCollectionFromPsiArrayUtil.java | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java index 618a8ea940b..84057adc231 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.structure.impl; import com.intellij.psi.*; import kotlin.collections.ArraysKt; +import kotlin.collections.CollectionsKt; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -96,13 +97,14 @@ public class JavaClassImpl extends JavaClassifierImpl implements JavaC @Override @NotNull public Collection getMethods() { - return methods(ArraysKt.filter(getPsi().getMethods(), new Function1() { + // We apply distinct here because PsiClass#getMethods() can return duplicate PSI methods, for example in Lombok (see KT-11778) + return CollectionsKt.distinct(methods(ArraysKt.filter(getPsi().getMethods(), new Function1() { @Override public Boolean invoke(PsiMethod method) { // Return type seems to be null for example for the 'clone' Groovy method generated by @AutoClone (see EA-73795) return !method.isConstructor() && method.getReturnType() != null; } - })); + }))); } @Override diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementCollectionFromPsiArrayUtil.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementCollectionFromPsiArrayUtil.java index b0cdd1b75a5..6ae40fefe3a 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementCollectionFromPsiArrayUtil.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementCollectionFromPsiArrayUtil.java @@ -131,8 +131,7 @@ public class JavaElementCollectionFromPsiArrayUtil { private static List convert(@NotNull Iterable elements, @NotNull final Factory factory) { if (!elements.iterator().hasNext()) return Collections.emptyList(); - // we apply distinct here, because sometimes PsiClass#getMethods() and others can give us duplicate psi methods. see KT-11778. - return CollectionsKt.map(CollectionsKt.distinct(elements), new Function1() { + return CollectionsKt.map(elements, new Function1() { @Override public Java invoke(Psi psi) { return factory.create(psi);