Recompile files which import companion constant

#KT-44741 Fixed
This commit is contained in:
nataliya.valtman
2021-02-20 19:06:12 +03:00
parent 5485c372e8
commit df08ed2ac0
10 changed files with 85 additions and 5 deletions
@@ -0,0 +1,7 @@
package test
class A {
companion object {
const val CONSTANT_VALUE = 16
}
}
@@ -0,0 +1,7 @@
package test
class A {
companion object {
const val CONSTANT_VALUE = 17
}
}
@@ -0,0 +1,13 @@
package foo
import test.A.Companion.CONSTANT_VALUE
class B {
companion object {
fun main() {
println("Import companion constant: ${CONSTANT_VALUE}")
}
}
}
@@ -0,0 +1,12 @@
package foo
import test.A
class C {
companion object {
fun main() {
println("Companion constant: ${A.CONSTANT_VALUE}")
}
}
}
@@ -0,0 +1,10 @@
package foo
class DoNotUseConstant {
companion object {
const val CONSTANT_VALUE = 10
fun main() {
println("Use local constant: ${CONSTANT_VALUE}")
}
}
}
@@ -0,0 +1,11 @@
================ Step #1 =================
Compiling files:
src/A.kt
src/B.kt
src/C.kt
src/companionUsage.kt
src/constantUsage.kt
End of files
Exit code: OK
------------------------------------------
@@ -0,0 +1,5 @@
package foo
import test.A
fun callCompanionConstant() = "Companion constant: ${A.CONSTANT_VALUE}"
@@ -0,0 +1,6 @@
package foo
import test.A.Companion.CONSTANT_VALUE
fun importCompanionConstant() = "Import companion constant: ${CONSTANT_VALUE}"