FIR: suppress excessive warning on java Class
The root cause is https://youtrack.jetbrains.com/issue/KT-49358 though. We should undo this change after that issue is fixed.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3f2c86afb8
commit
31b7248769
+6
@@ -32575,6 +32575,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnClass.kt")
|
||||
public void testWhenOnClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenOnClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnNothing.kt")
|
||||
public void testWhenOnNothing() throws Exception {
|
||||
|
||||
+6
@@ -32575,6 +32575,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnClass.kt")
|
||||
public void testWhenOnClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenOnClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnNothing.kt")
|
||||
public void testWhenOnNothing() throws Exception {
|
||||
|
||||
+6
@@ -32575,6 +32575,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnClass.kt")
|
||||
public void testWhenOnClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenOnClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnNothing.kt")
|
||||
public void testWhenOnNothing() throws Exception {
|
||||
|
||||
+6
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
@@ -45,6 +46,8 @@ import org.jetbrains.kotlin.types.Variance
|
||||
*/
|
||||
object ConeTypeCompatibilityChecker {
|
||||
|
||||
private val javaClassClassId = ClassId.fromString("java/lang/Class")
|
||||
|
||||
/**
|
||||
* The result returned by [ConeTypeCompatibilityChecker]. Note the order of enum entries matters.
|
||||
*/
|
||||
@@ -146,6 +149,9 @@ object ConeTypeCompatibilityChecker {
|
||||
|
||||
if (upperBounds.size < 2) return Compatibility.COMPATIBLE
|
||||
|
||||
// TODO: Due to KT-49358, we skip any checks on Java class.
|
||||
if (upperBounds.any { it.classId == javaClassClassId }) return Compatibility.COMPATIBLE
|
||||
|
||||
// Base types are compatible. Now we check type parameters.
|
||||
|
||||
val typeArgumentMapping = mutableMapOf<FirTypeParameterSymbol, BoundTypeArguments>().apply {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// FIR_IDENTICAL
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
interface A
|
||||
interface B : A
|
||||
interface C
|
||||
|
||||
fun test1(a: A) {
|
||||
when (a.javaClass) {
|
||||
A::class.java -> {}
|
||||
B::class.java -> {}
|
||||
C::class.java -> {}
|
||||
Any::class.java -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
class Foo : B
|
||||
class Bar
|
||||
|
||||
fun test2(f: Foo) {
|
||||
when (f.javaClass) {
|
||||
Foo::class.java -> {}
|
||||
Bar::class.java -> {}
|
||||
A::class.java -> {}
|
||||
B::class.java -> {}
|
||||
C::class.java -> {}
|
||||
Any::class.java -> {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package
|
||||
|
||||
public fun test1(/*0*/ a: A): kotlin.Unit
|
||||
public fun test2(/*0*/ f: Foo): kotlin.Unit
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B : A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Bar {
|
||||
public constructor Bar()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface C {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Foo : B {
|
||||
public constructor Foo()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Generated
+6
@@ -32671,6 +32671,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnClass.kt")
|
||||
public void testWhenOnClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/whenOnClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenOnNothing.kt")
|
||||
public void testWhenOnNothing() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user