Minor: reformat code

This commit is contained in:
Dmitry Petrov
2018-03-13 14:50:36 +03:00
parent 6675d7814c
commit 3b3cc5233f
@@ -48,14 +48,13 @@ private val RETENTION_PARAMETER_NAME = Name.identifier("value")
fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = companionObjectDescriptor ?: this fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = companionObjectDescriptor ?: this
fun DeclarationDescriptor.getImportableDescriptor(): DeclarationDescriptor { fun DeclarationDescriptor.getImportableDescriptor(): DeclarationDescriptor =
return when { when (this) {
this is TypeAliasConstructorDescriptor -> containingDeclaration is TypeAliasConstructorDescriptor -> containingDeclaration
this is ConstructorDescriptor -> containingDeclaration is ConstructorDescriptor -> containingDeclaration
this is PropertyAccessorDescriptor -> correspondingProperty is PropertyAccessorDescriptor -> correspondingProperty
else -> this else -> this
} }
}
val DeclarationDescriptor.fqNameUnsafe: FqNameUnsafe val DeclarationDescriptor.fqNameUnsafe: FqNameUnsafe
get() = DescriptorUtils.getFqName(this) get() = DescriptorUtils.getFqName(this)
@@ -71,7 +70,10 @@ val DeclarationDescriptor.module: ModuleDescriptor
fun ModuleDescriptor.resolveTopLevelClass(topLevelClassFqName: FqName, location: LookupLocation): ClassDescriptor? { fun ModuleDescriptor.resolveTopLevelClass(topLevelClassFqName: FqName, location: LookupLocation): ClassDescriptor? {
assert(!topLevelClassFqName.isRoot) assert(!topLevelClassFqName.isRoot)
return getPackage(topLevelClassFqName.parent()).memberScope.getContributedClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor return getPackage(topLevelClassFqName.parent()).memberScope.getContributedClassifier(
topLevelClassFqName.shortName(),
location
) as? ClassDescriptor
} }
val ClassifierDescriptorWithTypeParameters.denotedClassDescriptor: ClassDescriptor? val ClassifierDescriptorWithTypeParameters.denotedClassDescriptor: ClassDescriptor?
@@ -250,6 +252,7 @@ fun CallableMemberDescriptor.firstOverridden(
result = current result = current
} }
} }
override fun result(): CallableMemberDescriptor? = result override fun result(): CallableMemberDescriptor? = result
} }
) )
@@ -356,10 +359,11 @@ fun ClassifierDescriptor.getAllSuperClassifiers(): Sequence<ClassifierDescriptor
fun ClassifierDescriptor.doGetAllSuperClassesAndInterfaces(): Sequence<ClassifierDescriptor> = fun ClassifierDescriptor.doGetAllSuperClassesAndInterfaces(): Sequence<ClassifierDescriptor> =
if (original in set) { if (original in set) {
emptySequence() emptySequence()
} } else {
else {
set += original set += original
sequenceOf(original) + typeConstructor.supertypes.asSequence().flatMap { it.constructor.declarationDescriptor?.doGetAllSuperClassesAndInterfaces() ?: sequenceOf() } sequenceOf(original) + typeConstructor.supertypes.asSequence().flatMap {
it.constructor.declarationDescriptor?.doGetAllSuperClassesAndInterfaces() ?: sequenceOf()
}
} }
return doGetAllSuperClassesAndInterfaces() return doGetAllSuperClassesAndInterfaces()
@@ -400,8 +404,8 @@ fun DeclarationDescriptor.isPublishedApi(): Boolean {
return descriptor.annotations.hasAnnotation(KotlinBuiltIns.FQ_NAMES.publishedApi) return descriptor.annotations.hasAnnotation(KotlinBuiltIns.FQ_NAMES.publishedApi)
} }
fun DeclarationDescriptor.isAncestorOf(descriptor: DeclarationDescriptor, strict: Boolean): Boolean fun DeclarationDescriptor.isAncestorOf(descriptor: DeclarationDescriptor, strict: Boolean): Boolean =
= DescriptorUtils.isAncestor(this, descriptor, strict) DescriptorUtils.isAncestor(this, descriptor, strict)
fun DeclarationDescriptor.isCompanionObject(): Boolean = DescriptorUtils.isCompanionObject(this) fun DeclarationDescriptor.isCompanionObject(): Boolean = DescriptorUtils.isCompanionObject(this)
@@ -422,7 +426,8 @@ fun MemberDescriptor.isEffectivelyExternal(): Boolean {
if (this is PropertyDescriptor) { if (this is PropertyDescriptor) {
if (getter?.isExternal == true && if (getter?.isExternal == true &&
(!isVar || setter?.isExternal == true)) return true (!isVar || setter?.isExternal == true)
) return true
} }
val containingClass = getContainingClass(this) val containingClass = getContainingClass(this)