diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 8c673bf33e4..027fa80e720 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -71,7 +71,6 @@ import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isNullableAny; import static org.jetbrains.kotlin.codegen.AsmUtil.*; import static org.jetbrains.kotlin.codegen.JvmSerializationBindings.*; import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION; -import static org.jetbrains.kotlin.load.java.JvmAnnotationNames.OLD_JET_VALUE_PARAMETER_ANNOTATION; import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.getSourceFromDescriptor; import static org.jetbrains.kotlin.resolve.DescriptorUtils.*; import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE; @@ -170,10 +169,6 @@ public class FunctionCodegen { AnnotationCodegen.forMethod(mv, typeMapper).genAnnotations(functionDescriptor, asmMethod.getReturnType()); generateParameterAnnotations(functionDescriptor, mv, typeMapper.mapSignature(functionDescriptor)); - if (state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES) { - generateJetValueParameterAnnotations(mv, functionDescriptor, jvmSignature); - } - generateBridges(functionDescriptor); boolean staticInCompanionObject = AnnotationsPackage.isPlatformStaticInCompanionObject(functionDescriptor); @@ -239,56 +234,6 @@ public class FunctionCodegen { } } - @SuppressWarnings("deprecation") - private static void generateJetValueParameterAnnotations( - @NotNull MethodVisitor mv, - @NotNull FunctionDescriptor functionDescriptor, - @NotNull JvmMethodSignature jvmSignature - ) { - Iterator descriptors = functionDescriptor.getValueParameters().iterator(); - List kotlinParameterTypes = jvmSignature.getValueParameters(); - - for (int i = 0; i < kotlinParameterTypes.size(); i++) { - JvmMethodParameterKind kind = kotlinParameterTypes.get(i).getKind(); - if (kind.isSkippedInGenericSignature()) continue; - - String name; - boolean nullableType; - if (kind == JvmMethodParameterKind.VALUE) { - ValueParameterDescriptor descriptor = descriptors.next(); - name = descriptor.getName().asString(); - nullableType = descriptor.getType().isMarkedNullable(); - } - else { - String lowercaseKind = kind.name().toLowerCase(); - if (needIndexForVar(kind)) { - name = "$" + lowercaseKind + "$" + i; - } - else { - name = "$" + lowercaseKind; - } - - if (kind == JvmMethodParameterKind.RECEIVER) { - ReceiverParameterDescriptor receiver = functionDescriptor.getExtensionReceiverParameter(); - nullableType = receiver == null || receiver.getType().isMarkedNullable(); - } - else { - nullableType = true; - } - } - - AnnotationVisitor av = - mv.visitParameterAnnotation(i, asmDescByFqNameWithoutInnerClasses(OLD_JET_VALUE_PARAMETER_ANNOTATION), true); - if (av != null) { - av.visit("name", name); - if (nullableType) { - av.visit("type", "?"); - } - av.visitEnd(); - } - } - } - private void markEnumOrInnerConstructorParameterAsSynthetic(MethodVisitor mv, int i) { // IDEA's ClsPsi builder fails to annotate synthetic parameters if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) return; diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/JetValueParameterAnnotationTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/JetValueParameterAnnotationTest.java deleted file mode 100644 index 79b3910ff28..00000000000 --- a/compiler/tests/org/jetbrains/kotlin/codegen/JetValueParameterAnnotationTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2010-2015 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.kotlin.codegen; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.test.ConfigurationKind; - -import java.lang.annotation.Annotation; - -@SuppressWarnings("deprecation") -public class JetValueParameterAnnotationTest extends CodegenTestCase { - @Override - protected void setUp() throws Exception { - super.setUp(); - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); - } - - private static class ValueParameter { - public final String name; - public final String type; - - private ValueParameter(@NotNull String name, @NotNull String type) { - this.name = name; - this.type = type; - } - } - - @NotNull - private static ValueParameter valueParameter(@NotNull String name, boolean nullable) { - return new ValueParameter(name, nullable ? "?" : ""); - } - - public void testOneNotNullParam() { - doTest( - "fun foo(byte: Byte) {}", - valueParameter("byte", false) - ); - } - - public void testTwoNotNullParams() { - doTest( - "fun foo(int: Int, string: String) {}", - valueParameter("int", false), - valueParameter("string", false) - ); - } - - public void testTwoNullableParams() { - doTest( - "fun foo(long: Long?, unit: Unit?) {}", - valueParameter("long", true), - valueParameter("unit", true) - ); - } - - public void testTwoMixedParams() { - doTest( - "fun foo(short: Short?, boolean: Boolean) {}", - valueParameter("short", true), - valueParameter("boolean", false) - ); - } - - public void testNotNullReceiver() { - doTest( - "fun Int.foo() {}", - valueParameter("$receiver", false) - ); - } - - public void testNullableReceiver() { - doTest( - "fun String?.foo() {}", - valueParameter("$receiver", true) - ); - } - - private void doTest(@NotNull String code, @NotNull ValueParameter... expected) { - loadText(code); - - Annotation[][] annotations = generateFunction().getParameterAnnotations(); - assertSize(expected.length, annotations); - - for (int i = 0, length = annotations.length; i < length; i++) { - assertSize(1, annotations[i]); - Annotation annotation = annotations[i][0]; - assertEquals("jet.runtime.typeinfo.JetValueParameter", annotation.annotationType().getName()); - assertEquals(expected[i].name, CodegenTestUtil.getAnnotationAttribute(annotation, "name")); - assertEquals(expected[i].type, CodegenTestUtil.getAnnotationAttribute(annotation, "type")); - } - } -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java index ede6c7a0f3d..6adf563543a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java @@ -101,8 +101,6 @@ public final class JvmAnnotationNames { @Deprecated public static final FqName OLD_JET_PACKAGE_CLASS_ANNOTATION = new FqName("jet.runtime.typeinfo.JetPackageClass"); @Deprecated - public static final FqName OLD_JET_VALUE_PARAMETER_ANNOTATION = new FqName("jet.runtime.typeinfo.JetValueParameter"); - @Deprecated public static final FqName OLD_KOTLIN_CLASS = new FqName("jet.KotlinClass"); @Deprecated public static final FqName OLD_KOTLIN_PACKAGE = new FqName("jet.KotlinPackage"); diff --git a/core/runtime.jvm/src/jet/runtime/typeinfo/JetValueParameter.java b/core/runtime.jvm/src/jet/runtime/typeinfo/JetValueParameter.java index 1cbabd700a8..060b337a85b 100644 --- a/core/runtime.jvm/src/jet/runtime/typeinfo/JetValueParameter.java +++ b/core/runtime.jvm/src/jet/runtime/typeinfo/JetValueParameter.java @@ -21,15 +21,16 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * @deprecated This class is no longer used in the bytecode produced by Kotlin compiler + * and exists in the Kotlin Java Runtime only for compatibility with the older code. + * It will be deleted completely after M13. + */ @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) @Deprecated public @interface JetValueParameter { String name(); - /** - * This is a hack for Kara - * @return "?" if the type of this parameter is nullable, an empty string otherwise - */ String type() default ""; }