Skip to content

Commit 345abae

Browse files
author
Vlad Vladov
committed
Fix error with LiteralExpression
1 parent 3f50c4c commit 345abae

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/main/kotlin/space/whitememory/pythoninlayparams/types/AbstractPythonInlayTypeHintsCollector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class AbstractPythonInlayTypeHintsCollector(editor: Editor) :
4343
separator: String = " | ",
4444
limit: Int? = 3
4545
): InlayPresentation {
46-
val convertedInlayInfoDetails = infoDetails.map { getInlayPresentationForInlayInfoDetails(it) }
46+
val convertedInlayInfoDetails = infoDetails.distinct().map { getInlayPresentationForInlayInfoDetails(it) }
4747

4848
return factory.seq(*separatePresentation(convertedInlayInfoDetails, separator, limit).toTypedArray())
4949
}

src/main/kotlin/space/whitememory/pythoninlayparams/types/hints/HintGenerator.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,20 @@ data class InlayInfoDetails(
252252
sealed class InlayInfoDetail(val text: String)
253253

254254
class TextInlayInfoDetail(text: String) : InlayInfoDetail(text)
255-
class PsiInlayInfoDetail(text: String, val element: PsiElement) : InlayInfoDetail(text)
255+
class PsiInlayInfoDetail(text: String, val element: PsiElement) : InlayInfoDetail(text) {
256+
override fun equals(other: Any?): Boolean {
257+
if (this === other) return true
258+
259+
if (other !is PsiInlayInfoDetail) return false
260+
261+
if (text != other.text) return false
262+
263+
if (element != other.element) return false
264+
265+
return true
266+
}
267+
268+
override fun hashCode(): Int {
269+
return element.hashCode()
270+
}
271+
}

0 commit comments

Comments
 (0)