[FIR] Report errors about invisible types from type resolution

This commit is contained in:
Dmitriy Novozhilov
2021-11-23 15:18:40 +03:00
committed by teamcityserver
parent f2c319c4ae
commit 8707be51c9
39 changed files with 217 additions and 122 deletions
@@ -32275,6 +32275,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/visibility/privateCompanionInSuperClass.kt");
}
@Test
@TestMetadata("privateDeclarationInAnotherFile.kt")
public void testPrivateDeclarationInAnotherFile() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
}
@Test
@TestMetadata("protectedInternal.kt")
public void testProtectedInternal() throws Exception {
@@ -17,7 +17,7 @@ FILE: exposedFunctionParameterType.kt
super<R|kotlin/Any|>()
}
public final fun foo(value: R|A.AInner|): R|kotlin/Unit| {
public final fun foo(value: <ERROR TYPE REF: HIDDEN: A.AInner is invisible>): R|kotlin/Unit| {
}
}
@@ -3,7 +3,7 @@ class A {
}
class B {
fun foo(<!EXPOSED_PARAMETER_TYPE!>value: A.AInner<!>) {
fun foo(<!EXPOSED_PARAMETER_TYPE!>value: <!INVISIBLE_REFERENCE!>A.AInner<!><!>) {
}
}
@@ -17,7 +17,7 @@ FILE: exposedFunctionReturnType.kt
super<R|kotlin/Any|>()
}
public final fun foo(str: R|kotlin/String|): R|A.InnerA|
public final fun foo(str: R|kotlin/String|): <ERROR TYPE REF: HIDDEN: A.InnerA is invisible>
}
private final enum class Some : R|kotlin/Enum<Some>| {
@@ -5,7 +5,7 @@ class A {
}
abstract class B {
<!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(str: String): A.InnerA<!>
<!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(str: String): <!INVISIBLE_REFERENCE!>A.InnerA<!><!>
}
private enum class Some {
@@ -57,16 +57,16 @@ FILE: exposedPropertyType.kt
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
public final var var4: R|A.AInnerPrivate|
public get(): R|A.AInnerPrivate|
public set(value: R|A.AInnerPrivate|): R|kotlin/Unit|
public final var var4: <ERROR TYPE REF: HIDDEN: A.AInnerPrivate is invisible>
public get(): <ERROR TYPE REF: HIDDEN: A.AInnerPrivate is invisible>
public set(value: <ERROR TYPE REF: HIDDEN: A.AInnerPrivate is invisible>): R|kotlin/Unit|
public final var var5: R|A.AInnerPublic|
public get(): R|A.AInnerPublic|
public set(value: R|A.AInnerPublic|): R|kotlin/Unit|
public final var var6: R|A.AInnerProtectedEnum|
public get(): R|A.AInnerProtectedEnum|
public set(value: R|A.AInnerProtectedEnum|): R|kotlin/Unit|
public final var var6: <ERROR TYPE REF: HIDDEN: A.AInnerProtectedEnum is invisible>
public get(): <ERROR TYPE REF: HIDDEN: A.AInnerProtectedEnum is invisible>
public set(value: <ERROR TYPE REF: HIDDEN: A.AInnerProtectedEnum is invisible>): R|kotlin/Unit|
}
@@ -17,7 +17,7 @@ class Property {
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var var1: String<!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var var2: String<!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var var3: Int<!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var <!EXPOSED_PROPERTY_TYPE!>var4<!>: A.AInnerPrivate<!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var <!EXPOSED_PROPERTY_TYPE!>var4<!>: <!INVISIBLE_REFERENCE!>A.AInnerPrivate<!><!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var var5: A.AInnerPublic<!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var <!EXPOSED_PROPERTY_TYPE!>var6<!>: A.AInnerProtectedEnum<!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var <!EXPOSED_PROPERTY_TYPE!>var6<!>: <!INVISIBLE_REFERENCE!>A.AInnerProtectedEnum<!><!>
}
@@ -74,7 +74,7 @@ FILE: exposedSupertype.kt
}
}
public final class Test4 : R|E|, R|A.AProtectedI| {
public final class Test4 : R|E|, <ERROR TYPE REF: HIDDEN: A.AProtectedI is invisible> {
public constructor(): R|Test4| {
super<R|kotlin/Any|>()
}
@@ -46,7 +46,7 @@ class Test3 : C.CPublicI, <!EXPOSED_SUPER_CLASS, FINAL_SUPERTYPE, SUPERTYPE_NOT_
}
class Test4 : E, A.AProtectedI {
class Test4 : E, <!INVISIBLE_REFERENCE!>A.AProtectedI<!> {
}
@@ -17,7 +17,7 @@ FILE: exposedTypeAlias.kt
super<R|kotlin/Any|>()
}
public final typealias AInner = R|A.Inner|
public final typealias AInner = <ERROR TYPE REF: HIDDEN: A.Inner is invisible>
public final inner class Inner : R|kotlin/Any| {
public B.constructor(): R|B.Inner| {
@@ -35,7 +35,7 @@ FILE: exposedTypeAlias.kt
public final typealias BInner = R|B.Inner|
}
public final typealias AInner0 = R|A.Inner|
public final typealias AInner0 = <ERROR TYPE REF: HIDDEN: A.Inner is invisible>
public final typealias BInner0 = R|B.Inner|
private final typealias MyString = R|kotlin/String|
public final fun foo(): R|MyString| {
@@ -2,7 +2,7 @@ class A {
private inner class Inner
}
class B {
<!TOPLEVEL_TYPEALIASES_ONLY!>typealias <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>AInner<!> = A.Inner<!>
<!TOPLEVEL_TYPEALIASES_ONLY!>typealias <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>AInner<!> = <!INVISIBLE_REFERENCE!>A.Inner<!><!>
inner class Inner
}
@@ -10,9 +10,9 @@ class C {
<!TOPLEVEL_TYPEALIASES_ONLY!>typealias BInner = B.Inner<!>
}
typealias <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>AInner0<!> = A.Inner
typealias <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>AInner0<!> = <!INVISIBLE_REFERENCE!>A.Inner<!>
typealias BInner0 = B.Inner
private typealias MyString = String
fun foo(): MyString = ""
fun foo(): MyString = ""
@@ -42,8 +42,8 @@ FILE: exposedTypeParameters.kt
}
}
public final class Test3<T : R|E|, P : R|C.D|> : R|kotlin/Any| {
public constructor<T : R|E|, P : R|C.D|>(): R|Test3<T, P>| {
public final class Test3<T : R|E|, P : <ERROR TYPE REF: HIDDEN: C.D is invisible>> : R|kotlin/Any| {
public constructor<T : R|E|, P : <ERROR TYPE REF: HIDDEN: C.D is invisible>>(): R|Test3<T, P>| {
super<R|kotlin/Any|>()
}
@@ -80,5 +80,5 @@ FILE: exposedTypeParameters.kt
}
}
public abstract interface Test8<T : R|A|, P : R|B|, F : R|C|, N : R|C.D|, M : R|E|> : R|kotlin/Any| {
public abstract interface Test8<T : R|A|, P : R|B|, F : R|C|, N : <ERROR TYPE REF: HIDDEN: C.D is invisible>, M : R|E|> : R|kotlin/Any| {
}
@@ -15,7 +15,7 @@ public class Test1<T: <!EXPOSED_TYPE_PARAMETER_BOUND!>A<!>>
public class Test2<T: C, P: E>
// invalid, D is protected
public class Test3<T: E, P: <!EXPOSED_TYPE_PARAMETER_BOUND!>C.D<!>>
public class Test3<T: E, P: <!EXPOSED_TYPE_PARAMETER_BOUND, INVISIBLE_REFERENCE!>C.D<!>>
// valid, B is internal
internal class Test4<T: B>
@@ -32,4 +32,4 @@ public class Container : <!SUPERTYPE_NOT_INITIALIZED!>C<!> {
}
// invalid, A is private, B is internal, D is protected
public interface Test8<T: <!EXPOSED_TYPE_PARAMETER_BOUND!>A<!>, P: <!EXPOSED_TYPE_PARAMETER_BOUND!>B<!>, F: C, N: <!EXPOSED_TYPE_PARAMETER_BOUND!>C.D<!>, M: E>
public interface Test8<T: <!EXPOSED_TYPE_PARAMETER_BOUND!>A<!>, P: <!EXPOSED_TYPE_PARAMETER_BOUND!>B<!>, F: C, N: <!EXPOSED_TYPE_PARAMETER_BOUND, INVISIBLE_REFERENCE!>C.D<!>, M: E>
@@ -1,5 +1,5 @@
FILE: lowPriorityInResolution.kt
@R|kotlin/Suppress|(names = vararg(String(INVISIBLE_MEMBER), String(INVISIBLE_REFERENCE))) @R|kotlin/internal/LowPriorityInOverloadResolution|() public final fun foo(): R|kotlin/Int| {
@R|kotlin/Suppress|(names = vararg(String(INVISIBLE_MEMBER), String(INVISIBLE_REFERENCE))) @<ERROR TYPE REF: HIDDEN: kotlin/internal/LowPriorityInOverloadResolution is invisible>() public final fun foo(): R|kotlin/Int| {
^foo Int(1)
}
public final fun foo(): R|kotlin/String| {
@@ -32275,6 +32275,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/visibility/privateCompanionInSuperClass.kt");
}
@Test
@TestMetadata("privateDeclarationInAnotherFile.kt")
public void testPrivateDeclarationInAnotherFile() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
}
@Test
@TestMetadata("protectedInternal.kt")
public void testProtectedInternal() throws Exception {
@@ -32275,6 +32275,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/visibility/privateCompanionInSuperClass.kt");
}
@Test
@TestMetadata("privateDeclarationInAnotherFile.kt")
public void testPrivateDeclarationInAnotherFile() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
}
@Test
@TestMetadata("protectedInternal.kt")
public void testProtectedInternal() throws Exception {
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.FirSessionComponent
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
import org.jetbrains.kotlin.fir.resolve.transformers.ScopeClassDeclaration
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirTypeRef
@@ -20,7 +21,7 @@ abstract class FirTypeResolver : FirSessionComponent {
isOperandOfIsOperator: Boolean,
useSiteFile: FirFile?,
supertypeSupplier: SupertypeSupplier
): ConeKotlinType
): Pair<ConeKotlinType, ConeDiagnostic?>
}
val FirSession.typeResolver: FirTypeResolver by FirSession.sessionComponentAccessor()
@@ -6,19 +6,19 @@
package org.jetbrains.kotlin.fir.resolve.providers.impl
import org.jetbrains.kotlin.KtSourceElement
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.ThreadSafeMutableState
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.impl.FirOuterClassTypeParameterRef
import org.jetbrains.kotlin.fir.declarations.utils.isEnumClass
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.ConeUnexpectedTypeArgumentsError
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeOuterClassArgumentsRequired
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedQualifierError
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnsupportedDynamicType
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeWrongNumberOfTypeArgumentsError
import org.jetbrains.kotlin.fir.resolve.diagnostics.*
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
import org.jetbrains.kotlin.fir.resolve.transformers.ScopeClassDeclaration
@@ -30,8 +30,10 @@ import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef
import org.jetbrains.kotlin.fir.visibilityChecker
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.utils.addToStdlib.runIf
@ThreadSafeMutableState
class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
@@ -101,18 +103,18 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
scopeClassDeclaration: ScopeClassDeclaration,
useSiteFile: FirFile?,
supertypeSupplier: SupertypeSupplier
): Pair<FirBasedSymbol<*>?, ConeSubstitutor?> {
): Triple<FirBasedSymbol<*>?, ConeSubstitutor?, ConeDiagnostic?> {
return when (typeRef) {
is FirResolvedTypeRef -> {
val resultSymbol = typeRef.coneTypeSafe<ConeLookupTagBasedType>()?.lookupTag?.let(symbolProvider::getSymbolByLookupTag)
resultSymbol to null
Triple(resultSymbol, null, null)
}
is FirUserTypeRef -> {
val qualifierResolver = session.qualifierResolver
var acceptedSymbol: FirBasedSymbol<*>? = null
var firstNonApplicable: FirBasedSymbol<*>? = null
var substitutor: ConeSubstitutor? = null
val notApplicableSymbols = mutableListOf<Pair<FirBasedSymbol<*>, ConeSubstitutor>>()
val qualifier = typeRef.qualifier
val scopes = scopeClassDeclaration.scopes
val containingDeclarations = scopeClassDeclaration.containingDeclarations
@@ -121,36 +123,48 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
if (acceptedSymbol != null) {
break
}
val collectNonApplicable = notApplicableSymbols.isEmpty()
scope.processClassifiersByNameWithSubstitution(qualifier.first().name) { symbol, substitutorFromScope ->
if (acceptedSymbol != null) {
return@processClassifiersByNameWithSubstitution
}
if (acceptedSymbol != null) return@processClassifiersByNameWithSubstitution
val resolvedSymbol = resolveSymbol(symbol, qualifier, qualifierResolver)
?: return@processClassifiersByNameWithSubstitution
if (resolvedSymbol.isVisible(useSiteFile, containingDeclarations, supertypeSupplier)) {
acceptedSymbol = resolvedSymbol
substitutor = substitutorFromScope
} else {
firstNonApplicable = resolvedSymbol
} else if (collectNonApplicable) {
resolvedSymbol.isVisible(useSiteFile, containingDeclarations, supertypeSupplier)
notApplicableSymbols += resolvedSymbol to substitutorFromScope
}
}
}
if (acceptedSymbol == null) {
acceptedSymbol = firstNonApplicable
}
when {
acceptedSymbol != null -> Triple(acceptedSymbol, substitutor, null)
// TODO: Imports
val resultSymbol: FirBasedSymbol<*>? = acceptedSymbol ?: qualifierResolver.resolveSymbol(qualifier)
resultSymbol to substitutor
notApplicableSymbols.size == 1 -> {
val (notApplicableSymbol, resultingSubstitutor) = notApplicableSymbols.single()
Triple(notApplicableSymbol, resultingSubstitutor, ConeVisibilityError(notApplicableSymbol))
}
else -> {
val symbolFromQualifier = qualifierResolver.resolveSymbol(qualifier)
val diagnostic = runIf(
symbolFromQualifier != null &&
!symbolFromQualifier.isVisible(useSiteFile, containingDeclarations, supertypeSupplier)
) {
ConeVisibilityError(symbolFromQualifier!!)
}
Triple(symbolFromQualifier, null, diagnostic)
}
}
}
is FirImplicitBuiltinTypeRef -> {
resolveBuiltInQualified(typeRef.id, session) to null
Triple(resolveBuiltInQualified(typeRef.id, session), null, null)
}
else -> null to null
else -> Triple(null, null, null)
}
}
@@ -455,11 +469,11 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
isOperandOfIsOperator: Boolean,
useSiteFile: FirFile?,
supertypeSupplier: SupertypeSupplier
): ConeKotlinType {
): Pair<ConeKotlinType, ConeDiagnostic?> {
return when (typeRef) {
is FirResolvedTypeRef -> typeRef.type
is FirResolvedTypeRef -> typeRef.type to null
is FirUserTypeRef -> {
val (symbol, substitutor) = resolveToSymbol(typeRef, scopeClassDeclaration, useSiteFile, supertypeSupplier)
val (symbol, substitutor, diagnostic) = resolveToSymbol(typeRef, scopeClassDeclaration, useSiteFile, supertypeSupplier)
resolveUserType(
typeRef,
symbol,
@@ -467,10 +481,10 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
areBareTypesAllowed,
scopeClassDeclaration.topContainer ?: scopeClassDeclaration.containingDeclarations.lastOrNull(),
isOperandOfIsOperator
)
) to diagnostic
}
is FirFunctionTypeRef -> createFunctionalType(typeRef)
is FirDynamicTypeRef -> ConeKotlinErrorType(ConeUnsupportedDynamicType())
is FirFunctionTypeRef -> createFunctionalType(typeRef) to null
is FirDynamicTypeRef -> ConeKotlinErrorType(ConeUnsupportedDynamicType()) to null
else -> error(typeRef.render())
}
}
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fakeElement
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.ConeUnexpectedTypeArgumentsError
import org.jetbrains.kotlin.fir.resolve.SupertypeSupplier
@@ -77,17 +78,15 @@ class FirSpecificTypeResolverTransformer(
withBareTypes(allowed = false) {
typeRef.transformChildren(this, data)
}
return transformType(
val (resolvedType, diagnostic) = typeResolver.resolveType(
typeRef,
typeResolver.resolveType(
typeRef,
data,
areBareTypesAllowed,
isOperandOfIsOperator,
currentFile,
supertypeSupplier
)
data,
areBareTypesAllowed,
isOperandOfIsOperator,
currentFile,
supertypeSupplier
)
return transformType(typeRef, resolvedType, diagnostic)
}
@OptIn(PrivateForInline::class)
@@ -98,15 +97,17 @@ class FirSpecificTypeResolverTransformer(
functionTypeRef.transformChildren(this, data)
val scopeOwnerLookupNames = data.scopes.flatMap { it.scopeOwnerLookupNames }
session.lookupTracker?.recordTypeLookup(functionTypeRef, scopeOwnerLookupNames, currentFile?.source)
val resolvedType = typeResolver.resolveType(
val resolvedTypeWithDiagnostic = typeResolver.resolveType(
functionTypeRef,
data,
areBareTypesAllowed,
isOperandOfIsOperator,
currentFile,
supertypeSupplier
).takeIfAcceptable()
return if (resolvedType != null && resolvedType !is ConeClassErrorType) {
)
val resolvedType = resolvedTypeWithDiagnostic.first.takeIfAcceptable()
val diagnostic = resolvedTypeWithDiagnostic.second
return if (resolvedType != null && resolvedType !is ConeClassErrorType && diagnostic == null) {
buildResolvedTypeRef {
source = functionTypeRef.source
type = resolvedType
@@ -119,39 +120,51 @@ class FirSpecificTypeResolverTransformer(
if (resolvedType != null) {
type = resolvedType
}
diagnostic = (resolvedType as? ConeClassErrorType)?.diagnostic
?: ConeSimpleDiagnostic("Unresolved functional type: ${functionTypeRef.render()}")
this.diagnostic = diagnostic ?: (resolvedType as? ConeClassErrorType)?.diagnostic
?: ConeSimpleDiagnostic("Unresolved functional type: ${functionTypeRef.render()}")
}
}
}
private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType): FirResolvedTypeRef {
return if (resolvedType !is ConeClassErrorType) {
buildResolvedTypeRef {
source = typeRef.source
type = resolvedType
annotations += typeRef.annotations
delegatedTypeRef = typeRef
}
} else {
buildErrorTypeRef {
val typeRefSourceKind = typeRef.source?.kind
val diagnosticSource = resolvedType.diagnostic.safeAs<ConeUnexpectedTypeArgumentsError>()
?.source.safeAs<KtSourceElement>()
private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType, diagnostic: ConeDiagnostic?): FirResolvedTypeRef {
return when {
resolvedType is ConeClassErrorType -> {
buildErrorTypeRef {
val typeRefSourceKind = typeRef.source?.kind
val diagnosticSource = resolvedType.diagnostic.safeAs<ConeUnexpectedTypeArgumentsError>()
?.source.safeAs<KtSourceElement>()
source = if (diagnosticSource != null) {
if (typeRefSourceKind is KtFakeSourceElementKind) {
diagnosticSource.fakeElement(typeRefSourceKind)
source = if (diagnosticSource != null) {
if (typeRefSourceKind is KtFakeSourceElementKind) {
diagnosticSource.fakeElement(typeRefSourceKind)
} else {
diagnosticSource
}
} else {
diagnosticSource
typeRef.source
}
} else {
typeRef.source
}
delegatedTypeRef = typeRef
type = resolvedType
this.diagnostic = resolvedType.diagnostic
}
}
diagnostic != null -> {
buildErrorTypeRef {
source = typeRef.source
this.diagnostic = diagnostic
type = resolvedType
diagnostic = resolvedType.diagnostic
delegatedTypeRef = typeRef
}
}
else -> {
buildResolvedTypeRef {
source = typeRef.source
type = resolvedType
annotations += typeRef.annotations
delegatedTypeRef = typeRef
}
}
}
}
@@ -2,11 +2,11 @@ package kotlin.io
import kotlin.internal.*
@<!INVISIBLE_REFERENCE!>RequireKotlin<!>(<!ILLEGAL_KOTLIN_VERSION_STRING_VALUE!>"1.x"<!>)
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>RequireKotlin<!>(<!ILLEGAL_KOTLIN_VERSION_STRING_VALUE!>"1.x"<!>)
class IllegalVersion()
@<!INVISIBLE_REFERENCE!>RequireKotlin<!>("1.2")
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>RequireKotlin<!>("1.2")
class LegalMinimum()
@<!INVISIBLE_REFERENCE!>RequireKotlin<!>("1.2", versionKind = <!INVISIBLE_REFERENCE!>RequireKotlinVersionKind<!>.<!INVISIBLE_REFERENCE!>COMPILER_VERSION<!>, message = "Requires newer compiler version to be inlined correctly.")
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>RequireKotlin<!>("1.2", versionKind = <!INVISIBLE_REFERENCE!>RequireKotlinVersionKind<!>.<!INVISIBLE_REFERENCE!>COMPILER_VERSION<!>, message = "Requires newer compiler version to be inlined correctly.")
class LegalStdLib()
@@ -10,5 +10,5 @@ class Bar: Foo() {
protected fun foo(): Nested? = null
}
private fun foo(): Nested? = null
private fun bar(): p.Foo.Nested? = null
private fun foo(): <!INVISIBLE_REFERENCE!>Nested<!>? = null
private fun bar(): <!INVISIBLE_REFERENCE!>p.Foo.Nested<!>? = null
@@ -15,4 +15,4 @@ package p1
import p2.*
val x: X = X()
val <!EXPOSED_PROPERTY_TYPE!>y<!>: Y = <!INVISIBLE_REFERENCE!>Y<!>()
val <!EXPOSED_PROPERTY_TYPE!>y<!>: <!INVISIBLE_REFERENCE!>Y<!> = <!INVISIBLE_REFERENCE!>Y<!>()
@@ -8,4 +8,4 @@ package a
import pack1.*
private class X : <!INVISIBLE_REFERENCE!>SomeClass<!>()
private class X : <!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>SomeClass<!>()
@@ -11,4 +11,4 @@ package a
import pack1.SomeClass.*
private class X : <!EXPOSED_SUPER_CLASS, FINAL_SUPERTYPE, INVISIBLE_REFERENCE!>N<!>()
private class X : <!EXPOSED_SUPER_CLASS, FINAL_SUPERTYPE, INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>N<!>()
@@ -1,7 +1,7 @@
// !CHECK_TYPE
@kotlin.internal.<!INVISIBLE_REFERENCE!>InlineOnly<!>
@<!INVISIBLE_REFERENCE!>kotlin.internal.<!INVISIBLE_REFERENCE!>InlineOnly<!><!>
public inline fun <C, R> C.ifEmpty(f: () -> R): R where C : Collection<*>, C : R = if (isEmpty()) f() else this
public fun <T> listOf(t: T): List<T> = TODO()
@@ -25,8 +25,8 @@ package b
fun f() {
val c1: a.M.Inner
val c2: a.M.Nested
val c3: a.M.PrInner
val c4: a.M.PrNested
val c3: <!INVISIBLE_REFERENCE!>a.M.PrInner<!>
val c4: <!INVISIBLE_REFERENCE!>a.M.PrNested<!>
}
@@ -15,5 +15,5 @@ class Bar : Foo() {
protected fun foo(): Nested? = null
}
private fun foo(): Nested? = null
private fun bar(): p.Foo.Nested? = null
private fun foo(): <!INVISIBLE_REFERENCE!>Nested<!>? = null
private fun bar(): <!INVISIBLE_REFERENCE!>p.Foo.Nested<!>? = null
@@ -11,9 +11,9 @@ package a
import p.Foo
import p.Foo.Nested
class Bar : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE!>Foo<!>() {
protected fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(): Nested? = null
class Bar : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>Foo<!>() {
protected fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(): <!INVISIBLE_REFERENCE!>Nested<!>? = null
}
private fun foo(): Nested? = null
private fun bar(): p.Foo.Nested? = null
private fun foo(): <!INVISIBLE_REFERENCE!>Nested<!>? = null
private fun bar(): <!INVISIBLE_REFERENCE!>p.Foo.Nested<!>? = null
@@ -17,11 +17,11 @@ class C1
// FILE: 2.kt
package pp
@<!INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
fun f2() {}
@<!INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
val p2 = ""
@<!INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
class C2
@@ -32,7 +32,7 @@ fun test() {
y.<!INVISIBLE_REFERENCE!>bar<!>()
<!INVISIBLE_REFERENCE!>foo<!>()
val u : A = <!INVISIBLE_REFERENCE!>A<!>()
val u : <!INVISIBLE_REFERENCE!>A<!> = <!INVISIBLE_REFERENCE!>A<!>()
val z = <!INVISIBLE_REFERENCE!>x<!>
<!INVISIBLE_REFERENCE!>x<!> = 30
@@ -43,7 +43,7 @@ fun test() {
<!INVISIBLE_SETTER("xx; private; file")!>xx<!> = 40
}
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE!>A<!>() {}
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>A<!>() {}
class Q {
class W {
@@ -29,13 +29,13 @@ fun test() {
y.<!INVISIBLE_REFERENCE!>bar<!>()
<!INVISIBLE_REFERENCE!>foo<!>()
val u : A = <!INVISIBLE_REFERENCE!>A<!>()
val a : java.util.Arrays.ArrayList<Int>;
val u : <!INVISIBLE_REFERENCE!>A<!> = <!INVISIBLE_REFERENCE!>A<!>()
val a : <!INVISIBLE_REFERENCE!>java.util.Arrays.ArrayList<Int><!>;
val po = <!INVISIBLE_REFERENCE!>PO<!>
}
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE!>A<!>() {}
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>A<!>() {}
class Q {
class W {
@@ -28,7 +28,7 @@ fun test() {
y.<!INVISIBLE_REFERENCE!>bar<!>()
<!INVISIBLE_REFERENCE!>foo<!>()
val u : A = <!INVISIBLE_REFERENCE!>A<!>()
val u : <!INVISIBLE_REFERENCE!>A<!> = <!INVISIBLE_REFERENCE!>A<!>()
val z = <!INVISIBLE_REFERENCE!>x<!>
<!INVISIBLE_REFERENCE!>x<!> = 30
@@ -36,7 +36,7 @@ fun test() {
val po = <!INVISIBLE_REFERENCE!>PO<!>
}
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE!>A<!>() {}
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>A<!>() {}
class Q {
class W {
@@ -30,5 +30,5 @@ fun baz() {
a.A3("") checkType { _<String>() }
val x: a.A2 = B("") // A2 is unresolved because it's private in file, OK
val x: <!INVISIBLE_REFERENCE!>a.A2<!> = B("") // A2 is unresolved because it's private in file, OK
}
@@ -4,12 +4,12 @@ private class C {
companion object
}
private typealias TA = C
private typealias TA = <!INVISIBLE_REFERENCE!>C<!>
private val test1: C = <!INVISIBLE_REFERENCE!>C<!>()
private val test1co: C.Companion = <!INITIALIZER_TYPE_MISMATCH, INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>C<!>
private val test1: <!INVISIBLE_REFERENCE!>C<!> = <!INVISIBLE_REFERENCE!>C<!>()
private val test1co: <!INVISIBLE_REFERENCE!>C.Companion<!> = <!INITIALIZER_TYPE_MISMATCH, INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>C<!>
private val test2: TA = <!INITIALIZER_TYPE_MISMATCH!>TA(<!NO_VALUE_FOR_PARAMETER!>)<!><!>
private val test2: <!INVISIBLE_REFERENCE!>TA<!> = <!INITIALIZER_TYPE_MISMATCH!>TA(<!NO_VALUE_FOR_PARAMETER!>)<!><!>
private val test2co = <!INVISIBLE_REFERENCE!>TA<!>
// FILE: file2.kt
@@ -0,0 +1,13 @@
// FILE: 1.kt
private class Private {
class Public
}
// FILE: 2.kt
import Private.Public
private fun test_1(x: <!INVISIBLE_REFERENCE!>Private.Public<!>, y: <!INVISIBLE_REFERENCE!>Public<!>) {
}
@@ -0,0 +1,13 @@
// FILE: 1.kt
private class Private {
class Public
}
// FILE: 2.kt
import <!INVISIBLE_REFERENCE!>Private<!>.Public
private fun test_1(x: <!INVISIBLE_REFERENCE!>Private<!>.<!INVISIBLE_REFERENCE!>Public<!>, y: <!INVISIBLE_REFERENCE!>Public<!>) {
}
@@ -0,0 +1,17 @@
package
private fun test_1(/*0*/ x: Private.Public, /*1*/ y: Private.Public): kotlin.Unit
private final class Private {
public constructor Private()
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 final class Public {
public constructor Public()
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
}
}
@@ -11,5 +11,5 @@ import p.*
interface I {
val v1: FilteringSequence
val <!EXPOSED_PROPERTY_TYPE!>v2<!>: IndexingSequence<String>
val <!EXPOSED_PROPERTY_TYPE!>v2<!>: <!INVISIBLE_REFERENCE!>IndexingSequence<String><!>
}
@@ -32371,6 +32371,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/visibility/privateCompanionInSuperClass.kt");
}
@Test
@TestMetadata("privateDeclarationInAnotherFile.kt")
public void testPrivateDeclarationInAnotherFile() throws Exception {
runTest("compiler/testData/diagnostics/tests/visibility/privateDeclarationInAnotherFile.kt");
}
@Test
@TestMetadata("protectedInternal.kt")
public void testProtectedInternal() throws Exception {