[FE] Prohibit explicit @ContextFunctionTypeParams usage
This commit is contained in:
committed by
TeamCityServer
parent
a091b345a0
commit
b3591e77be
+12
@@ -10582,6 +10582,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsage.kt")
|
||||
public void testContextReceiverTypeParamsUsage() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsageError.kt")
|
||||
public void testContextReceiverTypeParamsUsageError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsageError.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType.kt")
|
||||
public void testFunctionalType() throws Exception {
|
||||
|
||||
+12
@@ -10582,6 +10582,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsage.kt")
|
||||
public void testContextReceiverTypeParamsUsage() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsageError.kt")
|
||||
public void testContextReceiverTypeParamsUsageError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsageError.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType.kt")
|
||||
public void testFunctionalType() throws Exception {
|
||||
|
||||
+12
@@ -10582,6 +10582,18 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsage.kt")
|
||||
public void testContextReceiverTypeParamsUsage() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsageError.kt")
|
||||
public void testContextReceiverTypeParamsUsageError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsageError.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType.kt")
|
||||
public void testFunctionalType() throws Exception {
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
||||
@@ -224,6 +225,12 @@ class AnnotationChecker(
|
||||
*/
|
||||
descriptor.forceResolveAllContents()
|
||||
}
|
||||
|
||||
val contextReceiversSupported = languageVersionSettings.supportsFeature(ContextReceivers)
|
||||
if (descriptor.fqName == FqName("kotlin.ContextFunctionTypeParams") && !contextReceiversSupported) {
|
||||
trace.report(Errors.UNSUPPORTED_FEATURE.on(entry, ContextReceivers to languageVersionSettings))
|
||||
}
|
||||
|
||||
val classDescriptor = descriptor.annotationClass ?: continue
|
||||
|
||||
val useSiteTarget = entry.useSiteTarget?.getAnnotationUseSiteTarget() ?: annotated.getDefaultUseSiteTarget(descriptor)
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// FIR_IDENTICAL
|
||||
|
||||
fun <T> f(t: @ContextFunctionTypeParams(42) T, tt: @ContextFunctionTypeParams(1) Int) {}
|
||||
|
||||
fun test() {
|
||||
val f: @ContextFunctionTypeParams(1) @ExtensionFunctionType (Int, String) -> Unit = {}
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> f(/*0*/ t: @kotlin.ContextFunctionTypeParams(count = 42) T, /*1*/ tt: @kotlin.ContextFunctionTypeParams(count = 1) kotlin.Int): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
fun <T> f(t: <!UNSUPPORTED_FEATURE!>@ContextFunctionTypeParams(42)<!> T, tt: <!UNSUPPORTED_FEATURE!>@ContextFunctionTypeParams(1)<!> Int) {}
|
||||
|
||||
fun test() {
|
||||
val f: <!UNSUPPORTED_FEATURE!>@ContextFunctionTypeParams(1)<!> @ExtensionFunctionType (Int, String) -> Unit = {}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> f(/*0*/ t: @kotlin.ContextFunctionTypeParams(count = 42) T, /*1*/ tt: @kotlin.ContextFunctionTypeParams(count = 1) kotlin.Int): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
Generated
+12
@@ -10588,6 +10588,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsage.kt")
|
||||
public void testContextReceiverTypeParamsUsage() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiverTypeParamsUsageError.kt")
|
||||
public void testContextReceiverTypeParamsUsageError() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/contextReceiverTypeParamsUsageError.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType.kt")
|
||||
public void testFunctionalType() throws Exception {
|
||||
|
||||
@@ -97,7 +97,6 @@ public enum class DeprecationLevel {
|
||||
@MustBeDocumented
|
||||
public annotation class ExtensionFunctionType
|
||||
|
||||
// TODO: How to make it require opt-in? @RequiresOptIn doesn't support TYPE target
|
||||
@Target(TYPE)
|
||||
@MustBeDocumented
|
||||
public annotation class ContextFunctionTypeParams(val count: Int)
|
||||
|
||||
Reference in New Issue
Block a user