FIR: Do not mark not found classes' based types from Java as error
The same happens in FE1.0
This commit is contained in:
committed by
TeamCityServer
parent
201dded237
commit
4892ad42b9
+6
@@ -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 {
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
+1
-1
@@ -75,5 +75,5 @@ fun test() {
|
||||
}
|
||||
// TODO: FIR
|
||||
// {AbstractAssert<*, out Any!>! & EnumerableAssert<*, {Comparable<*> & java.io.Serializable!}>!} with unfolded flexible nullability
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("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<kotlin.String & kotlin.Char> & java.io.Serializable..kotlin.Comparable<kotlin.String & kotlin.Char>? & 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<kotlin.String & kotlin.Char> & java.io.Serializable..kotlin.Comparable<kotlin.String & kotlin.Char>? & java.io.Serializable?>?")!>assertion<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("AbstractAssert<*, out kotlin.Any..kotlin.Any?!> & EnumerableAssert<*, out kotlin.Comparable<kotlin.String & kotlin.Char> & java.io.Serializable..kotlin.Comparable<kotlin.String & kotlin.Char>? & java.io.Serializable?>..AbstractAssert<*, out kotlin.Any..kotlin.Any?!>? & EnumerableAssert<*, out kotlin.Comparable<kotlin.String & kotlin.Char> & java.io.Serializable..kotlin.Comparable<kotlin.String & kotlin.Char>? & java.io.Serializable?>?")!>assertion<!>
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ fun main() {
|
||||
a.baz(listOf())
|
||||
|
||||
a.manyParams(null)
|
||||
a.manyParams(any<kotlin.jvm.functions.FunctionN<Unit>>())
|
||||
a.<!NONE_APPLICABLE!>manyParams<!>(any<kotlin.jvm.functions.FunctionN<Unit>>())
|
||||
|
||||
// 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
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user