Eliminate some warnings (mostly redundant is checks in whens)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3623f581b8
commit
9dc5354f24
@@ -44,8 +44,7 @@ class AddVarianceModifierInspection : AbstractKotlinInspection() {
|
||||
for (member in klass.declarations + klass.primaryConstructorParameters) {
|
||||
val descriptor = when (member) {
|
||||
is KtParameter -> context.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, member)
|
||||
is KtDeclaration -> context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, member)
|
||||
else -> null
|
||||
else -> context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, member)
|
||||
} as? MemberDescriptor ?: continue
|
||||
when (member) {
|
||||
is KtClassOrObject -> {
|
||||
|
||||
+1
-3
@@ -136,12 +136,10 @@ fun KotlinType.hasTypeParametersToAdd(functionDescriptor: FunctionDescriptor, co
|
||||
(functionDescriptor.containingDeclaration as? ClassDescriptorWithResolutionScopes)?.scopeForClassHeaderResolution
|
||||
}
|
||||
|
||||
is FunctionDescriptor -> {
|
||||
else -> {
|
||||
val function = functionDescriptor.source.getPsi() as? KtFunction
|
||||
function?.bodyExpression?.getResolutionScope(context, function.getResolutionFacade())
|
||||
}
|
||||
|
||||
else -> null
|
||||
} ?: return true
|
||||
|
||||
return typeParametersToAdd.any { scope.findClassifier(it.name, NoLookupLocation.FROM_IDE) != it }
|
||||
|
||||
@@ -968,7 +968,7 @@ fun KtNamedDeclaration.isCompanionMemberOf(klass: KtClassOrObject): Boolean {
|
||||
|
||||
internal fun KtDeclaration.withHeaderImplementations(): List<KtDeclaration> {
|
||||
val header = liftToHeader() ?: return listOf(this)
|
||||
val implementations = header.headerImplementations() ?: emptySet()
|
||||
val implementations = header.headerImplementations()
|
||||
return listOf(header) + implementations
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user