FIR2IR: Fix "expected FirResolvedTypeRef but was FirJavaTypeRef" crash
The problem was that we were using unenhanced constructors that still might contain java type refs. Basically, most of the `firClass.declarations` usages are unsafe in that meaning. The test is very complicated because to reproduce the exception there should be some conditions met: - MyClass should be compiled with K1, so it has `@EnhancedNullability` annotation serialized (that is unnecessary, but don't do any harm) - `@Nls` scope should be properly resolved, so enum entries are converted to resolved type refs - That leads to attempt to check if null-check might be needed to be inserted and to failure at FirTypeUtilsKt.getCanBeNull While this quite controversial to have this check being performed for freshly created annotations calls, the problem with improper constructor lookup anyway existed and fixed correctly. ^KT-57213 Fixed
This commit is contained in:
committed by
Space Team
parent
a643dfbe83
commit
9c2c11f7e9
+25
@@ -0,0 +1,25 @@
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE, ElementType.TYPE, ElementType.PACKAGE})
|
||||
public @interface Nls {
|
||||
enum Capitalization {
|
||||
|
||||
NotSpecified,
|
||||
/**
|
||||
* e.g. This Is a Title
|
||||
*/
|
||||
Title,
|
||||
/**
|
||||
* e.g. This is a sentence
|
||||
*/
|
||||
Sentence
|
||||
}
|
||||
|
||||
Capitalization capitalization() default Capitalization.NotSpecified;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
class MyClass(val name: @Nls(capitalization = Nls.Capitalization.Title) String)
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/deserializedAnnotationReferencesJava/output.txt
Vendored
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
// This class is only needed to force resolution of `@Nls` scope, so its types would be converted to resolved
|
||||
class LocalClassToUseAnnotation(val name: @Nls(capitalization = Nls.Capitalization.Title) String)
|
||||
|
||||
return MyClass("OK").name
|
||||
}
|
||||
Reference in New Issue
Block a user