strict checking for internal visibility

This commit is contained in:
Michael Nedzelsky
2015-09-08 05:12:41 +03:00
parent ae36981a0f
commit ea11133142
11 changed files with 53 additions and 51 deletions
+16 -16
View File
@@ -5,16 +5,16 @@
package p package p
public class A { public class A {
val a = A() internal val a = A()
var v = A() internal var v = A()
fun a() = A() internal fun a() = A()
inner class B internal inner class B
} }
val a = A() internal val a = A()
var v = A() internal var v = A()
fun a() = A() internal fun a() = A()
class B internal class B
// MODULE: m2(m1) // MODULE: m2(m1)
// FILE: b.kt // FILE: b.kt
@@ -22,14 +22,14 @@ class B
import p.* import p.*
fun test() { fun test() {
val _a = a val _a = <!INVISIBLE_MEMBER!>a<!>
val _v = v val _v = <!INVISIBLE_MEMBER!>v<!>
a() <!INVISIBLE_MEMBER!>a<!>()
B() <!INVISIBLE_MEMBER!>B<!>()
val inst = A() val inst = A()
val ia = inst.a val ia = inst.<!INVISIBLE_MEMBER!>a<!>
val iv = inst.v val iv = inst.<!INVISIBLE_MEMBER!>v<!>
inst.a() inst.<!INVISIBLE_MEMBER!>a<!>()
inst.B() inst.<!INVISIBLE_MEMBER!>B<!>()
} }
+14 -12
View File
@@ -2,20 +2,20 @@
package package
package p { package p {
public val a: p.A internal val a: p.A
public var v: p.A internal var v: p.A
public fun a(): p.A internal fun a(): p.A
public final class A { public final class A {
public constructor A() public constructor A()
public final val a: p.A internal final val a: p.A
public final var v: p.A internal final var v: p.A
public final fun a(): p.A internal final fun a(): p.A
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean 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 hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final inner class B { internal final inner class B {
public constructor 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 equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -23,7 +23,7 @@ package p {
} }
} }
public final class B { internal final class B {
public constructor 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 equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -38,15 +38,17 @@ package
public fun test(): kotlin.Unit public fun test(): kotlin.Unit
package p { package p {
public val a: p.A internal val a: p.A
public var v: p.A internal var v: p.A
public fun a(): p.A internal fun a(): p.A
public final class A { public final class A {
// -- Module: <m1> -- // -- Module: <m1> --
} }
public final class B { internal final class B {
// -- Module: <m1> -- // -- Module: <m1> --
} }
} }
@@ -120,8 +120,8 @@ public class Visibilities {
@Override @Override
public boolean isVisible(@NotNull ReceiverValue receiver, @NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) { public boolean isVisible(@NotNull ReceiverValue receiver, @NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) {
//NOTE: supposedly temporarily DeclarationDescriptor fromOrModule = from instanceof PackageViewDescriptor ? ((PackageViewDescriptor) from).getModule() : from;
return PUBLIC.isVisible(receiver, what, from); return isInFriendModule(what, fromOrModule);
} }
}; };
+1 -1
View File
@@ -4,7 +4,7 @@ import shared.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: test">t
private fun privateInM1() { private fun privateInM1() {
} }
fun internalInM1() { internal fun internalInM1() {
} }
public fun publicInM1() { public fun publicInM1() {
} }
@@ -4,7 +4,7 @@ import shared.*
private fun privateInM1Test() { private fun privateInM1Test() {
} }
fun internalInM1Test() { internal fun internalInM1Test() {
} }
public fun publicInM1Test() { public fun publicInM1Test() {
} }
+2 -2
View File
@@ -4,14 +4,14 @@ import shared.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: test">t
private fun privateInM2() { private fun privateInM2() {
} }
fun internalInM2() { internal fun internalInM2() {
} }
public fun publicInM2() { public fun publicInM2() {
} }
fun access() { fun access() {
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1': it is 'private' in 'shared'">privateInM1</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1': it is 'private' in 'shared'">privateInM1</error>()
internalInM1() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalInM1': it is 'internal' in 'shared'">internalInM1</error>()
publicInM1() publicInM1()
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: privateInM1Test">privateInM1Test</error>() <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: privateInM1Test">privateInM1Test</error>()
@@ -4,18 +4,18 @@ import shared.*
private fun privateInM2Test() { private fun privateInM2Test() {
} }
fun internalInM2Test() { internal fun internalInM2Test() {
} }
public fun publicInM2Test() { public fun publicInM2Test() {
} }
fun access() { fun access() {
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1': it is 'private' in 'shared'">privateInM1</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1': it is 'private' in 'shared'">privateInM1</error>()
internalInM1() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalInM1': it is 'internal' in 'shared'">internalInM1</error>()
publicInM1() publicInM1()
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1Test': it is 'private' in 'test'">privateInM1Test</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1Test': it is 'private' in 'test'">privateInM1Test</error>()
internalInM1Test() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalInM1Test': it is 'internal' in 'test'">internalInM1Test</error>()
publicInM1Test() publicInM1Test()
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM2': it is 'private' in 'shared'">privateInM2</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM2': it is 'private' in 'shared'">privateInM2</error>()
+1 -1
View File
@@ -4,7 +4,7 @@ import shared.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: test">t
private fun privateInM3() { private fun privateInM3() {
} }
fun internalInM3() { internal fun internalInM3() {
} }
public fun publicInM3() { public fun publicInM3() {
} }
@@ -4,26 +4,26 @@ import shared.*
private fun privateInM3Test() { private fun privateInM3Test() {
} }
fun internalInM3Test() { internal fun internalInM3Test() {
} }
public fun publicInM3Test() { public fun publicInM3Test() {
} }
fun access() { fun access() {
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1': it is 'private' in 'shared'">privateInM1</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1': it is 'private' in 'shared'">privateInM1</error>()
internalInM1() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalInM1': it is 'internal' in 'shared'">internalInM1</error>()
publicInM1() publicInM1()
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1Test': it is 'private' in 'test'">privateInM1Test</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM1Test': it is 'private' in 'test'">privateInM1Test</error>()
internalInM1Test() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalInM1Test': it is 'internal' in 'test'">internalInM1Test</error>()
publicInM1Test() publicInM1Test()
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM2': it is 'private' in 'shared'">privateInM2</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM2': it is 'private' in 'shared'">privateInM2</error>()
internalInM2() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalInM2': it is 'internal' in 'shared'">internalInM2</error>()
publicInM2() publicInM2()
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM2Test': it is 'private' in 'test'">privateInM2Test</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM2Test': it is 'private' in 'test'">privateInM2Test</error>()
internalInM2Test() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalInM2Test': it is 'internal' in 'test'">internalInM2Test</error>()
publicInM2Test() publicInM2Test()
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM3': it is 'private' in 'shared'">privateInM3</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateInM3': it is 'private' in 'shared'">privateInM3</error>()
+3 -3
View File
@@ -1,12 +1,12 @@
package m1 package m1
public class PublicClassInM1 public class PublicClassInM1
class InternalClassInM1 internal class InternalClassInM1
private class PrivateClassInM1 private class PrivateClassInM1
public fun publicFunInM1() { public fun publicFunInM1() {
} }
fun internalFunInM1() { internal fun internalFunInM1() {
} }
private fun privateFunInM1() { private fun privateFunInM1() {
} }
@@ -18,7 +18,7 @@ fun testVisibility() {
public open class A internal constructor() { public open class A internal constructor() {
private fun pri() { private fun pri() {
} }
fun int() { internal fun int() {
} }
protected fun pro() { protected fun pro() {
} }
+5 -5
View File
@@ -5,22 +5,22 @@ import m1.*
fun testVisibility() { fun testVisibility() {
PublicClassInM1() PublicClassInM1()
InternalClassInM1() <error descr="[INVISIBLE_MEMBER] Cannot access 'InternalClassInM1': it is 'internal' in 'm1'">InternalClassInM1</error>()
<error descr="[INVISIBLE_MEMBER] Cannot access 'PrivateClassInM1': it is 'private' in 'm1'">PrivateClassInM1</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'PrivateClassInM1': it is 'private' in 'm1'">PrivateClassInM1</error>()
publicFunInM1() publicFunInM1()
internalFunInM1() <error descr="[INVISIBLE_MEMBER] Cannot access 'internalFunInM1': it is 'internal' in 'm1'">internalFunInM1</error>()
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateFunInM1': it is 'private' in 'm1'">privateFunInM1</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'privateFunInM1': it is 'private' in 'm1'">privateFunInM1</error>()
} }
public class ClassInM2 public class ClassInM2
public class B: A() { public class B: <error descr="[INVISIBLE_MEMBER] Cannot access '<init>': it is 'internal' in 'A'">A</error>() {
fun accessA(<warning>a</warning>: A) {} fun accessA(<warning descr="[UNUSED_PARAMETER] Parameter 'a' is never used">a</warning>: A) {}
fun f() { fun f() {
<error descr="[INVISIBLE_MEMBER] Cannot access 'pri': it is 'invisible_fake' in 'B'">pri</error>() <error descr="[INVISIBLE_MEMBER] Cannot access 'pri': it is 'invisible_fake' in 'B'">pri</error>()
@@ -29,6 +29,6 @@ public class B: A() {
pub() pub()
int() <error descr="[INVISIBLE_MEMBER] Cannot access 'int': it is 'invisible_fake' in 'B'">int</error>()
} }
} }