From 705a081919d894416b8ed4321bb0ac2a7020c201 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 10 Jun 2014 14:10:49 +0400 Subject: [PATCH] KT-5214 Annotation to provide platform name to avoid signature conflict #KT-5214 Fixed --- .../jet/codegen/state/JetTypeMapper.java | 23 +++++++ .../jet/lang/diagnostics/Errors.java | 3 +- .../rendering/DefaultErrorMessages.java | 1 + .../jet/lang/resolve/ModifiersChecker.java | 33 ++++++++-- .../ExpressionTypingVisitorForStatements.java | 4 +- .../platformNames/callableReference.kt | 11 ++++ .../platformNames/clashingErasure.kt | 16 +++++ .../platformNames/functionName.kt | 11 ++++ .../platformNames/propertyName.kt | 14 ++++ .../method/platformName/PlatformName.java | 7 ++ .../method/platformName/PlatformName.kt | 6 ++ .../property/platformName/PlatformName.java | 8 +++ .../property/platformName/PlatformName.kt | 9 +++ .../PlatformNames.A.kt | 12 ++++ .../PlatformNames.B.kt | 8 +++ .../annotationApplicability/platformName.kt | 66 +++++++++++++++++++ ...JetDiagnosticsTestWithStdLibGenerated.java | 16 ++++- ...lackBoxWithStdlibCodegenTestGenerated.java | 31 ++++++++- ...CompileJavaAgainstKotlinTestGenerated.java | 38 ++++++++++- ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++ .../stdlib/src/kotlin/platform/annotations.kt | 19 ++++++ 21 files changed, 329 insertions(+), 12 deletions(-) create mode 100644 compiler/testData/codegen/boxWithStdlib/platformNames/callableReference.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/platformNames/clashingErasure.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/platformNames/functionName.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/platformNames/propertyName.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.kt create mode 100644 compiler/testData/compileKotlinAgainstKotlin/PlatformNames.A.kt create mode 100644 compiler/testData/compileKotlinAgainstKotlin/PlatformNames.B.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/platformName.kt create mode 100644 libraries/stdlib/src/kotlin/platform/annotations.kt diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java index 8a0111111d0..71fca18edd0 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java @@ -27,6 +27,8 @@ import org.jetbrains.jet.codegen.signature.BothSignatureWriter; import org.jetbrains.jet.config.IncrementalCompilation; import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedCallableMemberDescriptor; import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.descriptors.annotations.Annotated; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor; import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall; import org.jetbrains.jet.lang.psi.JetFile; @@ -34,6 +36,8 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.OverrideResolver; +import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.resolve.constants.StringValue; import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants; import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.java.PackageClassUtils; @@ -42,6 +46,7 @@ import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind; import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature; import org.jetbrains.jet.lang.resolve.java.mapping.KotlinToJavaTypesMap; +import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; @@ -50,6 +55,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method; import java.util.ArrayList; import java.util.List; +import java.util.Map; import static org.jetbrains.jet.codegen.AsmUtil.*; import static org.jetbrains.jet.codegen.JvmCodegenUtil.*; @@ -512,6 +518,9 @@ public class JetTypeMapper { @NotNull private static String mapFunctionName(@NotNull FunctionDescriptor descriptor) { + String platformName = getPlatformName(descriptor); + if (platformName != null) return platformName; + if (descriptor instanceof PropertyAccessorDescriptor) { PropertyDescriptor property = ((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty(); if (isAnnotationClass(property.getContainingDeclaration())) { @@ -533,6 +542,20 @@ public class JetTypeMapper { } } + @Nullable + private static String getPlatformName(@NotNull Annotated descriptor) { + AnnotationDescriptor platformNameAnnotation = descriptor.getAnnotations().findAnnotation(new FqName("kotlin.platform.platformName")); + if (platformNameAnnotation == null) return null; + + Map> arguments = platformNameAnnotation.getAllValueArguments(); + if (arguments.isEmpty()) return null; + + CompileTimeConstant name = arguments.values().iterator().next(); + if (!(name instanceof StringValue)) return null; + + return ((StringValue) name).getValue(); + } + @NotNull public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor descriptor) { return mapSignature(descriptor, OwnerKind.IMPLEMENTATION); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index 885b1920462..e307cc599d8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -106,7 +106,8 @@ public interface Errors { DiagnosticFactory1> INCOMPATIBLE_MODIFIERS = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 ILLEGAL_MODIFIER = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(Severity.WARNING); + DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING); + DiagnosticFactory0 INAPPLICABLE_ANNOTATION = DiagnosticFactory0.create(ERROR); // Annotations diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java index a6069de8946..e9906b350e8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java @@ -65,6 +65,7 @@ public class DefaultErrorMessages { } }); MAP.put(ILLEGAL_MODIFIER, "Illegal modifier ''{0}''", TO_STRING); + MAP.put(INAPPLICABLE_ANNOTATION, "Inapplicable annotation"); MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING); MAP.put(ABSTRACT_MODIFIER_IN_TRAIT, "Modifier ''abstract'' is redundant in trait"); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ModifiersChecker.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ModifiersChecker.java index 0b1d802dda0..155d6ded010 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ModifiersChecker.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ModifiersChecker.java @@ -25,11 +25,10 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.diagnostics.Errors; -import org.jetbrains.jet.lang.psi.JetClass; -import org.jetbrains.jet.lang.psi.JetEnumEntry; -import org.jetbrains.jet.lang.psi.JetModifierList; -import org.jetbrains.jet.lang.psi.JetModifierListOwner; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lexer.JetModifierKeywordToken; import java.util.Collection; @@ -37,6 +36,7 @@ import java.util.Collections; import java.util.Map; import static org.jetbrains.jet.lang.diagnostics.Errors.ILLEGAL_MODIFIER; +import static org.jetbrains.jet.lang.diagnostics.Errors.INAPPLICABLE_ANNOTATION; import static org.jetbrains.jet.lexer.JetTokens.*; public class ModifiersChecker { @@ -78,11 +78,13 @@ public class ModifiersChecker { checkModalityModifiers(modifierList); checkVisibilityModifiers(modifierList, descriptor); checkInnerModifier(modifierListOwner, descriptor); + checkPlatformNameApplicability(descriptor); } - public void checkModifiersForLocalDeclaration(@NotNull JetModifierListOwner modifierListOwner) { + public void checkModifiersForLocalDeclaration(@NotNull JetModifierListOwner modifierListOwner, @NotNull DeclarationDescriptor descriptor) { checkIllegalModalityModifiers(modifierListOwner); checkIllegalVisibilityModifiers(modifierListOwner); + checkPlatformNameApplicability(descriptor); } public void checkIllegalModalityModifiers(@NotNull JetModifierListOwner modifierListOwner) { @@ -149,6 +151,27 @@ public class ModifiersChecker { return containingClass.isInner() || containingClass.getContainingDeclaration() instanceof FunctionDescriptor; } + private void checkPlatformNameApplicability(@NotNull DeclarationDescriptor descriptor) { + if (!DescriptorUtils.isTopLevelDeclaration(descriptor) || !(descriptor instanceof FunctionDescriptor)) { + AnnotationDescriptor annotation = descriptor.getAnnotations().findAnnotation(new FqName("kotlin.platform.platformName")); + if (annotation != null) { + JetAnnotationEntry annotationEntry = trace.get(BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotation); + if (annotationEntry != null) { + trace.report(INAPPLICABLE_ANNOTATION.on(annotationEntry)); + } + } + } + if (descriptor instanceof PropertyDescriptor) { + PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor; + if (propertyDescriptor.getGetter() != null) { + checkPlatformNameApplicability(propertyDescriptor.getGetter()); + } + if (propertyDescriptor.getSetter() != null) { + checkPlatformNameApplicability(propertyDescriptor.getSetter()); + } + } + } + private void checkCompatibility(@Nullable JetModifierList modifierList, Collection availableModifiers, Collection... availableCombinations) { if (modifierList == null) return; Collection presentModifiers = Sets.newLinkedHashSet(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java index 6c150cffc6d..87d10554c36 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java @@ -137,7 +137,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito } scope.addVariableDescriptor(propertyDescriptor); - ModifiersChecker.create(context.trace).checkModifiersForLocalDeclaration(property); + ModifiersChecker.create(context.trace).checkModifiersForLocalDeclaration(property, propertyDescriptor); return DataFlowUtils.checkStatementType(property, context, dataFlowInfo); } @@ -174,7 +174,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito components.expressionTypingServices.resolveValueParameters(function.getValueParameters(), functionDescriptor.getValueParameters(), scope, context.dataFlowInfo, context.trace, /* needCompleteAnalysis = */ true); - ModifiersChecker.create(context.trace).checkModifiersForLocalDeclaration(function); + ModifiersChecker.create(context.trace).checkModifiersForLocalDeclaration(function, functionDescriptor); return DataFlowUtils.checkStatementType(function, context, context.dataFlowInfo); } diff --git a/compiler/testData/codegen/boxWithStdlib/platformNames/callableReference.kt b/compiler/testData/codegen/boxWithStdlib/platformNames/callableReference.kt new file mode 100644 index 00000000000..073293901c1 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/platformNames/callableReference.kt @@ -0,0 +1,11 @@ +import kotlin.platform.* + +[platformName("bar")] +fun foo() = "foo" + +fun box(): String { + val f = (::foo)() + if (f != "foo") return "Fail: $f" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/platformNames/clashingErasure.kt b/compiler/testData/codegen/boxWithStdlib/platformNames/clashingErasure.kt new file mode 100644 index 00000000000..3ce689eb6cf --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/platformNames/clashingErasure.kt @@ -0,0 +1,16 @@ +import kotlin.platform.* + +fun List.foo() = "foo" + +[platformName("fooInt")] +fun List.foo() = "fooInt" + +fun box(): String { + val strings = listOf("", "").foo() + if (strings != "foo") return "Fail: $strings" + + val ints = listOf(1, 2).foo() + if (ints != "fooInt") return "Fail: $ints" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/platformNames/functionName.kt b/compiler/testData/codegen/boxWithStdlib/platformNames/functionName.kt new file mode 100644 index 00000000000..bfcc64535c8 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/platformNames/functionName.kt @@ -0,0 +1,11 @@ +import kotlin.platform.* + +[platformName("bar")] +fun foo() = "foo" + +fun box(): String { + val f = foo() + if (f != "foo") return "Fail: $f" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/platformNames/propertyName.kt b/compiler/testData/codegen/boxWithStdlib/platformNames/propertyName.kt new file mode 100644 index 00000000000..ca7a0490f0c --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/platformNames/propertyName.kt @@ -0,0 +1,14 @@ +import kotlin.platform.* + +var v: Int = 1 + [platformName("vget")] + get + [platformName("vset")] + set + +fun box(): String { + v += 1 + if (v != 2) return "Fail: $v" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.java b/compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.java new file mode 100644 index 00000000000..73e221d4101 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.java @@ -0,0 +1,7 @@ +package test; + +public class PlatformName { + public static void main(String[] args) { + TestPackage.bar(); + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.kt b/compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.kt new file mode 100644 index 00000000000..3013466a2be --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.kt @@ -0,0 +1,6 @@ +package test + +import kotlin.platform.* + +[platformName("bar")] +fun foo() {} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.java b/compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.java new file mode 100644 index 00000000000..af1a5fbfcbc --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.java @@ -0,0 +1,8 @@ +package test; + +public class PlatformName { + public static void main(String[] args) { + int x = TestPackage.vget(); + TestPackage.vset(0); + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.kt b/compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.kt new file mode 100644 index 00000000000..edca82e6f8f --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.kt @@ -0,0 +1,9 @@ +package test + +import kotlin.platform.* + +var v: Int = 1 + [platformName("vget")] + get + [platformName("vset")] + set diff --git a/compiler/testData/compileKotlinAgainstKotlin/PlatformNames.A.kt b/compiler/testData/compileKotlinAgainstKotlin/PlatformNames.A.kt new file mode 100644 index 00000000000..5e837c66373 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstKotlin/PlatformNames.A.kt @@ -0,0 +1,12 @@ +package lib + +import kotlin.platform.* + +[platformName("bar")] +fun foo() = "foo" + +var v: Int = 1 + [platformName("vget")] + get + [platformName("vset")] + set diff --git a/compiler/testData/compileKotlinAgainstKotlin/PlatformNames.B.kt b/compiler/testData/compileKotlinAgainstKotlin/PlatformNames.B.kt new file mode 100644 index 00000000000..d4cac39505c --- /dev/null +++ b/compiler/testData/compileKotlinAgainstKotlin/PlatformNames.B.kt @@ -0,0 +1,8 @@ +import lib.* + +fun main(args: Array) { + foo() + + v = 1 + println(v) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/platformName.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/platformName.kt new file mode 100644 index 00000000000..70d765bf601 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/platformName.kt @@ -0,0 +1,66 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE + +import kotlin.platform.* + +[platformName("a")] +fun foo() {} + +[platformName("b")] +fun Any.foo() {} + +[platformName("c")] +val px = 1 + +[platformName("d")] +val Any.px : Int + get() = 1 + +val valx: Int + [platformName("e")] + get() = 1 + +var varx: Int + [platformName("f")] + get() = 1 + [platformName("g")] + set(v) {} + +var vardef: Int = 1 + [platformName("f")] + get + [platformName("g")] + set + +[platformName("C")] +class C { + [platformName("a")] + fun foo() {} + + [platformName("b")] + fun Any.foo() {} + + [platformName("c")] + val px = 1 + + [platformName("d")] + val Any.px : Int + get() = 1 + + val valx: Int + [platformName("e")] + get() = 1 + + var varx: Int + [platformName("f")] + get() = 1 + [platformName("g")] + set(v) {} +} + +fun foo1() { + [platformName("a")] + fun foo() {} + + [platformName("a")] + val x = 1 +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java index e0530809c43..f87cb328be6 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -38,7 +38,7 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic } @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") - @InnerTestClasses({Annotations.AnnotationParameterMustBeConstant.class}) + @InnerTestClasses({Annotations.AnnotationApplicability.class, Annotations.AnnotationParameterMustBeConstant.class}) public static class Annotations extends AbstractJetDiagnosticsTestWithStdLib { public void testAllFilesPresentInAnnotations() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/testsWithStdLib/annotations"), Pattern.compile("^(.+)\\.kt$"), true); @@ -49,6 +49,19 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic doTest("compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsClass.kt"); } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability") + public static class AnnotationApplicability extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInAnnotationApplicability() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("platformName.kt") + public void testPlatformName() throws Exception { + doTest("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/platformName.kt"); + } + + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant") public static class AnnotationParameterMustBeConstant extends AbstractJetDiagnosticsTestWithStdLib { public void testAllFilesPresentInAnnotationParameterMustBeConstant() throws Exception { @@ -80,6 +93,7 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic public static Test innerSuite() { TestSuite suite = new TestSuite("Annotations"); suite.addTestSuite(Annotations.class); + suite.addTestSuite(AnnotationApplicability.class); suite.addTestSuite(AnnotationParameterMustBeConstant.class); return suite; } diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index b4a5d55a063..3e17574daba 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") @TestMetadata("compiler/testData/codegen/boxWithStdlib") -@InnerTestClasses({BlackBoxWithStdlibCodegenTestGenerated.Annotations.class, BlackBoxWithStdlibCodegenTestGenerated.Arrays.class, BlackBoxWithStdlibCodegenTestGenerated.CallableReference.class, BlackBoxWithStdlibCodegenTestGenerated.Casts.class, BlackBoxWithStdlibCodegenTestGenerated.DataClasses.class, BlackBoxWithStdlibCodegenTestGenerated.Evaluate.class, BlackBoxWithStdlibCodegenTestGenerated.FullJdk.class, BlackBoxWithStdlibCodegenTestGenerated.JdkAnnotations.class, BlackBoxWithStdlibCodegenTestGenerated.Ranges.class, BlackBoxWithStdlibCodegenTestGenerated.Reflection.class, BlackBoxWithStdlibCodegenTestGenerated.Regressions.class, BlackBoxWithStdlibCodegenTestGenerated.Strings.class, BlackBoxWithStdlibCodegenTestGenerated.ToArray.class, BlackBoxWithStdlibCodegenTestGenerated.Vararg.class, BlackBoxWithStdlibCodegenTestGenerated.When.class}) +@InnerTestClasses({BlackBoxWithStdlibCodegenTestGenerated.Annotations.class, BlackBoxWithStdlibCodegenTestGenerated.Arrays.class, BlackBoxWithStdlibCodegenTestGenerated.CallableReference.class, BlackBoxWithStdlibCodegenTestGenerated.Casts.class, BlackBoxWithStdlibCodegenTestGenerated.DataClasses.class, BlackBoxWithStdlibCodegenTestGenerated.Evaluate.class, BlackBoxWithStdlibCodegenTestGenerated.FullJdk.class, BlackBoxWithStdlibCodegenTestGenerated.JdkAnnotations.class, BlackBoxWithStdlibCodegenTestGenerated.PlatformNames.class, BlackBoxWithStdlibCodegenTestGenerated.Ranges.class, BlackBoxWithStdlibCodegenTestGenerated.Reflection.class, BlackBoxWithStdlibCodegenTestGenerated.Regressions.class, BlackBoxWithStdlibCodegenTestGenerated.Strings.class, BlackBoxWithStdlibCodegenTestGenerated.ToArray.class, BlackBoxWithStdlibCodegenTestGenerated.Vararg.class, BlackBoxWithStdlibCodegenTestGenerated.When.class}) public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testAllFilesPresentInBoxWithStdlib() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithStdlib"), Pattern.compile("^(.+)\\.kt$"), true); @@ -883,6 +883,34 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/platformNames") + public static class PlatformNames extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInPlatformNames() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithStdlib/platformNames"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("callableReference.kt") + public void testCallableReference() throws Exception { + doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/platformNames/callableReference.kt"); + } + + @TestMetadata("clashingErasure.kt") + public void testClashingErasure() throws Exception { + doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/platformNames/clashingErasure.kt"); + } + + @TestMetadata("functionName.kt") + public void testFunctionName() throws Exception { + doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/platformNames/functionName.kt"); + } + + @TestMetadata("propertyName.kt") + public void testPropertyName() throws Exception { + doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/platformNames/propertyName.kt"); + } + + } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/ranges") @InnerTestClasses({Ranges.Expression.class, Ranges.Literal.class}) public static class Ranges extends AbstractBlackBoxCodegenTest { @@ -1578,6 +1606,7 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode suite.addTestSuite(Evaluate.class); suite.addTestSuite(FullJdk.class); suite.addTestSuite(JdkAnnotations.class); + suite.addTestSuite(PlatformNames.class); suite.addTest(Ranges.innerSuite()); suite.addTest(Reflection.innerSuite()); suite.addTestSuite(Regressions.class); diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java index 31528f5a171..b20ad8e53d5 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java @@ -106,7 +106,7 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg } @TestMetadata("compiler/testData/compileJavaAgainstKotlin/method") - @InnerTestClasses({Method.PrimitiveOverride.class, Method.Throws.class}) + @InnerTestClasses({Method.PlatformName.class, Method.PrimitiveOverride.class, Method.Throws.class}) public static class Method extends AbstractCompileJavaAgainstKotlinTest { @TestMetadata("AccessorGenericSignature.kt") public void testAccessorGenericSignature() throws Exception { @@ -227,6 +227,19 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg doTest("compiler/testData/compileJavaAgainstKotlin/method/Void.kt"); } + @TestMetadata("compiler/testData/compileJavaAgainstKotlin/method/platformName") + public static class PlatformName extends AbstractCompileJavaAgainstKotlinTest { + public void testAllFilesPresentInPlatformName() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/compileJavaAgainstKotlin/method/platformName"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("PlatformName.kt") + public void testPlatformName() throws Exception { + doTest("compiler/testData/compileJavaAgainstKotlin/method/platformName/PlatformName.kt"); + } + + } + @TestMetadata("compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride") public static class PrimitiveOverride extends AbstractCompileJavaAgainstKotlinTest { public void testAllFilesPresentInPrimitiveOverride() throws Exception { @@ -336,6 +349,7 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg public static Test innerSuite() { TestSuite suite = new TestSuite("Method"); suite.addTestSuite(Method.class); + suite.addTestSuite(PlatformName.class); suite.addTestSuite(PrimitiveOverride.class); suite.addTestSuite(Throws.class); return suite; @@ -343,6 +357,7 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg } @TestMetadata("compiler/testData/compileJavaAgainstKotlin/property") + @InnerTestClasses({Property.PlatformName.class}) public static class Property extends AbstractCompileJavaAgainstKotlinTest { public void testAllFilesPresentInProperty() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/compileJavaAgainstKotlin/property"), Pattern.compile("^(.+)\\.kt$"), true); @@ -358,6 +373,25 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg doTest("compiler/testData/compileJavaAgainstKotlin/property/GenericProperty.kt"); } + @TestMetadata("compiler/testData/compileJavaAgainstKotlin/property/platformName") + public static class PlatformName extends AbstractCompileJavaAgainstKotlinTest { + public void testAllFilesPresentInPlatformName() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/compileJavaAgainstKotlin/property/platformName"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("PlatformName.kt") + public void testPlatformName() throws Exception { + doTest("compiler/testData/compileJavaAgainstKotlin/property/platformName/PlatformName.kt"); + } + + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("Property"); + suite.addTestSuite(Property.class); + suite.addTestSuite(PlatformName.class); + return suite; + } } @TestMetadata("compiler/testData/compileJavaAgainstKotlin/staticFields") @@ -398,7 +432,7 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg suite.addTestSuite(CompileJavaAgainstKotlinTestGenerated.class); suite.addTestSuite(Class.class); suite.addTest(Method.innerSuite()); - suite.addTestSuite(Property.class); + suite.addTest(Property.innerSuite()); suite.addTestSuite(StaticFields.class); return suite; } diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java index 457171a6a21..7a56fb31825 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java @@ -96,6 +96,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl doTest("compiler/testData/compileKotlinAgainstKotlin/KotlinPropertyAsAnnotationParameter.A.kt"); } + @TestMetadata("PlatformNames.A.kt") + public void testPlatformNames() throws Exception { + doTest("compiler/testData/compileKotlinAgainstKotlin/PlatformNames.A.kt"); + } + @TestMetadata("Simple.A.kt") public void testSimple() throws Exception { doTest("compiler/testData/compileKotlinAgainstKotlin/Simple.A.kt"); diff --git a/libraries/stdlib/src/kotlin/platform/annotations.kt b/libraries/stdlib/src/kotlin/platform/annotations.kt new file mode 100644 index 00000000000..a3759935b7c --- /dev/null +++ b/libraries/stdlib/src/kotlin/platform/annotations.kt @@ -0,0 +1,19 @@ +/* + * 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 kotlin.platform + +public annotation class platformName(val name: String) \ No newline at end of file