[FIR] Fix effective visibility calculation & relevant test data

This commit is contained in:
rapturemain
2020-04-14 14:08:28 +03:00
committed by Mikhail Glukhikh
parent d811f6f4a6
commit 6d63de01ac
34 changed files with 137 additions and 99 deletions
@@ -15,7 +15,7 @@ fun test(e: MyException, stream: PrintStream) {
val result = e.getLocalizedMessage() val result = e.getLocalizedMessage()
} }
fun test(e: YourException, stream: PrintStream) { fun test(<!EXPOSED_PARAMETER_TYPE!>e: YourException<!>, stream: PrintStream) {
e.printStackTrace() e.printStackTrace()
e.printStackTrace(stream) e.printStackTrace(stream)
val result = e.getLocalizedMessage() val result = e.getLocalizedMessage()
@@ -6,14 +6,12 @@
package org.jetbrains.kotlin.fir.analysis.checkers.declaration package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3
import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticFactory3
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.analysis.diagnostics.onSource
import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.coneTypeSafe import org.jetbrains.kotlin.fir.types.coneTypeSafe
@@ -111,8 +109,8 @@ object FirExposedVisibilityChecker : FirDeclarationChecker<FirMemberDeclaration>
} }
} }
private inline fun <reified E : PsiElement> DiagnosticReporter.reportExposure( private inline fun <reified E : FirSourceElement, P : PsiElement> DiagnosticReporter.reportExposure(
error: DiagnosticFactory3<E, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>, error: FirDiagnosticFactory3<E, P, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>,
restrictingDeclaration: DeclarationWithRelation, restrictingDeclaration: DeclarationWithRelation,
elementVisibility: FirEffectiveVisibility, elementVisibility: FirEffectiveVisibility,
restrictingVisibility: FirEffectiveVisibility, restrictingVisibility: FirEffectiveVisibility,
@@ -120,8 +118,8 @@ object FirExposedVisibilityChecker : FirDeclarationChecker<FirMemberDeclaration>
) { ) {
source?.let { source?.let {
report( report(
error.onSource( error.on(
it, it as E,
elementVisibility, elementVisibility,
restrictingDeclaration, restrictingDeclaration,
restrictingVisibility restrictingVisibility
@@ -71,5 +71,6 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
map.put(EXPOSED_FUNCTION_RETURN_TYPE, "{0} function exposes its {2} return type{1}", TO_STRING, TO_STRING, TO_STRING) map.put(EXPOSED_FUNCTION_RETURN_TYPE, "{0} function exposes its {2} return type{1}", TO_STRING, TO_STRING, TO_STRING)
map.put(EXPOSED_RECEIVER_TYPE, "{0} member exposes its {2} receiver type{1}", TO_STRING, TO_STRING, TO_STRING) map.put(EXPOSED_RECEIVER_TYPE, "{0} member exposes its {2} receiver type{1}", TO_STRING, TO_STRING, TO_STRING)
map.put(EXPOSED_PARAMETER_TYPE, "{0} function exposes its {2} parameter type{1}", TO_STRING, TO_STRING, TO_STRING) map.put(EXPOSED_PARAMETER_TYPE, "{0} function exposes its {2} parameter type{1}", TO_STRING, TO_STRING, TO_STRING)
}
} }
} }
@@ -14,6 +14,8 @@ import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.KtTypeReference
object FirErrors { object FirErrors {
val UNRESOLVED_REFERENCE by error1<FirSourceElement, PsiElement, String?>() val UNRESOLVED_REFERENCE by error1<FirSourceElement, PsiElement, String?>()
@@ -49,11 +51,11 @@ object FirErrors {
val NON_PRIVATE_CONSTRUCTOR_IN_SEALED by existing<FirSourceElement, PsiElement>(Errors.NON_PRIVATE_CONSTRUCTOR_IN_SEALED) val NON_PRIVATE_CONSTRUCTOR_IN_SEALED by existing<FirSourceElement, PsiElement>(Errors.NON_PRIVATE_CONSTRUCTOR_IN_SEALED)
// Exposed visibility group // Exposed visibility group
val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3<FirSourceElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>() val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3<FirSourceElement, PsiElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>()
val EXPOSED_FUNCTION_RETURN_TYPE by error3<FirSourceElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>() val EXPOSED_FUNCTION_RETURN_TYPE by error3<FirSourceElement, PsiElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>()
val EXPOSED_RECEIVER_TYPE by error3<FirSourceElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>() val EXPOSED_RECEIVER_TYPE by error3<FirSourceElement, KtTypeReference, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>()
val EXPOSED_PROPERTY_TYPE by error3<FirSourceElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>() val EXPOSED_PROPERTY_TYPE by error3<FirSourceElement, PsiElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>()
val EXPOSED_PARAMETER_TYPE by error3<FirSourceElement, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>() val EXPOSED_PARAMETER_TYPE by error3<FirSourceElement, KtParameter, FirEffectiveVisibility, DeclarationWithRelation, FirEffectiveVisibility>()
val REPEATED_MODIFIER by error1<FirSourceElement, PsiElement, KtModifierKeywordToken>() val REPEATED_MODIFIER by error1<FirSourceElement, PsiElement, KtModifierKeywordToken>()
val REDUNDANT_MODIFIER by error2<FirSourceElement, PsiElement, KtModifierKeywordToken, KtModifierKeywordToken>() val REDUNDANT_MODIFIER by error2<FirSourceElement, PsiElement, KtModifierKeywordToken, KtModifierKeywordToken>()
@@ -10,6 +10,8 @@ import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.fir.FirEffectiveVisibility.* import org.jetbrains.kotlin.fir.FirEffectiveVisibility.*
import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.resolve.declaredMemberScopeProvider
import org.jetbrains.kotlin.fir.resolve.firProvider
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeClassLikeType
@@ -34,14 +36,27 @@ fun ConeKotlinType.leastPermissiveDescriptor(session: FirSession, base: FirEffec
fun FirMemberDeclaration.firEffectiveVisibility( fun FirMemberDeclaration.firEffectiveVisibility(
session: FirSession, visibility: Visibility = this.visibility, checkPublishedApi: Boolean = false session: FirSession, visibility: Visibility = this.visibility, checkPublishedApi: Boolean = false
): FirEffectiveVisibility = ): FirEffectiveVisibility {
lowerBound( val containing = this.containingClass(session)
return lowerBound(
visibility.firEffectiveVisibility(session, this), visibility.firEffectiveVisibility(session, this),
this.containingClass(session)?.firEffectiveVisibility(session, checkPublishedApi) ?: Public this.effectiveVisibility,
containing?.firEffectiveVisibility(session, checkPublishedApi) ?: Public,
containing?.effectiveVisibility ?: Public
) )
}
private fun lowerBound(first: FirEffectiveVisibility, second: FirEffectiveVisibility) =
first.lowerBound(second) private fun lowerBound(vararg elements: FirEffectiveVisibility): FirEffectiveVisibility {
if (elements.size < 2) {
throw IllegalArgumentException("Number of elements must be greater than 1")
}
var result = elements[0]
for (el in elements) {
result = result.lowerBound(el)
}
return result
}
private fun FirMemberDeclaration.containingClass(session: FirSession): FirRegularClass? { private fun FirMemberDeclaration.containingClass(session: FirSession): FirRegularClass? {
val classId = when (this) { val classId = when (this) {
@@ -50,7 +65,9 @@ private fun FirMemberDeclaration.containingClass(session: FirSession): FirRegula
else -> null else -> null
} ?: return null } ?: return null
if (classId.isLocal) return null if (classId.isLocal) return null
return session.firSymbolProvider.getClassLikeSymbolByFqName(classId)?.fir as? FirRegularClass val buffer = session.declaredMemberScopeProvider.getClassByClassId(classId)
return (session.firSymbolProvider.getClassLikeSymbolByFqName(classId)?.fir as? FirRegularClass)
?: (session.declaredMemberScopeProvider.getClassByClassId(classId) as? FirRegularClass)
} }
private fun Visibility.forVisibility( private fun Visibility.forVisibility(
@@ -63,7 +80,8 @@ private fun Visibility.forVisibility(
Visibilities.PUBLIC -> Public Visibilities.PUBLIC -> Public
Visibilities.LOCAL -> Local Visibilities.LOCAL -> Local
// NB: visibility must be already normalized here, so e.g. no JavaVisibilities are possible at this point // NB: visibility must be already normalized here, so e.g. no JavaVisibilities are possible at this point
else -> throw AssertionError("Visibility $name is not allowed in forVisibility") // TODO: else -> throw AssertionError("Visibility $name is not allowed in forVisibility")
else -> Private
} }
class DeclarationWithRelation internal constructor(val declaration: FirMemberDeclaration, private val relation: RelationToType) { class DeclarationWithRelation internal constructor(val declaration: FirMemberDeclaration, private val relation: RelationToType) {
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.scopes.impl
import org.jetbrains.kotlin.fir.FirSessionComponent import org.jetbrains.kotlin.fir.FirSessionComponent
import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirClass
import org.jetbrains.kotlin.fir.declarations.classId
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
import org.jetbrains.kotlin.fir.resolve.declaredMemberScopeProvider import org.jetbrains.kotlin.fir.resolve.declaredMemberScopeProvider
import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.FirScope
@@ -18,6 +19,24 @@ class FirDeclaredMemberScopeProvider : FirSessionComponent {
private val declaredMemberCache = mutableMapOf<FirClass<*>, FirScope>() private val declaredMemberCache = mutableMapOf<FirClass<*>, FirScope>()
private val nestedClassifierCache = mutableMapOf<FirClass<*>, FirNestedClassifierScope>() private val nestedClassifierCache = mutableMapOf<FirClass<*>, FirNestedClassifierScope>()
fun getClassByClassId(classId: ClassId): FirClass<*>? {
for ((clazz, _) in declaredMemberCache) {
if (clazz.classId.packageFqName == classId.packageFqName
&& clazz.classId.relativeClassName == classId.relativeClassName
) {
return clazz
}
}
for ((clazz, _) in nestedClassifierCache) {
if (clazz.classId.packageFqName == classId.packageFqName
&& clazz.classId.relativeClassName == classId.relativeClassName
) {
return clazz
}
}
return null
}
fun declaredMemberScope( fun declaredMemberScope(
klass: FirClass<*>, klass: FirClass<*>,
useLazyNestedClassifierScope: Boolean, useLazyNestedClassifierScope: Boolean,
@@ -7,4 +7,4 @@ enum class E {
fun foo() = E.values() fun foo() = E.values()
fun bar() = E.valueOf("ENTRY") fun bar() = E.valueOf("ENTRY")
fun baz() = E.ENTRY fun baz() = E.ENTRY
fun quux() = E <!EXPOSED_FUNCTION_RETURN_TYPE!>fun quux() = E<!>
@@ -3,10 +3,10 @@ internal class My
class Your class Your
// Both arguments should be exposed // Both arguments should be exposed
fun foo(my: My, f: (My) -> Unit) = f(my) fun foo(<!EXPOSED_PARAMETER_TYPE!>my: My<!>, <!EXPOSED_PARAMETER_TYPE!>f: (My) -> Unit<!>) = f(my)
// Ok // Ok
fun bar(your: Your, f: (Your) -> Unit) = f(your) fun bar(your: Your, f: (Your) -> Unit) = f(your)
// Exposed, returns My // Exposed, returns My
fun gav(f: () -> My) = f() <!EXPOSED_FUNCTION_RETURN_TYPE!>fun gav(<!EXPOSED_PARAMETER_TYPE!>f: () -> My<!>) = f()<!>
@@ -10,13 +10,13 @@ internal open class Your: My() {
open class His: Your() { open class His: Your() {
protected open class Nested protected open class Nested
// error, public from internal // error, public from internal
val x = My() <!EXPOSED_PROPERTY_TYPE!>val x = My()<!>
// valid, private from internal // valid, private from internal
private fun bar() = My() private fun bar() = My()
// valid, internal from internal // valid, internal from internal
internal var y: My? = null internal var y: My? = null
// error, protected from internal // error, protected from internal
protected fun baz() = Your() <!EXPOSED_FUNCTION_RETURN_TYPE!>protected fun baz() = Your()<!>
} }
internal class Their: His() { internal class Their: His() {
@@ -3,8 +3,8 @@ interface Your
class My { class My {
internal val x = object : Your {} internal val x = object : Your {}
internal fun foo() = { <!EXPOSED_FUNCTION_RETURN_TYPE!>internal fun foo() = {
class Local class Local
Local() Local()
}() }()<!>
} }
+4 -4
View File
@@ -1,14 +1,14 @@
// invalid, depends on local class // invalid, depends on local class
fun foo() = run { <!EXPOSED_FUNCTION_RETURN_TYPE!>fun foo() = run {
class A class A
A() A()
} }<!>
// invalid, depends on local class // invalid, depends on local class
fun gav() = { <!EXPOSED_FUNCTION_RETURN_TYPE!>fun gav() = {
class B class B
B() B()
} }<!>
abstract class My abstract class My
@@ -2,27 +2,27 @@ class My<T>(val value: T)
open class Base open class Base
fun invalid1() = run { <!EXPOSED_FUNCTION_RETURN_TYPE!>fun invalid1() = run {
class Local class Local
My(Local()) My(Local())
} }<!>
fun invalid2() = My(object {}) fun invalid2() = My(object {})
fun invalid3() = My(object : Base() {}) fun invalid3() = My(object : Base() {})
fun invalid4() = run { <!EXPOSED_FUNCTION_RETURN_TYPE!>fun invalid4() = run {
class Local class Local
My(My(Local())) My(My(Local()))
} }<!>
fun invalid5() = run { <!EXPOSED_FUNCTION_RETURN_TYPE!>fun invalid5() = run {
fun invalid5a() = run { fun invalid5a() = run {
class Local class Local
Local() Local()
} }
My(invalid5a()) My(invalid5a())
} }<!>
// Valid: effectively Any // Valid: effectively Any
fun valid1() = object {} fun valid1() = object {}
@@ -4,9 +4,9 @@ class Something {
internal val internalVal1 = object { override fun toString() = "!" } internal val internalVal1 = object { override fun toString() = "!" }
private val privateVal1 = object { override fun toString() = "!" } private val privateVal1 = object { override fun toString() = "!" }
public val publicVal2 = run { class A; A() } <!EXPOSED_PROPERTY_TYPE!>public val publicVal2 = run { class A; A() }<!>
protected val protectedVal2 = run { class A; A() } <!EXPOSED_PROPERTY_TYPE!>protected val protectedVal2 = run { class A; A() }<!>
internal val internalVal2 = run { class A; A() } <!EXPOSED_PROPERTY_TYPE!>internal val internalVal2 = run { class A; A() }<!>
private val privateVal2 = run { class A; A() } private val privateVal2 = run { class A; A() }
public fun publicFun1() = object { override fun toString() = "!" } public fun publicFun1() = object { override fun toString() = "!" }
@@ -14,8 +14,8 @@ class Something {
internal fun internalFun1() = object { override fun toString() = "!" } internal fun internalFun1() = object { override fun toString() = "!" }
private fun privateFun1() = object { override fun toString() = "!" } private fun privateFun1() = object { override fun toString() = "!" }
public fun publicFun2() = run { class A; A() } <!EXPOSED_FUNCTION_RETURN_TYPE!>public fun publicFun2() = run { class A; A() }<!>
protected fun protectedFun2() = run { class A; A() } <!EXPOSED_FUNCTION_RETURN_TYPE!>protected fun protectedFun2() = run { class A; A() }<!>
internal fun internalFun2() = run { class A; A() } <!EXPOSED_FUNCTION_RETURN_TYPE!>internal fun internalFun2() = run { class A; A() }<!>
private fun privateFun2() = run { class A; A() } private fun privateFun2() = run { class A; A() }
} }
@@ -2,27 +2,27 @@ class My<T>(val value: T)
open class Base open class Base
val invalid1 = run { <!EXPOSED_PROPERTY_TYPE!>val invalid1 = run {
class Local class Local
My(Local()) My(Local())
} }<!>
val invalid2 = My(object {}) val invalid2 = My(object {})
val invalid3 = My(object : Base() {}) val invalid3 = My(object : Base() {})
val invalid4 = run { <!EXPOSED_PROPERTY_TYPE!>val invalid4 = run {
class Local class Local
My(My(Local())) My(My(Local()))
} }<!>
val invalid5 = run { <!EXPOSED_PROPERTY_TYPE!>val invalid5 = run {
fun invalid5a() = run { fun invalid5a() = run {
class Local class Local
Local() Local()
} }
My(invalid5a()) My(invalid5a())
} }<!>
// Valid: effectively Any // Valid: effectively Any
val valid1 = object {} val valid1 = object {}
+7 -7
View File
@@ -1,7 +1,7 @@
// From KT-10753 // From KT-10753
object My : Inter() { object My : Inter() {
fun foo(arg: Inter): Inter = arg <!EXPOSED_FUNCTION_RETURN_TYPE!>fun foo(<!EXPOSED_PARAMETER_TYPE!>arg: Inter<!>): Inter = arg<!>
val x: Inter? = null <!EXPOSED_PROPERTY_TYPE!>val x: Inter? = null<!>
} }
internal open class Inter internal open class Inter
@@ -10,21 +10,21 @@ internal open class Inter
open class Test { open class Test {
protected class Protected protected class Protected
fun foo(x: Protected) = x <!EXPOSED_FUNCTION_RETURN_TYPE!>fun foo(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x<!>
interface NestedInterface { interface NestedInterface {
fun create(x: Protected) fun create(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>)
} }
class NestedClass { class NestedClass {
fun create(x: Protected) = x <!EXPOSED_FUNCTION_RETURN_TYPE!>fun create(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x<!>
} }
object NestedObject { object NestedObject {
fun create(x: Protected) = x <!EXPOSED_FUNCTION_RETURN_TYPE!>fun create(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x<!>
} }
companion object { companion object {
fun create(x: Protected) = x <!EXPOSED_FUNCTION_RETURN_TYPE!>fun create(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x<!>
} }
} }
@@ -1,3 +1,3 @@
private enum class Foo { A, B } private enum class Foo { A, B }
class Bar private constructor(val foo: Foo) class Bar private constructor(<!EXPOSED_PROPERTY_TYPE!>val foo: Foo<!>)
@@ -1,3 +1,3 @@
private enum class Foo { A, B } private enum class Foo { A, B }
class Bar(val foo: Foo) class Bar(<!EXPOSED_PARAMETER_TYPE, EXPOSED_PROPERTY_TYPE!>val foo: Foo<!>)
+6 -6
View File
@@ -6,18 +6,18 @@ public interface Your: My {
fun <T: Base> foo(): T fun <T: Base> foo(): T
} }
public class Derived<T: My>(val x: My): Base() { public class Derived<T: My>(<!EXPOSED_PARAMETER_TYPE, EXPOSED_PROPERTY_TYPE!>val x: My<!>): Base() {
constructor(xx: My?, x: My): this(xx ?: x) constructor(<!EXPOSED_PARAMETER_TYPE!>xx: My?<!>, <!EXPOSED_PARAMETER_TYPE!>x: My<!>): this(xx ?: x)
val y: Base? = null <!EXPOSED_PROPERTY_TYPE!>val y: Base? = null<!>
val My.z: Int val <!EXPOSED_RECEIVER_TYPE!>My<!>.z: Int
get() = 42 get() = 42
fun foo(m: My): My = m <!EXPOSED_FUNCTION_RETURN_TYPE!>fun foo(<!EXPOSED_PARAMETER_TYPE!>m: My<!>): My = m<!>
fun My.bar(): My = this <!EXPOSED_FUNCTION_RETURN_TYPE!>fun <!EXPOSED_RECEIVER_TYPE!>My<!>.bar(): My = this<!>
} }
@@ -2,7 +2,7 @@ internal open class My
abstract class Your { abstract class Your {
// invalid, List<My> is effectively internal // invalid, List<My> is effectively internal
abstract fun give(): List<My> <!EXPOSED_FUNCTION_RETURN_TYPE!>abstract fun give(): List<My><!>
} }
// invalid, List<My> is effectively internal // invalid, List<My> is effectively internal
@@ -16,7 +16,7 @@ private class TopLevelClass {
} }
} }
private enum class TopLevelEnum(private val e: NestedEnum) { <!EXPOSED_FUNCTION_RETURN_TYPE, EXPOSED_FUNCTION_RETURN_TYPE!>private enum class TopLevelEnum(private val e: NestedEnum) {
E1(NestedEntry); E1(NestedEntry);
private enum class NestedEnum { private enum class NestedEnum {
@@ -7,7 +7,7 @@ open class Foo {
} }
class Bar: Foo() { class Bar: Foo() {
protected fun foo(): Nested? = null <!EXPOSED_FUNCTION_RETURN_TYPE!>protected fun foo(): Nested? = null<!>
} }
private fun foo(): Nested? = null private fun foo(): Nested? = null
@@ -14,5 +14,5 @@ package p1
import p2.* import p2.*
val x: X = X() <!EXPOSED_PROPERTY_TYPE!>val x: X = X()<!>
val y: Y = <!INAPPLICABLE_CANDIDATE!>Y<!>() <!EXPOSED_PROPERTY_TYPE!>val y: Y = <!INAPPLICABLE_CANDIDATE!>Y<!>()<!>
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE // !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
inline fun call(a: A) { inline fun call(<!EXPOSED_PARAMETER_TYPE!>a: A<!>) {
a.test() a.test()
privateFun() privateFun()
@@ -6,7 +6,7 @@ private class S public constructor() {
} }
} }
internal inline fun x(s: S, z: () -> Unit) { internal inline fun x(<!EXPOSED_PARAMETER_TYPE!>s: S<!>, z: () -> Unit) {
z() z()
S() S()
s.a() s.a()
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE // !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
inline fun call(a: A) { inline fun call(<!EXPOSED_PARAMETER_TYPE!>a: A<!>) {
a.test() a.test()
publishedTopLevel() publishedTopLevel()
@@ -16,10 +16,10 @@ class MyJavaClass {
//FILE:a.kt //FILE:a.kt
package a package a
val mc = MyJavaClass() <!EXPOSED_PROPERTY_TYPE!>val mc = MyJavaClass()<!>
val x = MyJavaClass.staticMethod() val x = MyJavaClass.staticMethod()
val y = MyJavaClass.NestedClass.staticMethodOfNested() val y = MyJavaClass.NestedClass.staticMethodOfNested()
val z = MyJavaClass.NestedClass() <!EXPOSED_PROPERTY_TYPE!>val z = MyJavaClass.NestedClass()<!>
//FILE: b.kt //FILE: b.kt
package b package b
@@ -20,7 +20,7 @@ private fun bar() {
xx = 30 xx = 30
} }
fun makeA() = A() <!EXPOSED_FUNCTION_RETURN_TYPE!>fun makeA() = A()<!>
private object PO {} private object PO {}
@@ -17,7 +17,7 @@ class E private constructor() {
} }
val a = A val a = A
val b = B <!EXPOSED_PROPERTY_TYPE!>val b = B<!>
val c = C val c = C
val d = D val d = D
val e = E(42) val e = E(42)
@@ -9,7 +9,7 @@ private open class A {
private fun foo() {} private fun foo() {}
fun makeA() = A() <!EXPOSED_FUNCTION_RETURN_TYPE!>fun makeA() = A()<!>
private object PO {} private object PO {}
@@ -16,7 +16,7 @@ private fun bar() {
x = 20 x = 20
} }
fun makeA() = A() <!EXPOSED_FUNCTION_RETURN_TYPE!>fun makeA() = A()<!>
private object PO {} private object PO {}
@@ -6,14 +6,14 @@ package p
private fun foo(a: Int) = run { private fun foo(a: Int) = run {
object { object {
inner class A inner class A
fun foo() = A() <!EXPOSED_FUNCTION_RETURN_TYPE!>fun foo() = A()<!>
}.foo() }.foo()
} }
private fun foo() = run { private fun foo() = run {
object { object {
inner class A inner class A
fun foo() = A() <!EXPOSED_FUNCTION_RETURN_TYPE!>fun foo() = A()<!>
}.foo() }.foo()
} }
@@ -7,39 +7,39 @@ class Outer {
protected class Protected protected class Protected
internal class Internal internal class Internal
typealias TestPrivate1 = Private <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestPrivate1 = Private<!>
protected typealias TestPrivate2 = Private <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>protected typealias TestPrivate2 = Private<!>
internal typealias TestPrivate3 = Private <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>internal typealias TestPrivate3 = Private<!>
private typealias TestPrivate4 = Private private typealias TestPrivate4 = Private
typealias TestPrivate5 = L<Private> <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestPrivate5 = L<Private><!>
typealias TestPrivate6 = L<TestPrivate1> typealias TestPrivate6 = L<TestPrivate1>
typealias TestProtected1 = Protected <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestProtected1 = Protected<!>
protected typealias TestProtected2 = Protected protected typealias TestProtected2 = Protected
internal typealias TestProtected3 = Protected <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>internal typealias TestProtected3 = Protected<!>
private typealias TestProtected4 = Protected private typealias TestProtected4 = Protected
typealias TestProtected5 = L<Protected> <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestProtected5 = L<Protected><!>
typealias TestProtected6 = L<TestProtected1> typealias TestProtected6 = L<TestProtected1>
typealias TestInternal1 = Internal <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestInternal1 = Internal<!>
protected typealias TestInternal2 = Internal <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>protected typealias TestInternal2 = Internal<!>
internal typealias TestInternal3 = Internal internal typealias TestInternal3 = Internal
private typealias TestInternal4 = Internal private typealias TestInternal4 = Internal
typealias TestInternal5 = L<Internal> <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestInternal5 = L<Internal><!>
typealias TestInternal6 = L<TestInternal1> typealias TestInternal6 = L<TestInternal1>
} }
private class Private private class Private
internal class Internal internal class Internal
typealias TestPrivate1 = Private <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestPrivate1 = Private<!>
internal typealias TestPrivate2 = Private <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>internal typealias TestPrivate2 = Private<!>
private typealias TestPrivate3 = Private private typealias TestPrivate3 = Private
typealias TestPrivate4 = L<Private> <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestPrivate4 = L<Private><!>
typealias TestPrivate5 = L<TestPrivate1> typealias TestPrivate5 = L<TestPrivate1>
typealias TestInternal1 = Internal <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestInternal1 = Internal<!>
internal typealias TestInternal2 = Internal internal typealias TestInternal2 = Internal
private typealias TestInternal3 = Internal private typealias TestInternal3 = Internal
typealias TestInternal4 = L<Internal> <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>typealias TestInternal4 = L<Internal><!>
typealias TestInternal5 = L<TestInternal1> typealias TestInternal5 = L<TestInternal1>
@@ -4,5 +4,5 @@ class C {
typealias CAlias = C typealias CAlias = C
val test1 = CAlias <!EXPOSED_PROPERTY_TYPE!>val test1 = CAlias<!>
val test1a = C <!EXPOSED_PROPERTY_TYPE!>val test1a = C<!>
@@ -10,6 +10,6 @@ package kotlin.sequences
import p.* import p.*
interface I { interface I {
val v1: FilteringSequence <!EXPOSED_PROPERTY_TYPE!>val v1: FilteringSequence<!>
val v2: IndexingSequence<String> <!EXPOSED_PROPERTY_TYPE!>val v2: IndexingSequence<String><!>
} }