Skip to content

Commit b95677e

Browse files
committed
Fix MixinClassCastInspectionSuppressor for pattern match instanceof and architectury projects
1 parent ad3304a commit b95677e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/main/kotlin/platform/mixin/inspection/suppress/MixinClassCastInspectionSuppressor.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import com.intellij.psi.PsiExpression
3939
import com.intellij.psi.PsiInstanceOfExpression
4040
import com.intellij.psi.PsiType
4141
import com.intellij.psi.PsiTypeCastExpression
42+
import com.intellij.psi.PsiTypeTestPattern
4243
import com.intellij.psi.util.PsiUtil
4344

4445
/**
@@ -54,7 +55,9 @@ class MixinClassCastInspectionSuppressor : InspectionSuppressor {
5455

5556
// check instanceof
5657
if (element is PsiInstanceOfExpression) {
57-
val castType = element.checkType?.type ?: return false
58+
val castType = element.checkType?.type
59+
?: (element.pattern as? PsiTypeTestPattern)?.checkType?.type
60+
?: return false
5861
var operand = PsiUtil.skipParenthesizedExprDown(element.operand) ?: return false
5962
while (operand is PsiTypeCastExpression) {
6063
operand = PsiUtil.skipParenthesizedExprDown(operand.operand) ?: return false

src/main/kotlin/platform/mixin/util/Mixin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fun isAssignable(left: PsiType, right: PsiType): Boolean {
201201
private fun isClassAssignable(leftClass: PsiClass, rightClass: PsiClass): Boolean {
202202
var result = false
203203
InheritanceUtil.processSupers(rightClass, true) {
204-
if (it == leftClass) {
204+
if (it.qualifiedName == leftClass.qualifiedName) {
205205
result = true
206206
false
207207
} else {

0 commit comments

Comments
 (0)