Eliminate some warnings (mostly redundant is checks in whens)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3623f581b8
commit
9dc5354f24
@@ -38,8 +38,7 @@ fun KtElement.suppressDiagnosticsInDebugMode(): Boolean {
|
||||
var KtFile.suppressDiagnosticsInDebugMode: Boolean
|
||||
get() = when (this) {
|
||||
is KtCodeFragment -> true
|
||||
is KtFile -> getUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE) ?: false
|
||||
else -> false
|
||||
else -> getUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE) ?: false
|
||||
}
|
||||
set(skip) {
|
||||
putUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE, skip)
|
||||
|
||||
+1
-2
@@ -350,7 +350,7 @@ private fun FunctionDescriptor.generateDefaultsFunction(context: CommonBackendCo
|
||||
/* annotations = */ annotations,
|
||||
/* isPrimary = */ false,
|
||||
/* source = */ source)
|
||||
is FunctionDescriptor -> {
|
||||
else -> {
|
||||
val name = Name.identifier("$name\$default")
|
||||
|
||||
SimpleFunctionDescriptorImpl.create(
|
||||
@@ -360,7 +360,6 @@ private fun FunctionDescriptor.generateDefaultsFunction(context: CommonBackendCo
|
||||
/* kind = */ CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
/* source = */ source)
|
||||
}
|
||||
else -> TODO("FIXME: $this")
|
||||
}
|
||||
|
||||
val syntheticParameters = MutableList(valueParameters.size / 32 + 1) { i ->
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ abstract class JsCallDataRenderer : DiagnosticParameterRenderer<JsCallData> {
|
||||
override fun render(data: JsCallData, context: RenderingContext): String =
|
||||
when (data) {
|
||||
is JsCallDataWithCode -> format(data)
|
||||
is JsCallData -> data.message
|
||||
else -> throw AssertionError("Cannot render null data")
|
||||
else -> data.message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user