Effective visibility: java package-private is now considered as equivalent to Kotlin internal #KT-9755 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-10-26 14:32:42 +03:00
parent 994feafd6e
commit d0e01153ec
5 changed files with 95 additions and 12 deletions
@@ -0,0 +1,35 @@
// FILE: test/My.java
package test;
class Internal {}
public class My {
static public Internal foo() { return new Internal(); }
}
// FILE: test/His.kt
package test
class His {
// Ok: private vs package-private
private fun private() = My.foo()
// Ok: internal vs package-private in same package
internal fun internal() = My.foo()
// Error: protected vs package-private
protected fun <!EXPOSED_FUNCTION_RETURN_TYPE!>protected<!>() = My.foo()
// Error: public vs package-private
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>public<!>() = My.foo()
}
// FILE: other/Your.kt
package other
import test.My
class Your {
// Ok but dangerous: internal vs package-private in different package
internal fun bar() = My.foo()
}