Fix FQ name usage of experimental marker in UseExperimental
#KT-26366 Fixed
This commit is contained in:
+6
-2
@@ -306,8 +306,11 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
return false
|
||||
}
|
||||
|
||||
private fun PsiElement.isUsageAsUseExperimentalArgument(bindingContext: BindingContext): Boolean =
|
||||
parent is KtClassLiteralExpression &&
|
||||
private fun PsiElement.isUsageAsUseExperimentalArgument(bindingContext: BindingContext): Boolean {
|
||||
val qualifier = (this as? KtSimpleNameExpression)?.getTopmostParentQualifiedExpressionForSelector() ?: this
|
||||
val parent = qualifier.parent
|
||||
|
||||
return parent is KtClassLiteralExpression &&
|
||||
parent.parent is KtValueArgument &&
|
||||
parent.parent.parent is KtValueArgumentList &&
|
||||
parent.parent.parent.parent.let { entry ->
|
||||
@@ -315,6 +318,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
annotation.fqName == USE_EXPERIMENTAL_FQ_NAME || annotation.fqName == WAS_EXPERIMENTAL_FQ_NAME
|
||||
} == true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Overrides(project: Project) : DeclarationChecker {
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
|
||||
package test.abc
|
||||
|
||||
@Experimental
|
||||
annotation class E
|
||||
|
||||
@UseExperimental(test.abc.E::class)
|
||||
fun f() {}
|
||||
|
||||
@test.abc.E
|
||||
fun g() {}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
package test {
|
||||
|
||||
package test.abc {
|
||||
@kotlin.UseExperimental(markerClass = {test.abc.E::class}) public fun f(): kotlin.Unit
|
||||
@test.abc.E public fun g(): kotlin.Unit
|
||||
|
||||
@kotlin.Experimental public final annotation class E : kotlin.Annotation {
|
||||
public constructor E()
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -2422,6 +2422,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalUnsignedLiterals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fullFqNameUsage.kt")
|
||||
public void testFullFqNameUsage() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/fullFqNameUsage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("importStatement.kt")
|
||||
public void testImportStatement() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/importStatement.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -2422,6 +2422,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalUnsignedLiterals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fullFqNameUsage.kt")
|
||||
public void testFullFqNameUsage() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/fullFqNameUsage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("importStatement.kt")
|
||||
public void testImportStatement() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/importStatement.kt");
|
||||
|
||||
Reference in New Issue
Block a user