More cleanup: lift return / assignment out

This commit is contained in:
Mikhail Glukhikh
2017-07-07 13:57:36 +03:00
parent 9269de721e
commit dfe2c16bc7
116 changed files with 472 additions and 517 deletions
@@ -79,10 +79,10 @@ private fun chooseMoreSpecific(type1: KotlinType, type2: KotlinType): KotlinType
else -> { // type1IsSubtype && type2IsSubtype
val flexible1 = type1.unwrap() as? FlexibleType
val flexible2 = type2.unwrap() as? FlexibleType
when {
flexible1 != null && flexible2 == null -> return type2
flexible2 != null && flexible1 == null -> return type1
else -> return null //TODO?
return when {
flexible1 != null && flexible2 == null -> type2
flexible2 != null && flexible1 == null -> type1
else -> null //TODO?
}
}
}
@@ -42,11 +42,11 @@ fun <TCallable : CallableDescriptor> TCallable.substituteExtensionIfCallable(
containingDeclarationOrModule: DeclarationDescriptor
): Collection<TCallable> {
val sequence = receivers.asSequence().flatMap { substituteExtensionIfCallable(it, callType, context, dataFlowInfo, containingDeclarationOrModule).asSequence() }
if (typeParameters.isEmpty()) { // optimization for non-generic callables
return sequence.firstOrNull()?.let { listOf(it) } ?: listOf()
return if (typeParameters.isEmpty()) { // optimization for non-generic callables
sequence.firstOrNull()?.let { listOf(it) } ?: listOf()
}
else {
return sequence.toList()
sequence.toList()
}
}
@@ -91,11 +91,11 @@ fun <TCallable : CallableDescriptor> TCallable.substituteExtensionIfCallable(
}
substitutor
}
if (typeParameters.isEmpty()) { // optimization for non-generic callables
return if (substitutors.any()) listOf(this) else listOf()
return if (typeParameters.isEmpty()) { // optimization for non-generic callables
if (substitutors.any()) listOf(this) else listOf()
}
else {
return substitutors
substitutors
.mapNotNull { @Suppress("UNCHECKED_CAST") (substitute(it) as TCallable?) }
.toList()
}