Fix visibility checks for constructor call based on type alias

Constructor is invisible iff. either underlying constructor or corresposing type alias is invisible

 #KT-12888 Fixed
This commit is contained in:
Denis Zharkov
2016-06-28 12:33:25 +03:00
parent 1b416a674d
commit f1363cbf88
4 changed files with 64 additions and 0 deletions
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// !CHECK_TYPE
// FILE: a.kt
package a
class B(x: String)
typealias A1 = B
private typealias A2 = B
private typealias A3 = B
fun A3(x: Any) = "OK"
fun bar() {
A3("") checkType { _<B>() }
}
// FILE: main.kt
package usage
import a.B
fun baz() {
a.A1("") // resolved to B constructor, OK
a.<!INVISIBLE_MEMBER!>A2<!>("") // resolved to B constructor, INVISIBLE_MEMBER because type alias is private, OK
a.A3("") checkType { _<String>() }
val x: a.<!INVISIBLE_REFERENCE!>A2<!> = B("") // A2 is unresolved because it's private in file, OK
}
@@ -0,0 +1,20 @@
package
package a {
public typealias A1 = a.B
private typealias A2 = a.B
private typealias A3 = a.B
public fun A3(/*0*/ x: kotlin.Any): kotlin.String
public fun bar(): kotlin.Unit
public final class B {
public constructor B(/*0*/ x: kotlin.String)
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
}
}
package usage {
public fun baz(): kotlin.Unit
}