J2K: all annotations should be with "@"

This commit is contained in:
Valentin Kipyatkov
2015-09-15 12:47:08 +03:00
parent cc4aa6ed21
commit 7caccd7578
71 changed files with 129 additions and 129 deletions
@@ -5,7 +5,7 @@ internal class C {
}
companion object {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
}
}
}
@@ -2,4 +2,4 @@ package to
import kotlin.reflect.KClass
annotation internal class Ann(val value: KClass<Any>)
internal annotation class Ann(val value: KClass<Any>)
@@ -1,2 +1,2 @@
Ann(String::class)
@Ann(String::class)
class X
@@ -1,3 +1,3 @@
package to
Volatile internal var field = 1
@Volatile internal var field = 1
@@ -1,7 +1,7 @@
package to
object JavaClass {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
println("Hello, world!")
}
}
@@ -1,6 +1,6 @@
package to
SomeAnnotation
@SomeAnnotation
fun foo(): String {
return ""
}
@@ -55,7 +55,7 @@ class AnnotationConverter(private val converter: Converter) {
if (child is PsiWhiteSpace) !child.isInSingleLine() else false
}
annotations.map { convertAnnotation(it, withAt = owner is PsiLocalVariable, newLineAfter = newLines) }.filterNotNull() //TODO: '@' is also needed for local classes
annotations.map { convertAnnotation(it, newLineAfter = newLines) }.filterNotNull() //TODO: '@' is also needed for local classes
}
else {
listOf()
@@ -77,14 +77,14 @@ class AnnotationConverter(private val converter: Converter) {
LiteralExpression("\"" + StringUtil.escapeStringCharacters(deprecatedTag.content()) + "\"").assignNoPrototype()
}
return Annotation(Identifier("Deprecated").assignPrototype(deprecatedTag.getNameElement()),
listOf(null to deferredExpression), withAt = false, newLineAfter = true)
listOf(null to deferredExpression), newLineAfter = true)
.assignPrototype(deprecatedTag)
}
private fun convertModifiersToAnnotations(owner: PsiModifierListOwner): Annotations {
val list = MODIFIER_TO_ANNOTATION
.filter { owner.hasModifierProperty(it.first) }
.map { Annotation(Identifier(it.second).assignNoPrototype(), listOf(), withAt = false, newLineAfter = false).assignNoPrototype() }
.map { Annotation(Identifier(it.second).assignNoPrototype(), listOf(), newLineAfter = false).assignNoPrototype() }
return Annotations(list).assignNoPrototype()
}
@@ -99,11 +99,11 @@ class AnnotationConverter(private val converter: Converter) {
return expr.referenceName?.let { JavaAnnotationTargetMapper.mapJavaTargetArgumentByName(it) } ?: emptySet()
}
public fun convertAnnotation(annotation: PsiAnnotation, withAt: Boolean, newLineAfter: Boolean): Annotation? {
public fun convertAnnotation(annotation: PsiAnnotation, newLineAfter: Boolean): Annotation? {
val qualifiedName = annotation.getQualifiedName()
if (qualifiedName == CommonClassNames.JAVA_LANG_DEPRECATED && annotation.getParameterList().getAttributes().isEmpty()) {
val deferredExpression = converter.deferredElement<Expression> { LiteralExpression("\"\"").assignNoPrototype() }
return Annotation(Identifier("Deprecated").assignNoPrototype(), listOf(null to deferredExpression), withAt, newLineAfter).assignPrototype(annotation) //TODO: insert comment
return Annotation(Identifier("Deprecated").assignNoPrototype(), listOf(null to deferredExpression), newLineAfter).assignPrototype(annotation) //TODO: insert comment
}
if (qualifiedName == CommonClassNames.JAVA_LANG_ANNOTATION_TARGET) {
val attributes = annotation.parameterList.attributes
@@ -129,7 +129,7 @@ class AnnotationConverter(private val converter: Converter) {
}
}
return Annotation(Identifier("Target").assignNoPrototype(),
deferredExpressionList, true, newLineAfter).assignPrototype(annotation)
deferredExpressionList, newLineAfter).assignPrototype(annotation)
}
val nameRef = annotation.getNameReferenceElement()
@@ -148,7 +148,7 @@ class AnnotationConverter(private val converter: Converter) {
attrValues.map { attrName to converter.deferredElement(it) }
}
return Annotation(name, arguments, withAt, newLineAfter).assignPrototype(annotation)
return Annotation(name, arguments, newLineAfter).assignPrototype(annotation)
}
public fun convertAnnotationMethodDefault(method: PsiAnnotationMethod): DeferredElement<Expression>? {
@@ -109,7 +109,7 @@ class Converter private constructor(
is PsiExpression -> createDefaultCodeConverter().convertExpression(element)
is PsiImportList -> convertImportList(element)
is PsiImportStatementBase -> convertImport(element, false)
is PsiAnnotation -> annotationConverter.convertAnnotation(element, withAt = false, newLineAfter = false)
is PsiAnnotation -> annotationConverter.convertAnnotation(element, newLineAfter = false)
is PsiPackageStatement -> PackageStatement(quoteKeywords(element.getPackageName() ?: "")).assignPrototype(element)
is PsiJavaCodeReferenceElement -> {
if (element.parent is PsiReferenceList) {
@@ -280,10 +280,9 @@ class Converter private constructor(
classBody = ClassBody(constructorSignature, classBody.baseClassParams, classBody.members,
classBody.companionObjectMembers, classBody.lBrace, classBody.rBrace, classBody.isEnumBody, classBody.isAnonymousClassBody)
val annotationAnnotation = Annotation(Identifier("annotation").assignNoPrototype(), listOf(), withAt = false, newLineAfter = false).assignNoPrototype()
return Class(psiClass.declarationIdentifier(),
convertAnnotations(psiClass) + Annotations(listOf(annotationAnnotation)),
convertModifiers(psiClass).without(Modifier.ABSTRACT),
convertAnnotations(psiClass),
convertModifiers(psiClass).with(Modifier.ANNOTATION).without(Modifier.ABSTRACT),
TypeParameterList.Empty,
listOf(),
null,
@@ -427,7 +426,6 @@ class Converter private constructor(
function.annotations += Annotations(
listOf(Annotation(identifier,
listOf(),
withAt = false,
newLineAfter = false).assignNoPrototype())).assignNoPrototype()
}
@@ -435,7 +433,6 @@ class Converter private constructor(
function.annotations += Annotations(
listOf(Annotation(Identifier("JvmOverloads").assignNoPrototype(),
listOf(),
withAt = false,
newLineAfter = false).assignNoPrototype())).assignNoPrototype()
}
@@ -586,7 +583,7 @@ class Converter private constructor(
val convertedType = typeConverter.convertType(types[index], Nullability.NotNull)
null to deferredElement<Expression> { ClassLiteralExpression(convertedType.assignPrototype(refElements[index])) }
}
val annotation = Annotation(Identifier("Throws").assignNoPrototype(), arguments, withAt = false, newLineAfter = true)
val annotation = Annotation(Identifier("Throws").assignNoPrototype(), arguments, newLineAfter = true)
return Annotations(listOf(annotation.assignPrototype(throwsList))).assignPrototype(throwsList)
}
@@ -16,11 +16,13 @@
package org.jetbrains.kotlin.j2k.ast
import org.jetbrains.kotlin.j2k.*
import org.jetbrains.kotlin.j2k.CodeBuilder
import org.jetbrains.kotlin.j2k.append
import org.jetbrains.kotlin.j2k.buildList
class Annotation(val name: Identifier, val arguments: List<Pair<Identifier?, DeferredElement<Expression>>>, val withAt: Boolean, val newLineAfter: Boolean) : Element() {
class Annotation(val name: Identifier, val arguments: List<Pair<Identifier?, DeferredElement<Expression>>>, val newLineAfter: Boolean) : Element() {
override fun generateCode(builder: CodeBuilder) {
if (withAt) builder.append("@")
builder.append("@")
if (arguments.isEmpty()) {
builder.append(name)
}
@@ -23,6 +23,7 @@ enum class Modifier(val name: String) {
PROTECTED("protected"),
PRIVATE("private"),
INTERNAL("internal"),
ANNOTATION("annotation"),
ABSTRACT("abstract"),
OPEN("open"),
OVERRIDE("override"),
@@ -1,12 +1,12 @@
annotation internal class Anon(val stringArray: Array<String>, val intArray: IntArray, // string
internal annotation class Anon(val stringArray: Array<String>, val intArray: IntArray, // string
val string: String)
Anon(string = "a", stringArray = arrayOf("a", "b"), intArray = intArrayOf(1, 2))
@Anon(string = "a", stringArray = arrayOf("a", "b"), intArray = intArrayOf(1, 2))
@Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD)
annotation internal class I
internal annotation class I
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
annotation internal class J
internal annotation class J
@Target
annotation internal class K
internal annotation class K
@@ -1,4 +1,4 @@
annotation internal class Anon(val s: String = "a", val stringArray: Array<String> = arrayOf("a", "b"), val intArray: IntArray)
internal annotation class Anon(val s: String = "a", val stringArray: Array<String> = arrayOf("a", "b"), val intArray: IntArray)
Anon(intArray = intArrayOf(1, 2))
@Anon(intArray = intArrayOf(1, 2))
internal class A
@@ -1,6 +1,6 @@
// ERROR: Body is not allowed for annotation class
// ERROR: Modifier 'companion' is not applicable inside 'annotation class'
annotation internal class Anon(val value: String) {
internal annotation class Anon(val value: String) {
enum class E {
A, B
@@ -12,7 +12,7 @@ annotation internal class Anon(val value: String) {
}
}
Anon("a")
@Anon("a")
internal interface I {
companion object {
val e: Anon.E = Anon.field
@@ -1,13 +1,13 @@
annotation internal class Anon(vararg val value: String, val x: Int = 1)
internal annotation class Anon(vararg val value: String, val x: Int = 1)
Anon("a", "b")
@Anon("a", "b")
internal interface I1
Anon("c", "d", x = 1)
@Anon("c", "d", x = 1)
internal interface I2
Anon("c", "d", x = 1)
@Anon("c", "d", x = 1)
internal interface I3
Anon(value = *arrayOf("c", "d"))
@Anon(value = *arrayOf("c", "d"))
internal interface I4
+15 -15
View File
@@ -3,30 +3,30 @@
// ERROR: This annotation is not applicable to target 'value parameter'
import javaApi.*
Anon1(value = *arrayOf("a"), stringArray = arrayOf("b"), intArray = intArrayOf(1, 2), string = "x")
Anon2(value = "a", intValue = 1, charValue = 'a')
Anon3(e = E.A, stringArray = arrayOf(), value = *arrayOf("a", "b"))
Anon4("x", "y")
Anon5(1)
Anon6("x", "y")
Anon7(String::class, StringBuilder::class)
Anon8(classes = arrayOf(String::class, StringBuilder::class))
@Anon1(value = *arrayOf("a"), stringArray = arrayOf("b"), intArray = intArrayOf(1, 2), string = "x")
@Anon2(value = "a", intValue = 1, charValue = 'a')
@Anon3(e = E.A, stringArray = arrayOf(), value = *arrayOf("a", "b"))
@Anon4("x", "y")
@Anon5(1)
@Anon6("x", "y")
@Anon7(String::class, StringBuilder::class)
@Anon8(classes = arrayOf(String::class, StringBuilder::class))
internal class C {
Anon5(1) Deprecated("") private val field1 = 0
@Anon5(1) @Deprecated("") private val field1 = 0
Anon5(1)
@Anon5(1)
private val field2 = 0
Anon5(1) internal var field3 = 0
@Anon5(1) internal var field3 = 0
Anon5(1)
@Anon5(1)
internal var field4 = 0
Anon6
internal fun foo(Deprecated("") p1: Int, Deprecated("") Anon5(2) p2: Char) {
@Anon6
internal fun foo(@Deprecated("") p1: Int, @Deprecated("") @Anon5(2) p2: Char) {
@Deprecated("") @Anon5(3) val c = 'a'
}
Anon5(1) internal fun bar() {
@Anon5(1) internal fun bar() {
}
}
@@ -1,6 +1,6 @@
import kotlin.reflect.KClass
annotation internal class Ann(val value: KClass<*>, val other: KClass<*>)
internal annotation class Ann(val value: KClass<*>, val other: KClass<*>)
Ann(other = String::class, value = Any::class)
@Ann(other = String::class, value = Any::class)
internal class C
@@ -1,9 +1,9 @@
import kotlin.reflect.KClass
annotation internal class Ann(vararg val value: KClass<*>)
internal annotation class Ann(vararg val value: KClass<*>)
Ann(String::class, Any::class)
@Ann(String::class, Any::class)
internal class C
Ann
@Ann
internal class D
@@ -1,2 +1,2 @@
internal class C Deprecated("")
internal class C @Deprecated("")
constructor()
@@ -1,5 +1,5 @@
object A {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
println(Void.TYPE)
println(Integer.TYPE)
println(java.lang.Double.TYPE)
@@ -1,5 +1,5 @@
internal class A// this is a primary constructor
JvmOverloads internal constructor(p: Int = 1) {
@JvmOverloads internal constructor(p: Int = 1) {
private val v: Int
init {
+1 -1
View File
@@ -1,6 +1,6 @@
package pack
internal class C JvmOverloads internal constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0)
internal class C @JvmOverloads internal constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0)
object User {
fun main() {
@@ -1,16 +1,16 @@
import javaApi.Anon5
internal class A
Anon5(10)
@Anon5(10)
constructor(private val a: Int, private val b: Int) {
Deprecated("") // this constructor will not be replaced by default parameter value in primary because of this annotation
@Deprecated("") // this constructor will not be replaced by default parameter value in primary because of this annotation
constructor(a: Int) : this(a, 1) {
}
}
internal class B Anon5(11)
internal class B @Anon5(11)
constructor()
internal class C Anon5(12)
internal class C @Anon5(12)
private constructor()
@@ -1 +1 @@
internal class C JvmOverloads constructor(private val string: String, a: Int = string.length())
internal class C @JvmOverloads constructor(private val string: String, a: Int = string.length())
@@ -1,3 +1,3 @@
import java.lang.SuppressWarnings
internal class C(Deprecated("") private val p1: Int, Deprecated("") private val myP2: Int, Deprecated("") SuppressWarnings("x") var p3: Int)
internal class C(@Deprecated("") private val p1: Int, @Deprecated("") private val myP2: Int, @Deprecated("") @SuppressWarnings("x") var p3: Int)
@@ -1,4 +1,4 @@
internal class A JvmOverloads internal constructor(nested: A.Nested = A.Nested(A.Nested.FIELD)) {
internal class A @JvmOverloads internal constructor(nested: A.Nested = A.Nested(A.Nested.FIELD)) {
internal class Nested internal constructor(p: Int) {
companion object {
@@ -1,7 +1,7 @@
// ERROR: Property must be initialized or be abstract
import A.Nested
internal class A JvmOverloads internal constructor(nested: Nested = Nested(Nested.FIELD)) {
internal class A @JvmOverloads internal constructor(nested: Nested = Nested(Nested.FIELD)) {
internal class Nested internal constructor(p: Int) {
companion object {
@@ -3,7 +3,7 @@ package pack
import pack.A.Nested
internal class A JvmOverloads internal constructor(nested: Nested = Nested(Nested.FIELD)) {
internal class A @JvmOverloads internal constructor(nested: Nested = Nested(Nested.FIELD)) {
internal class Nested internal constructor(p: Int) {
companion object {
@@ -3,7 +3,7 @@ package pack
import pack.A.*
internal class A JvmOverloads internal constructor(nested: Nested = Nested(Nested.FIELD)) {
internal class A @JvmOverloads internal constructor(nested: Nested = Nested(Nested.FIELD)) {
internal class Nested internal constructor(p: Int) {
companion object {
@@ -1,6 +1,6 @@
package pack
internal class C JvmOverloads internal constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
internal class C @JvmOverloads internal constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
internal constructor(a: Int) : this(a, 0, 0, 0, 1) {
}
@@ -1,6 +1,6 @@
package pack
internal class C JvmOverloads internal constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
internal class C @JvmOverloads internal constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
internal constructor(a1: Int, b1: Int, c1: Int) : this(a1, b1, c1, 0, 0) {
}
@@ -1,6 +1,6 @@
package pack
internal class C JvmOverloads internal constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
internal class C @JvmOverloads internal constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
internal constructor(a: Int, b: Int, c: Int) : this(b, a, c, 0, 0) {
}
@@ -1,3 +1,3 @@
package pack
internal class C JvmOverloads internal constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
internal class C @JvmOverloads internal constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
@@ -1,3 +1,3 @@
package pack
internal class C JvmOverloads internal constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
internal class C @JvmOverloads internal constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
@@ -1,4 +1,4 @@
internal class C JvmOverloads internal constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
internal class C @JvmOverloads internal constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
private val field: Int
init {
@@ -7,7 +7,7 @@ internal class A {
constructor() {
}
JvmOverloads constructor(p: Int, s: String, x: Int = 1) {
@JvmOverloads constructor(p: Int, s: String, x: Int = 1) {
this.s = s
this.x = x
}
@@ -4,7 +4,7 @@ internal class A() {
private val s = ""
private val x = 0
JvmOverloads constructor(p: Int, s: String, x: Int = 1) : this() {
@JvmOverloads constructor(p: Int, s: String, x: Int = 1) : this() {
this.s = s
this.x = x
}
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* This is a deprecated class.
*/
Deprecated("do not use")
@Deprecated("do not use")
internal class C
@@ -1,2 +1,2 @@
Deprecated("do not use")
@Deprecated("do not use")
internal class C
@@ -1 +1 @@
class C JvmOverloads internal constructor(c: C, val x: Int = c.x)
class C @JvmOverloads internal constructor(c: C, val x: Int = c.x)
@@ -1,10 +1,10 @@
// ERROR: This annotation is not applicable to target 'member property'
internal class A {
Deprecated("")
Volatile internal var field1 = 0
@Deprecated("")
@Volatile internal var field1 = 0
Transient internal var field2 = 1
@Transient internal var field2 = 1
// Should work even for bad modifiers
Strictfp internal var field3 = 2.0
@Strictfp internal var field3 = 2.0
}
+1 -1
View File
@@ -1,5 +1,5 @@
object TestClass {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
var i = 0
while (i < 10) {
if (i == 4 || i == 8) {
+1 -1
View File
@@ -1,5 +1,5 @@
object TestClass {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
var i = 0
var j = 1
while (i < 10) {
+1 -1
View File
@@ -1,5 +1,5 @@
object TestClass {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
var i = 1
while (i < 1000) {
if (i == 4 || i == 8) {
+1 -1
View File
@@ -1,5 +1,5 @@
object TestClass {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
var i = 1
OuterLoop1@ OuterLoop2@ while (i < 1000) {
var j = 1
@@ -11,7 +11,7 @@ internal class Test : Base() {
return super.equals(o)
}
Throws(CloneNotSupportedException::class)
@Throws(CloneNotSupportedException::class)
override fun clone(): Any {
return super.clone()
}
@@ -20,7 +20,7 @@ internal class Test : Base() {
return super.toString()
}
Throws(Throwable::class)
@Throws(Throwable::class)
override fun finalize() {
super.finalize()
}
@@ -35,7 +35,7 @@ internal open class Base {
return super.equals(o)
}
Throws(CloneNotSupportedException::class)
@Throws(CloneNotSupportedException::class)
protected open fun clone(): Any {
return super.clone()
}
@@ -44,7 +44,7 @@ internal open class Base {
return super.toString()
}
Throws(Throwable::class)
@Throws(Throwable::class)
protected open fun finalize() {
super.finalize()
}
+1 -1
View File
@@ -1,2 +1,2 @@
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
}
+1 -1
View File
@@ -1,4 +1,4 @@
object A {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
}
}
@@ -1,5 +1,5 @@
// !forceNotNullTypes: false
object A {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
}
}
+2 -2
View File
@@ -12,14 +12,14 @@ internal class X {
return super.toString()
}
Throws(CloneNotSupportedException::class)
@Throws(CloneNotSupportedException::class)
protected fun clone(): Any {
return super.clone()
}
}
internal class Y : Thread() {
Throws(CloneNotSupportedException::class)
@Throws(CloneNotSupportedException::class)
override fun clone(): Any {
return super.clone()
}
+1 -1
View File
@@ -14,7 +14,7 @@ internal class X : Base() {
return super.toString()
}
Throws(CloneNotSupportedException::class)
@Throws(CloneNotSupportedException::class)
protected fun clone(): Any {
return super.clone()
}
+1 -1
View File
@@ -1,5 +1,5 @@
internal class A {
Synchronized internal fun foo() {
@Synchronized internal fun foo() {
bar()
}
+1 -1
View File
@@ -1,2 +1,2 @@
Throws(IOException::class, SerializationException::class)
@Throws(IOException::class, SerializationException::class)
internal fun foo()
+1 -1
View File
@@ -21,7 +21,7 @@ class Identifier<T> {
}
object User {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
val i1 = Identifier("name", false, true)
val i2 = Identifier("name", false)
val i3 = Identifier("name")
+1 -1
View File
@@ -5,7 +5,7 @@
import java.io.*
internal object FileRead {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
try {
val fstream = FileInputStream()
val `in` = DataInputStream(fstream)
+1 -1
View File
@@ -1,7 +1,7 @@
package demo
internal object Program {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
println("Halo!")
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
import java.lang.reflect.Constructor
internal object X {
Throws(Exception::class)
@Throws(Exception::class)
internal fun <T> foo(constructor: Constructor<T>, args1: Array<Any>, args2: Array<Any>) {
constructor.newInstance(*args1)
constructor.newInstance(args1, args2)
+2 -2
View File
@@ -1,7 +1,7 @@
// ERROR: Type mismatch: inferred type is kotlin.Any? but kotlin.Any was expected
// ERROR: Type mismatch: inferred type is kotlin.Any? but kotlin.Any was expected
internal class A {
JvmOverloads internal fun foo(s: String? = null): Any {
@JvmOverloads internal fun foo(s: String? = null): Any {
println("s = " + s!!)
return ""
}
@@ -24,7 +24,7 @@ internal class A {
return bar1(null)
}
Deprecated("")
@Deprecated("")
fun f() {
f(1)
}
+2 -2
View File
@@ -1,9 +1,9 @@
internal class A {
JvmOverloads internal fun foo(i: Int, c: Char = 'a', s: String = "") {
@JvmOverloads internal fun foo(i: Int, c: Char = 'a', s: String = "") {
println("foo" + i + c + s)
}
JvmOverloads internal fun bar(s: String? = null): Int {
@JvmOverloads internal fun bar(s: String? = null): Int {
println("s = " + s!!)
return 0
}
+1 -1
View File
@@ -3,7 +3,7 @@ internal class A {
println("p = [$p]")
}
Synchronized fun foo() {
@Synchronized fun foo() {
foo(calcSomething())
}
+1 -1
View File
@@ -76,7 +76,7 @@ object SwitchDemo {
println(monthString)
}
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
for (i in 1..12)
test(i)
}
+1 -1
View File
@@ -1,5 +1,5 @@
object NonDefault {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
val value = 3
val valueString = ""
+1 -1
View File
@@ -1,7 +1,7 @@
package switch_demo
object SwitchDemo {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
val month = 8
val monthString: String
when (month) {
+1 -1
View File
@@ -1,5 +1,5 @@
object C {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
when (args.size()) {
1 -> {
run {
+1 -1
View File
@@ -1,7 +1,7 @@
package switch_demo
object SwitchDemo {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
val month = 8
val monthString: String
+1 -1
View File
@@ -1,5 +1,5 @@
object NonDefault {
JvmStatic fun main(args: Array<String>) {
@JvmStatic fun main(args: Array<String>) {
val value = 3
var valueString = ""
+1 -1
View File
@@ -1,7 +1,7 @@
import java.io.*
class C {
Throws(IOException::class)
@Throws(IOException::class)
internal fun foo() {
ByteArrayInputStream(ByteArray(10)).use { stream ->
// reading something
@@ -1,7 +1,7 @@
import java.io.*
class C {
Throws(IOException::class)
@Throws(IOException::class)
internal fun foo() {
ByteArrayInputStream(ByteArray(10)).use { input ->
ByteArrayOutputStream().use { output ->
+1 -1
View File
@@ -1,7 +1,7 @@
import java.io.*
class C {
Throws(IOException::class)
@Throws(IOException::class)
internal fun foo() {
ByteArrayInputStream(ByteArray(10)).use { stream -> println(stream.read()) }
}
+1 -1
View File
@@ -1,7 +1,7 @@
import java.io.*
class C {
Throws(IOException::class)
@Throws(IOException::class)
internal fun foo() {
try {
ByteArrayInputStream(ByteArray(10)).use { stream ->
@@ -1,16 +1,16 @@
import java.io.*
internal interface I {
Throws(IOException::class)
@Throws(IOException::class)
fun doIt(stream: InputStream): Int
}
class C {
Throws(IOException::class)
@Throws(IOException::class)
internal fun foo() {
ByteArrayInputStream(ByteArray(10)).use { stream ->
bar(object : I {
Throws(IOException::class)
@Throws(IOException::class)
override fun doIt(stream: InputStream): Int {
return stream.available()
}
@@ -18,7 +18,7 @@ class C {
}
}
Throws(IOException::class)
@Throws(IOException::class)
internal fun bar(i: I, stream: InputStream): Int {
return i.doIt(stream)
}
@@ -1,16 +1,16 @@
import java.io.*
internal interface I {
Throws(IOException::class)
@Throws(IOException::class)
fun doIt(stream: InputStream): Int
}
class C {
Throws(IOException::class)
@Throws(IOException::class)
internal fun foo(): Int {
ByteArrayInputStream(ByteArray(10)).use { stream ->
return bar(object : I {
Throws(IOException::class)
@Throws(IOException::class)
override fun doIt(stream: InputStream): Int {
return stream.available()
}
@@ -18,7 +18,7 @@ class C {
}
}
Throws(IOException::class)
@Throws(IOException::class)
internal fun bar(i: I, stream: InputStream): Int {
return i.doIt(stream)
}