JS: fix exception in JS front-end when checking JsName that was resolved with errors
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
// !DIAGNOSTICS: -NO_VALUE_FOR_PARAMETER, -CONSTANT_EXPECTED_TYPE_MISMATCH
|
||||
// This should not crash, see KT-14752
|
||||
package foo
|
||||
|
||||
@JsName fun foo(x: Int) = x
|
||||
|
||||
@JsName(23) fun bar(x: Int) = x
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
package foo {
|
||||
@kotlin.js.JsName(name = 23) public fun bar(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
@kotlin.js.JsName public fun foo(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
}
|
||||
@@ -386,6 +386,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("jsNameWithoutParameter.kt")
|
||||
public void testJsNameWithoutParameter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameWithoutParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("methodAndMethod.kt")
|
||||
public void testMethodAndMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndMethod.kt");
|
||||
|
||||
@@ -119,13 +119,14 @@ public final class AnnotationsUtils {
|
||||
@Nullable
|
||||
public static String getJsName(@NotNull DeclarationDescriptor descriptor) {
|
||||
AnnotationDescriptor annotation = getJsNameAnnotation(descriptor);
|
||||
if (annotation == null) return null;
|
||||
if (annotation == null || annotation.getAllValueArguments().isEmpty()) return null;
|
||||
|
||||
ConstantValue<?> value = annotation.getAllValueArguments().values().iterator().next();
|
||||
assert value != null : "JsName annotation should always declare string parameter";
|
||||
if (value == null) return null;
|
||||
|
||||
Object result = value.getValue();
|
||||
assert result instanceof String : "Parameter of JsName annotation should be string";
|
||||
if (!(result instanceof String)) return null;
|
||||
|
||||
return (String) result;
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@ public final class AnnotationsUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasAnnotationOrInsideAnnotatedClass(
|
||||
private static boolean hasAnnotationOrInsideAnnotatedClass(
|
||||
@NotNull DeclarationDescriptor descriptor,
|
||||
@NotNull PredefinedAnnotation annotation
|
||||
) {
|
||||
|
||||
@@ -7082,6 +7082,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt13557.kt")
|
||||
public void testKt13557() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/local/kt13557.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localVal.kt")
|
||||
public void testLocalVal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/local/localVal.kt");
|
||||
|
||||
Reference in New Issue
Block a user