[FIR] Forbid explicit backing fields for FE 1.0
This commit is contained in:
committed by
TeamCityServer
parent
37f832bc2f
commit
6776930881
@@ -71,6 +71,8 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, Pair<LanguageFeature, LanguageVersionSettings>> EXPERIMENTAL_FEATURE_WARNING = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, Pair<LanguageFeature, LanguageVersionSettings>> EXPERIMENTAL_FEATURE_ERROR = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtElement> EXPLICIT_BACKING_FIELDS_UNSUPPORTED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Generic errors/warnings: applicable in many contexts
|
||||
|
||||
+2
@@ -712,6 +712,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(EXPERIMENTAL_FEATURE_WARNING, "{0}", new LanguageFeatureMessageRenderer(LanguageFeatureMessageRenderer.Type.WARNING));
|
||||
MAP.put(EXPERIMENTAL_FEATURE_ERROR, "{0}", new LanguageFeatureMessageRenderer(LanguageFeatureMessageRenderer.Type.ERROR));
|
||||
|
||||
MAP.put(EXPLICIT_BACKING_FIELDS_UNSUPPORTED, "Explicit backing field declarations are not supported in FE 1.0");
|
||||
|
||||
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
|
||||
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
|
||||
MAP.put(UNNECESSARY_SAFE_CALL, "Unnecessary safe call on a non-null receiver of type {0}. This expression will have nullable type in future releases", RENDER_TYPE);
|
||||
|
||||
@@ -591,6 +591,12 @@ class DeclarationsChecker(
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkBackingField(property: KtProperty) {
|
||||
property.fieldDeclaration?.let {
|
||||
trace.report(EXPLICIT_BACKING_FIELDS_UNSUPPORTED.on(it))
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkProperty(property: KtProperty, propertyDescriptor: PropertyDescriptor) {
|
||||
val containingDeclaration = propertyDescriptor.containingDeclaration
|
||||
if (containingDeclaration is ClassDescriptor) {
|
||||
@@ -605,6 +611,7 @@ class DeclarationsChecker(
|
||||
checkPropertyTypeParametersAreUsedInReceiverType(propertyDescriptor)
|
||||
checkImplicitCallableType(property, propertyDescriptor)
|
||||
checkPrivateExpectedDeclaration(property, propertyDescriptor)
|
||||
checkBackingField(property)
|
||||
}
|
||||
|
||||
private fun checkPrivateExpectedDeclaration(declaration: KtDeclaration, descriptor: MemberDescriptor) {
|
||||
|
||||
Reference in New Issue
Block a user