Can be replaced with binary operator: do not suggest when receiver or argument is floating point type
#KT-28596 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
48619a49ed
commit
d583c1be58
+4
-3
@@ -25,7 +25,8 @@ fun KtExpression?.getKotlinTypeWithPossibleSmartCastToFP(
|
||||
bindingContext: BindingContext,
|
||||
descriptor: DeclarationDescriptor?,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
dataFlowValueFactory: DataFlowValueFactory
|
||||
dataFlowValueFactory: DataFlowValueFactory,
|
||||
defaultType: (KotlinType, Set<KotlinType>) -> KotlinType = { givenType, _ -> givenType }
|
||||
): KotlinType? {
|
||||
val givenType = this?.getKotlinTypeForComparison(bindingContext) ?: return null
|
||||
|
||||
@@ -40,13 +41,13 @@ fun KtExpression?.getKotlinTypeWithPossibleSmartCastToFP(
|
||||
if (descriptor != null) {
|
||||
val dataFlow = dataFlowValueFactory.createDataFlowValue(this, givenType, bindingContext, descriptor)
|
||||
val stableTypes = bindingContext.getDataFlowInfoBefore(this).getStableTypes(dataFlow, languageVersionSettings)
|
||||
stableTypes.firstNotNullResult {
|
||||
return stableTypes.firstNotNullResult {
|
||||
when {
|
||||
KotlinBuiltIns.isDoubleOrNullableDouble(it) -> it
|
||||
KotlinBuiltIns.isFloatOrNullableFloat(it) -> it
|
||||
else -> null
|
||||
}
|
||||
}?.let { return it }
|
||||
} ?: defaultType(givenType, stableTypes)
|
||||
}
|
||||
return givenType
|
||||
}
|
||||
Reference in New Issue
Block a user