Prohibit accessing nested classes/objects of class object using class literal
The fqname of class should be clear from code Example: can't shorten A.Default.B.Default.C to A.B.C Also fixes problem when nested class of enum class could be accessed via enum entry
This commit is contained in:
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
fun test() {
|
||||
A.d
|
||||
A.<!INVISIBLE_MEMBER!>f<!>
|
||||
A.Default.<!INVISIBLE_MEMBER!>f<!>
|
||||
B.<!INVISIBLE_MEMBER!>D<!>
|
||||
<!INVISIBLE_MEMBER!>CCC<!>
|
||||
CCC.<!INVISIBLE_MEMBER!>classObjectVar<!>
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package a
|
||||
|
||||
class A {
|
||||
class Nested
|
||||
inner class Inner
|
||||
|
||||
|
||||
class object {
|
||||
|
||||
class Nested2
|
||||
|
||||
val c: Int = 1
|
||||
|
||||
object Obj2 {
|
||||
val c: Int = 1
|
||||
}
|
||||
}
|
||||
|
||||
object Obj
|
||||
}
|
||||
|
||||
object O {
|
||||
class A
|
||||
|
||||
object O
|
||||
}
|
||||
|
||||
fun f() {
|
||||
A.c
|
||||
A.hashCode()
|
||||
A().<!NO_CLASS_OBJECT, NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE!>Nested<!>
|
||||
A.Nested()
|
||||
A().Inner()
|
||||
A.Default.<!UNRESOLVED_REFERENCE!>Nested<!>
|
||||
A.Default.<!UNRESOLVED_REFERENCE!>Inner<!>
|
||||
A.<!UNRESOLVED_REFERENCE!>Inner<!>
|
||||
A.Default.c
|
||||
A.Default.Obj2
|
||||
A.Default.Obj2.c
|
||||
|
||||
A.Default.Nested2()
|
||||
A.Default.c
|
||||
A.Obj
|
||||
A.Default.Obj2
|
||||
A.<!UNRESOLVED_REFERENCE!>Obj2<!>
|
||||
A.<!UNRESOLVED_REFERENCE!>Obj2<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>c<!>
|
||||
A.<!UNRESOLVED_REFERENCE!>Nested2<!>
|
||||
|
||||
O.O
|
||||
O.A()
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package
|
||||
|
||||
package a {
|
||||
internal fun f(): kotlin.Unit
|
||||
|
||||
internal final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal class object Default {
|
||||
private constructor Default()
|
||||
internal final val c: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal final class Nested2 {
|
||||
public constructor Nested2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal object Obj2 {
|
||||
private constructor Obj2()
|
||||
internal final val c: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
internal final inner class Inner {
|
||||
public constructor Inner()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final class Nested {
|
||||
public constructor Nested()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal object Obj {
|
||||
private constructor Obj()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
internal object O {
|
||||
private constructor O()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal object O {
|
||||
private constructor O()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package a
|
||||
|
||||
|
||||
enum class C {
|
||||
E1 E2 E3 {
|
||||
object O_O
|
||||
|
||||
fun b() {
|
||||
O_O
|
||||
}
|
||||
|
||||
class G
|
||||
}
|
||||
|
||||
E4 {
|
||||
fun c() {
|
||||
//TODO: this is a bug
|
||||
this.<!UNRESOLVED_REFERENCE!>B<!>()
|
||||
|
||||
C.A()
|
||||
A()
|
||||
//TODO: this is a bug
|
||||
this.<!UNRESOLVED_REFERENCE!>A<!>()
|
||||
}
|
||||
}
|
||||
|
||||
class A
|
||||
inner class B
|
||||
object O {
|
||||
object InO
|
||||
}
|
||||
}
|
||||
|
||||
fun f() {
|
||||
C.E1.<!NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE, FUNCTION_CALL_EXPECTED!>A<!>
|
||||
C.E1.<!NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE!>A<!>()
|
||||
C.E2.B()
|
||||
|
||||
C.E2.<!UNRESOLVED_REFERENCE!>O<!>
|
||||
C.E3.<!UNRESOLVED_REFERENCE!>O<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>InO<!>
|
||||
|
||||
C.O
|
||||
C.O.InO
|
||||
C.A()
|
||||
C.<!UNRESOLVED_REFERENCE!>B<!>()
|
||||
|
||||
C.E3.<!UNRESOLVED_REFERENCE!>O_O<!>
|
||||
C.E3.<!UNRESOLVED_REFERENCE!>G<!>()
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package
|
||||
|
||||
package a {
|
||||
internal fun f(): kotlin.Unit
|
||||
|
||||
internal final enum class C : kotlin.Enum<a.C> {
|
||||
public enum entry E1 : a.C {
|
||||
private constructor E1()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: a.C): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public enum entry E2 : a.C {
|
||||
private constructor E2()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: a.C): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public enum entry E3 : a.C {
|
||||
private constructor E3()
|
||||
internal final fun b(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: a.C): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal final class G {
|
||||
public constructor G()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal object O_O {
|
||||
private constructor O_O()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public enum entry E4 : a.C {
|
||||
private constructor E4()
|
||||
internal final fun c(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: a.C): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
private constructor C()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: a.C): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final inner class B {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal object O {
|
||||
private constructor O()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal object InO {
|
||||
private constructor InO()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): a.C
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<a.C>
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,6 @@ class A {
|
||||
}
|
||||
}
|
||||
|
||||
fun f1() = A.B.<!INVISIBLE_MEMBER!>C<!>
|
||||
fun f1() = A.Default.B.<!INVISIBLE_MEMBER!>C<!>
|
||||
|
||||
fun f2() = A.B.C.<!INVISIBLE_MEMBER!>foo<!>()
|
||||
fun f2() = A.Default.B.C.<!INVISIBLE_MEMBER!>foo<!>()
|
||||
+3
-3
@@ -21,10 +21,10 @@ public class M1 {
|
||||
public val a: A = A()
|
||||
public val b: A.B = A.B()
|
||||
public val c: A.C = A.C
|
||||
public val d: A.Default.D = A.D()
|
||||
public val e: A.Default.D.E = A.D.E
|
||||
public val d: A.Default.D = A.Default.D()
|
||||
public val e: A.Default.D.E = A.Default.D.E
|
||||
public val f: A.F = A().F()
|
||||
public val g: A.Default.G = A.G()
|
||||
public val g: A.Default.G = A.Default.G()
|
||||
}
|
||||
|
||||
// MODULE: m2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//no nested class access via instance reference error
|
||||
fun test() {
|
||||
A.f(<!TYPE_MISMATCH!>""<!>)
|
||||
A.Default.f(<!TYPE_MISMATCH!>""<!>)
|
||||
}
|
||||
|
||||
class A() {
|
||||
|
||||
Reference in New Issue
Block a user