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
|
var KtFile.suppressDiagnosticsInDebugMode: Boolean
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
is KtCodeFragment -> true
|
is KtCodeFragment -> true
|
||||||
is KtFile -> getUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE) ?: false
|
else -> getUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE) ?: false
|
||||||
else -> false
|
|
||||||
}
|
}
|
||||||
set(skip) {
|
set(skip) {
|
||||||
putUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE, skip)
|
putUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE, skip)
|
||||||
|
|||||||
+1
-2
@@ -350,7 +350,7 @@ private fun FunctionDescriptor.generateDefaultsFunction(context: CommonBackendCo
|
|||||||
/* annotations = */ annotations,
|
/* annotations = */ annotations,
|
||||||
/* isPrimary = */ false,
|
/* isPrimary = */ false,
|
||||||
/* source = */ source)
|
/* source = */ source)
|
||||||
is FunctionDescriptor -> {
|
else -> {
|
||||||
val name = Name.identifier("$name\$default")
|
val name = Name.identifier("$name\$default")
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl.create(
|
SimpleFunctionDescriptorImpl.create(
|
||||||
@@ -360,7 +360,6 @@ private fun FunctionDescriptor.generateDefaultsFunction(context: CommonBackendCo
|
|||||||
/* kind = */ CallableMemberDescriptor.Kind.SYNTHESIZED,
|
/* kind = */ CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||||
/* source = */ source)
|
/* source = */ source)
|
||||||
}
|
}
|
||||||
else -> TODO("FIXME: $this")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val syntheticParameters = MutableList(valueParameters.size / 32 + 1) { i ->
|
val syntheticParameters = MutableList(valueParameters.size / 32 + 1) { i ->
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ class AddVarianceModifierInspection : AbstractKotlinInspection() {
|
|||||||
for (member in klass.declarations + klass.primaryConstructorParameters) {
|
for (member in klass.declarations + klass.primaryConstructorParameters) {
|
||||||
val descriptor = when (member) {
|
val descriptor = when (member) {
|
||||||
is KtParameter -> context.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, member)
|
is KtParameter -> context.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, member)
|
||||||
is KtDeclaration -> context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, member)
|
else -> context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, member)
|
||||||
else -> null
|
|
||||||
} as? MemberDescriptor ?: continue
|
} as? MemberDescriptor ?: continue
|
||||||
when (member) {
|
when (member) {
|
||||||
is KtClassOrObject -> {
|
is KtClassOrObject -> {
|
||||||
|
|||||||
+1
-3
@@ -136,12 +136,10 @@ fun KotlinType.hasTypeParametersToAdd(functionDescriptor: FunctionDescriptor, co
|
|||||||
(functionDescriptor.containingDeclaration as? ClassDescriptorWithResolutionScopes)?.scopeForClassHeaderResolution
|
(functionDescriptor.containingDeclaration as? ClassDescriptorWithResolutionScopes)?.scopeForClassHeaderResolution
|
||||||
}
|
}
|
||||||
|
|
||||||
is FunctionDescriptor -> {
|
else -> {
|
||||||
val function = functionDescriptor.source.getPsi() as? KtFunction
|
val function = functionDescriptor.source.getPsi() as? KtFunction
|
||||||
function?.bodyExpression?.getResolutionScope(context, function.getResolutionFacade())
|
function?.bodyExpression?.getResolutionScope(context, function.getResolutionFacade())
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> null
|
|
||||||
} ?: return true
|
} ?: return true
|
||||||
|
|
||||||
return typeParametersToAdd.any { scope.findClassifier(it.name, NoLookupLocation.FROM_IDE) != it }
|
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> {
|
internal fun KtDeclaration.withHeaderImplementations(): List<KtDeclaration> {
|
||||||
val header = liftToHeader() ?: return listOf(this)
|
val header = liftToHeader() ?: return listOf(this)
|
||||||
val implementations = header.headerImplementations() ?: emptySet()
|
val implementations = header.headerImplementations()
|
||||||
return listOf(header) + implementations
|
return listOf(header) + implementations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ abstract class JsCallDataRenderer : DiagnosticParameterRenderer<JsCallData> {
|
|||||||
override fun render(data: JsCallData, context: RenderingContext): String =
|
override fun render(data: JsCallData, context: RenderingContext): String =
|
||||||
when (data) {
|
when (data) {
|
||||||
is JsCallDataWithCode -> format(data)
|
is JsCallDataWithCode -> format(data)
|
||||||
is JsCallData -> data.message
|
else -> data.message
|
||||||
else -> throw AssertionError("Cannot render null data")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user