@@ -23,18 +23,21 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
23
23
import org.jetbrains.kotlin.idea.caches.resolve.analyze
24
24
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
25
25
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
26
+ import org.jetbrains.kotlin.name.SpecialNames
26
27
import org.jetbrains.kotlin.psi.*
27
28
import org.jetbrains.kotlin.psi.psiUtil.endOffset
28
29
import org.jetbrains.kotlin.renderer.DescriptorRenderer
29
30
import org.jetbrains.kotlin.renderer.RenderingFormat
30
31
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
31
32
import org.jetbrains.kotlin.types.KotlinType
32
- import org.jetbrains.kotlin.types.isError
33
+ import org.jetbrains.kotlin.types.typeUtil.containsError
34
+ import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes
33
35
34
36
// hack to separate type presentation from param info presentation
35
37
const val TYPE_INFO_PREFIX = " @TYPE@"
36
38
private val typeRenderer = DescriptorRenderer .COMPACT_WITH_SHORT_TYPES .withOptions {
37
39
textFormat = RenderingFormat .PLAIN
40
+ renderUnabbreviatedType = false
38
41
}
39
42
40
43
fun providePropertyTypeHint (elem : PsiElement ): List <InlayInfo > {
@@ -47,8 +50,17 @@ fun providePropertyTypeHint(elem: PsiElement): List<InlayInfo> {
47
50
}
48
51
49
52
fun provideTypeHint (element : KtCallableDeclaration , offset : Int ): List <InlayInfo > {
50
- val type = SpecifyTypeExplicitlyIntention .getTypeForDeclaration(element)
51
- return if (! type.isError && isUnclearType(type, element)) {
53
+ var type: KotlinType = SpecifyTypeExplicitlyIntention .getTypeForDeclaration(element).unwrap()
54
+ if (type.containsError()) return emptyList()
55
+ val name = type.constructor .declarationDescriptor?.name
56
+ if (name == SpecialNames .NO_NAME_PROVIDED ) {
57
+ type = type.immediateSupertypes().singleOrNull() ? : return emptyList()
58
+ }
59
+ else if (name?.isSpecial == true ) {
60
+ return emptyList()
61
+ }
62
+
63
+ return if (isUnclearType(type, element)) {
52
64
val settings = CodeStyleSettingsManager .getInstance(element.project).currentSettings
53
65
.getCustomSettings(KotlinCodeStyleSettings ::class .java)
54
66
0 commit comments