Skip to content

Commit f4cb5c6

Browse files
committed
Don't exclude properties for sealed classes either
1 parent aabf0a4 commit f4cb5c6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

server/src/main/kotlin/org/javacs/kt/completion/Completions.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ private fun completeMembers(file: CompiledFile, cursor: Int, receiverExpr: KtExp
365365
val extensions = extensionFunctions(lexicalScope).filter { isExtensionFor(receiverType, it) }
366366
descriptors = members + extensions
367367

368-
if (!isCompanionOfEnum(receiverType)) {
368+
if (!isCompanionOfEnum(receiverType) && !isCompanionOfSealed(receiverType)) {
369369
return descriptors
370370
}
371371
}
@@ -393,6 +393,16 @@ private fun isCompanionOfEnum(kotlinType: KotlinType): Boolean {
393393
return DescriptorUtils.isEnumClass(classDescriptor?.containingDeclaration)
394394
}
395395

396+
private fun isCompanionOfSealed(kotlinType: KotlinType): Boolean {
397+
val classDescriptor = TypeUtils.getClassDescriptor(kotlinType)
398+
val isCompanion = DescriptorUtils.isCompanionObject(classDescriptor)
399+
if (!isCompanion) {
400+
return false
401+
}
402+
403+
return DescriptorUtils.isSealedClass(classDescriptor?.containingDeclaration)
404+
}
405+
396406
private fun findPartialIdentifier(file: CompiledFile, cursor: Int): String {
397407
val line = file.lineBefore(cursor)
398408
if (line.matches(Regex(".*\\."))) return ""

0 commit comments

Comments
 (0)