[FIR] Improve INVISIBLE_REFERENCE message

Report the nearest invisible containing declaration in cases where
the declaration itself is visible.

#KT-53820 Fixed
This commit is contained in:
Kirill Rakhman
2023-06-19 15:02:57 +02:00
committed by Space Team
parent 6a073e0b17
commit 911e62257a
24 changed files with 237 additions and 98 deletions
@@ -0,0 +1,46 @@
/b.kt:34:10: error: cannot access 'B': it is private in file
import a.B
^
/b.kt:35:10: error: cannot access 'B': it is private in file
import a.B.Companion.bar
^
/b.kt:37:12: error: cannot access 'Companion': it is private in 'C'
import a.C.Companion.baz
^
/b.kt:38:10: error: cannot access 'D': it is private in file
import a.D
^
/b.kt:39:10: error: cannot access 'D': it is private in file
import a.D.Companion.quux
^
/b.kt:39:12: error: cannot access 'Companion': it is private in 'D'
import a.D.Companion.quux
^
/b.kt:43:7: error: cannot access 'B': it is private in file
f(B)
^
/b.kt:44:7: error: cannot access 'Companion': it is private in 'C'
f(C)
^
/b.kt:45:7: error: cannot access 'Companion': it is private in 'D'
f(D)
^
/b.kt:48:5: error: cannot access 'B': it is private in file
B.bar()
^
/b.kt:48:7: error: cannot access 'B': it is private in file
B.bar()
^
/b.kt:49:7: error: cannot access 'Companion': it is private in 'C'
C.baz()
^
/b.kt:50:5: error: cannot access 'D': it is private in file
D.quux()
^
/b.kt:50:7: error: cannot access 'Companion': it is private in 'D'
D.quux()
^
/b.kt:53:9: error: cannot access 'Companion': it is private in 'C'
a.C.baz()
^
@@ -0,0 +1,27 @@
/b.kt:(96,97): error: Cannot access 'class B : Any': it is private in file
/b.kt:(107,108): error: Cannot access 'class B : Any': it is private in file
/b.kt:(145,154): error: Cannot access 'companion object Companion : Any': it is private in 'a/C'
/b.kt:(168,169): error: Cannot access 'class D : Any': it is private in file
/b.kt:(179,180): error: Cannot access 'class D : Any': it is private in file
/b.kt:(181,190): error: Cannot access 'companion object Companion : Any': it is private in 'a/D'
/b.kt:(225,226): error: Cannot access 'class B : Any': it is private in file
/b.kt:(243,244): error: Cannot access 'class D : Any': it is private in file
/b.kt:(263,264): error: Cannot access 'class B : Any': it is private in file
/b.kt:(265,268): error: Cannot access 'class B : Any': it is private in file
/b.kt:(277,280): error: Cannot access 'companion object Companion : Any': it is private in 'a/C'
/b.kt:(287,288): error: Cannot access 'class D : Any': it is private in file
/b.kt:(289,293): error: Cannot access 'companion object Companion : Any': it is private in 'a/D'
/b.kt:(319,322): error: Cannot access 'companion object Companion : Any': it is private in 'a/C'
@@ -1,3 +1,4 @@
// RENDER_DIAGNOSTICS_FULL_TEXT
//FILE:a.kt
package a
@@ -29,9 +30,13 @@ private class D {
package b
import a.A
import a.A.Companion.foo
import a.<!INVISIBLE_REFERENCE!>B<!>
import a.<!INVISIBLE_REFERENCE!>B<!>.Companion.bar
import a.C
import a.C.<!INVISIBLE_REFERENCE!>Companion<!>.baz
import a.<!INVISIBLE_REFERENCE!>D<!>
import a.<!INVISIBLE_REFERENCE!>D<!>.<!INVISIBLE_REFERENCE!>Companion<!>.quux
fun test() {
f(A)
@@ -1,3 +1,4 @@
// RENDER_DIAGNOSTICS_FULL_TEXT
//FILE:a.kt
package a
@@ -29,9 +30,13 @@ private class D {
package b
import a.A
import a.A.Companion.foo
import a.<!INVISIBLE_REFERENCE!>B<!>
import a.<!INVISIBLE_REFERENCE!>B<!>.Companion.bar
import a.C
import a.C.<!INVISIBLE_REFERENCE!>Companion<!>.baz
import a.<!INVISIBLE_REFERENCE!>D<!>
import a.<!INVISIBLE_REFERENCE!>D<!>.<!INVISIBLE_REFERENCE!>Companion<!>.quux
fun test() {
f(A)