IC: Add inline class -> @JvmInline value class warning

This commit is contained in:
Ilmir Usmanov
2021-02-17 20:57:37 +01:00
parent b417786fd4
commit 62123d72e2
74 changed files with 102 additions and 65 deletions
@@ -365,6 +365,7 @@ public interface Errors {
DiagnosticFactory0<PsiElement> SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INNER_CLASS_INSIDE_INLINE_CLASS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> VALUE_CLASS_CANNOT_BE_CLONEABLE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INLINE_CLASS_DEPRECATED = DiagnosticFactory0.create(WARNING);
// Result class
@@ -724,6 +724,7 @@ public class DefaultErrorMessages {
MAP.put(SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS, "Secondary constructors with bodies are reserved for for future releases");
MAP.put(INNER_CLASS_INSIDE_INLINE_CLASS, "Inline class cannot have inner classes");
MAP.put(VALUE_CLASS_CANNOT_BE_CLONEABLE, "Value class cannot be Cloneable");
MAP.put(INLINE_CLASS_DEPRECATED, "Inline classes are deprecated in favor of value classes");
MAP.put(RESULT_CLASS_IN_RETURN_TYPE, "'kotlin.Result' cannot be used as a return type");
MAP.put(RESULT_CLASS_WITH_NULLABLE_OPERATOR, "Expression of type 'kotlin.Result' cannot be used as a left operand of ''{0}''", STRING);
@@ -357,6 +357,13 @@ object ModifierCheckerCore {
continue
}
if (dependency == LanguageFeature.InlineClasses) {
if (languageVersionSettings.supportsFeature(LanguageFeature.JvmInlineValueClasses)) {
trace.report(Errors.INLINE_CLASS_DEPRECATED.on(node.psi))
continue
}
}
val diagnosticData = dependency to languageVersionSettings
when (featureSupport) {
LanguageFeature.State.ENABLED_WITH_WARNING -> {
@@ -15,10 +15,8 @@ import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.modalityModifier
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.isNothing
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter