[FIR] Support typed projections in exposed visibility declaration checker
#KT-62925
This commit is contained in:
committed by
Space Team
parent
a836e6bf29
commit
756cd25417
+1
-1
@@ -250,11 +250,11 @@ object FirExposedVisibilityDeclarationChecker : FirBasicDeclarationChecker() {
|
|||||||
for ((index, it) in type.typeArguments.withIndex()) {
|
for ((index, it) in type.typeArguments.withIndex()) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is ConeClassLikeType -> it.findVisibilityExposure(context, base, visitedTypes)?.let { return it }
|
is ConeClassLikeType -> it.findVisibilityExposure(context, base, visitedTypes)?.let { return it }
|
||||||
|
is ConeKotlinTypeProjection -> it.type.findVisibilityExposure(context, base, visitedTypes)?.let { return it }
|
||||||
is ConeStarProjection -> type.toRegularClassSymbol(context.session)
|
is ConeStarProjection -> type.toRegularClassSymbol(context.session)
|
||||||
?.typeParameterSymbols?.getOrNull(index)
|
?.typeParameterSymbols?.getOrNull(index)
|
||||||
?.resolvedBounds?.firstNotNullOfOrNull { it.type.findVisibilityExposure(context, base, visitedTypes) }
|
?.resolvedBounds?.firstNotNullOfOrNull { it.type.findVisibilityExposure(context, base, visitedTypes) }
|
||||||
?.let { return it }
|
?.let { return it }
|
||||||
else -> {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,21 @@ interface Our {
|
|||||||
// invalid, Generic<My> is effectively internal
|
// invalid, Generic<My> is effectively internal
|
||||||
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(): Generic<*>
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(): Generic<*>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MODULE: a
|
||||||
|
|
||||||
|
internal interface Inter {
|
||||||
|
fun foo() = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
class Wrapper<T>(val it: T)
|
||||||
|
|
||||||
|
fun <T: Inter?> public(a: T & Any) = Wrapper(a)
|
||||||
|
|
||||||
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>other<!>() = public(object : Inter {})
|
||||||
|
|
||||||
|
// MODULE: b(a)
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
other().it.<!INVISIBLE_REFERENCE!>foo<!>() // ok in K1, invisible reference in K2
|
||||||
|
}
|
||||||
|
|||||||
+19
-1
@@ -14,4 +14,22 @@ interface Generic<<!EXPOSED_TYPE_PARAMETER_BOUND!>E: My<!>>
|
|||||||
interface Our {
|
interface Our {
|
||||||
// invalid, Generic<My> is effectively internal
|
// invalid, Generic<My> is effectively internal
|
||||||
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(): Generic<*>
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(): Generic<*>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MODULE: a
|
||||||
|
|
||||||
|
internal interface Inter {
|
||||||
|
fun foo() = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
class Wrapper<T>(val it: T)
|
||||||
|
|
||||||
|
fun <T: Inter?> public(a: T & Any) = Wrapper(a)
|
||||||
|
|
||||||
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>other<!>() = public(object : Inter {})
|
||||||
|
|
||||||
|
// MODULE: b(a)
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
other().it.foo() // ok in K1, invisible reference in K2
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
// -- Module: <a> --
|
||||||
package
|
package
|
||||||
|
|
||||||
|
public fun other(): Wrapper<other.`<no name provided>`>
|
||||||
|
public fun </*0*/ T : Inter?> public(/*0*/ a: T & Any): Wrapper<T & Any>
|
||||||
|
|
||||||
public interface Generic</*0*/ E : My> {
|
public interface Generic</*0*/ E : My> {
|
||||||
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,6 +27,13 @@ public interface His : kotlin.collections.List<My> {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal interface Inter {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open fun foo(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
internal open class My {
|
internal open class My {
|
||||||
public constructor My()
|
public constructor My()
|
||||||
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
|
||||||
@@ -37,6 +48,14 @@ public interface Our {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class Wrapper</*0*/ T> {
|
||||||
|
public constructor Wrapper</*0*/ T>(/*0*/ it: T)
|
||||||
|
public final val it: T
|
||||||
|
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 abstract class Your {
|
public abstract class Your {
|
||||||
public constructor Your()
|
public constructor Your()
|
||||||
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
|
||||||
@@ -44,3 +63,9 @@ public abstract class Your {
|
|||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- Module: <b> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user