FIR checker: fix JAVA_TYPE_MISMATCH again
This commit is contained in:
committed by
TeamCityServer
parent
64ebddcbc6
commit
b77dc4136b
+6
@@ -21700,6 +21700,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kotlinStarProjection.kt")
|
||||||
|
public void testKotlinStarProjection() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinStarProjection.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("listSuperType.kt")
|
@TestMetadata("listSuperType.kt")
|
||||||
public void testListSuperType() throws Exception {
|
public void testListSuperType() throws Exception {
|
||||||
|
|||||||
+6
@@ -21700,6 +21700,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kotlinStarProjection.kt")
|
||||||
|
public void testKotlinStarProjection() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinStarProjection.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("listSuperType.kt")
|
@TestMetadata("listSuperType.kt")
|
||||||
public void testListSuperType() throws Exception {
|
public void testListSuperType() throws Exception {
|
||||||
|
|||||||
+3
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.analysis.jvm.checkers.expression
|
package org.jetbrains.kotlin.fir.analysis.jvm.checkers.expression
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.PrimitiveTypes
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker
|
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||||
@@ -162,10 +163,10 @@ object FirJavaGenericVarianceViolationTypeChecker : FirFunctionCallChecker() {
|
|||||||
return when (this) {
|
return when (this) {
|
||||||
is ConeKotlinTypeProjectionOut -> if (positive) type else this
|
is ConeKotlinTypeProjectionOut -> if (positive) type else this
|
||||||
is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn(type.removeOutProjection(!positive))
|
is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn(type.removeOutProjection(!positive))
|
||||||
|
is ConeStarProjection -> if (positive) PrimitiveTypes.Any else this
|
||||||
// Don't remove nested projections for types at invariant position.
|
// Don't remove nested projections for types at invariant position.
|
||||||
is ConeKotlinTypeConflictingProjection,
|
is ConeKotlinTypeConflictingProjection,
|
||||||
is ConeKotlinType,
|
is ConeKotlinType -> this
|
||||||
is ConeStarProjection -> this
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ object PrimitiveTypes {
|
|||||||
val Long: ConeClassLikeType = StandardClassIds.Long.createType()
|
val Long: ConeClassLikeType = StandardClassIds.Long.createType()
|
||||||
val Float: ConeClassLikeType = StandardClassIds.Float.createType()
|
val Float: ConeClassLikeType = StandardClassIds.Float.createType()
|
||||||
val Double: ConeClassLikeType = StandardClassIds.Double.createType()
|
val Double: ConeClassLikeType = StandardClassIds.Double.createType()
|
||||||
|
|
||||||
|
val Any: ConeClassLikeType = StandardClassIds.Any.createType()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ClassId.createType(): ConeClassLikeType =
|
private fun ClassId.createType(): ConeClassLikeType =
|
||||||
|
|||||||
Vendored
+37
@@ -0,0 +1,37 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
void foo(List<Object> x) {}
|
||||||
|
<T> void foo2(List<T> x) {}
|
||||||
|
void foo3(Collection<? extends Object> x) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.java
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class B<T> {
|
||||||
|
public B(Collection<T> c) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun test(a: A) {
|
||||||
|
a.foo(bar())
|
||||||
|
a.foo2(bar())
|
||||||
|
a.foo3(bar())
|
||||||
|
B(bar())
|
||||||
|
a.foo(<!JAVA_TYPE_MISMATCH!>bar2()<!>)
|
||||||
|
a.foo2(bar2())
|
||||||
|
a.foo3(bar2())
|
||||||
|
B(bar2())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(): MutableList<*> = TODO()
|
||||||
|
fun bar2(): MutableList<MutableList<*>> = TODO()
|
||||||
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun bar(): kotlin.collections.MutableList<*>
|
||||||
|
public fun bar2(): kotlin.collections.MutableList<kotlin.collections.MutableList<*>>
|
||||||
|
public fun test(/*0*/ a: A): kotlin.Unit
|
||||||
|
|
||||||
|
public open class A {
|
||||||
|
public constructor A()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)List<kotlin.Any!>!): kotlin.Unit
|
||||||
|
public/*package*/ open fun </*0*/ T : kotlin.Any!> foo2(/*0*/ x: kotlin.collections.(Mutable)List<T!>!): kotlin.Unit
|
||||||
|
public/*package*/ open fun foo3(/*0*/ x: (kotlin.collections.MutableCollection<out kotlin.Any!>..kotlin.collections.Collection<kotlin.Any!>?)): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class B</*0*/ T : kotlin.Any!> {
|
||||||
|
public constructor B</*0*/ T : kotlin.Any!>(/*0*/ c: kotlin.collections.(Mutable)Collection<T!>!)
|
||||||
|
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
@@ -21706,6 +21706,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kotlinStarProjection.kt")
|
||||||
|
public void testKotlinStarProjection() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinStarProjection.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("listSuperType.kt")
|
@TestMetadata("listSuperType.kt")
|
||||||
public void testListSuperType() throws Exception {
|
public void testListSuperType() throws Exception {
|
||||||
|
|||||||
+6
@@ -21700,6 +21700,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinOutProjection.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kotlinStarProjection.kt")
|
||||||
|
public void testKotlinStarProjection() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/genericVarianceViolation/kotlinStarProjection.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("listSuperType.kt")
|
@TestMetadata("listSuperType.kt")
|
||||||
public void testListSuperType() throws Exception {
|
public void testListSuperType() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user