mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[kotlin] Use semanticallyEquals instead of KaType.equals
#KTIJ-29056 GitOrigin-RevId: e480355542dc9ae9228b70f4ab581da3a90c069d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
05278c3668
commit
fc832724ee
8
.idea/inspectionProfiles/idea_default.xml
generated
8
.idea/inspectionProfiles/idea_default.xml
generated
@@ -917,14 +917,14 @@
|
|||||||
<constraint name="Expression" nameOfExprType="java\.util\.stream\.Stream" exprTypeWithinHierarchy="true" target="true" within="" contains="" />
|
<constraint name="Expression" nameOfExprType="java\.util\.stream\.Stream" exprTypeWithinHierarchy="true" target="true" within="" contains="" />
|
||||||
<constraint name="params" minCount="0" maxCount="2147483647" within="" contains="" />
|
<constraint name="params" minCount="0" maxCount="2147483647" within="" contains="" />
|
||||||
</searchConfiguration>
|
</searchConfiguration>
|
||||||
<replaceConfiguration name="Call to 'equals()' on KtType" description="Calling `equals` on two types only checks whether the structure of the types is equal, not whether the types are actually equal." suppressId="EqualsOnKtType" text="$lType$ == $rType$" recursive="false" caseInsensitive="true" type="Kotlin" pattern_context="default" reformatAccordingToStyle="false" shortenFQN="false" replacement="$lType$.isEqualTo($rType$)">
|
<replaceConfiguration name="Call to 'equals()' on KaType" description="Calling `equals` on two types only checks whether the structure of the types is equal, not whether the types are actually equal." suppressId="EqualsOnKaType" text="$lType$ == $rType$" recursive="false" caseInsensitive="true" type="Kotlin" pattern_context="default" reformatAccordingToStyle="false" shortenFQN="false" replacement="$lType$.semanticallyEquals($rType$)">
|
||||||
<constraint name="__context__" within="" contains="" />
|
<constraint name="__context__" within="" contains="" />
|
||||||
<constraint name="lType" nameOfExprType="org\.jetbrains\.kotlin\.analysis\.api\.types\.KtType" within="" contains="" />
|
<constraint name="lType" nameOfExprType="org\.jetbrains\.kotlin\.analysis\.api\.types\.KaType" within="" contains="" />
|
||||||
<constraint name="rType" within="" contains="" />
|
<constraint name="rType" within="" contains="" />
|
||||||
</replaceConfiguration>
|
</replaceConfiguration>
|
||||||
<replaceConfiguration name="Call to 'equals()' on KtType" text="$lType$ != $rType$" recursive="false" caseInsensitive="true" type="Kotlin" pattern_context="default" reformatAccordingToStyle="false" shortenFQN="false" replacement="!$lType$.isEqualTo($rType$)">
|
<replaceConfiguration name="Call to 'equals()' on KaType" text="$lType$ != $rType$" recursive="false" caseInsensitive="true" type="Kotlin" pattern_context="default" reformatAccordingToStyle="false" shortenFQN="false" replacement="!$lType$.semanticallyEquals($rType$)">
|
||||||
<constraint name="__context__" within="" contains="" />
|
<constraint name="__context__" within="" contains="" />
|
||||||
<constraint name="lType" nameOfExprType="org\.jetbrains\.kotlin\.analysis\.api\.types\.KtType" within="" contains="" />
|
<constraint name="lType" nameOfExprType="org\.jetbrains\.kotlin\.analysis\.api\.types\.KaType" within="" contains="" />
|
||||||
<constraint name="rType" within="" contains="" />
|
<constraint name="rType" within="" contains="" />
|
||||||
</replaceConfiguration>
|
</replaceConfiguration>
|
||||||
<replaceConfiguration name="can be simplified to ReadAction.compute()" uuid="44cf5267-e665-3ff5-9d2f-0de5c6983156" text="$application$.runReadAction(new $Computable$() { public $SearchScope$ compute() { return $e$; } })" recursive="false" caseInsensitive="true" type="JAVA" reformatAccordingToStyle="true" shortenFQN="true" replacement="com.intellij.openapi.application.ReadAction.compute(()->$e$)">
|
<replaceConfiguration name="can be simplified to ReadAction.compute()" uuid="44cf5267-e665-3ff5-9d2f-0de5c6983156" text="$application$.runReadAction(new $Computable$() { public $SearchScope$ compute() { return $e$; } })" recursive="false" caseInsensitive="true" type="JAVA" reformatAccordingToStyle="true" shortenFQN="true" replacement="com.intellij.openapi.application.ReadAction.compute(()->$e$)">
|
||||||
|
|||||||
@@ -137,11 +137,14 @@ internal class RemoveExplicitTypeIntention :
|
|||||||
val type = typeReference.type
|
val type = typeReference.type
|
||||||
val thenType = initializer.then?.expressionType
|
val thenType = initializer.then?.expressionType
|
||||||
val elseType = initializer.`else`?.expressionType
|
val elseType = initializer.`else`?.expressionType
|
||||||
type == thenType && type == elseType
|
thenType != null && elseType != null && type.semanticallyEquals(thenType) && type.semanticallyEquals(elseType)
|
||||||
}
|
}
|
||||||
is KtWhenExpression -> {
|
is KtWhenExpression -> {
|
||||||
val type = typeReference.type
|
val type = typeReference.type
|
||||||
initializer.entries.all { it.expression?.expressionType == type }
|
initializer.entries.all {
|
||||||
|
val expressionType = it.expression?.expressionType ?: return@all false
|
||||||
|
expressionType.semanticallyEquals(type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// consider types of expressions that the compiler views as constants, e.g. `1 + 2`, as independent
|
// consider types of expressions that the compiler views as constants, e.g. `1 + 2`, as independent
|
||||||
|
|||||||
Reference in New Issue
Block a user