New J2K: do not allow field and method declarations to be internal

For internal members new names are generated,
So, references to them from Java will be broken
This commit is contained in:
Ilya Kirillov
2019-10-07 12:32:47 +03:00
parent b30537de0e
commit d0f0b9e355
85 changed files with 185 additions and 191 deletions
@@ -12,44 +12,31 @@ import org.jetbrains.kotlin.nj2k.tree.*
class InternalDeclarationConversion(context: NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) { class InternalDeclarationConversion(context: NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) {
override fun applyToElement(element: JKTreeElement): JKTreeElement { override fun applyToElement(element: JKTreeElement): JKTreeElement {
if (element !is JKVisibilityOwner || element !is JKModalityOwner) return recurse(element) if (element !is JKVisibilityOwner || element !is JKModalityOwner) return recurse(element)
if (element.visibility != Visibility.INTERNAL) return recurse(element)
val containingClass = element.parentOfType<JKClass>() val containingClass = element.parentOfType<JKClass>()
val containingClassKind = containingClass?.classKind ?: element.psi<PsiMember>()?.containingClass?.classKind?.toJk()
if (element is JKClass && element.isLocalClass()) { val containingClassVisibility = containingClass?.visibility
element.visibility = Visibility.PUBLIC ?: element.psi<PsiMember>()
?.containingClass
?.visibility(context.converter.oldConverterServices.referenceSearcher, null)
?.visibility
element.visibility = when {
containingClassKind == JKClass.ClassKind.INTERFACE || containingClassKind == JKClass.ClassKind.ANNOTATION ->
Visibility.PUBLIC
containingClassKind == JKClass.ClassKind.ENUM && element is JKKtPrimaryConstructor ->
Visibility.PRIVATE
element is JKClass && !element.isLocalClass() ->
Visibility.INTERNAL
element is JKConstructor && containingClassVisibility != Visibility.INTERNAL ->
Visibility.INTERNAL
element is JKField || element is JKMethod ->
Visibility.PUBLIC
else -> Visibility.INTERNAL
} }
val containingClassVisibility =
containingClass?.visibility
?: element.psi<PsiMember>()
?.containingClass
?.visibility(context.converter.oldConverterServices.referenceSearcher, null)
?.visibility
val containingClassKind =
containingClass?.classKind
?: element.psi<PsiMember>()
?.containingClass
?.classKind
if (containingClassVisibility == Visibility.INTERNAL
&& element.visibility == Visibility.INTERNAL
&& element.modality == Modality.FINAL
&& (element is JKMethod || element is JKField)
) {
element.visibility = Visibility.PUBLIC
}
if (containingClassKind == JKClass.ClassKind.INTERFACE
|| containingClassKind == JKClass.ClassKind.ANNOTATION
) {
element.visibility = Visibility.PUBLIC
}
if (containingClassKind == JKClass.ClassKind.ENUM
&& element is JKKtPrimaryConstructor
) {
element.visibility = Visibility.PRIVATE
}
return recurse(element) return recurse(element)
} }
} }
@@ -6,11 +6,13 @@
package org.jetbrains.kotlin.nj2k package org.jetbrains.kotlin.nj2k
import com.intellij.codeInsight.generation.GenerateEqualsHelper.getEqualsSignature import com.intellij.codeInsight.generation.GenerateEqualsHelper.getEqualsSignature
import com.intellij.lang.jvm.JvmClassKind
import com.intellij.psi.* import com.intellij.psi.*
import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.InheritanceUtil import com.intellij.psi.util.InheritanceUtil
import com.intellij.psi.util.MethodSignatureUtil import com.intellij.psi.util.MethodSignatureUtil
import com.intellij.psi.util.PsiUtil import com.intellij.psi.util.PsiUtil
import org.jetbrains.kotlin.j2k.ClassKind
import org.jetbrains.kotlin.j2k.ReferenceSearcher import org.jetbrains.kotlin.j2k.ReferenceSearcher
import org.jetbrains.kotlin.j2k.isNullLiteral import org.jetbrains.kotlin.j2k.isNullLiteral
import org.jetbrains.kotlin.nj2k.tree.* import org.jetbrains.kotlin.nj2k.tree.*
@@ -80,6 +82,13 @@ fun PsiMember.modality(assignNonCodeElements: ((JKFormattingOwner, PsiElement) -
}?.firstOrNull() ?: JKModalityModifierElement(Modality.OPEN) }?.firstOrNull() ?: JKModalityModifierElement(Modality.OPEN)
fun JvmClassKind.toJk() = when (this) {
JvmClassKind.CLASS -> JKClass.ClassKind.CLASS
JvmClassKind.INTERFACE -> JKClass.ClassKind.INTERFACE
JvmClassKind.ANNOTATION -> JKClass.ClassKind.ANNOTATION
JvmClassKind.ENUM -> JKClass.ClassKind.ENUM
}
private fun PsiMember.handleProtectedVisibility(referenceSearcher: ReferenceSearcher): Visibility { private fun PsiMember.handleProtectedVisibility(referenceSearcher: ReferenceSearcher): Visibility {
val originalClass = containingClass ?: return Visibility.PROTECTED val originalClass = containingClass ?: return Visibility.PROTECTED
// Search for usages only in Java because java-protected member cannot be used in Kotlin from same package // Search for usages only in Java because java-protected member cannot be used in Kotlin from same package
+1 -1
View File
@@ -1,5 +1,5 @@
import java.io.File import java.io.File
internal fun foo(file: File?): List<String?>? { fun foo(file: File?): List<String?>? {
return emptyList<String>() return emptyList<String>()
} }
@@ -1,6 +1,6 @@
import java.io.File import java.io.File
class C { internal class C {
private fun memberFun(file: File) {} private fun memberFun(file: File) {}
companion object { companion object {
+1 -1
View File
@@ -2,4 +2,4 @@ package to
import kotlin.reflect.KClass import kotlin.reflect.KClass
annotation class Ann(val value: KClass<*>) internal annotation class Ann(val value: KClass<*>)
@@ -1,3 +1,3 @@
internal fun foo(p: Dependency): Double { fun foo(p: Dependency): Double {
return p.getInt().toDouble() // explicit conversion to Double must be added on conversion (if type Dependency) is correctly resolved return p.getInt().toDouble() // explicit conversion to Double must be added on conversion (if type Dependency) is correctly resolved
} }
@@ -1,4 +1,4 @@
package to package to
@Volatile @Volatile
internal var field = 1 var field = 1
+2 -2
View File
@@ -1,9 +1,9 @@
class A { class A {
internal fun foo() {} fun foo() {}
internal fun bar() {} fun bar() {}
fun f() {} fun f() {}
@@ -1,3 +1,3 @@
package to package to
internal fun foo(p: Int) fun foo(p: Int)
+3 -3
View File
@@ -14,9 +14,9 @@ class Target {
var hashMapOfNotImported: Map<ToBeImportedJava, ToBeImportedKotlin> = HashMap() var hashMapOfNotImported: Map<ToBeImportedJava, ToBeImportedKotlin> = HashMap()
internal fun acceptKotlinClass(tbi: ToBeImportedKotlin?) {} fun acceptKotlinClass(tbi: ToBeImportedKotlin?) {}
internal fun acceptJavaClass(tbi: ToBeImportedJava?) {} fun acceptJavaClass(tbi: ToBeImportedJava?) {}
var ambiguousKotlin: IAmbiguousKotlin = AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin var ambiguousKotlin: IAmbiguousKotlin = AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin
@@ -25,7 +25,7 @@ class Target {
var ambiguousJava: IAmbiguousJava = AmbiguousJava() // Should not add import in case of 2 declarations in Java var ambiguousJava: IAmbiguousJava = AmbiguousJava() // Should not add import in case of 2 declarations in Java
internal fun workWithStatics() { fun workWithStatics() {
val a = TO_BE_IMPORTED_CONST val a = TO_BE_IMPORTED_CONST
staticMethod() staticMethod()
} }
@@ -1,6 +1,6 @@
class A { class A {
val str: String = TODO() val str: String = TODO()
internal fun f() { fun f() {
str.length str.length
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
class Foo { class Foo {
var prop = 0 var prop = 0
internal fun foo() { fun foo() {
prop++ prop++
} }
} }
@@ -3,11 +3,11 @@ import java.util.ArrayList
class A { class A {
internal fun foo() { fun foo() {
val list = ArrayList<String>() val list = ArrayList<String>()
list.add(1) list.add(1)
} }
internal fun bar() {} fun bar() {}
} }
@@ -3,9 +3,9 @@ package to
import java.util.ArrayList import java.util.ArrayList
internal fun foo() { fun foo() {
val list = ArrayList<String>() val list = ArrayList<String>()
list.add(1) list.add(1)
} }
internal fun bar() {} fun bar() {}
@@ -4,8 +4,8 @@ import java.io.File
import java.util.ArrayList import java.util.ArrayList
class JavaClass { internal class JavaClass {
internal fun foo(file: File?, target: MutableList<String>?) { fun foo(file: File?, target: MutableList<String>?) {
val list = ArrayList<String>() val list = ArrayList<String>()
if (file != null) { if (file != null) {
list.add(file.name) list.add(file.name)
@@ -1,4 +1,4 @@
val str: String = TODO() val str: String = TODO()
internal fun f() { fun f() {
str.length str.length
} }
+2 -2
View File
@@ -3,8 +3,8 @@ package to
import java.util.ArrayList import java.util.ArrayList
class JavaClass { internal class JavaClass {
internal fun foo() { fun foo() {
val list = ArrayList<String>() val list = ArrayList<String>()
list.add(1) list.add(1)
} }
+1 -1
View File
@@ -3,7 +3,7 @@
package test package test
class Test(str: String) { class Test(str: String) {
internal var myStr = "String2" var myStr = "String2"
fun sout(str: String) { // UNNECESSARY_NOT_NULL_ASSERTION heuristic does not work any more, instead we can skip generating !! altogether fun sout(str: String) { // UNNECESSARY_NOT_NULL_ASSERTION heuristic does not work any more, instead we can skip generating !! altogether
println(str) println(str)
} }
+1 -1
View File
@@ -2,7 +2,7 @@
package test package test
class Test(str: String?) { class Test(str: String?) {
internal var myStr: String? = "String2" var myStr: String? = "String2"
fun sout(str: String?) { fun sout(str: String?) {
println(str) println(str)
} }
+2 -2
View File
@@ -1,7 +1,7 @@
import java.io.Serializable import java.io.Serializable
class Bar : Serializable { class Bar : Serializable {
internal var foobar = 0 var foobar = 0
companion object { companion object {
private const val serialVersionUID: Long = 0 private const val serialVersionUID: Long = 0
@@ -9,7 +9,7 @@ class Bar : Serializable {
} }
class Foo { class Foo {
internal var foobar = 0 var foobar = 0
companion object { companion object {
private const val serialVersionUID: Long = 0 private const val serialVersionUID: Long = 0
+3 -3
View File
@@ -11,7 +11,7 @@ class TEST1 {
} }
@Anon5(4) @Anon5(4)
internal var bar: @TypeUseAnon1 String? = null var bar: @TypeUseAnon1 String? = null
} }
class TEST2 { class TEST2 {
@@ -22,7 +22,7 @@ class TEST2 {
} }
@Anon5(4) @Anon5(4)
internal var bar: @TypeUseAnon2 String? = null var bar: @TypeUseAnon2 String? = null
} }
class TEST3 { class TEST3 {
@@ -33,5 +33,5 @@ class TEST3 {
} }
@Anon5(4) @Anon5(4)
internal var bar: @TypeUseAnon3 String? = null var bar: @TypeUseAnon3 String? = null
} }
+2 -2
View File
@@ -5,6 +5,6 @@ internal abstract class C {
val h = s2.hashCode() val h = s2.hashCode()
} }
internal abstract fun f(): String? abstract fun f(): String?
internal abstract fun g(): String? abstract fun g(): String?
} }
+1 -1
View File
@@ -1,5 +1,5 @@
internal abstract class A { internal abstract class A {
internal abstract fun callme() abstract fun callme()
fun callmetoo() { fun callmetoo() {
print("This is a concrete method.") print("This is a concrete method.")
} }
+2 -2
View File
@@ -1,10 +1,10 @@
object Util { object Util {
const val publicStr = "" const val publicStr = ""
internal const val protectedStr = "" internal const val protectedStr = ""
internal const val packageStr = "" const val packageStr = ""
private const val privateStr = "" private const val privateStr = ""
fun publicMethod() {} fun publicMethod() {}
internal fun protectedMethod() {} internal fun protectedMethod() {}
internal fun packageMethod() {} fun packageMethod() {}
private fun privateMethod() {} private fun privateMethod() {}
} }
+3 -3
View File
@@ -1,8 +1,8 @@
// ERROR: Property must be initialized or be abstract // ERROR: Property must be initialized or be abstract
class Test { class Test {
private val s: String private val s: String
internal var b = false var b = false
internal var d = 0.0 var d = 0.0
constructor() { constructor() {
b = true b = true
@@ -11,4 +11,4 @@ class Test {
constructor(s: String) { constructor(s: String) {
this.s = s this.s = s
} }
} }
+6 -6
View File
@@ -1,11 +1,11 @@
// ERROR: Property must be initialized or be abstract // ERROR: Property must be initialized or be abstract
class Test { class Test {
private val myName: String private val myName: String
internal var a = false var a = false
internal var b = 0.0 var b = 0.0
internal var c = 0f var c = 0f
internal var d: Long = 0 var d: Long = 0
internal var e = 0 var e = 0
protected var f: Short = 0 protected var f: Short = 0
protected var g = 0.toChar() protected var g = 0.toChar()
@@ -15,7 +15,7 @@ class Test {
} }
companion object { companion object {
internal fun foo(n: String?): String { fun foo(n: String?): String {
return "" return ""
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
class X { class X {
internal fun foo() { fun foo() {
val runnable: Runnable = object : Runnable { val runnable: Runnable = object : Runnable {
var value = 10 var value = 10
@@ -1,5 +1,4 @@
class C { class C {
var x: String? = null var x: String? = null
internal set
} }
@@ -1,15 +1,15 @@
class C { class C {
private var x = "" private var x = ""
internal var other: C? = null var other: C? = null
fun getX(): String { fun getX(): String {
return x return x
} }
internal fun setX(x: String) { fun setX(x: String) {
println("setter invoked") println("setter invoked")
if (other != null) { if (other != null) {
other!!.x = x other!!.x = x
} }
this.x = x this.x = x
} }
} }
@@ -9,7 +9,7 @@ class C {
myX = x myX = x
} }
internal fun foo() { fun foo() {
println("myX = $myX") println("myX = $myX")
} }
} }
@@ -9,7 +9,7 @@ class C {
this.x = x this.x = x
} }
internal fun foo() { fun foo() {
println("x = $x") println("x = $x")
} }
} }
@@ -7,7 +7,7 @@ class C {
myX = x myX = x
} }
internal fun foo() { fun foo() {
myX = "a" myX = "a"
} }
} }
@@ -9,7 +9,7 @@ class C {
this.x = x this.x = x
} }
internal fun foo() { fun foo() {
x = "a" x = "a"
} }
} }
@@ -1,7 +1,7 @@
class SomeClass { class SomeClass {
internal var a = 0 var a = 0
internal var b = 0 var b = 0
internal fun doSomeWhile(i: Int) { fun doSomeWhile(i: Int) {
do { do {
b = i b = i
a = b a = b
+1 -1
View File
@@ -3,5 +3,5 @@ enum class E {
override fun bar() {} override fun bar() {}
}; };
internal open fun bar() {} open fun bar() {}
} }
+2 -2
View File
@@ -9,7 +9,7 @@ enum class E(private val p: Int) {
override fun bar() {} override fun bar() {}
}; };
internal fun foo(p: Int) {} fun foo(p: Int) {}
internal abstract fun bar() abstract fun bar()
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo(array: Array<String?>) { fun foo(array: Array<String?>) {
for (i in array.indices.reversed()) { for (i in array.indices.reversed()) {
println(i) println(i)
} }
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
class SomeClass { class SomeClass {
internal fun doSomeFor() { fun doSomeFor() {
var a: Int var a: Int
var b: Int var b: Int
for (i in 0..9) { for (i in 0..9) {
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo() { fun foo() {
for (i in 10 downTo 0) { for (i in 10 downTo 0) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo() { fun foo() {
for (i in 10 downTo 1) { for (i in 10 downTo 1) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo(min: Int) { fun foo(min: Int) {
for (i in 10 downTo min + 1) { for (i in 10 downTo min + 1) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo(min: Int) { fun foo(min: Int) {
for (i in 10 downTo min + 1) { for (i in 10 downTo min + 1) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo(array: Array<String?>) { fun foo(array: Array<String?>) {
for (i in array.size downTo 0) { for (i in array.size downTo 0) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo(array: Array<String?>) { fun foo(array: Array<String?>) {
for (i in array.size - 2 downTo 0) { for (i in array.size - 2 downTo 0) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo(collection: Collection<String?>) { fun foo(collection: Collection<String?>) {
for (i in collection.size downTo 0) { for (i in collection.size downTo 0) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
class A { class A {
internal fun foo(collection: Collection<String?>) { fun foo(collection: Collection<String?>) {
for (i in collection.indices.reversed()) { for (i in collection.indices.reversed()) {
println(i) println(i)
} }
} }
} }
+2 -2
View File
@@ -1,8 +1,8 @@
class C { class C {
internal fun foo() { fun foo() {
val builder = StringBuilder() val builder = StringBuilder()
builder.append(1) builder.append(1)
.append(2).append(3) .append(2).append(3)
.append(4) .append(4)
} }
} }
+1 -1
View File
@@ -1 +1 @@
internal abstract val noofGears: Int abstract val noofGears: Int
+2 -2
View File
@@ -1,7 +1,7 @@
internal open class A { internal open class A {
internal open fun a() {} open fun a() {}
} }
internal class B : A() { internal class B : A() {
public override fun a() {} override fun a() {}
} }
+2 -2
View File
@@ -1,9 +1,9 @@
internal open class A { internal open class A {
internal open fun foo() {} open fun foo() {}
} }
internal open class B : A() { internal open class B : A() {
public override fun foo() {} override fun foo() {}
} }
internal class C : B() { internal class C : B() {
@@ -1,5 +1,5 @@
class SomeClass { class SomeClass {
internal fun doSomeIf(i: Int) { fun doSomeIf(i: Int) {
val a: Int val a: Int
val b: Int val b: Int
val c: Int val c: Int
+5 -5
View File
@@ -25,14 +25,14 @@ internal class D : I {
} }
internal abstract class E { internal abstract class E {
internal abstract fun f1() abstract fun f1()
internal open fun f2() {} open fun f2() {}
fun f3() {} fun f3() {}
} }
internal class F : E() { internal class F : E() {
public override fun f1() {} override fun f1() {}
public override fun f2() { override fun f2() {
super.f2() super.f2()
} }
} }
+2 -2
View File
@@ -5,12 +5,12 @@ import java.util.HashMap
internal class G<T : String?>(t: T) internal class G<T : String?>(t: T)
class Java { class Java {
internal fun test() { fun test() {
val m: HashMap<*, *> = HashMap<Any?, Any?>() val m: HashMap<*, *> = HashMap<Any?, Any?>()
m[1] = 1 m[1] = 1
} }
internal fun test2() { fun test2() {
val m: HashMap<*, *> = HashMap<Any?, Any?>() val m: HashMap<*, *> = HashMap<Any?, Any?>()
val g: G<*> = G<Any?>("") val g: G<*> = G<Any?>("")
val g2 = G("") val g2 = G("")
+1 -2
View File
@@ -1,2 +1 @@
class AppInfo(internal var mName: String, internal var mIcon: String, internal var mLastUpdateTime: Long) class AppInfo(var mName: String, var mIcon: String, var mLastUpdateTime: Long)
+7 -7
View File
@@ -1,13 +1,13 @@
class TestPackagePrivateFieldInit { class TestPackagePrivateFieldInit {
internal var start: Any? = null var start: Any? = null
internal var end: Any? = null var end: Any? = null
internal var handler: Any? = null var handler: Any? = null
internal var desc: String? = null var desc: String? = null
internal var type = 0 var type = 0
internal var next: TestPackagePrivateFieldInit? = null var next: TestPackagePrivateFieldInit? = null
companion object { companion object {
internal fun doStuff(h: TestPackagePrivateFieldInit?, start: Any, end: Any?): TestPackagePrivateFieldInit? { fun doStuff(h: TestPackagePrivateFieldInit?, start: Any, end: Any?): TestPackagePrivateFieldInit? {
var h = h var h = h
if (h == null) { if (h == null) {
return null return null
+2 -2
View File
@@ -1,5 +1,5 @@
class TestInitializeInTry { class TestInitializeInTry {
internal var x: Any? = null var x: Any? = null
private var y: Any? = null private var y: Any? = null
init { init {
@@ -12,4 +12,4 @@ class TestInitializeInTry {
x.toString() x.toString()
y.toString() y.toString()
} }
} }
+2 -2
View File
@@ -1,8 +1,8 @@
class Test { class Test {
internal var foo = 1 var foo = 1
init { init {
foo = 2 foo = 2
val foo = foo val foo = foo
} }
} }
+1 -1
View File
@@ -1,3 +1,3 @@
class A { class A {
internal fun foo(o: Map.Entry<Any?, Any?>?) {} fun foo(o: Map.Entry<Any?, Any?>?) {}
} }
+2 -2
View File
@@ -10,14 +10,14 @@ class Language(protected var code: String) : Serializable {
} }
internal open class Base { internal open class Base {
internal open fun test() {} open fun test() {}
override fun toString(): String { override fun toString(): String {
return "BASE" return "BASE"
} }
} }
internal class Child : Base() { internal class Child : Base() {
public override fun test() {} override fun test() {}
override fun toString(): String { override fun toString(): String {
return "Child" return "Child"
} }
@@ -1,7 +1,7 @@
import kotlinApi.KotlinClass import kotlinApi.KotlinClass
class C { class C {
internal fun bar() { fun bar() {
println(KotlinClass.CONST) println(KotlinClass.CONST)
} }
} }
@@ -1,7 +1,7 @@
import kotlinApi.KotlinClass import kotlinApi.KotlinClass
class C { class C {
internal fun bar() { fun bar() {
println(KotlinClass.CONST) println(KotlinClass.CONST)
} }
} }
+6 -6
View File
@@ -1,8 +1,8 @@
class Binary { class Binary {
internal var negativeBinaryInt = -1073741825 var negativeBinaryInt = -1073741825
internal var binaryInt = 1535 var binaryInt = 1535
internal var negativeBinaryLong = -4611686018427387905L var negativeBinaryLong = -4611686018427387905L
internal var binaryLong = 393215L var binaryLong = 393215L
internal var binaryShort: Short = 32767 var binaryShort: Short = 32767
internal var binaryByte: Byte = 83 var binaryByte: Byte = 83
} }
+7 -7
View File
@@ -1,9 +1,9 @@
class TestNumber { class TestNumber {
internal var longLiteral: Long = 1234567 var longLiteral: Long = 1234567
internal var longHexLiteral: Long = -0x1321a2 var longHexLiteral: Long = -0x1321a2
internal var intLiteral = 1234 var intLiteral = 1234
internal var floatLiteral = 1234f var floatLiteral = 1234f
internal var doubleLiteral = 1234.0 var doubleLiteral = 1234.0
internal var shortLiteral: Short = 123 var shortLiteral: Short = 123
internal var byteLiteral: Byte = 123 var byteLiteral: Byte = 123
} }
@@ -1,6 +1,6 @@
// RUNTIME_WITH_FULL_JDK // RUNTIME_WITH_FULL_JDK
class Test { class Test {
internal fun m() { fun m() {
java.lang.Double.isFinite(2.0) java.lang.Double.isFinite(2.0)
java.lang.Double.isNaN(2.0) java.lang.Double.isNaN(2.0)
java.lang.Float.isNaN(2.0f) java.lang.Float.isNaN(2.0f)
@@ -1,8 +1,8 @@
class Test { class Test {
internal fun m() { fun m() {
java.lang.Double.isFinite(2.0) java.lang.Double.isFinite(2.0)
java.lang.Double.isNaN(2.0) java.lang.Double.isNaN(2.0)
java.lang.Float.isNaN(2.0f) java.lang.Float.isNaN(2.0f)
java.lang.Float.isInfinite(2.0f) java.lang.Float.isInfinite(2.0f)
} }
} }
@@ -1,7 +1,7 @@
import java.util.ArrayList import java.util.ArrayList
class Test { class Test {
internal var list: List<MutableList<Int>> = ArrayList() var list: List<MutableList<Int>> = ArrayList()
fun test() { fun test() {
list[0].add(1) list[0].add(1)
} }
+2 -2
View File
@@ -1,7 +1,7 @@
import javax.swing.SwingUtilities import javax.swing.SwingUtilities
class A { class A {
internal fun foo() { fun foo() {
SwingUtilities.invokeLater { println("a") } SwingUtilities.invokeLater { println("a") }
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
class Test { class Test {
internal fun test(s: String?) { fun test(s: String?) {
requireNotNull(s) { "s should not be null" } requireNotNull(s) { "s should not be null" }
} }
} }
+2 -2
View File
@@ -11,5 +11,5 @@ class Derived(value: Int) : Base(value) {
} }
internal abstract class View { internal abstract class View {
internal abstract fun click() abstract fun click()
} }
+2 -2
View File
@@ -1,6 +1,6 @@
// !openByDefault: true // !openByDefault: true
internal open class A { internal open class A {
internal open fun foo1() {} open fun foo1() {}
private fun foo2() {} private fun foo2() {}
fun foo3() {} fun foo3() {}
} }
@@ -10,7 +10,7 @@ internal class B {
} }
internal abstract class C { internal abstract class C {
internal abstract fun foo() abstract fun foo()
} }
internal interface I { internal interface I {
@@ -1,6 +1,6 @@
internal class A { internal class A {
class Nested { class Nested {
internal fun foo() { fun foo() {
privateStatic1() privateStatic1()
} }
} }
@@ -1,6 +1,6 @@
internal class A { internal class A {
inner class Inner { inner class Inner {
internal fun foo() { fun foo() {
privateStatic1() privateStatic1()
} }
} }
+2 -2
View File
@@ -1,11 +1,11 @@
internal open class B(i: Int) { internal open class B(i: Int) {
internal open fun call(): Int { open fun call(): Int {
return 1 return 1
} }
} }
internal class A : B(10) { internal class A : B(10) {
public override fun call(): Int { override fun call(): Int {
return super.call() return super.call()
} }
} }
+1 -1
View File
@@ -3,7 +3,7 @@ import java.io.IOException
class C { class C {
@Throws(IOException::class) @Throws(IOException::class)
internal fun foo() { fun foo() {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
// reading something // reading something
val c = stream.read() val c = stream.read()
+2 -2
View File
@@ -4,7 +4,7 @@ import java.io.IOException
class C { class C {
@Throws(IOException::class) @Throws(IOException::class)
internal fun foo() { fun foo() {
ByteArrayInputStream(ByteArray(10)).use { input -> ByteArrayInputStream(ByteArray(10)).use { input ->
ByteArrayOutputStream().use { output -> ByteArrayOutputStream().use { output ->
output.write(input.read()) output.write(input.read())
@@ -12,4 +12,4 @@ class C {
} }
} }
} }
} }
+1 -1
View File
@@ -3,7 +3,7 @@ import java.io.IOException
class C { class C {
@Throws(IOException::class) @Throws(IOException::class)
internal fun foo() { fun foo() {
ByteArrayInputStream(ByteArray(10)).use { stream -> println(stream.read()) } ByteArrayInputStream(ByteArray(10)).use { stream -> println(stream.read()) }
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
class C { class C {
internal fun foo() { fun foo() {
try { try {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
// reading something // reading something
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
class C { class C {
internal fun foo() { fun foo() {
try { try {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
// reading something // reading something
+1 -1
View File
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
class C { class C {
internal fun foo() { fun foo() {
try { try {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
// reading something // reading something
+1 -1
View File
@@ -3,7 +3,7 @@ import java.io.IOException
class C { class C {
@Throws(IOException::class) @Throws(IOException::class)
internal fun foo() { fun foo() {
try { try {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
// reading something // reading something
+1 -1
View File
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
class C { class C {
internal fun foo(): Int { fun foo(): Int {
try { try {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
// reading something // reading something
@@ -2,14 +2,14 @@ import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
internal interface I { interface I {
@Throws(IOException::class) @Throws(IOException::class)
fun doIt(stream: InputStream): Int fun doIt(stream: InputStream): Int
} }
class C { class C {
@Throws(IOException::class) @Throws(IOException::class)
internal fun foo() { fun foo() {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
bar(object : I { bar(object : I {
@Throws(IOException::class) @Throws(IOException::class)
@@ -21,7 +21,7 @@ class C {
} }
@Throws(IOException::class) @Throws(IOException::class)
internal fun bar(i: I, stream: InputStream): Int { fun bar(i: I, stream: InputStream): Int {
return i.doIt(stream) return i.doIt(stream)
} }
} }
@@ -2,14 +2,14 @@ import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
internal interface I { interface I {
@Throws(IOException::class) @Throws(IOException::class)
fun doIt(stream: InputStream): Int fun doIt(stream: InputStream): Int
} }
class C { class C {
@Throws(IOException::class) @Throws(IOException::class)
internal fun foo(): Int { fun foo(): Int {
ByteArrayInputStream(ByteArray(10)).use { stream -> ByteArrayInputStream(ByteArray(10)).use { stream ->
return bar(object : I { return bar(object : I {
@Throws(IOException::class) @Throws(IOException::class)
@@ -21,7 +21,7 @@ class C {
} }
@Throws(IOException::class) @Throws(IOException::class)
internal fun bar(i: I, stream: InputStream): Int { fun bar(i: I, stream: InputStream): Int {
return i.doIt(stream) return i.doIt(stream)
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
class A { class A {
internal fun foo(o: Any?) { fun foo(o: Any?) {
if (o == null) return if (o == null) return
val length = (o as String).length val length = (o as String).length
} }
@@ -1,7 +1,7 @@
class SomeClass { class SomeClass {
internal var a = 0 var a = 0
internal var b = 0 var b = 0
internal fun doSomeWhile(i: Int) { fun doSomeWhile(i: Int) {
while (i < 0) { while (i < 0) {
b = i b = i
a = b a = b