diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 1ba8387c2d7..82f859d26d0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -22388,6 +22388,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/javaInterop/lambdaInstanceOf.kt"); } + @Test + @TestMetadata("notFoundClasses.kt") + public void testNotFoundClasses() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); + } + @Test @TestMetadata("protectedField.kt") public void testProtectedField() throws Exception { diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt index ca57447ba56..ae08861ad9f 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt @@ -12,8 +12,13 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirBuilderDsl -import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.diagnostics.* +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.diagnostics.ConeIntermediateDiagnostic +import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic +import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.builder.* import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass @@ -456,6 +461,12 @@ private fun JavaClassifierType.toConeKotlinTypeForFlexibleBound( val symbol = javaTypeParameterStack[classifier] ConeTypeParameterTypeImpl(symbol.toLookupTag(), isNullable = !isLowerBound) } + null -> { + val classId = ClassId.topLevel(FqName(this.classifierQualifiedName)) + ConeClassLikeLookupTagImpl(classId).constructClassType( + emptyArray(), isNullable = !isLowerBound, attributes, + ) + } else -> ConeKotlinErrorType(ConeSimpleDiagnostic("Unexpected classifier: $classifier", DiagnosticKind.Java)) } } diff --git a/compiler/testData/codegen/box/javaInterop/notFoundClasses.kt b/compiler/testData/codegen/box/javaInterop/notFoundClasses.kt new file mode 100644 index 00000000000..4ee2cbf0a6e --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notFoundClasses.kt @@ -0,0 +1,42 @@ +// TARGET_BACKEND: JVM + +// MODULE: old +// FILE: test2/Row.java + +package test2; + +public interface Row { + String res(); +} + +// MODULE: new(old) + +// FILE: test1/Row.java +package test1; + +public interface Row { + String res(); +} + +// FILE: JavaClass.java + +public class JavaClass { + public static test1.Row foo() { + return new test1.Row() { + @Override + public String res() { + return "OK"; + } + }; + } + + public static String bar(test1.Row y) { return y.res(); } + public static String bar(test2.Row y) { return y.res(); } +} + +// MODULE: main(new) +// FILE: main.kt +fun box(): String { + val r = JavaClass.foo() + return JavaClass.bar(r) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.fir.kt index 74d1efb30f0..de73553daf9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.fir.kt @@ -75,5 +75,5 @@ fun test() { } // TODO: FIR // {AbstractAssert<*, out Any!>! & EnumerableAssert<*, {Comparable<*> & java.io.Serializable!}>!} with unfolded flexible nullability - & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>..AbstractAssert<*, out ERROR CLASS: CST(ERROR CLASS: Unexpected classifier: null, kotlin/String..ERROR CLASS: CST(ERROR CLASS: Unexpected classifier: null, kotlin/String?!>? & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>?")!>assertion + & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>..AbstractAssert<*, out kotlin.Any..kotlin.Any?!>? & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>?")!>assertion } diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/functionN.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/functionN.fir.kt index 6f3227c76ac..0d24f1a4e8a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/functionN.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/functionN.fir.kt @@ -47,7 +47,7 @@ fun main() { a.baz(listOf()) a.manyParams(null) - a.manyParams(any>()) + a.manyParams(any>()) // Potentially, this would have better to forbid calling manyParams, too. // But it might be complicated because we need to match that it is an override diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index a835ae4bb13..9c9ad346b81 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -22346,6 +22346,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/javaInterop/lambdaInstanceOf.kt"); } + @Test + @TestMetadata("notFoundClasses.kt") + public void testNotFoundClasses() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); + } + @Test @TestMetadata("protectedField.kt") public void testProtectedField() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 94455b9d2e7..127c56eaaf0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -22388,6 +22388,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/javaInterop/lambdaInstanceOf.kt"); } + @Test + @TestMetadata("notFoundClasses.kt") + public void testNotFoundClasses() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); + } + @Test @TestMetadata("protectedField.kt") public void testProtectedField() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 1711a6378eb..460ccf498c7 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -18718,6 +18718,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/javaInterop/lambdaInstanceOf.kt"); } + @TestMetadata("notFoundClasses.kt") + public void testNotFoundClasses() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); + } + @TestMetadata("protectedField.kt") public void testProtectedField() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/protectedField.kt");