KT-20120 fixing bug for Java 9 Deprecated

Unconditionally changing it to @Deprecated("") in kotlin
This commit is contained in:
Alex Chmyr
2020-01-02 17:44:46 +00:00
committed by Ilya Kirillov
parent ba4163ba02
commit 16c82030a3
4 changed files with 35 additions and 5 deletions
@@ -28,10 +28,7 @@ class JavaAnnotationsConversion(context: NewJ2kConverterContext) : RecursiveAppl
private fun processAnnotation(annotation: JKAnnotation) {
if (annotation.classSymbol.fqName == "java.lang.Deprecated") {
annotation.classSymbol = symbolProvider.provideClassSymbol("kotlin.Deprecated")
if (annotation.arguments.isEmpty()) {
annotation.arguments +=
JKAnnotationParameterImpl(JKLiteralExpression("\"\"", JKLiteralExpression.LiteralType.STRING))
}
annotation.arguments = listOf(JKAnnotationParameterImpl(JKLiteralExpression("\"\"", JKLiteralExpression.LiteralType.STRING)))
}
if (annotation.classSymbol.fqName == "java.lang.annotation.Target") {
annotation.classSymbol = symbolProvider.provideClassSymbol("kotlin.annotation.Target")
@@ -80,4 +77,4 @@ class JavaAnnotationsConversion(context: NewJ2kConverterContext) : RecursiveAppl
"java.lang.annotation.ElementType.$java" to kotlins.map { "kotlin.annotation.AnnotationTarget.$it" }
}.toMap()
}
}
}
+7
View File
@@ -0,0 +1,7 @@
public class Deprecation {
@Deprecated() public void deprecate00() {}
@Deprecated(forRemoval = false) public void deprecate10() {}
@Deprecated(forRemoval = true) public void deprecate20() {}
@Deprecated(since = "2.0") public void deprecate01() {}
@Deprecated(forRemoval = true, since = "2.0") public void deprecate21() {}
}
+21
View File
@@ -0,0 +1,21 @@
class Deprecation {
@Deprecated("")
fun deprecate00() {
}
@Deprecated("")
fun deprecate10() {
}
@Deprecated("")
fun deprecate20() {
}
@Deprecated("")
fun deprecate01() {
}
@Deprecated("")
fun deprecate21() {
}
}
@@ -80,6 +80,11 @@ public class NewJavaToKotlinConverterSingleFileTestGenerated extends AbstractNew
runTest("nj2k/testData/newJ2k/annotations/annotationUsages.java");
}
@TestMetadata("java9Deprecated.java")
public void testJava9Deprecated() throws Exception {
runTest("nj2k/testData/newJ2k/annotations/java9Deprecated.java");
}
@TestMetadata("annotationsFromPropertyAccessors.java")
public void testAnnotationsFromPropertyAccessors() throws Exception {
runTest("nj2k/testData/newJ2k/annotations/annotationsFromPropertyAccessors.java");