From 9b065a89b9f7dced2188d5212731326c89e9da7a Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Tue, 16 Sep 2014 14:14:48 +0400 Subject: [PATCH] JS backend: fix annotation class compilation. --- .../k2js/test/semantics/AnnotationTest.java | 29 +++++++++++++++++++ .../k2js/translate/context/Namer.java | 1 - .../annotation/cases/annotationClass.kt | 9 ++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 js/js.tests/test/org/jetbrains/k2js/test/semantics/AnnotationTest.java create mode 100644 js/js.translator/testData/annotation/cases/annotationClass.kt diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/AnnotationTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/AnnotationTest.java new file mode 100644 index 00000000000..9e6cf67cc5f --- /dev/null +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/AnnotationTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.test.semantics; + +import org.jetbrains.k2js.test.SingleFileTranslationTest; + +public class AnnotationTest extends SingleFileTranslationTest { + public AnnotationTest() { + super("annotation/"); + } + + public void testAnnotationClass() throws Exception { + checkFooBoxIsOk(); + } +} diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/context/Namer.java b/js/js.translator/src/org/jetbrains/k2js/translate/context/Namer.java index cada21faeb4..c201449c73b 100644 --- a/js/js.translator/src/org/jetbrains/k2js/translate/context/Namer.java +++ b/js/js.translator/src/org/jetbrains/k2js/translate/context/Namer.java @@ -339,7 +339,6 @@ public final class Namer { case CLASS_OBJECT: return objectCreationMethodReference(); case ANNOTATION_CLASS: - throw new IllegalStateException("Can't create annotation class instance: " + descriptor); case CLASS: return DescriptorUtils.isAnonymousObject(descriptor) ? objectCreationMethodReference() diff --git a/js/js.translator/testData/annotation/cases/annotationClass.kt b/js/js.translator/testData/annotation/cases/annotationClass.kt new file mode 100644 index 00000000000..83e931132cd --- /dev/null +++ b/js/js.translator/testData/annotation/cases/annotationClass.kt @@ -0,0 +1,9 @@ +package foo + +annotation class bar + +public annotation class Baz(val a: String) + +fun box(): String { + return "OK" +}