Add check that we have JDK 15 in classpath when using @JvmRecord
^KT-43677 In Progress
This commit is contained in:
+5
@@ -201,6 +201,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmRecordWithoutJdk15.kt")
|
||||||
|
public void testJvmRecordWithoutJdk15() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmRecordWithoutJdk15.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JvmSyntheticOnDelegate.kt")
|
@TestMetadata("JvmSyntheticOnDelegate.kt")
|
||||||
public void testJvmSyntheticOnDelegate() throws Exception {
|
public void testJvmSyntheticOnDelegate() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");
|
||||||
|
|||||||
+7
@@ -10,12 +10,14 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.resolveTopLevelClass
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JAVA_LANG_RECORD_FQ_NAME
|
import org.jetbrains.kotlin.resolve.jvm.JAVA_LANG_RECORD_FQ_NAME
|
||||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_RECORD_ANNOTATION_FQ_NAME
|
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_RECORD_ANNOTATION_FQ_NAME
|
||||||
import org.jetbrains.kotlin.resolve.jvm.annotations.isJvmRecord
|
import org.jetbrains.kotlin.resolve.jvm.annotations.isJvmRecord
|
||||||
@@ -29,6 +31,11 @@ object JvmRecordApplicabilityChecker : DeclarationChecker {
|
|||||||
declaration.annotationEntries.firstOrNull { it.shortName == JVM_RECORD_ANNOTATION_FQ_NAME.shortName() }
|
declaration.annotationEntries.firstOrNull { it.shortName == JVM_RECORD_ANNOTATION_FQ_NAME.shortName() }
|
||||||
?: declaration
|
?: declaration
|
||||||
|
|
||||||
|
if (context.moduleDescriptor.resolveTopLevelClass(JAVA_LANG_RECORD_FQ_NAME, NoLookupLocation.FOR_DEFAULT_IMPORTS) == null) {
|
||||||
|
context.trace.report(ErrorsJvm.JVM_RECORD_REQUIRES_JDK15.on(reportOn))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.JvmRecordSupport)) {
|
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.JvmRecordSupport)) {
|
||||||
context.trace.report(
|
context.trace.report(
|
||||||
Errors.UNSUPPORTED_FEATURE.on(
|
Errors.UNSUPPORTED_FEATURE.on(
|
||||||
|
|||||||
+1
@@ -157,6 +157,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
|||||||
MAP.put(JVM_RECORD_NOT_VAL_PARAMETER, "Constructor parameter of @JvmRecord class should be a val");
|
MAP.put(JVM_RECORD_NOT_VAL_PARAMETER, "Constructor parameter of @JvmRecord class should be a val");
|
||||||
MAP.put(JVM_RECORD_NOT_LAST_VARARG_PARAMETER, "Only the last constructor parameter of @JvmRecord may be a vararg");
|
MAP.put(JVM_RECORD_NOT_LAST_VARARG_PARAMETER, "Only the last constructor parameter of @JvmRecord may be a vararg");
|
||||||
MAP.put(JVM_RECORD_EXTENDS_CLASS, "Record cannot inherit an other class but java.lang.Record" , RENDER_TYPE);
|
MAP.put(JVM_RECORD_EXTENDS_CLASS, "Record cannot inherit an other class but java.lang.Record" , RENDER_TYPE);
|
||||||
|
MAP.put(JVM_RECORD_REQUIRES_JDK15, "Using @JvmRecords requires at least JDK 15");
|
||||||
|
|
||||||
String MESSAGE_FOR_CONCURRENT_HASH_MAP_CONTAINS =
|
String MESSAGE_FOR_CONCURRENT_HASH_MAP_CONTAINS =
|
||||||
"Method 'contains' from ConcurrentHashMap may have unexpected semantics: it calls 'containsValue' instead of 'containsKey'. " +
|
"Method 'contains' from ConcurrentHashMap may have unexpected semantics: it calls 'containsValue' instead of 'containsKey'. " +
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ public interface ErrorsJvm {
|
|||||||
DiagnosticFactory0<PsiElement> JVM_RECORD_NOT_VAL_PARAMETER = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> JVM_RECORD_NOT_VAL_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> JVM_RECORD_NOT_LAST_VARARG_PARAMETER = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> JVM_RECORD_NOT_LAST_VARARG_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, KotlinType> JVM_RECORD_EXTENDS_CLASS = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, KotlinType> JVM_RECORD_EXTENDS_CLASS = DiagnosticFactory1.create(ERROR);
|
||||||
|
DiagnosticFactory0<PsiElement> JVM_RECORD_REQUIRES_JDK15 = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory0<KtDeclaration> NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
DiagnosticFactory0<KtDeclaration> NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||||
|
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// !LANGUAGE: +JvmRecordSupport
|
||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
@JvmRecord
|
||||||
|
class MyRec(
|
||||||
|
val x: String,
|
||||||
|
val y: Int,
|
||||||
|
vararg val z: Double,
|
||||||
|
)
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// !LANGUAGE: +JvmRecordSupport
|
||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
<!JVM_RECORD_REQUIRES_JDK15!>@JvmRecord<!>
|
||||||
|
class MyRec(
|
||||||
|
val x: String,
|
||||||
|
val y: Int,
|
||||||
|
vararg val z: Double,
|
||||||
|
)
|
||||||
+5
@@ -201,6 +201,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmRecordWithoutJdk15.kt")
|
||||||
|
public void testJvmRecordWithoutJdk15() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmRecordWithoutJdk15.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JvmSyntheticOnDelegate.kt")
|
@TestMetadata("JvmSyntheticOnDelegate.kt")
|
||||||
public void testJvmSyntheticOnDelegate() throws Exception {
|
public void testJvmSyntheticOnDelegate() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");
|
||||||
|
|||||||
+5
@@ -201,6 +201,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmRecordWithoutJdk15.kt")
|
||||||
|
public void testJvmRecordWithoutJdk15() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmRecordWithoutJdk15.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JvmSyntheticOnDelegate.kt")
|
@TestMetadata("JvmSyntheticOnDelegate.kt")
|
||||||
public void testJvmSyntheticOnDelegate() throws Exception {
|
public void testJvmSyntheticOnDelegate() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user