Files
kotlin-fork/compiler/testData/diagnostics/tests/exposed/packagePrivate.kt
T
Dmitry Petrov 112e54b35a KT-10752: if (inferred) type for an expression refers to a Java class
non-accessible in the current context, it is a compiler error.
Otherwise we might generate a CHECKCAST instruction that causes IAE at run-time.
Here we are somewhat less permissive then Java
(see inaccessibleType.kt in diagnostics tests).
2016-01-29 10:30:00 +03:00

35 lines
708 B
Kotlin
Vendored

// 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 {
internal fun bar() = <!INACCESSIBLE_TYPE!>My.foo()<!>
}