[FIR] Resolve annotations as calls

This commit is contained in:
Dmitriy Novozhilov
2020-07-23 17:47:38 +03:00
committed by Mikhail Glukhikh
parent bc1fa8ed7f
commit 721b9b4d8c
99 changed files with 529 additions and 232 deletions
@@ -0,0 +1,9 @@
annotation class Ann(val x: Int, val y: String, val z: String = "z")
@Ann(y = "y", x = 10)
class A
annotation class AnnVarargs(val x: Int, vararg val y: String, val z: Int)
<!INAPPLICABLE_CANDIDATE!>@AnnVarargs(1, "a", "b", "c", 2)<!>
class B
@@ -0,0 +1,43 @@
FILE: argumentsOfAnnotations.kt
public final annotation class Ann : R|kotlin/Annotation| {
public constructor(x: R|kotlin/Int|, y: R|kotlin/String|, z: R|kotlin/String| = String(z)): R|Ann| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public final val y: R|kotlin/String| = R|<local>/y|
public get(): R|kotlin/String|
public final val z: R|kotlin/String| = R|<local>/z|
public get(): R|kotlin/String|
}
@R|Ann|(y = String(y), x = Int(10)) public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public final annotation class AnnVarargs : R|kotlin/Annotation| {
public constructor(x: R|kotlin/Int|, vararg y: R|kotlin/Array<out kotlin/String>|, z: R|kotlin/Int|): R|AnnVarargs| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public final val y: R|kotlin/Array<out kotlin/String>| = R|<local>/y|
public get(): R|kotlin/Array<out kotlin/String>|
public final val z: R|kotlin/Int| = R|<local>/z|
public get(): R|kotlin/Int|
}
@R|AnnVarargs|(Int(1), String(a), String(b), String(c), Int(2)) public final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
}
@@ -0,0 +1,15 @@
// FILE: Ann.java
public @interface Ann {
String s();
int x();
int y() default 1;
}
// FILE: main.kt
@Ann(x = 10, s = "")
<!INAPPLICABLE_CANDIDATE!>@Ann(10, "")<!>
@Ann(x = 10, s = "", y = 10)
class A
@@ -0,0 +1,7 @@
FILE: main.kt
@R|Ann|(x = Int(10), s = String()) @R|Ann|(Int(10), String()) @R|Ann|(x = Int(10), s = String(), y = Int(10)) public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
@@ -43,6 +43,6 @@ annotation class Ann(val x: Byte)
@Ann(10)
fun test_6() {
@Ann(300)
<!INAPPLICABLE_CANDIDATE!>@Ann(300)<!>
val x = ""
}
@@ -61,6 +61,6 @@ FILE: integerLiteralTypes.kt
public get(): R|kotlin/Byte|
}
@R|Ann|(Int(10)) public final fun test_6(): R|kotlin/Unit| {
@R|Ann|(Byte(10)) public final fun test_6(): R|kotlin/Unit| {
@R|Ann|(Int(300)) lval x: R|kotlin/String| = String()
}
@@ -0,0 +1,16 @@
// FILE: Ann.java
public @interface Ann {
String[] value();
}
// FILE: main.kt
@Ann("a", "b")
fun test_1() {}
<!INAPPLICABLE_CANDIDATE!>@Ann(arrayOf("a", "b"))<!>
fun test_2() {}
@Ann(*arrayOf("a", "b"))
fun test_3() {}
@@ -0,0 +1,7 @@
FILE: main.kt
@R|Ann|(vararg(String(a), String(b))) public final fun test_1(): R|kotlin/Unit| {
}
@R|Ann|(R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(a), String(b)))) public final fun test_2(): R|kotlin/Unit| {
}
@R|Ann|(vararg(*R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(a), String(b))))) public final fun test_3(): R|kotlin/Unit| {
}
@@ -1,5 +1,5 @@
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.LowPriorityInOverloadResolution
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
fun foo(): Int = 1
fun foo(): String = ""
@@ -7,4 +7,4 @@ fun foo(): String = ""
fun test() {
val s = foo()
s.length
}
}
@@ -445,6 +445,16 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt");
}
@TestMetadata("argumentsOfAnnotations.kt")
public void testArgumentsOfAnnotations() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt");
}
@TestMetadata("argumentsOfJavaAnnotation.kt")
public void testArgumentsOfJavaAnnotation() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt");
}
@TestMetadata("default.kt")
public void testDefault() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/default.kt");
@@ -485,6 +495,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/invoke.kt");
}
@TestMetadata("javaAnnotationsWithArrayValue.kt")
public void testJavaAnnotationsWithArrayValue() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt");
}
@TestMetadata("javaArrayVariance.kt")
public void testJavaArrayVariance() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.kt");
@@ -445,6 +445,16 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt");
}
@TestMetadata("argumentsOfAnnotations.kt")
public void testArgumentsOfAnnotations() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt");
}
@TestMetadata("argumentsOfJavaAnnotation.kt")
public void testArgumentsOfJavaAnnotation() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfJavaAnnotation.kt");
}
@TestMetadata("default.kt")
public void testDefault() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/default.kt");
@@ -485,6 +495,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/invoke.kt");
}
@TestMetadata("javaAnnotationsWithArrayValue.kt")
public void testJavaAnnotationsWithArrayValue() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaAnnotationsWithArrayValue.kt");
}
@TestMetadata("javaArrayVariance.kt")
public void testJavaArrayVariance() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.kt");
@@ -19,12 +19,12 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.references.FirSuperReference
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.calls.isFunctional
import org.jetbrains.kotlin.fir.resolve.getCorrespondingConstructorReferenceOrNull
import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType
import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType
import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.types.*
@@ -420,16 +420,14 @@ class CallAndReferenceGenerator(
fun convertToIrConstructorCall(annotationCall: FirAnnotationCall): IrExpression {
val coneType = annotationCall.annotationTypeRef.coneTypeSafe<ConeLookupTagBasedType>()
val firSymbol = coneType?.lookupTag?.toSymbol(session) as? FirClassSymbol
val type = coneType?.toIrType()
val symbol = type?.classifierOrNull
return annotationCall.convertWithOffsets { startOffset, endOffset ->
when (symbol) {
is IrClassSymbol -> {
val irClass = symbol.owner
val fir = firSymbol?.fir as? FirClass<*>
val irConstructor = fir?.getPrimaryConstructorIfAny()?.let { firConstructor ->
this.declarationStorage.getIrConstructorSymbol(firConstructor.symbol)
val irConstructor = (annotationCall.toResolvedCallableSymbol() as? FirConstructorSymbol)?.let {
this.declarationStorage.getIrConstructorSymbol(it)
}
if (irConstructor == null) {
IrErrorCallExpressionImpl(startOffset, endOffset, type, "No annotation constructor found: ${irClass.name}")
@@ -492,13 +490,13 @@ class CallAndReferenceGenerator(
val calleeReference = when (call) {
is FirFunctionCall -> call.calleeReference
is FirDelegatedConstructorCall -> call.calleeReference
is FirAnnotationCall -> call.getCorrespondingConstructorReferenceOrNull(session)
is FirAnnotationCall -> call.calleeReference
else -> null
} as? FirResolvedNamedReference
val function = (calleeReference?.resolvedSymbol as? FirFunctionSymbol<*>)?.fir
val valueParameters = function?.valueParameters
val argumentMapping = call.argumentMapping
if (argumentMapping != null && argumentMapping.isNotEmpty()) {
if (argumentMapping != null && (annotationMode || argumentMapping.isNotEmpty())) {
if (valueParameters != null) {
return applyArgumentsWithReorderingIfNeeded(call, argumentMapping, valueParameters, annotationMode)
}
@@ -38,8 +38,10 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeParameterModifier
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeProjectionModifier
import org.jetbrains.kotlin.fir.references.builder.buildImplicitThisReference
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
import org.jetbrains.kotlin.fir.references.impl.FirReferenceForUnresolvedAnnotations
import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolvedAnnotations
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.CallableId
@@ -321,11 +323,15 @@ class DeclarationsConverter(
CONSTRUCTOR_CALLEE -> constructorCalleePair = convertConstructorInvocation(unescapedAnnotation)
}
}
val name = (constructorCalleePair.first as? FirUserTypeRef)?.qualifier?.last()?.name ?: Name.special("<no-annotation-name>")
return buildAnnotationCall {
source = unescapedAnnotation.toFirSourceElement()
useSiteTarget = annotationUseSiteTarget ?: defaultAnnotationUseSiteTarget
annotationTypeRef = constructorCalleePair.first
calleeReference = FirReferenceForUnresolvedAnnotations
calleeReference = buildSimpleNamedReference {
source = this@buildAnnotationCall.source
this.name = name
}
extractArgumentsFrom(constructorCalleePair.second, stubMode)
}
}
@@ -1288,7 +1288,11 @@ class RawFirBuilder(
useSiteTarget = annotationEntry.useSiteTarget?.getAnnotationUseSiteTarget()
annotationTypeRef = annotationEntry.typeReference.toFirOrErrorType()
annotationEntry.extractArgumentsTo(this)
calleeReference = FirReferenceForUnresolvedAnnotations
val name = (annotationTypeRef as? FirUserTypeRef)?.qualifier?.last()?.name ?: Name.special("<no-annotation-name>")
calleeReference = buildSimpleNamedReference {
source = this@buildAnnotationCall.source
this.name = name
}
}
}
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
import org.jetbrains.kotlin.fir.declarations.isInner
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
@@ -36,6 +37,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
class FirCallResolver(
private val components: BodyResolveComponents,
@@ -315,6 +317,55 @@ class FirCallResolver(
return callResolver.selectDelegatingConstructorCall(delegatedConstructorCall, name, result, callInfo)
}
fun resolveAnnotationCall(annotationCall: FirAnnotationCall): FirAnnotationCall? {
val reference = annotationCall.calleeReference as? FirSimpleNamedReference ?: return null
annotationCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
val callInfo = CallInfo(
CallKind.Function,
name = reference.name,
explicitReceiver = null,
annotationCall.argumentList,
isPotentialQualifierPart = false,
typeArguments = emptyList(),
session,
file,
containingDeclarations
)
val resolutionResult = createCandidateForAnnotationCall(annotationCall, callInfo)
?: ResolutionResult(callInfo, CandidateApplicability.HIDDEN, emptyList())
val resolvedReference = createResolvedNamedReference(
reference,
reference.name,
callInfo,
resolutionResult.candidates,
resolutionResult.applicability,
explicitReceiver = null
)
return annotationCall.transformCalleeReference(StoreNameReference, resolvedReference)
}
private fun createCandidateForAnnotationCall(annotationCall: FirAnnotationCall, callInfo: CallInfo): ResolutionResult? {
val annotationClassSymbol = annotationCall.getCorrespondingClassSymbolOrNull(session)
?.takeIf { it.fir.classKind == ClassKind.ANNOTATION_CLASS }
?: return null
var constructorSymbol: FirConstructorSymbol? = null
annotationClassSymbol.fir.buildUseSiteMemberScope(session, scopeSession)?.processDeclaredConstructors {
if (it.fir.isPrimary && constructorSymbol == null) {
constructorSymbol = it
}
}
if (constructorSymbol == null) return null
val candidate = CandidateFactory(components, callInfo).createCandidate(
constructorSymbol!!,
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
)
val applicability = resolutionStageRunner.processCandidate(candidate)
return ResolutionResult(callInfo, applicability, listOf(candidate))
}
@OptIn(PrivateForInline::class)
inline fun <T> withNoArgumentsTransform(block: () -> T): T {
val oldValue = needTransformArguments
@@ -469,20 +469,13 @@ private fun FirQualifiedAccess.expressionTypeOrUnitForAssignment(): ConeKotlinTy
return StandardClassIds.Unit.constructClassLikeType(emptyArray(), isNullable = false)
}
fun FirAnnotationCall.getCorrespondingConstructorReferenceOrNull(session: FirSession): FirResolvedNamedReference? =
annotationTypeRef.coneType.classId?.let {
fun FirAnnotationCall.getCorrespondingClassSymbolOrNull(session: FirSession): FirRegularClassSymbol? {
return annotationTypeRef.coneType.fullyExpandedType(session).classId?.let {
if (it.isLocal) {
// TODO: How to retrieve local annotaiton's constructor?
null
} else {
(session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol)?.fir
?.getPrimaryConstructorIfAny()
?.let { annotationConstructor ->
buildResolvedNamedReference {
source = this@getCorrespondingConstructorReferenceOrNull.source
name = it.shortClassName
resolvedSymbol = annotationConstructor.symbol
}
}
(session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol)
}
}
}
@@ -299,6 +299,11 @@ fun FirStatement.processAllContainingCallCandidates(processBlocks: Boolean, proc
lhs.processAllContainingCallCandidates(processBlocks, processor)
rhs.processAllContainingCallCandidates(processBlocks, processor)
}
is FirAnnotationCall -> {
processCandidateIfApplicable(processor, processBlocks)
arguments.forEach { it.processAllContainingCallCandidates(processBlocks, processor) }
}
}
}
@@ -170,6 +170,28 @@ class FirCallCompletionResultsWriterTransformer(
return result.compose()
}
override fun transformAnnotationCall(
annotationCall: FirAnnotationCall,
data: ExpectedArgumentType?
): CompositeTransformResult<FirStatement> {
val calleeReference = annotationCall.calleeReference as? FirNamedReferenceWithCandidate
?: return annotationCall.compose()
annotationCall.transformCalleeReference(
StoreCalleeReference,
calleeReference.toResolvedReference(),
)
val subCandidate = calleeReference.candidate
val expectedArgumentsTypeMapping = runIf(!calleeReference.isError) { subCandidate.createArgumentsMapping() }
annotationCall.argumentList.transformArguments(this, expectedArgumentsTypeMapping)
if (!calleeReference.isError) {
subCandidate.handleVarargs(annotationCall.argumentList)
subCandidate.argumentMapping?.let {
annotationCall.replaceArgumentList(buildResolvedArgumentList(it))
}
}
return annotationCall.compose()
}
private fun Candidate.handleVarargs(argumentList: FirArgumentList) {
val argumentMapping = this.argumentMapping
val varargParameter = argumentMapping?.values?.firstOrNull { it.isVararg }
@@ -726,35 +726,22 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: ResolutionMode): CompositeTransformResult<FirStatement> {
if (annotationCall.resolveStatus == FirAnnotationResolveStatus.Resolved) return annotationCall.compose()
return resolveAnnotationCall(annotationCall, data, FirAnnotationResolveStatus.Resolved)
return resolveAnnotationCall(annotationCall, FirAnnotationResolveStatus.Resolved)
}
protected fun resolveAnnotationCall(
annotationCall: FirAnnotationCall,
data: ResolutionMode,
status: FirAnnotationResolveStatus
): CompositeTransformResult<FirAnnotationCall> {
dataFlowAnalyzer.enterAnnotationCall(annotationCall)
return withFirArrayOfCallTransformer {
(annotationCall.transformChildren(transformer, data) as FirAnnotationCall).also {
// TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls
it.argumentList.transformArguments(integerLiteralTypeApproximator, null)
annotationCall.getCorrespondingConstructorReferenceOrNull(session)?.let { calleeReference ->
val callee = calleeReference.resolvedSymbol.fir as FirFunction<*>
val argumentMapping = mapArguments(it.arguments, callee).toArgumentToParameterMapping()
val varargParameter = callee.valueParameters.firstOrNull { param -> param.isVararg }
if (varargParameter == null) {
it.replaceArgumentList(buildResolvedArgumentList(argumentMapping))
} else {
val varargParameterTypeRef = varargParameter.returnTypeRef
val arrayType = varargParameterTypeRef.coneType
val newArgumentMapping = remapArgumentsWithVararg(varargParameter, arrayType, it.argumentList, argumentMapping)
it.replaceArgumentList(buildResolvedArgumentList(newArgumentMapping))
}
}
it.replaceResolveStatus(status)
dataFlowAnalyzer.exitAnnotationCall(it)
}.compose()
annotationCall.transformAnnotationTypeRef(transformer, ResolutionMode.ContextIndependent)
if (status == FirAnnotationResolveStatus.PartiallyResolved) return annotationCall.compose()
val result = callResolver.resolveAnnotationCall(annotationCall) ?: return annotationCall.compose()
callCompleter.completeCall(result, noExpectedType)
result.replaceResolveStatus(status)
dataFlowAnalyzer.exitAnnotationCall(result)
annotationCall.compose()
}
}
@@ -100,7 +100,7 @@ private class FirExpressionsResolveTransformerForSpecificAnnotations(
override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: ResolutionMode): CompositeTransformResult<FirStatement> {
if (annotationArgumentsMode) {
return resolveAnnotationCall(annotationCall, data, FirAnnotationResolveStatus.PartiallyResolved)
return resolveAnnotationCall(annotationCall, FirAnnotationResolveStatus.PartiallyResolved)
}
annotationCall.transformAnnotationTypeRef(transformer, data)
@@ -110,7 +110,7 @@ private class FirExpressionsResolveTransformerForSpecificAnnotations(
return annotationCall.compose()
}
annotationArgumentsMode = true
return resolveAnnotationCall(annotationCall, data, FirAnnotationResolveStatus.PartiallyResolved).also {
return resolveAnnotationCall(annotationCall, FirAnnotationResolveStatus.PartiallyResolved).also {
annotationArgumentsMode = false
}
}
@@ -193,4 +193,4 @@ private class FirExpressionsResolveTransformerForSpecificAnnotations(
): CompositeTransformResult<FirStatement> {
return augmentedArraySetCall.compose()
}
}
}
@@ -44,7 +44,7 @@ inline val FirCall.argumentMapping: Map<FirExpression, FirValueParameter>?
get() = (argumentList as? FirResolvedArgumentList)?.mapping
fun FirExpression.toResolvedCallableReference(): FirResolvedNamedReference? {
return (this as? FirQualifiedAccess)?.calleeReference as? FirResolvedNamedReference
return (this as? FirResolvable)?.calleeReference as? FirResolvedNamedReference
}
fun FirExpression.toResolvedCallableSymbol(): FirCallableSymbol<*>? {
@@ -93,4 +93,4 @@ fun FirBlock.replaceFirstStatement(statement: FirStatement): FirStatement {
val existed = statements[0]
statements[0] = statement
return existed
}
}
@@ -1,5 +1,4 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FULL_JDK
// SKIP_JDK6
@@ -1,6 +1,6 @@
// !WITH_NEW_INFERENCE
import java.util.ArrayList
@ArrayList<Int>(1, 1) fun b() {}
@<!UNRESOLVED_REFERENCE!>Xoo<!>(<!UNRESOLVED_REFERENCE!>x<!>) fun c() {}
@java.lang.Deprecated(x) fun a() {}
<!UNRESOLVED_REFERENCE!>@ArrayList<Int>(1, 1)<!> fun b() {}
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>Xoo<!>(<!UNRESOLVED_REFERENCE!>x<!>)<!> fun c() {}
<!INAPPLICABLE_CANDIDATE!>@java.lang.Deprecated(<!UNRESOLVED_REFERENCE!>x<!>)<!> fun a() {}
@@ -1,10 +1,10 @@
annotation class A1
annotation class A2(val some: Int = 12)
class TopLevelClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> {
class InnerClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> {
class TopLevelClass<@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T> {
class InnerClass<@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T> {
fun test() {
class InFun<@A1 @A2(3) @A2 @A1(12) @A2("Test") T>
class InFun<@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T>
}
}
}
}
@@ -1,12 +1,12 @@
annotation class A1
annotation class A2(val some: Int = 12)
fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> topFun() = 12
fun <@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T> topFun() = 12
class SomeClass {
fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> method() = 12
fun <@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T> method() = 12
fun foo() {
fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> innerFun() = 12
fun <@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T> innerFun() = 12
}
}
}
@@ -6,7 +6,7 @@ annotation class annotation
package test
@test.annotation class annotation
<!UNRESOLVED_REFERENCE!>@test.annotation<!> class annotation
// FILE: other/c.kt
@@ -14,6 +14,6 @@ package other
annotation class My
@test.annotation class Your
<!UNRESOLVED_REFERENCE!>@test.annotation<!> class Your
@My class Our
@My class Our
@@ -3,12 +3,12 @@
annotation class A1
annotation class A2(val some: Int = 12)
val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.topProp: Int get() = 12
val <@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T> T.topProp: Int get() = 12
class SomeClass {
val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.field: Int get() = 12
val <@A1 @A2(3) @A2 <!INAPPLICABLE_CANDIDATE!>@A1(12)<!> <!INAPPLICABLE_CANDIDATE!>@A2("Test")<!> T> T.field: Int get() = 12
fun foo() {
val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> localVal = 12
}
}
}
@@ -3,7 +3,7 @@ annotation class my1(val i : Int)
annotation class my2(val i : Int = 0)
@my fun foo() {}
@my1 fun foo2() {}
<!INAPPLICABLE_CANDIDATE!>@my1<!> fun foo2() {}
@my1(2) fun foo3() {}
@my2() fun foo4() {}
@my2 fun foo41() {}
@@ -1,3 +1,3 @@
class Foo
@Foo class Bar
<!UNRESOLVED_REFERENCE!>@Foo<!> class Bar
@@ -1,2 +1,2 @@
// Class constructor parameter CAN be recursively annotated
class RecursivelyAnnotated(@RecursivelyAnnotated(1) val x: Int)
class RecursivelyAnnotated(<!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>@RecursivelyAnnotated(1)<!> val x: Int)
@@ -1,8 +1,8 @@
package test
@BadAnnotation(1)
<!INAPPLICABLE_CANDIDATE!>@BadAnnotation(1)<!>
object SomeObject
val some = SomeObject
annotation class BadAnnotation(val s: String)
annotation class BadAnnotation(val s: String)
@@ -11,5 +11,5 @@ enum class MyEnum {
A
}
@AnnE(Test())
class Test2
<!INAPPLICABLE_CANDIDATE!>@AnnE(Test())<!>
class Test2
@@ -11,5 +11,5 @@ enum class MyEnum {
A
}
@AnnE(Test())
class Test2
<!INAPPLICABLE_CANDIDATE!>@AnnE(Test())<!>
class Test2
@@ -13,7 +13,7 @@ fun foo() {
return@l1 103
}
bar @Ann("") {
bar <!INAPPLICABLE_CANDIDATE!>@Ann("")<!> {
104
}
}
@@ -8,7 +8,7 @@ annotation class Ann(val x: Int = 6)
@Ann(1) @Ann(2) @Ann(3) private class A @Ann constructor() {
@Ann(x = 5) fun foo() {
1 + @Ann(1) 1 * @Ann("") 6
1 + @Ann(1) 1 * <!INAPPLICABLE_CANDIDATE!>@Ann("")<!> 6
@Ann fun local() {}
}
@@ -2,9 +2,9 @@
import java.lang.annotation.Repeatable
@java.lang.annotation.Repeatable(Annotations::class) annotation class RepAnn
<!INAPPLICABLE_CANDIDATE!>@java.lang.annotation.Repeatable(Annotations::class)<!> annotation class RepAnn
@Repeatable(OtherAnnotations::class) annotation class OtherAnn
<!INAPPLICABLE_CANDIDATE!>@Repeatable(OtherAnnotations::class)<!> annotation class OtherAnn
annotation class Annotations(vararg val value: RepAnn)
@@ -3,36 +3,36 @@ package test
import kotlin.internal.RequireKotlin
@RequireKotlin("")
<!HIDDEN!>@RequireKotlin("")<!>
fun f01() {}
@RequireKotlin("x")
<!HIDDEN!>@RequireKotlin("x")<!>
fun f02() {}
@RequireKotlin("1")
<!HIDDEN!>@RequireKotlin("1")<!>
fun f03() {}
@RequireKotlin("1.0-beta")
<!HIDDEN!>@RequireKotlin("1.0-beta")<!>
fun f04() {}
@RequireKotlin("1.1.0-dev-1111")
<!HIDDEN!>@RequireKotlin("1.1.0-dev-1111")<!>
fun f05() {}
@RequireKotlin("1.5.3.7")
<!HIDDEN!>@RequireKotlin("1.5.3.7")<!>
fun f06() {}
@RequireKotlin("1..0")
<!HIDDEN!>@RequireKotlin("1..0")<!>
fun f07() {}
@RequireKotlin(" 1.0")
<!HIDDEN!>@RequireKotlin(" 1.0")<!>
fun f08() {}
@RequireKotlin("1.1")
<!HIDDEN!>@RequireKotlin("1.1")<!>
fun ok1() {}
@RequireKotlin("1.1.0")
<!HIDDEN!>@RequireKotlin("1.1.0")<!>
fun ok2() {}
@RequireKotlin("0.0.0")
<!HIDDEN!>@RequireKotlin("0.0.0")<!>
fun ok3() {}
@@ -1,10 +1,10 @@
// !WITH_NEW_INFERENCE
fun foo(@<!UNRESOLVED_REFERENCE!>varargs<!> f : Int) {}
fun foo(<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>varargs<!> f : Int) {}
var bar : Int = 1
set(@<!UNRESOLVED_REFERENCE!>varargs<!> v) {}
set(<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>varargs<!> v) {}
val x : (Int) -> Int = {@<!UNRESOLVED_REFERENCE!>varargs<!> x <!SYNTAX!>: Int -> x<!>}
val x : (Int) -> Int = {<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>varargs<!> x <!SYNTAX!>: Int -> x<!>}
class Hello(@<!UNRESOLVED_REFERENCE!>varargs<!> args: Any) {
}
class Hello(<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>varargs<!> args: Any) {
}
@@ -1,9 +1,9 @@
class Foo<T> {
@T
<!UNRESOLVED_REFERENCE!>@T<!>
fun foo() = 0
}
class Bar<T : Annotation> {
@T
<!UNRESOLVED_REFERENCE!>@T<!>
fun foo() = 0
}
}
@@ -1,5 +1,5 @@
@<!UNRESOLVED_REFERENCE!>Ann<!> class A
@<!UNRESOLVED_REFERENCE!>Ann<!> class B
@<!UNRESOLVED_REFERENCE!>Ann<!>(1) class C
@<!UNRESOLVED_REFERENCE!>kotlin.Ann<!>(1) class D
@<!UNRESOLVED_REFERENCE!>kotlin.annotation.Ann<!>(1) class E
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>Ann<!> class A
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>Ann<!> class B
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>Ann<!>(1)<!> class C
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>kotlin.Ann<!>(1)<!> class D
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>kotlin.annotation.Ann<!>(1)<!> class E
@@ -34,8 +34,8 @@ fun test6() {}
annotation class AnnArray(val a: Array<String>)
@AnnArray(*["/"])
<!INAPPLICABLE_CANDIDATE!>@AnnArray(*["/"])<!>
fun testArray() {}
@Ann1([""])
fun testVararg() {}
fun testVararg() {}
@@ -11,6 +11,6 @@ public class A {
// FILE: B.kt
class B(private @property:Deprecated val foo: String) : A() {
class B(private <!INAPPLICABLE_CANDIDATE, INAPPLICABLE_CANDIDATE!>@property:Deprecated<!> val foo: String) : A() {
override fun getFoo(text: String): String = super.getFoo(text + foo)
}
@@ -1,7 +1,7 @@
// !CHECK_TYPE
@kotlin.internal.InlineOnly
<!HIDDEN!>@kotlin.internal.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()
@@ -13,4 +13,4 @@ fun usage(c: List<String>) {
val cs = c.ifEmpty { listOf("x") }
cs checkType { _<List<String>>() }
}
}
@@ -3,7 +3,7 @@
fun f() {
<!LOCAL_ANNOTATION_CLASS_ERROR!>annotation class Anno<!>
@Anno class Local {
<!UNRESOLVED_REFERENCE!>@Anno<!> class Local {
<!LOCAL_ANNOTATION_CLASS_ERROR!>annotation class Nested<!>
}
}
@@ -3,7 +3,7 @@
fun f() {
<!LOCAL_ANNOTATION_CLASS_ERROR!>annotation class Anno<!>
@Anno class Local {
<!UNRESOLVED_REFERENCE!>@Anno<!> class Local {
<!LOCAL_ANNOTATION_CLASS_ERROR!>annotation class Nested<!>
}
}
@@ -1,4 +1,4 @@
@<!UNRESOLVED_REFERENCE!><!SYNTAX!><!>myAnnotation<!> public
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!><!SYNTAX!><!>myAnnotation<!> public
package illegal_modifiers
abstract class A() {
@@ -8,6 +8,6 @@ open class Base {
class Derived : Base() {
@<!UNRESOLVED_REFERENCE!>Foo<!>
<!UNRESOLVED_REFERENCE!>@<!UNRESOLVED_REFERENCE!>Foo<!>
fun foo() = 42
}
}
@@ -17,11 +17,11 @@ class C1
// FILE: 2.kt
package pp
@A(<!HIDDEN!>foo<!>)
<!HIDDEN!>@A(<!HIDDEN!>foo<!>)<!>
fun f2() {}
@A(<!HIDDEN!>foo<!>)
<!HIDDEN!>@A(<!HIDDEN!>foo<!>)<!>
val p2 = ""
@A(<!HIDDEN!>foo<!>)
<!HIDDEN!>@A(<!HIDDEN!>foo<!>)<!>
class C2
@@ -5,8 +5,8 @@ annotation class Ann2(val x: Int)
class A {
@Ann1
constructor()
@Ann2
<!INAPPLICABLE_CANDIDATE!>@Ann2<!>
constructor(x1: Int)
@Ann2(2)
constructor(x1: Int, x2: Int)
}
}
@@ -31,6 +31,6 @@ fun test_ann(s: String, arr: Array<String>) {
@Ann("", x = 1)
foo()
@Ann(s = "", x = 1)
<!INAPPLICABLE_CANDIDATE!>@Ann(s = "", x = 1)<!>
foo()
}
}
@@ -31,6 +31,6 @@ fun test_ann(s: String, arr: Array<String>) {
@Ann("", x = 1)
foo()
@Ann(s = "", x = 1)
<!INAPPLICABLE_CANDIDATE!>@Ann(s = "", x = 1)<!>
foo()
}
@@ -15,10 +15,10 @@ annotation class Ann(vararg val s: String)
@Ann(s = arrayOf())
fun test1() {}
@Ann(s = intArrayOf())
<!INAPPLICABLE_CANDIDATE!>@Ann(s = intArrayOf())<!>
fun test2() {}
@Ann(s = arrayOf(1))
<!INAPPLICABLE_CANDIDATE!>@Ann(s = arrayOf(1))<!>
fun test3() {}
@Ann("value1", "value2")
@@ -43,4 +43,4 @@ annotation class IntAnn(vararg val i: Int)
fun foo1() {}
@IntAnn(i = intArrayOf(0))
fun foo2() {}
fun foo2() {}
@@ -11,7 +11,7 @@
annotation class Ann(vararg val s: String)
@Ann(s = "value")
<!INAPPLICABLE_CANDIDATE!>@Ann(s = "value")<!>
fun test1() {}
@Ann(s = *arrayOf("value"))
@@ -20,11 +20,11 @@ fun test2() {}
@Ann(s = *["value"])
fun test3() {}
@JavaAnn(value = "value")
<!INAPPLICABLE_CANDIDATE!>@JavaAnn(value = "value")<!>
fun test4() {}
@JavaAnn("value", path = arrayOf("path"))
fun test5() {}
@JavaAnn("value", path = ["path"])
fun test6() {}
fun test6() {}
@@ -11,7 +11,7 @@
annotation class Ann(vararg val s: String)
@Ann(s = "value")
<!INAPPLICABLE_CANDIDATE!>@Ann(s = "value")<!>
fun test1() {}
@Ann(s = *arrayOf("value"))
@@ -20,11 +20,11 @@ fun test2() {}
@Ann(s = *["value"])
fun test3() {}
@JavaAnn(value = "value")
<!INAPPLICABLE_CANDIDATE!>@JavaAnn(value = "value")<!>
fun test4() {}
@JavaAnn("value", path = arrayOf("path"))
fun test5() {}
@JavaAnn("value", path = ["path"])
fun test6() {}
fun test6() {}
@@ -15,10 +15,10 @@ annotation class Ann(vararg val s: String)
@Ann(s = arrayOf())
fun test1() {}
@Ann(s = intArrayOf())
<!INAPPLICABLE_CANDIDATE!>@Ann(s = intArrayOf())<!>
fun test2() {}
@Ann(s = arrayOf(1))
<!INAPPLICABLE_CANDIDATE!>@Ann(s = arrayOf(1))<!>
fun test3() {}
@Ann(s = ["value"])
@@ -43,7 +43,7 @@ fun foo2() {}
fun foo(vararg i: Int) {}
@Ann(s = "value")
<!INAPPLICABLE_CANDIDATE!>@Ann(s = "value")<!>
fun dep1() {
<!INAPPLICABLE_CANDIDATE!>foo<!>(i = 1)
}
}
@@ -4,7 +4,7 @@
annotation class Anno1(vararg val s: String)
annotation class Anno2(vararg val i: Int)
@Anno1(s = "foo")
<!INAPPLICABLE_CANDIDATE!>@Anno1(s = "foo")<!>
@Anno2(i = *intArrayOf(1))
fun f1() {}
@@ -12,12 +12,12 @@ public @interface A {
@A(*arrayOf("5", "6"), "7", y = 3) fun test3() {}
@A("1", "2", "3", x = String::class, y = 4) fun test4() {}
<!INAPPLICABLE_CANDIDATE!>@A("1", "2", "3", x = String::class, y = 4)<!> fun test4() {}
@A("4", y = 5) fun test5() {}
@A(*arrayOf("5", "6"), "7", x = Any::class, y = 6) fun test6() {}
<!INAPPLICABLE_CANDIDATE!>@A(*arrayOf("5", "6"), "7", x = Any::class, y = 6)<!> fun test6() {}
@A(y = 7) fun test7() {}
@A("8", "9", "10") fun test8() {}
<!INAPPLICABLE_CANDIDATE!>@A("8", "9", "10")<!> fun test8() {}
@@ -15,16 +15,16 @@ public @interface A {
@A(*arrayOf("5", "6"), "7") fun test3() {}
@A("1", "2", "3", x = String::class) fun test4() {}
<!INAPPLICABLE_CANDIDATE!>@A("1", "2", "3", x = String::class)<!> fun test4() {}
@A("4", y = 2) fun test5() {}
@A(*arrayOf("5", "6"), "7", x = Any::class, y = 3) fun test6() {}
<!INAPPLICABLE_CANDIDATE!>@A(*arrayOf("5", "6"), "7", x = Any::class, y = 3)<!> fun test6() {}
@A() fun test7() {}
@A fun test8() {}
@A(x = Any::class, *arrayOf("5", "6"), "7", y = 3) fun test9() {}
@A(x = Any::class, value = ["5", "6"], "7", y = 3) fun test10() {}
@A(x = Any::class, value = ["5", "6", "7"], y = 3) fun test11() {}
<!INAPPLICABLE_CANDIDATE!>@A(x = Any::class, *arrayOf("5", "6"), "7", y = 3)<!> fun test9() {}
<!INAPPLICABLE_CANDIDATE!>@A(x = Any::class, value = ["5", "6"], "7", y = 3)<!> fun test10() {}
<!INAPPLICABLE_CANDIDATE!>@A(x = Any::class, value = ["5", "6", "7"], y = 3)<!> fun test11() {}
@@ -6,6 +6,6 @@ public @interface A {
}
// FILE: b.kt
@A(*arrayOf(1, "b"))
<!INAPPLICABLE_CANDIDATE!>@A(*arrayOf(1, "b"))<!>
fun test() {
}
@@ -2,6 +2,6 @@
annotation class B(vararg val args: String)
@B(*arrayOf(1, "b"))
<!INAPPLICABLE_CANDIDATE!>@B(*arrayOf(1, "b"))<!>
fun test() {
}
@@ -1,27 +1,27 @@
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE
// FILE: b.kt
@file:JvmPackageName("")
<!HIDDEN!>@file:JvmPackageName("")<!>
package b
fun b() {}
// FILE: c.kt
@file:JvmPackageName("invalid-fq-name")
<!HIDDEN!>@file:JvmPackageName("invalid-fq-name")<!>
package c
fun c() {}
// FILE: d.kt
@file:JvmPackageName("d")
<!HIDDEN!>@file:JvmPackageName("d")<!>
package d
class D
fun d() {}
// FILE: e.kt
@file:JvmPackageName(42)
<!HIDDEN!>@file:JvmPackageName(42)<!>
package e
fun e() {}
// FILE: f.kt
@file:JvmPackageName(f)
<!HIDDEN!>@file:JvmPackageName(f)<!>
package f
const val name = "f"
@@ -14,7 +14,7 @@ class MyClass1
@Ann1(arrayOf(Any::class))
class MyClass1a
@Ann1(arrayOf(B1::class))
<!INAPPLICABLE_CANDIDATE!>@Ann1(arrayOf(B1::class))<!>
class MyClass2
annotation class Ann2(val arg: Array<KClass<in B1>>)
@@ -25,5 +25,5 @@ class MyClass3
@Ann2(arrayOf(B1::class))
class MyClass4
@Ann2(arrayOf(B2::class))
<!INAPPLICABLE_CANDIDATE!>@Ann2(arrayOf(B2::class))<!>
class MyClass5
@@ -11,7 +11,7 @@ annotation class Ann1(val arg: Array<KClass<out A>>)
@Ann1(arrayOf(A::class))
class MyClass1
@Ann1(arrayOf(Any::class))
<!INAPPLICABLE_CANDIDATE!>@Ann1(arrayOf(Any::class))<!>
class MyClass1a
@Ann1(arrayOf(B1::class))
@@ -19,11 +19,11 @@ class MyClass2
annotation class Ann2(val arg: Array<KClass<out B1>>)
@Ann2(arrayOf(A::class))
<!INAPPLICABLE_CANDIDATE!>@Ann2(arrayOf(A::class))<!>
class MyClass3
@Ann2(arrayOf(B1::class))
class MyClass4
@Ann2(arrayOf(B2::class))
<!INAPPLICABLE_CANDIDATE!>@Ann2(arrayOf(B2::class))<!>
class MyClass5
@@ -12,7 +12,7 @@ class MyClass1
@Ann1(Any::class)
class MyClass1a
@Ann1(B1::class)
<!INAPPLICABLE_CANDIDATE!>@Ann1(B1::class)<!>
class MyClass2
annotation class Ann2(val arg: KClass<in B1>)
@@ -23,5 +23,5 @@ class MyClass3
@Ann2(B1::class)
class MyClass4
@Ann2(B2::class)
<!INAPPLICABLE_CANDIDATE!>@Ann2(B2::class)<!>
class MyClass5
@@ -9,7 +9,7 @@ annotation class Ann1(val arg: KClass<out A>)
@Ann1(A::class)
class MyClass1
@Ann1(Any::class)
<!INAPPLICABLE_CANDIDATE!>@Ann1(Any::class)<!>
class MyClass1a
@Ann1(B1::class)
@@ -17,11 +17,11 @@ class MyClass2
annotation class Ann2(val arg: KClass<out B1>)
@Ann2(A::class)
<!INAPPLICABLE_CANDIDATE!>@Ann2(A::class)<!>
class MyClass3
@Ann2(B1::class)
class MyClass4
@Ann2(B2::class)
<!INAPPLICABLE_CANDIDATE!>@Ann2(B2::class)<!>
class MyClass5
@@ -8,15 +8,15 @@ annotation class Ann1(val arg: KClass<A>)
@Ann1(A::class)
class MyClass1
@Ann1(Any::class)
<!INAPPLICABLE_CANDIDATE!>@Ann1(Any::class)<!>
class MyClass1a
@Ann1(B::class)
<!INAPPLICABLE_CANDIDATE!>@Ann1(B::class)<!>
class MyClass2
annotation class Ann2(val arg: KClass<B>)
@Ann2(A::class)
<!INAPPLICABLE_CANDIDATE!>@Ann2(A::class)<!>
class MyClass3
@Ann2(B::class)
@@ -6,6 +6,6 @@ public @interface A {
}
// FILE: b.kt
@A(false,
<!INAPPLICABLE_CANDIDATE!>@A(false,
1.0,
false, 1, 2) fun foo1() {}
false, 1, 2)<!> fun foo1() {}
@@ -6,8 +6,8 @@ public @interface A {
}
// FILE: b.kt
@A(false,
<!INAPPLICABLE_CANDIDATE!>@A(false,
1.0,
false) fun foo1() {}
false)<!> fun foo1() {}
@A(2.0, x = true, b = 2.0) fun foo2() {}
<!INAPPLICABLE_CANDIDATE!>@A(2.0, x = true, b = 2.0)<!> fun foo2() {}
@@ -10,19 +10,19 @@ fun newPublishedFun() {}
annotation class Marker
@SinceKotlin("1.4")
@WasExperimental(Marker::class)
<!HIDDEN!>@WasExperimental(Marker::class)<!>
fun newFunExperimentalInThePast() {}
@SinceKotlin("1.4")
@WasExperimental(Marker::class)
<!HIDDEN!>@WasExperimental(Marker::class)<!>
val newValExperimentalInThePast = ""
@SinceKotlin("1.4")
@WasExperimental(Marker::class)
<!HIDDEN!>@WasExperimental(Marker::class)<!>
class NewClassExperimentalInThePast
@SinceKotlin("1.4")
@WasExperimental(Marker::class)
<!HIDDEN!>@WasExperimental(Marker::class)<!>
typealias TypeAliasToNewClass = NewClassExperimentalInThePast
@@ -1,6 +1,6 @@
class Foo {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.LowPriorityInOverloadResolution
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
val test: Bar = Bar()
}
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?>
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K, V, V1 : V?>
Map<out K, @kotlin.internal.Exact V>.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO()
fun test() {
@@ -14,4 +14,4 @@ fun test() {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>r2<!>
map.getOrDefault_Exact("y", "string")
}
}
@@ -5,7 +5,7 @@ interface Parent
object ChildA : Parent
object ChildB : Parent
fun <@kotlin.internal.OnlyInputTypes T> select(a: T, b: T) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> select(a: T, b: T) {}
fun test() {
select(ChildA, ChildB) // should be error
@@ -7,17 +7,17 @@ class CX : Base()
class CY : Base()
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes T> foo(a: T, b: T) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> foo(a: T, b: T) {}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes T : Any> fooA(a: T, b: T) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T : Any> fooA(a: T, b: T) {}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T : Base> fooB(a: T, b: T) {}
fun usage(x: CX, y: CY) {
foo(x, y) // expected err, got err
fooA(x, y) // expected err, got ok
fooB(x, y) // expected err, got ok
}
}
@@ -0,0 +1,12 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
annotation class Anno
fun test(a: List<Class<Anno>>) {
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> S> strictSelect(arg1: S, arg2: S): S = TODO()
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -10,4 +9,4 @@ fun test(a: List<Class<Anno>>) {
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
}
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
@@ -3,7 +3,7 @@
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
public fun <T> Iterable<T>.contains1(element: T): Int = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -13,4 +13,4 @@ public fun <T> Iterable<T>.contains1(element: @kotlin.internal.NoInfer T): Boole
fun test() {
val a: Boolean = listOf(1).contains1("")
val b: Boolean = listOf(1).contains1(1)
}
}
@@ -0,0 +1,18 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: TestBase.java
public class TestBase<T> { }
// FILE: Test.java
public class Test<K> extends TestBase<K> { }
// FILE: main.kt
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> TestBase<out K>.foo(key: K) = null
fun foo(result: Test<*>) {
result.foo("sd") // Type inference failed (NI), OK in OI
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -16,4 +15,4 @@ public class Test<K> extends TestBase<K> { }
fun <@kotlin.internal.OnlyInputTypes K> TestBase<out K>.foo(key: K) = null
fun foo(result: Test<*>) {
result.foo("sd") // Type inference failed (NI), OK in OI
}
}
@@ -0,0 +1,24 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
interface IFace<K, out V>
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K, V> IFace<out K, V>.get(key: K): V? = TODO()
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> I> id(arg: I): I = arg
interface InvBase<B>
class DerivedInv : InvBase<DerivedInv>
class InvRecursive<E : InvBase<E>>
fun test1(argument: InvRecursive<*>, receiver: IFace<InvRecursive<DerivedInv>, Any>) {
receiver.get(argument)
}
fun test2(arg: InvRecursive<out DerivedInv>) {
id(arg)
}
fun test3(arg: InvRecursive<in DerivedInv>) {
id(arg)
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -3,7 +3,7 @@
// !WITH_NEW_INFERENCE
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.contains1(element: T): Boolean = null!!
class In<in T>
@@ -4,19 +4,19 @@
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
public fun <T> Iterable<T>.contains1(element: T): Int = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.contains1(element: T): Boolean = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@JvmName("getAny")
@kotlin.internal.LowPriorityInOverloadResolution
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
public fun <K, V> Map<K, V>.get1(key: Any?): Int = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
public fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get1(key: K): V? = null!!
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K, V> Map<out K, V>.get1(key: K): V? = null!!
fun test(map: Map<Int, String>) {
val a: Int = listOf(1).contains1("")
@@ -24,4 +24,4 @@ fun test(map: Map<Int, String>) {
val c: String? = map.get1("")
val d: String? = map.get1(1)
}
}
@@ -5,13 +5,13 @@
class Inv<T>
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes K> Inv<out K>.onlyOut(e: K) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> Inv<out K>.onlyOut(e: K) {}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes K : Number> Inv<out K>.onlyOutUB(e: K) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K : Number> Inv<out K>.onlyOutUB(e: K) {}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes K> Inv<in K>.onlyIn(e: K) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> Inv<in K>.onlyIn(e: K) {}
fun test(
invStar: Inv<*>,
@@ -71,4 +71,4 @@ class Test5 {
}
field = value
}
}
}
@@ -0,0 +1,19 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER
//FILE:Foo.java
public class Foo {
public static String foo() {
return null;
}
}
//FILE:Bar.kt
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> assertEquals1(t1: T, t2: T) {}
fun test() {
assertEquals1(null, Foo.foo())
assertEquals1("", Foo.foo())
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
//!DIAGNOSTICS: -UNUSED_PARAMETER
//FILE:Foo.java
@@ -17,4 +16,4 @@ fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {}
fun test() {
assertEquals1(null, Foo.foo())
assertEquals1("", Foo.foo())
}
}
@@ -4,10 +4,10 @@
// Issue: KT-26698
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.contains1(element: T): Boolean = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.foo(element: T): T = null!!
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.foo(element: T): T = null!!
class Inv<T>
class Inv2<T, R>
@@ -16,8 +16,8 @@ class InB<in C : Bound>(v: C)
class Out<out O>(val v: O)
class OutB<out O : Bound>(val v: O)
fun <@OnlyInputTypes M> strictId(arg: M): M = arg
fun <@OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = arg1
fun <<!HIDDEN!>@OnlyInputTypes<!> M> strictId(arg: M): M = arg
fun <<!HIDDEN!>@OnlyInputTypes<!> S> strictSelect(arg1: S, arg2: S): S = arg1
fun testOK(first: First, bound: Bound, second: Second) {
strictId(Inv(15))
@@ -10,4 +10,4 @@ fun <T> foo(i: Inv<in T>, o: Out<T>) {
bar(i, o)
}
fun <@kotlin.internal.OnlyInputTypes K> bar(r: Inv<out K>, o: Out<K>): K = TODO()
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> bar(r: Inv<out K>, o: Out<K>): K = TODO()
@@ -2,7 +2,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes S> select(a1: S, a2: S): S = TODO()
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> S> select(a1: S, a2: S): S = TODO()
interface Common
class First : Common
@@ -3,7 +3,7 @@
// !WITH_NEW_INFERENCE
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {}
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> assertEquals1(t1: T, t2: T) {}
open class A
class B: A()
@@ -19,8 +19,8 @@ fun test1(a: A, b: B, c: C) {
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {}
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> expect1(expected: T, block: () -> T) {}
fun test() {
expect1(2) { byteArrayOf(1, 2, 3).indexOf(3) }
}
}
@@ -0,0 +1,31 @@
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER -NULLABLE_INLINE_PARAMETER
<!HIDDEN!>@kotlin.internal.InlineOnly<!>
inline fun test() {
}
<!HIDDEN!>@kotlin.internal.InlineOnly<!>
inline fun test3(noinline s : (Int) -> Int) {
}
<!HIDDEN!>@kotlin.internal.InlineOnly<!>
inline fun test4(noinline s : Int.() -> Int) {
}
<!HIDDEN!>@kotlin.internal.InlineOnly<!>
inline fun Function1<Int, Int>?.test5() {
}
<!HIDDEN!>@kotlin.internal.InlineOnly<!>
inline fun Function1<Int, Int>?.test6() {
}
<!HIDDEN!>@kotlin.internal.InlineOnly<!>
inline fun test2(s : ((Int) -> Int)?) {
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER -NULLABLE_INLINE_PARAMETER
@kotlin.internal.InlineOnly
@@ -29,4 +28,4 @@ inline fun Function1<Int, Int>?.test6() {
@kotlin.internal.InlineOnly
inline fun test2(s : ((Int) -> Int)?) {
}
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
inline fun <reified <!HIDDEN!>@kotlin.internal.PureReifiable<!> T> foo(x: T) {}
fun test() {
foo<List<String>>(listOf(""))
foo(listOf(""))
foo<Array<String>>(arrayOf(""))
foo(arrayOf(""))
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -1,8 +1,8 @@
@JvmName()
<!INAPPLICABLE_CANDIDATE!>@JvmName()<!>
fun foo() {}
@JvmName(42)
<!INAPPLICABLE_CANDIDATE!>@JvmName(42)<!>
fun bar() {}
@JvmName("a", "b")
<!INAPPLICABLE_CANDIDATE!>@JvmName("a", "b")<!>
fun baz() {}
@@ -8,11 +8,11 @@ package b
import a.A
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach(i: Int) = i
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach(s: String) {}
@@ -28,11 +28,11 @@ class A {
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach() = ""
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach(s: String) {}
fun test(a: A) {
@@ -8,12 +8,12 @@ class A {
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach(i: Int) = i
class B {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach() = this@B
fun test(a: A) {
@@ -27,11 +27,11 @@ class B {
fun test2(a: A) {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach() = ""
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.HidesMembers
<!HIDDEN!>@kotlin.internal.HidesMembers<!>
fun A.forEach(i: Int) = ""
a.forEach() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
@@ -41,4 +41,4 @@ fun test2(a: A) {
forEach() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
forEach(1)
}
}
}
@@ -1,7 +0,0 @@
FILE fqName:<root> fileName:/javaAnnotation.kt
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
@@ -1,4 +1,5 @@
// FILE: JavaAnn.java
// FIR_IDENTICAL
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -9,6 +10,7 @@ import java.lang.annotation.RetentionPolicy;
}
// FILE: javaAnnotation.kt
// FIR_IDENTICAL
@JavaAnn fun test1() {}
@JavaAnn(value="abc", i=123) fun test2() {}