From 482c87a5a78ad13d2732490815f34e3eadb26825 Mon Sep 17 00:00:00 2001 From: tangzx Date: Thu, 24 Aug 2017 15:26:29 +0800 Subject: [PATCH] optimize tostring --- src/main/java/com/tang/intellij/lua/ty/Ty.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tang/intellij/lua/ty/Ty.kt b/src/main/java/com/tang/intellij/lua/ty/Ty.kt index 016cee395..da3eaf962 100644 --- a/src/main/java/com/tang/intellij/lua/ty/Ty.kt +++ b/src/main/java/com/tang/intellij/lua/ty/Ty.kt @@ -89,10 +89,16 @@ abstract class Ty(override val kind: TyKind) : ITy { override fun toString(): String { val list = mutableListOf() - TyUnion.each(this) { - if (!it.isAnonymous) + TyUnion.each(this) { //尽量不使用Global + if (!it.isAnonymous && !(it is ITyClass && it.hasFlag(TyFlags.GLOBAL))) list.add(it.displayName) } + if (list.isEmpty()) { //使用Global + TyUnion.each(this) { + if (!it.isAnonymous && (it is ITyClass && it.hasFlag(TyFlags.GLOBAL))) + list.add(it.displayName) + } + } return list.joinToString("|") }