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:
@@ -12,44 +12,31 @@ import org.jetbrains.kotlin.nj2k.tree.*
|
||||
class InternalDeclarationConversion(context: NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) {
|
||||
override fun applyToElement(element: JKTreeElement): JKTreeElement {
|
||||
if (element !is JKVisibilityOwner || element !is JKModalityOwner) return recurse(element)
|
||||
if (element.visibility != Visibility.INTERNAL) return recurse(element)
|
||||
|
||||
val containingClass = element.parentOfType<JKClass>()
|
||||
val containingClassKind = containingClass?.classKind ?: element.psi<PsiMember>()?.containingClass?.classKind?.toJk()
|
||||
|
||||
if (element is JKClass && element.isLocalClass()) {
|
||||
element.visibility = Visibility.PUBLIC
|
||||
val containingClassVisibility = containingClass?.visibility
|
||||
?: 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)
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,13 @@
|
||||
package org.jetbrains.kotlin.nj2k
|
||||
|
||||
import com.intellij.codeInsight.generation.GenerateEqualsHelper.getEqualsSignature
|
||||
import com.intellij.lang.jvm.JvmClassKind
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.util.InheritanceUtil
|
||||
import com.intellij.psi.util.MethodSignatureUtil
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
import org.jetbrains.kotlin.j2k.ClassKind
|
||||
import org.jetbrains.kotlin.j2k.ReferenceSearcher
|
||||
import org.jetbrains.kotlin.j2k.isNullLiteral
|
||||
import org.jetbrains.kotlin.nj2k.tree.*
|
||||
@@ -80,6 +82,13 @@ fun PsiMember.modality(assignNonCodeElements: ((JKFormattingOwner, PsiElement) -
|
||||
}?.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 {
|
||||
val originalClass = containingClass ?: return Visibility.PROTECTED
|
||||
// Search for usages only in Java because java-protected member cannot be used in Kotlin from same package
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import java.io.File
|
||||
|
||||
internal fun foo(file: File?): List<String?>? {
|
||||
fun foo(file: File?): List<String?>? {
|
||||
return emptyList<String>()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import java.io.File
|
||||
|
||||
class C {
|
||||
internal class C {
|
||||
private fun memberFun(file: File) {}
|
||||
|
||||
companion object {
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ package to
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package to
|
||||
|
||||
@Volatile
|
||||
internal var field = 1
|
||||
var field = 1
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
class A {
|
||||
|
||||
|
||||
internal fun foo() {}
|
||||
fun foo() {}
|
||||
|
||||
internal fun bar() {}
|
||||
fun bar() {}
|
||||
|
||||
|
||||
fun f() {}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package to
|
||||
|
||||
internal fun foo(p: Int)
|
||||
fun foo(p: Int)
|
||||
@@ -14,9 +14,9 @@ class Target {
|
||||
|
||||
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
|
||||
|
||||
@@ -25,7 +25,7 @@ class Target {
|
||||
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
|
||||
staticMethod()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class A {
|
||||
val str: String = TODO()
|
||||
internal fun f() {
|
||||
fun f() {
|
||||
str.length
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
var prop = 0
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
prop++
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ import java.util.ArrayList
|
||||
|
||||
|
||||
class A {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
val list = ArrayList<String>()
|
||||
list.add(1)
|
||||
}
|
||||
|
||||
internal fun bar() {}
|
||||
fun bar() {}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package to
|
||||
import java.util.ArrayList
|
||||
|
||||
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
val list = ArrayList<String>()
|
||||
list.add(1)
|
||||
}
|
||||
|
||||
internal fun bar() {}
|
||||
fun bar() {}
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.File
|
||||
import java.util.ArrayList
|
||||
|
||||
|
||||
class JavaClass {
|
||||
internal fun foo(file: File?, target: MutableList<String>?) {
|
||||
internal class JavaClass {
|
||||
fun foo(file: File?, target: MutableList<String>?) {
|
||||
val list = ArrayList<String>()
|
||||
if (file != null) {
|
||||
list.add(file.name)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
val str: String = TODO()
|
||||
internal fun f() {
|
||||
fun f() {
|
||||
str.length
|
||||
}
|
||||
+2
-2
@@ -3,8 +3,8 @@ package to
|
||||
import java.util.ArrayList
|
||||
|
||||
|
||||
class JavaClass {
|
||||
internal fun foo() {
|
||||
internal class JavaClass {
|
||||
fun foo() {
|
||||
val list = ArrayList<String>()
|
||||
list.add(1)
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
package test
|
||||
|
||||
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
|
||||
println(str)
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
package test
|
||||
|
||||
class Test(str: String?) {
|
||||
internal var myStr: String? = "String2"
|
||||
var myStr: String? = "String2"
|
||||
fun sout(str: String?) {
|
||||
println(str)
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import java.io.Serializable
|
||||
|
||||
class Bar : Serializable {
|
||||
internal var foobar = 0
|
||||
var foobar = 0
|
||||
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 0
|
||||
@@ -9,7 +9,7 @@ class Bar : Serializable {
|
||||
}
|
||||
|
||||
class Foo {
|
||||
internal var foobar = 0
|
||||
var foobar = 0
|
||||
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 0
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ class TEST1 {
|
||||
}
|
||||
|
||||
@Anon5(4)
|
||||
internal var bar: @TypeUseAnon1 String? = null
|
||||
var bar: @TypeUseAnon1 String? = null
|
||||
}
|
||||
|
||||
class TEST2 {
|
||||
@@ -22,7 +22,7 @@ class TEST2 {
|
||||
}
|
||||
|
||||
@Anon5(4)
|
||||
internal var bar: @TypeUseAnon2 String? = null
|
||||
var bar: @TypeUseAnon2 String? = null
|
||||
}
|
||||
|
||||
class TEST3 {
|
||||
@@ -33,5 +33,5 @@ class TEST3 {
|
||||
}
|
||||
|
||||
@Anon5(4)
|
||||
internal var bar: @TypeUseAnon3 String? = null
|
||||
var bar: @TypeUseAnon3 String? = null
|
||||
}
|
||||
+2
-2
@@ -5,6 +5,6 @@ internal abstract class C {
|
||||
val h = s2.hashCode()
|
||||
}
|
||||
|
||||
internal abstract fun f(): String?
|
||||
internal abstract fun g(): String?
|
||||
abstract fun f(): String?
|
||||
abstract fun g(): String?
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
internal abstract class A {
|
||||
internal abstract fun callme()
|
||||
abstract fun callme()
|
||||
fun callmetoo() {
|
||||
print("This is a concrete method.")
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
object Util {
|
||||
const val publicStr = ""
|
||||
internal const val protectedStr = ""
|
||||
internal const val packageStr = ""
|
||||
const val packageStr = ""
|
||||
private const val privateStr = ""
|
||||
fun publicMethod() {}
|
||||
internal fun protectedMethod() {}
|
||||
internal fun packageMethod() {}
|
||||
fun packageMethod() {}
|
||||
private fun privateMethod() {}
|
||||
}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
// ERROR: Property must be initialized or be abstract
|
||||
class Test {
|
||||
private val s: String
|
||||
internal var b = false
|
||||
internal var d = 0.0
|
||||
var b = false
|
||||
var d = 0.0
|
||||
|
||||
constructor() {
|
||||
b = true
|
||||
@@ -11,4 +11,4 @@ class Test {
|
||||
constructor(s: String) {
|
||||
this.s = s
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
// ERROR: Property must be initialized or be abstract
|
||||
class Test {
|
||||
private val myName: String
|
||||
internal var a = false
|
||||
internal var b = 0.0
|
||||
internal var c = 0f
|
||||
internal var d: Long = 0
|
||||
internal var e = 0
|
||||
var a = false
|
||||
var b = 0.0
|
||||
var c = 0f
|
||||
var d: Long = 0
|
||||
var e = 0
|
||||
protected var f: Short = 0
|
||||
protected var g = 0.toChar()
|
||||
|
||||
@@ -15,7 +15,7 @@ class Test {
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun foo(n: String?): String {
|
||||
fun foo(n: String?): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class X {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
val runnable: Runnable = object : Runnable {
|
||||
var value = 10
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class C {
|
||||
var x: String? = null
|
||||
internal set
|
||||
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
class C {
|
||||
private var x = ""
|
||||
internal var other: C? = null
|
||||
var other: C? = null
|
||||
fun getX(): String {
|
||||
return x
|
||||
}
|
||||
|
||||
internal fun setX(x: String) {
|
||||
fun setX(x: String) {
|
||||
println("setter invoked")
|
||||
if (other != null) {
|
||||
other!!.x = x
|
||||
}
|
||||
this.x = x
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ class C {
|
||||
myX = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
println("myX = $myX")
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ class C {
|
||||
this.x = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
println("x = $x")
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ class C {
|
||||
myX = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
myX = "a"
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ class C {
|
||||
this.x = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
x = "a"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
class SomeClass {
|
||||
internal var a = 0
|
||||
internal var b = 0
|
||||
internal fun doSomeWhile(i: Int) {
|
||||
var a = 0
|
||||
var b = 0
|
||||
fun doSomeWhile(i: Int) {
|
||||
do {
|
||||
b = i
|
||||
a = b
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@ enum class E {
|
||||
override fun bar() {}
|
||||
};
|
||||
|
||||
internal open fun bar() {}
|
||||
open fun bar() {}
|
||||
}
|
||||
+2
-2
@@ -9,7 +9,7 @@ enum class E(private val p: Int) {
|
||||
override fun bar() {}
|
||||
};
|
||||
|
||||
internal fun foo(p: Int) {}
|
||||
internal abstract fun bar()
|
||||
fun foo(p: Int) {}
|
||||
abstract fun bar()
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo(array: Array<String?>) {
|
||||
fun foo(array: Array<String?>) {
|
||||
for (i in array.indices.reversed()) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
class SomeClass {
|
||||
internal fun doSomeFor() {
|
||||
fun doSomeFor() {
|
||||
var a: Int
|
||||
var b: Int
|
||||
for (i in 0..9) {
|
||||
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
for (i in 10 downTo 0) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
for (i in 10 downTo 1) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo(min: Int) {
|
||||
fun foo(min: Int) {
|
||||
for (i in 10 downTo min + 1) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo(min: Int) {
|
||||
fun foo(min: Int) {
|
||||
for (i in 10 downTo min + 1) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo(array: Array<String?>) {
|
||||
fun foo(array: Array<String?>) {
|
||||
for (i in array.size downTo 0) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo(array: Array<String?>) {
|
||||
fun foo(array: Array<String?>) {
|
||||
for (i in array.size - 2 downTo 0) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo(collection: Collection<String?>) {
|
||||
fun foo(collection: Collection<String?>) {
|
||||
for (i in collection.size downTo 0) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
internal fun foo(collection: Collection<String?>) {
|
||||
fun foo(collection: Collection<String?>) {
|
||||
for (i in collection.indices.reversed()) {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
class C {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
val builder = StringBuilder()
|
||||
builder.append(1)
|
||||
.append(2).append(3)
|
||||
.append(4)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
internal abstract val noofGears: Int
|
||||
abstract val noofGears: Int
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
internal open class A {
|
||||
internal open fun a() {}
|
||||
open fun a() {}
|
||||
}
|
||||
|
||||
internal class B : A() {
|
||||
public override fun a() {}
|
||||
override fun a() {}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
internal open class A {
|
||||
internal open fun foo() {}
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
internal open class B : A() {
|
||||
public override fun foo() {}
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
internal class C : B() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SomeClass {
|
||||
internal fun doSomeIf(i: Int) {
|
||||
fun doSomeIf(i: Int) {
|
||||
val a: Int
|
||||
val b: Int
|
||||
val c: Int
|
||||
|
||||
+5
-5
@@ -25,14 +25,14 @@ internal class D : I {
|
||||
}
|
||||
|
||||
internal abstract class E {
|
||||
internal abstract fun f1()
|
||||
internal open fun f2() {}
|
||||
abstract fun f1()
|
||||
open fun f2() {}
|
||||
fun f3() {}
|
||||
}
|
||||
|
||||
internal class F : E() {
|
||||
public override fun f1() {}
|
||||
public override fun f2() {
|
||||
override fun f1() {}
|
||||
override fun f2() {
|
||||
super.f2()
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -5,12 +5,12 @@ import java.util.HashMap
|
||||
|
||||
internal class G<T : String?>(t: T)
|
||||
class Java {
|
||||
internal fun test() {
|
||||
fun test() {
|
||||
val m: HashMap<*, *> = HashMap<Any?, Any?>()
|
||||
m[1] = 1
|
||||
}
|
||||
|
||||
internal fun test2() {
|
||||
fun test2() {
|
||||
val m: HashMap<*, *> = HashMap<Any?, Any?>()
|
||||
val g: G<*> = G<Any?>("")
|
||||
val g2 = G("")
|
||||
|
||||
+1
-2
@@ -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
@@ -1,13 +1,13 @@
|
||||
class TestPackagePrivateFieldInit {
|
||||
internal var start: Any? = null
|
||||
internal var end: Any? = null
|
||||
internal var handler: Any? = null
|
||||
internal var desc: String? = null
|
||||
internal var type = 0
|
||||
internal var next: TestPackagePrivateFieldInit? = null
|
||||
var start: Any? = null
|
||||
var end: Any? = null
|
||||
var handler: Any? = null
|
||||
var desc: String? = null
|
||||
var type = 0
|
||||
var next: TestPackagePrivateFieldInit? = null
|
||||
|
||||
companion object {
|
||||
internal fun doStuff(h: TestPackagePrivateFieldInit?, start: Any, end: Any?): TestPackagePrivateFieldInit? {
|
||||
fun doStuff(h: TestPackagePrivateFieldInit?, start: Any, end: Any?): TestPackagePrivateFieldInit? {
|
||||
var h = h
|
||||
if (h == null) {
|
||||
return null
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
class TestInitializeInTry {
|
||||
internal var x: Any? = null
|
||||
var x: Any? = null
|
||||
private var y: Any? = null
|
||||
|
||||
init {
|
||||
@@ -12,4 +12,4 @@ class TestInitializeInTry {
|
||||
x.toString()
|
||||
y.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
class Test {
|
||||
internal var foo = 1
|
||||
var foo = 1
|
||||
|
||||
init {
|
||||
foo = 2
|
||||
val foo = foo
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
class A {
|
||||
internal fun foo(o: Map.Entry<Any?, Any?>?) {}
|
||||
fun foo(o: Map.Entry<Any?, Any?>?) {}
|
||||
}
|
||||
+2
-2
@@ -10,14 +10,14 @@ class Language(protected var code: String) : Serializable {
|
||||
}
|
||||
|
||||
internal open class Base {
|
||||
internal open fun test() {}
|
||||
open fun test() {}
|
||||
override fun toString(): String {
|
||||
return "BASE"
|
||||
}
|
||||
}
|
||||
|
||||
internal class Child : Base() {
|
||||
public override fun test() {}
|
||||
override fun test() {}
|
||||
override fun toString(): String {
|
||||
return "Child"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import kotlinApi.KotlinClass
|
||||
|
||||
class C {
|
||||
internal fun bar() {
|
||||
fun bar() {
|
||||
println(KotlinClass.CONST)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import kotlinApi.KotlinClass
|
||||
|
||||
class C {
|
||||
internal fun bar() {
|
||||
fun bar() {
|
||||
println(KotlinClass.CONST)
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
class Binary {
|
||||
internal var negativeBinaryInt = -1073741825
|
||||
internal var binaryInt = 1535
|
||||
internal var negativeBinaryLong = -4611686018427387905L
|
||||
internal var binaryLong = 393215L
|
||||
internal var binaryShort: Short = 32767
|
||||
internal var binaryByte: Byte = 83
|
||||
var negativeBinaryInt = -1073741825
|
||||
var binaryInt = 1535
|
||||
var negativeBinaryLong = -4611686018427387905L
|
||||
var binaryLong = 393215L
|
||||
var binaryShort: Short = 32767
|
||||
var binaryByte: Byte = 83
|
||||
}
|
||||
+7
-7
@@ -1,9 +1,9 @@
|
||||
class TestNumber {
|
||||
internal var longLiteral: Long = 1234567
|
||||
internal var longHexLiteral: Long = -0x1321a2
|
||||
internal var intLiteral = 1234
|
||||
internal var floatLiteral = 1234f
|
||||
internal var doubleLiteral = 1234.0
|
||||
internal var shortLiteral: Short = 123
|
||||
internal var byteLiteral: Byte = 123
|
||||
var longLiteral: Long = 1234567
|
||||
var longHexLiteral: Long = -0x1321a2
|
||||
var intLiteral = 1234
|
||||
var floatLiteral = 1234f
|
||||
var doubleLiteral = 1234.0
|
||||
var shortLiteral: Short = 123
|
||||
var byteLiteral: Byte = 123
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
class Test {
|
||||
internal fun m() {
|
||||
fun m() {
|
||||
java.lang.Double.isFinite(2.0)
|
||||
java.lang.Double.isNaN(2.0)
|
||||
java.lang.Float.isNaN(2.0f)
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
class Test {
|
||||
internal fun m() {
|
||||
fun m() {
|
||||
java.lang.Double.isFinite(2.0)
|
||||
java.lang.Double.isNaN(2.0)
|
||||
java.lang.Float.isNaN(2.0f)
|
||||
java.lang.Float.isInfinite(2.0f)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
class Test {
|
||||
internal var list: List<MutableList<Int>> = ArrayList()
|
||||
var list: List<MutableList<Int>> = ArrayList()
|
||||
fun test() {
|
||||
list[0].add(1)
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
class A {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
SwingUtilities.invokeLater { println("a") }
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Test {
|
||||
internal fun test(s: String?) {
|
||||
fun test(s: String?) {
|
||||
requireNotNull(s) { "s should not be null" }
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -11,5 +11,5 @@ class Derived(value: Int) : Base(value) {
|
||||
}
|
||||
|
||||
internal abstract class View {
|
||||
internal abstract fun click()
|
||||
}
|
||||
abstract fun click()
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// !openByDefault: true
|
||||
internal open class A {
|
||||
internal open fun foo1() {}
|
||||
open fun foo1() {}
|
||||
private fun foo2() {}
|
||||
fun foo3() {}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ internal class B {
|
||||
}
|
||||
|
||||
internal abstract class C {
|
||||
internal abstract fun foo()
|
||||
abstract fun foo()
|
||||
}
|
||||
|
||||
internal interface I {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
internal class A {
|
||||
class Nested {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
privateStatic1()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
internal class A {
|
||||
inner class Inner {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
privateStatic1()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
internal open class B(i: Int) {
|
||||
internal open fun call(): Int {
|
||||
open fun call(): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
internal class A : B(10) {
|
||||
public override fun call(): Int {
|
||||
override fun call(): Int {
|
||||
return super.call()
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@ import java.io.IOException
|
||||
|
||||
class C {
|
||||
@Throws(IOException::class)
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
val c = stream.read()
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.IOException
|
||||
|
||||
class C {
|
||||
@Throws(IOException::class)
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
ByteArrayInputStream(ByteArray(10)).use { input ->
|
||||
ByteArrayOutputStream().use { output ->
|
||||
output.write(input.read())
|
||||
@@ -12,4 +12,4 @@ class C {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@ import java.io.IOException
|
||||
|
||||
class C {
|
||||
@Throws(IOException::class)
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream -> println(stream.read()) }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
|
||||
class C {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
try {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
|
||||
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
|
||||
class C {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
try {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
|
||||
class C {
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
try {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import java.io.IOException
|
||||
|
||||
class C {
|
||||
@Throws(IOException::class)
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
try {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
|
||||
class C {
|
||||
internal fun foo(): Int {
|
||||
fun foo(): Int {
|
||||
try {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
|
||||
@@ -2,14 +2,14 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
|
||||
internal interface I {
|
||||
interface I {
|
||||
@Throws(IOException::class)
|
||||
fun doIt(stream: InputStream): Int
|
||||
}
|
||||
|
||||
class C {
|
||||
@Throws(IOException::class)
|
||||
internal fun foo() {
|
||||
fun foo() {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
bar(object : I {
|
||||
@Throws(IOException::class)
|
||||
@@ -21,7 +21,7 @@ class C {
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
internal fun bar(i: I, stream: InputStream): Int {
|
||||
fun bar(i: I, stream: InputStream): Int {
|
||||
return i.doIt(stream)
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,14 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
|
||||
internal interface I {
|
||||
interface I {
|
||||
@Throws(IOException::class)
|
||||
fun doIt(stream: InputStream): Int
|
||||
}
|
||||
|
||||
class C {
|
||||
@Throws(IOException::class)
|
||||
internal fun foo(): Int {
|
||||
fun foo(): Int {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
return bar(object : I {
|
||||
@Throws(IOException::class)
|
||||
@@ -21,7 +21,7 @@ class C {
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
internal fun bar(i: I, stream: InputStream): Int {
|
||||
fun bar(i: I, stream: InputStream): Int {
|
||||
return i.doIt(stream)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class A {
|
||||
internal fun foo(o: Any?) {
|
||||
fun foo(o: Any?) {
|
||||
if (o == null) return
|
||||
val length = (o as String).length
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class SomeClass {
|
||||
internal var a = 0
|
||||
internal var b = 0
|
||||
internal fun doSomeWhile(i: Int) {
|
||||
var a = 0
|
||||
var b = 0
|
||||
fun doSomeWhile(i: Int) {
|
||||
while (i < 0) {
|
||||
b = i
|
||||
a = b
|
||||
|
||||
Reference in New Issue
Block a user