drop deprecated @platformName and @platformStatic annotations

This commit is contained in:
Dmitry Jemerov
2015-10-29 14:29:53 +01:00
parent 15370244dc
commit 736b496f6a
74 changed files with 139 additions and 274 deletions
@@ -66,7 +66,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
* *
* @param functionDescriptor the method for which the overloads are generated * @param functionDescriptor the method for which the overloads are generated
* @param delegateFunctionDescriptor the method descriptor for the implementation that we need to call * @param delegateFunctionDescriptor the method descriptor for the implementation that we need to call
* (same as [functionDescriptor] in all cases except for companion object methods annotated with [platformStatic], * (same as [functionDescriptor] in all cases except for companion object methods annotated with @JvmStatic,
* where [functionDescriptor] is the static method in the main class and [delegateFunctionDescriptor] is the * where [functionDescriptor] is the static method in the main class and [delegateFunctionDescriptor] is the
* implementation in the companion object class) * implementation in the companion object class)
* @return true if the overloads annotation was found on the element, false otherwise * @return true if the overloads annotation was found on the element, false otherwise
@@ -102,7 +102,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
* *
* @param functionDescriptor the method for which the overloads are generated * @param functionDescriptor the method for which the overloads are generated
* @param delegateFunctionDescriptor the method descriptor for the implementation that we need to call * @param delegateFunctionDescriptor the method descriptor for the implementation that we need to call
* (same as [functionDescriptor] in all cases except for companion object methods annotated with [platformStatic], * (same as [functionDescriptor] in all cases except for companion object methods annotated with @JvmStatic,
* where [functionDescriptor] is the static method in the main class and [delegateFunctionDescriptor] is the * where [functionDescriptor] is the static method in the main class and [delegateFunctionDescriptor] is the
* implementation in the companion object class) * implementation in the companion object class)
* @param methodElement the PSI element for the method implementation (used in diagnostic messages only) * @param methodElement the PSI element for the method implementation (used in diagnostic messages only)
@@ -187,7 +187,7 @@ public class FunctionCodegen {
boolean staticInCompanionObject = AnnotationUtilKt.isPlatformStaticInCompanionObject(functionDescriptor); boolean staticInCompanionObject = AnnotationUtilKt.isPlatformStaticInCompanionObject(functionDescriptor);
if (staticInCompanionObject) { if (staticInCompanionObject) {
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen(); ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
parentBodyCodegen.addAdditionalTask(new PlatformStaticGenerator(functionDescriptor, origin, state)); parentBodyCodegen.addAdditionalTask(new JvmStaticGenerator(functionDescriptor, origin, state));
} }
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES || isAbstractMethod(functionDescriptor, contextKind)) { if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES || isAbstractMethod(functionDescriptor, contextKind)) {
@@ -209,9 +209,9 @@ public class FunctionCodegen {
generateMethodBody(mv, functionDescriptor, methodContext, jvmSignature, strategy, memberCodegen); generateMethodBody(mv, functionDescriptor, methodContext, jvmSignature, strategy, memberCodegen);
} }
else if (staticInCompanionObject) { else if (staticInCompanionObject) {
// native platformStatic foo() in companion object should delegate to the static native function moved to the outer class // native @JvmStatic foo() in companion object should delegate to the static native function moved to the outer class
mv.visitCode(); mv.visitCode();
FunctionDescriptor staticFunctionDescriptor = PlatformStaticGenerator.createStaticFunctionDescriptor(functionDescriptor); FunctionDescriptor staticFunctionDescriptor = JvmStaticGenerator.createStaticFunctionDescriptor(functionDescriptor);
JvmMethodSignature jvmMethodSignature = JvmMethodSignature jvmMethodSignature =
typeMapper.mapSignature(memberCodegen.getContext().accessibleDescriptor(staticFunctionDescriptor, null)); typeMapper.mapSignature(memberCodegen.getContext().accessibleDescriptor(staticFunctionDescriptor, null));
Type owningType = typeMapper.mapClass((ClassifierDescriptor) staticFunctionDescriptor.getContainingDeclaration()); Type owningType = typeMapper.mapClass((ClassifierDescriptor) staticFunctionDescriptor.getContainingDeclaration());
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.org.objectweb.asm.MethodVisitor import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
class PlatformStaticGenerator( class JvmStaticGenerator(
val descriptor: FunctionDescriptor, val descriptor: FunctionDescriptor,
val declarationOrigin: JvmDeclarationOrigin, val declarationOrigin: JvmDeclarationOrigin,
val state: GenerationState val state: GenerationState
@@ -16,21 +16,15 @@
package org.jetbrains.kotlin.cli.jvm package org.jetbrains.kotlin.cli.jvm
import kotlin.platform.*
import java.util.jar.JarFile
import java.util.jar.Attributes
import java.util.regex.Pattern
import com.intellij.util.containers.MultiMap import com.intellij.util.containers.MultiMap
import java.net.URLClassLoader
import java.net.URL
import java.io.File
import java.util.ServiceLoader
import java.io.IOException
import java.util.Enumeration
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.utils.valuesToMap
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.compiler.plugin.* import org.jetbrains.kotlin.compiler.plugin.*
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.utils.valuesToMap
import java.io.File
import java.net.URL
import java.net.URLClassLoader
import java.util.*
public object PluginCliParser { public object PluginCliParser {
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.DeclarationChecker
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.annotations.hasIntrinsicAnnotation import org.jetbrains.kotlin.resolve.annotations.hasIntrinsicAnnotation
import org.jetbrains.kotlin.resolve.annotations.hasPlatformStaticAnnotation import org.jetbrains.kotlin.resolve.annotations.hasJvmStaticAnnotation
import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmOverloadsAnnotation import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmOverloadsAnnotation
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
@@ -58,7 +58,7 @@ public class PlatformStaticAnnotationChecker : DeclarationChecker {
diagnosticHolder: DiagnosticSink, diagnosticHolder: DiagnosticSink,
bindingContext: BindingContext bindingContext: BindingContext
) { ) {
if (descriptor.hasPlatformStaticAnnotation()) { if (descriptor.hasJvmStaticAnnotation()) {
if (declaration is KtNamedFunction || declaration is KtProperty || declaration is KtPropertyAccessor) { if (declaration is KtNamedFunction || declaration is KtProperty || declaration is KtPropertyAccessor) {
checkDeclaration(declaration, descriptor, diagnosticHolder) checkDeclaration(declaration, descriptor, diagnosticHolder)
} }
@@ -108,7 +108,7 @@ public class MainFunctionDetector {
DeclarationDescriptor containingDeclaration = functionDescriptor.getContainingDeclaration(); DeclarationDescriptor containingDeclaration = functionDescriptor.getContainingDeclaration();
return containingDeclaration instanceof ClassDescriptor return containingDeclaration instanceof ClassDescriptor
&& ((ClassDescriptor) containingDeclaration).getKind().isSingleton() && ((ClassDescriptor) containingDeclaration).getKind().isSingleton()
&& AnnotationUtilKt.hasPlatformStaticAnnotation(functionDescriptor); && AnnotationUtilKt.hasJvmStaticAnnotation(functionDescriptor);
} }
@Nullable @Nullable
@@ -16,14 +16,13 @@
package org.jetbrains.kotlin.kdoc.parser package org.jetbrains.kotlin.kdoc.parser
import com.intellij.lang.ASTNode
import com.intellij.lang.PsiBuilder
import com.intellij.lang.PsiBuilderFactory
import com.intellij.lang.PsiParser import com.intellij.lang.PsiParser
import com.intellij.psi.tree.IElementType import com.intellij.psi.tree.IElementType
import com.intellij.lang.PsiBuilder
import com.intellij.lang.ASTNode
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.lexer.KotlinLexer import org.jetbrains.kotlin.lexer.KotlinLexer
import com.intellij.lang.PsiBuilderFactory import org.jetbrains.kotlin.lexer.KtTokens
import kotlin.platform.*
/** /**
* Parses the contents of a Markdown link in KDoc. Uses the standard Kotlin lexer. * Parses the contents of a Markdown link in KDoc. Uses the standard Kotlin lexer.
@@ -22,13 +22,11 @@ import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
public fun DeclarationDescriptor.hasPlatformStaticAnnotation(): Boolean { public fun DeclarationDescriptor.hasJvmStaticAnnotation(): Boolean {
return getAnnotations().findAnnotation(FqName("kotlin.platform.platformStatic")) != null || return getAnnotations().findAnnotation(FqName("kotlin.jvm.JvmStatic")) != null
getAnnotations().findAnnotation(FqName("kotlin.jvm.JvmStatic")) != null
} }
public fun DeclarationDescriptor.hasJvmSyntheticAnnotation(): Boolean { public fun DeclarationDescriptor.hasJvmSyntheticAnnotation(): Boolean {
@@ -52,9 +50,9 @@ private fun CallableDescriptor.isPlatformStaticIn(predicate: (DeclarationDescrip
is PropertyAccessorDescriptor -> { is PropertyAccessorDescriptor -> {
val propertyDescriptor = getCorrespondingProperty() val propertyDescriptor = getCorrespondingProperty()
predicate(propertyDescriptor.getContainingDeclaration()) && predicate(propertyDescriptor.getContainingDeclaration()) &&
(hasPlatformStaticAnnotation() || propertyDescriptor.hasPlatformStaticAnnotation()) (hasJvmStaticAnnotation() || propertyDescriptor.hasJvmStaticAnnotation())
} }
else -> predicate(getContainingDeclaration()) && hasPlatformStaticAnnotation() else -> predicate(getContainingDeclaration()) && hasJvmStaticAnnotation()
} }
public fun AnnotationDescriptor.argumentValue(parameterName: String): Any? { public fun AnnotationDescriptor.argumentValue(parameterName: String): Any? {
@@ -1,10 +1,8 @@
package test package test
import kotlin.platform.platformStatic
class PlatformStaticClass { class PlatformStaticClass {
companion object { companion object {
@platformStatic @JvmStatic
fun <T> inClassObject() {} fun <T> inClassObject() {}
} }
@@ -1,10 +1,9 @@
import kotlin.platform.platformName
import kotlin.reflect.jvm.* import kotlin.reflect.jvm.*
var state: String = "value" var state: String = "value"
@platformName("getter") @JvmName("getter")
get get
@platformName("setter") @JvmName("setter")
set set
fun box(): String { fun box(): String {
@@ -1,12 +1,11 @@
package foo package foo
import kotlin.jvm.* import kotlin.jvm.*
import kotlin.platform.*
object ObjWithNative { object ObjWithNative {
external fun foo(x: Int = 1): Double external fun foo(x: Int = 1): Double
@platformStatic external fun bar(l: Long, s: String = ""): Double @JvmStatic external fun bar(l: Long, s: String = ""): Double
} }
external fun topLevel(x: Int = 1): Double external fun topLevel(x: Int = 1): Double
@@ -1,9 +1,8 @@
import kotlin.jvm.* import kotlin.jvm.*
import kotlin.platform.*
class C { class C {
companion object { companion object {
private @platformStatic external fun foo() private @JvmStatic external fun foo()
} }
fun bar() { fun bar() {
@@ -1,16 +1,15 @@
package foo package foo
import kotlin.jvm.* import kotlin.jvm.*
import kotlin.platform.*
class WithNative { class WithNative {
companion object { companion object {
@platformStatic external fun bar(l: Long, s: String): Double @JvmStatic external fun bar(l: Long, s: String): Double
} }
} }
object ObjWithNative { object ObjWithNative {
@platformStatic external fun bar(l: Long, s: String): Double @JvmStatic external fun bar(l: Long, s: String): Double
} }
fun box(): String { fun box(): String {
@@ -1,7 +1,6 @@
package foo package foo
import kotlin.jvm.* import kotlin.jvm.*
import kotlin.platform.*
external fun bar(l: Long, s: String): Double external fun bar(l: Long, s: String): Double
@@ -1,6 +1,4 @@
import kotlin.platform.* @JvmName("bar")
@platformName("bar")
fun foo() = "foo" fun foo() = "foo"
fun box(): String { fun box(): String {
@@ -1,8 +1,6 @@
import kotlin.platform.*
fun <T> List<T>.foo() = "foo" fun <T> List<T>.foo() = "foo"
@platformName("fooInt") @JvmName("fooInt")
fun List<Int>.foo() = "fooInt" fun List<Int>.foo() = "fooInt"
fun box(): String { fun box(): String {
@@ -1,5 +1,3 @@
import kotlin.platform.*
// See: // See:
// http://kotlinlang.org/docs/reference/java-interop.html#handling-signature-clashes-with-platformname // http://kotlinlang.org/docs/reference/java-interop.html#handling-signature-clashes-with-platformname
// https://youtrack.jetbrains.com/issue/KT-5524 // https://youtrack.jetbrains.com/issue/KT-5524
@@ -10,18 +8,18 @@ val ints = listOf(1, 2, 3)
class C { class C {
// Instance methods // Instance methods
@platformName("instMethodStr") @JvmName("instMethodStr")
fun instMethod(list: List<String>): String = "instMethodStr" fun instMethod(list: List<String>): String = "instMethodStr"
@platformName("instMethodInt") @JvmName("instMethodInt")
fun instMethod(list: List<Int>): String = "instMethodInt" fun instMethod(list: List<Int>): String = "instMethodInt"
// Properties // Properties
var rwProperty: Int var rwProperty: Int
@platformName("get_rwProperty") @JvmName("get_rwProperty")
get() = 123 get() = 123
@platformName("set_rwProperty") @JvmName("set_rwProperty")
set(v) {} set(v) {}
var rwValue = 111 var rwValue = 111
@@ -36,27 +34,27 @@ class C {
class Inner class Inner
@platformName("extMethodWithGenericParamStr") @JvmName("extMethodWithGenericParamStr")
fun Inner.extMethodWithGenericParam(list: List<String>): String = "extMethodWithGenericParamStr" fun Inner.extMethodWithGenericParam(list: List<String>): String = "extMethodWithGenericParamStr"
@platformName("extMethodWithGenericParamInt") @JvmName("extMethodWithGenericParamInt")
fun Inner.extMethodWithGenericParam(list: List<Int>): String = "extMethodWithGenericParamInt" fun Inner.extMethodWithGenericParam(list: List<Int>): String = "extMethodWithGenericParamInt"
// This is already covered by extMethodWithGenericParam(), but might be relevant for a platform // This is already covered by extMethodWithGenericParam(), but might be relevant for a platform
// with extension method code generation strategy different from Java 6. // with extension method code generation strategy different from Java 6.
@platformName("extMethodWithGenericReceiverStr") @JvmName("extMethodWithGenericReceiverStr")
fun List<String>.extMethodWithGenericReceiver(): String = "extMethodWithGenericReceiverStr" fun List<String>.extMethodWithGenericReceiver(): String = "extMethodWithGenericReceiverStr"
@platformName("extMethodWithGenericReceiverInt") @JvmName("extMethodWithGenericReceiverInt")
fun List<Int>.extMethodWithGenericReceiver(): String = "extMethodWithGenericReceiverInt" fun List<Int>.extMethodWithGenericReceiver(): String = "extMethodWithGenericReceiverInt"
// Extension method vs instance method // Extension method vs instance method
@platformName("ambigMethod1") @JvmName("ambigMethod1")
fun ambigMethod(str: String): String = "ambigMethod1" fun ambigMethod(str: String): String = "ambigMethod1"
@platformName("ambigMethod2") @JvmName("ambigMethod2")
fun String.ambigMethod(): String = "ambigMethod2" fun String.ambigMethod(): String = "ambigMethod2"
} }
@@ -1,6 +1,4 @@
import kotlin.platform.* @JvmName("bar")
@platformName("bar")
fun foo() = "foo" fun foo() = "foo"
fun box(): String { fun box(): String {
@@ -1,9 +1,7 @@
import kotlin.platform.*
var v: Int = 1 var v: Int = 1
@platformName("vget") @JvmName("vget")
get get
@platformName("vset") @JvmName("vset")
set set
fun box(): String { fun box(): String {
@@ -1,6 +1,6 @@
class C { class C {
companion object { companion object {
@kotlin.platform.platformStatic @kotlin.jvm.JvmOverloads public fun foo(o: String, k: String = "K"): String { @JvmStatic @kotlin.jvm.JvmOverloads public fun foo(o: String, k: String = "K"): String {
return o + k return o + k
} }
} }
@@ -1,16 +1,14 @@
import kotlin.platform.platformStatic
object A { object A {
val b: String = "OK" val b: String = "OK"
@platformStatic val c: String = "OK" @JvmStatic val c: String = "OK"
@platformStatic fun test1() : String { @JvmStatic fun test1() : String {
return {b}() return {b}()
} }
@platformStatic fun test2() : String { @JvmStatic fun test2() : String {
return {test1()}() return {test1()}()
} }
@@ -18,11 +16,11 @@ object A {
return {"1".test5()}() return {"1".test5()}()
} }
@platformStatic fun test4(): String { @JvmStatic fun test4(): String {
return {"1".test5()}() return {"1".test5()}()
} }
@platformStatic fun String.test5() : String { @JvmStatic fun String.test5() : String {
return {this + b}() return {this + b}()
} }
@@ -1,5 +1,3 @@
import kotlin.platform.platformStatic
class B(var s: Int = 0) { class B(var s: Int = 0) {
} }
@@ -10,7 +8,7 @@ object A {
v += B(1000) v += B(1000)
} }
@platformStatic fun B.plusAssign(b: B) { @JvmStatic fun B.plusAssign(b: B) {
this.s += b.s this.s += b.s
} }
} }
@@ -1,8 +1,6 @@
import kotlin.platform.platformStatic
object A { object A {
@platformStatic fun test(b: String = "OK") : String { @JvmStatic fun test(b: String = "OK") : String {
return b return b
} }
} }
@@ -1,10 +1,8 @@
import kotlin.platform.platformStatic
object AX { object AX {
@platformStatic val c: String = "OK" @JvmStatic val c: String = "OK"
@platformStatic fun aStatic(): String { @JvmStatic fun aStatic(): String {
return AX.b() return AX.b()
} }
@@ -12,7 +10,7 @@ object AX {
return AX.b() return AX.b()
} }
@platformStatic fun b(): String { @JvmStatic fun b(): String {
return "OK" return "OK"
} }
@@ -1,5 +1,3 @@
import kotlin.platform.platformStatic
var holder = "" var holder = ""
fun getA(): A { fun getA(): A {
@@ -8,7 +6,7 @@ fun getA(): A {
} }
object A { object A {
@platformStatic fun a(): String { @JvmStatic fun a(): String {
return holder return holder
} }
} }
@@ -1,8 +1,6 @@
import kotlin.platform.platformStatic
object A { object A {
@platformStatic inline fun test(b: String = "OK") : String { @JvmStatic inline fun test(b: String = "OK") : String {
return b return b
} }
} }
@@ -1,14 +1,12 @@
import kotlin.platform.platformStatic
object A { object A {
@platformStatic var a: Int = 1 @JvmStatic var a: Int = 1
var b: Int = 1 var b: Int = 1
@platformStatic get @JvmStatic get
var c: Int = 1 var c: Int = 1
@platformStatic set @JvmStatic set
} }
@@ -1,14 +1,12 @@
import kotlin.platform.platformStatic
object A { object A {
@platformStatic var a: Int = 1 @JvmStatic var a: Int = 1
var b: Int = 1 var b: Int = 1
@platformStatic get @JvmStatic get
var c: Int = 1 var c: Int = 1
@platformStatic set @JvmStatic set
} }
@@ -1,8 +1,6 @@
import kotlin.platform.platformStatic
object A { object A {
private @platformStatic fun a(): String { private @JvmStatic fun a(): String {
return "OK" return "OK"
} }
@@ -1,5 +1,3 @@
import kotlin.platform.platformStatic
var holder = "" var holder = ""
fun getA(): A { fun getA(): A {
@@ -9,13 +7,13 @@ fun getA(): A {
object A { object A {
@platformStatic var a: Int = 1 @JvmStatic var a: Int = 1
var b: Int = 1 var b: Int = 1
@platformStatic get @JvmStatic get
var c: Int = 1 var c: Int = 1
@platformStatic set @JvmStatic set
} }
@@ -1,7 +1,5 @@
import kotlin.platform.platformStatic
object X { object X {
@platformStatic val x = "OK" @JvmStatic val x = "OK"
fun fn(value : String = x): String = value fun fn(value : String = x): String = value
} }
@@ -1,16 +1,14 @@
import kotlin.platform.platformStatic
object A { object A {
val b: String = "OK" val b: String = "OK"
@platformStatic val c: String = "OK" @JvmStatic val c: String = "OK"
@platformStatic fun test1() : String { @JvmStatic fun test1() : String {
return b return b
} }
@platformStatic fun test2() : String { @JvmStatic fun test2() : String {
return test1() return test1()
} }
@@ -18,11 +16,11 @@ object A {
return "1".test5() return "1".test5()
} }
@platformStatic fun test4(): String { @JvmStatic fun test4(): String {
return "1".test5() return "1".test5()
} }
@platformStatic fun String.test5() : String { @JvmStatic fun String.test5() : String {
return this + b return this + b
} }
} }
@@ -1,8 +1,6 @@
import kotlin.platform.*
class C { class C {
companion object { companion object {
private @platformStatic fun foo(): String { private @JvmStatic fun foo(): String {
return "OK" return "OK"
} }
} }
@@ -7,7 +7,7 @@ class A {
} }
object O { object O {
@kotlin.platform.platformStatic fun baz() {} @JvmStatic fun baz() {}
} }
fun nullableUnit(unit: Boolean): Unit? = if (unit) Unit else null fun nullableUnit(unit: Boolean): Unit? = if (unit) Unit else null
@@ -1,13 +1,11 @@
package test package test
import kotlin.platform.platformStatic
open class B open class B
class A { class A {
companion object { companion object {
@platformStatic @JvmStatic
fun <T: B> a(s: T) : T { fun <T: B> a(s: T) : T {
return s return s
} }
@@ -1,20 +1,18 @@
package test package test
import kotlin.platform.platformStatic
class A { class A {
companion object { companion object {
val b: String = "OK" val b: String = "OK"
@platformStatic fun test1() { @JvmStatic fun test1() {
b b
test2() test2()
test3() test3()
"".test4() "".test4()
} }
@platformStatic fun test2() { @JvmStatic fun test2() {
b b
} }
@@ -22,7 +20,7 @@ class A {
} }
@platformStatic fun String.test4() { @JvmStatic fun String.test4() {
b b
} }
} }
@@ -8,10 +8,10 @@ public final class A {
public companion object Companion { public companion object Companion {
private constructor Companion() private constructor Companion()
public final val b: kotlin.String public final val b: kotlin.String
@kotlin.platform.platformStatic() public final fun test1(): kotlin.Unit @kotlin.jvm.JvmStatic() public final fun test1(): kotlin.Unit
@kotlin.platform.platformStatic() public final fun test2(): kotlin.Unit @kotlin.jvm.JvmStatic() public final fun test2(): kotlin.Unit
public final fun test3(): kotlin.Unit public final fun test3(): kotlin.Unit
@kotlin.platform.platformStatic() public final fun kotlin.String.test4(): kotlin.Unit @kotlin.jvm.JvmStatic() public final fun kotlin.String.test4(): kotlin.Unit
} }
} }
@@ -1,14 +1,12 @@
package test package test
import kotlin.platform.platformStatic
class A { class A {
companion object { companion object {
@platformStatic val b: String = "OK" @JvmStatic val b: String = "OK"
var A.c: String var A.c: String
@platformStatic get() = "OK" @JvmStatic get() = "OK"
@platformStatic set(t: String) {} @JvmStatic set(t: String) {}
} }
} }
@@ -7,7 +7,7 @@ public final class A {
public companion object Companion { public companion object Companion {
private constructor Companion() private constructor Companion()
@kotlin.platform.platformStatic() public final val b: kotlin.String @kotlin.jvm.JvmStatic() public final val b: kotlin.String
public final var test.A.c: kotlin.String public final var test.A.c: kotlin.String
} }
} }
@@ -1,19 +1,17 @@
package test package test
import kotlin.platform.platformStatic
object A { object A {
val b: String = "OK" val b: String = "OK"
@platformStatic fun test1() { @JvmStatic fun test1() {
b b
test2() test2()
test3() test3()
"".test4() "".test4()
} }
@platformStatic fun test2() { @JvmStatic fun test2() {
b b
} }
@@ -21,7 +19,7 @@ object A {
} }
@platformStatic fun String.test4() { @JvmStatic fun String.test4() {
b b
} }
} }
@@ -5,10 +5,10 @@ public fun main(/*0*/ kotlin.Array<kotlin.String>): kotlin.Unit
public object A { public object A {
private constructor A() private constructor A()
public final val b: kotlin.String public final val b: kotlin.String
@kotlin.platform.platformStatic() public final fun test1(): kotlin.Unit @kotlin.jvm.JvmStatic() public final fun test1(): kotlin.Unit
@kotlin.platform.platformStatic() public final fun test2(): kotlin.Unit @kotlin.jvm.JvmStatic() public final fun test2(): kotlin.Unit
public final fun test3(): kotlin.Unit public final fun test3(): kotlin.Unit
@kotlin.platform.platformStatic() public final fun kotlin.String.test4(): kotlin.Unit @kotlin.jvm.JvmStatic() public final fun kotlin.String.test4(): kotlin.Unit
} }
public/*package*/ open class Test { public/*package*/ open class Test {
@@ -1,13 +1,11 @@
package test package test
import kotlin.platform.platformStatic
object A { object A {
@platformStatic val b: String = "OK" @JvmStatic val b: String = "OK"
var A.c: String var A.c: String
@platformStatic get() = "OK" @JvmStatic get() = "OK"
@platformStatic set(t: String) {} @JvmStatic set(t: String) {}
} }
@@ -4,7 +4,7 @@ public fun main(/*0*/ kotlin.Array<kotlin.String>): kotlin.Unit
public object A { public object A {
private constructor A() private constructor A()
@kotlin.platform.platformStatic() public final val b: kotlin.String @kotlin.jvm.JvmStatic() public final val b: kotlin.String
public final var test.A.c: kotlin.String public final var test.A.c: kotlin.String
} }
@@ -1,9 +1,7 @@
package test package test
import kotlin.platform.*
var v: Int = 1 var v: Int = 1
@platformName("vget") @JvmName("vget")
get get
@platformName("vset") @JvmName("vset")
set set
@@ -1,12 +1,10 @@
package lib package lib
import kotlin.platform.* @JvmName("bar")
@platformName("bar")
fun foo() = "foo" fun foo() = "foo"
var v: Int = 1 var v: Int = 1
@platformName("vget") @JvmName("vget")
get get
@platformName("vset") @JvmName("vset")
set set
@@ -1,18 +1,16 @@
package test package test
import kotlin.platform.*
annotation class A(val s: String) annotation class A(val s: String)
@platformName("bar")
@A("1") @A("1")
@JvmName("bar")
fun foo() = "foo" fun foo() = "foo"
@field:A("2") @field:A("2")
var v: Int = 1 var v: Int = 1
@platformName("vget")
@A("3") @A("3")
@JvmName("vget")
get get
@platformName("vset")
@A("4") @A("4")
@JvmName("vset")
set set
@@ -1,9 +1,9 @@
package test package test
@field:test.A(s = "2") public var v: kotlin.Int @field:test.A(s = "2") public var v: kotlin.Int
@kotlin.platform.platformName(name = "vget") @test.A(s = "3") public fun <get-v>(): kotlin.Int @test.A(s = "3") @kotlin.jvm.JvmName(name = "vget") public fun <get-v>(): kotlin.Int
@kotlin.platform.platformName(name = "vset") @test.A(s = "4") public fun <set-v>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit @test.A(s = "4") @kotlin.jvm.JvmName(name = "vset") public fun <set-v>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
@kotlin.platform.platformName(name = "bar") @test.A(s = "1") public fun foo(): kotlin.String @test.A(s = "1") @kotlin.jvm.JvmName(name = "bar") public fun foo(): kotlin.String
public final annotation class A : kotlin.Annotation { public final annotation class A : kotlin.Annotation {
/*primary*/ public constructor A(/*0*/ s: kotlin.String) /*primary*/ public constructor A(/*0*/ s: kotlin.String)
@@ -50,7 +50,6 @@ public class DescriptorUtils {
public static final Name ENUM_VALUES = Name.identifier("values"); public static final Name ENUM_VALUES = Name.identifier("values");
public static final Name ENUM_VALUE_OF = Name.identifier("valueOf"); public static final Name ENUM_VALUE_OF = Name.identifier("valueOf");
public static final FqName JVM_NAME = new FqName("kotlin.jvm.JvmName"); public static final FqName JVM_NAME = new FqName("kotlin.jvm.JvmName");
public static final FqName PLATFORM_NAME = new FqName("kotlin.platform.platformName");
public static final FqName VOLATILE = new FqName("kotlin.jvm.Volatile"); public static final FqName VOLATILE = new FqName("kotlin.jvm.Volatile");
public static final FqName SYNCHRONIZED = new FqName("kotlin.jvm.Synchronized"); public static final FqName SYNCHRONIZED = new FqName("kotlin.jvm.Synchronized");
@@ -531,9 +530,6 @@ public class DescriptorUtils {
@Nullable @Nullable
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotations annotations) { public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotations annotations) {
AnnotationWithTarget jvmName = Annotations.Companion.findAnyAnnotation(annotations, JVM_NAME); AnnotationWithTarget jvmName = Annotations.Companion.findAnyAnnotation(annotations, JVM_NAME);
if (jvmName == null) {
jvmName = Annotations.Companion.findAnyAnnotation(annotations, PLATFORM_NAME);
}
return jvmName == null ? null : jvmName.getAnnotation(); return jvmName == null ? null : jvmName.getAnnotation();
} }
@@ -61,7 +61,6 @@ internal open class KFunctionImpl protected constructor(
is Constructor<*> -> FunctionCaller.Constructor(member) is Constructor<*> -> FunctionCaller.Constructor(member)
is Method -> when { is Method -> when {
!Modifier.isStatic(member.modifiers) -> FunctionCaller.InstanceMethod(member) !Modifier.isStatic(member.modifiers) -> FunctionCaller.InstanceMethod(member)
descriptor.annotations.findAnnotation(PLATFORM_STATIC) != null,
descriptor.annotations.findAnnotation(JVM_STATIC) != null -> descriptor.annotations.findAnnotation(JVM_STATIC) != null ->
FunctionCaller.JvmStaticInObject(member) FunctionCaller.JvmStaticInObject(member)
@@ -90,7 +89,6 @@ internal open class KFunctionImpl protected constructor(
when (member) { when (member) {
is Constructor<*> -> FunctionCaller.Constructor(member) is Constructor<*> -> FunctionCaller.Constructor(member)
is Method -> when { is Method -> when {
descriptor.annotations.findAnnotation(PLATFORM_STATIC) != null,
descriptor.annotations.findAnnotation(JVM_STATIC) != null -> descriptor.annotations.findAnnotation(JVM_STATIC) != null ->
FunctionCaller.JvmStaticInObject(member) FunctionCaller.JvmStaticInObject(member)
@@ -97,7 +97,6 @@ private fun KPropertyImpl.Accessor<*>.computeCallerForAccessor(isGetter: Boolean
return false return false
} }
fun isJvmStaticProperty() = fun isJvmStaticProperty() =
property.descriptor.annotations.findAnnotation(PLATFORM_STATIC) != null ||
property.descriptor.annotations.findAnnotation(JVM_STATIC) != null property.descriptor.annotations.findAnnotation(JVM_STATIC) != null
@@ -19,7 +19,6 @@ package kotlin.reflect.jvm.internal
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import kotlin.reflect.IllegalCallableAccessException import kotlin.reflect.IllegalCallableAccessException
internal val PLATFORM_STATIC = FqName("kotlin.platform.platformStatic")
internal val JVM_STATIC = FqName("kotlin.jvm.JvmStatic") internal val JVM_STATIC = FqName("kotlin.jvm.JvmStatic")
// TODO: wrap other exceptions // TODO: wrap other exceptions
@@ -45,7 +45,7 @@ public abstract class CallableReference implements KCallable {
} }
/** /**
* @return Kotlin name of the callable, the one which was declared in the source code (@platformName doesn't change it) * @return Kotlin name of the callable, the one which was declared in the source code (@JvmName doesn't change it)
*/ */
@Override @Override
public String getName() { public String getName() {
@@ -1,5 +1,3 @@
import kotlin.platform.platformName
class C(i: Int){ class C(i: Int){
class Nested class Nested
inner class Inner inner class Inner
@@ -9,10 +7,10 @@ class C(i: Int){
} }
} }
platformName("foo1") @JvmName("foo1")
fun foo(p: () -> C.Nested){} fun foo(p: () -> C.Nested){}
platformName("foo2") @JvmName("foo2")
fun foo(p: () -> C.Inner){} fun foo(p: () -> C.Inner){}
// EXIST: ::Nested // EXIST: ::Nested
@@ -1,8 +1,6 @@
package ppp package ppp
import kotlin.platform.platformStatic
public object Dependency { public object Dependency {
@platformStatic @JvmStatic
public val FIELD: Int = 1 public val FIELD: Int = 1
} }
@@ -1,14 +1,12 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtObjectDeclaration // PSI_ELEMENT: org.jetbrains.kotlin.psi.KtObjectDeclaration
// OPTIONS: usages // OPTIONS: usages
import kotlin.platform.platformStatic
class Foo { class Foo {
companion <caret>object { companion <caret>object {
fun f() { fun f() {
} }
@platformStatic fun s() { @JvmStatic fun s() {
} }
val CONST = 42 val CONST = 42
@@ -1,7 +1,5 @@
package companionObjectUsedInJava package companionObjectUsedInJava
import kotlin.platform.platformStatic
class A { class A {
companion object { companion object {
val CONST = 42 val CONST = 42
@@ -10,7 +8,7 @@ class A {
class B { class B {
companion object { companion object {
platformStatic fun foo() { @JvmStatic fun foo() {
} }
} }
} }
@@ -23,7 +21,7 @@ class C {
class D { class D {
companion object Named { companion object Named {
platformStatic fun foo() { @JvmStatic fun foo() {
} }
} }
} }
@@ -2,7 +2,7 @@ package companionObjectWithStatics
class Foo { class Foo {
companion object { companion object {
platformStatic fun foo() { @JvmStatic fun foo() {
} }
val CONST = 111 val CONST = 111
@@ -2,10 +2,8 @@ package entryPoint
// WITH_RUNTIME // WITH_RUNTIME
import kotlin.platform.platformStatic
object EntryPoint { object EntryPoint {
@platformStatic public fun main(args: Array<String>) { @JvmStatic public fun main(args: Array<String>) {
} }
} }
@@ -1,10 +1,8 @@
// FULL_JDK // FULL_JDK
import kotlin.platform.platformStatic
class Klass : java.io.Serializable { class Klass : java.io.Serializable {
companion object { companion object {
private platformStatic val serialVersionUID: Long = 239 private @JvmStatic val serialVersionUID: Long = 239
} }
} }
@@ -3,7 +3,7 @@ class Foo {
fun f() { fun f() {
} }
platformStatic fun s() { @JvmStatic fun s() {
} }
val CONST = 42 val CONST = 42
@@ -3,7 +3,7 @@ class Foo {
fun f() { fun f() {
} }
platformStatic fun s() { @JvmStatic fun s() {
} }
val CONST = 42 val CONST = 42
@@ -3,7 +3,7 @@ class Foo {
fun f() { fun f() {
} }
platformStatic fun s() { @JvmStatic fun s() {
} }
val CONST = 42 val CONST = 42
@@ -3,7 +3,7 @@ class Foo {
fun f() { fun f() {
} }
platformStatic fun s() { @JvmStatic fun s() {
} }
val CONST = 42 val CONST = 42
@@ -3,7 +3,7 @@ class Foo {
fun f() { fun f() {
} }
platformStatic fun s() { @JvmStatic fun s() {
} }
val CONST = 42 val CONST = 42
@@ -3,7 +3,7 @@ class Foo {
fun f() { fun f() {
} }
platformStatic fun s() { @JvmStatic fun s() {
} }
val CONST = 42 val CONST = 42
+1 -3
View File
@@ -1,7 +1,5 @@
package k package k
import kotlin.platform.platformStatic
public class Class() { public class Class() {
public val prop: Int = 0 public val prop: Int = 0
fun function() = 1 fun function() = 1
@@ -32,7 +30,7 @@ public interface StaticFieldInClassObjectInTrait {
} }
object PlatformStaticFun { object PlatformStaticFun {
platformStatic @JvmStatic
fun test() { fun test() {
} }
} }
+5 -7
View File
@@ -1,11 +1,9 @@
package q package q
import kotlin.platform.platformStatic
// RUN: q.Foo // RUN: q.Foo
object Foo { object Foo {
// RUN: q.Foo // RUN: q.Foo
@platformStatic fun main(s: Array<String>) { @JvmStatic fun main(s: Array<String>) {
println("Foo") println("Foo")
} }
@@ -13,7 +11,7 @@ object Foo {
class InnerFoo { class InnerFoo {
companion object { companion object {
// RUN: q.Foo.InnerFoo // RUN: q.Foo.InnerFoo
@platformStatic fun main(s: Array<String>) { @JvmStatic fun main(s: Array<String>) {
println("InnerFoo") println("InnerFoo")
} }
} }
@@ -22,7 +20,7 @@ object Foo {
// RUN: q.Foo // RUN: q.Foo
class InnerFoo2 { class InnerFoo2 {
// RUN: q.Foo // RUN: q.Foo
@platformStatic fun main(s: Array<String>) { @JvmStatic fun main(s: Array<String>) {
println("InnerFoo") println("InnerFoo")
} }
} }
@@ -40,7 +38,7 @@ object Foo2 {
class Bar { class Bar {
companion object { companion object {
// RUN: q.Bar // RUN: q.Bar
@platformStatic fun main(s: Array<String>) { @JvmStatic fun main(s: Array<String>) {
println("Bar") println("Bar")
} }
} }
@@ -59,7 +57,7 @@ class Bar2 {
// RUN: q.TestKt // RUN: q.TestKt
class Baz { class Baz {
// RUN: q.TestKt // RUN: q.TestKt
platformStatic fun main(s: Array<String>) { @JvmStatic fun main(s: Array<String>) {
println("Baz") println("Baz")
} }
} }
+5 -8
View File
@@ -1,11 +1,8 @@
package companions package companions
import kotlin.platform.platformName
import kotlin.platform.platformStatic
class A { class A {
companion object { companion object {
@platformStatic @JvmStatic
fun main(args: Array<String>) { fun main(args: Array<String>) {
// yes // yes
} }
@@ -22,8 +19,8 @@ class B {
class C { class C {
companion object { companion object {
@platformStatic @JvmStatic
@platformName("main0") @JvmName("main0")
fun main(args: Array<String>) { // no fun main(args: Array<String>) { // no
} }
} }
@@ -31,8 +28,8 @@ class C {
class D { class D {
companion object { companion object {
@platformStatic @JvmStatic
@platformName("main") @JvmName("main")
fun badName(args: Array<String>) { // yes fun badName(args: Array<String>) { // yes
} }
} }
@@ -1,8 +1,6 @@
package pkg2 package pkg2
import kotlin.platform.platformName @JvmName("aa")
@platformName("aa")
fun main(args: Array<String>) { fun main(args: Array<String>) {
// no // no
} }
@@ -1,8 +1,6 @@
package pkg3 package pkg3
import kotlin.platform.platformName @JvmName("main")
@platformName("main")
fun aaa(args: Array<String>) { fun aaa(args: Array<String>) {
// yes // yes
} }
+1 -3
View File
@@ -1,8 +1,6 @@
package renameTest package renameTest
import kotlin.platform.platformStatic
object Foo { object Foo {
@platformStatic fun main(args: Array<String>) { @JvmStatic fun main(args: Array<String>) {
} }
} }
@@ -1,8 +1,6 @@
package renameTest package renameTest
import kotlin.platform.platformStatic
object Foo { object Foo {
@platformStatic fun main(args: Array<String>) { @JvmStatic fun main(args: Array<String>) {
} }
} }
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import java.util.ArrayList import java.util.ArrayList
import java.util.HashSet import java.util.HashSet
import java.util.LinkedHashSet import java.util.LinkedHashSet
import kotlin.platform.platformName
fun<T> CodeBuilder.buildList(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder { fun<T> CodeBuilder.buildList(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder {
if (generators.isNotEmpty()) { if (generators.isNotEmpty()) {
@@ -1,31 +0,0 @@
/*
* 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
import kotlin.annotation.AnnotationTarget.*
@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@Deprecated("Use kotlin.jvm.JvmName instead", ReplaceWith("kotlin.jvm.JvmName"))
public annotation class platformName(public val name: String)
@Target(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@Deprecated("Use kotlin.jvm.JvmStatic instead", ReplaceWith("kotlin.jvm.JvmStatic"))
public annotation class platformStatic