KT-8575 Fix warnings for Java synthetic properties

This commit is contained in:
Pavel Mikhailovskii
2022-10-10 22:35:10 +02:00
committed by teamcity
parent 26dc010d30
commit f4bdf54601
13 changed files with 37 additions and 59 deletions
@@ -18,8 +18,7 @@ package org.jetbrains.kotlin.resolve.jvm.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.diagnostics.Errors.CALLABLE_REFERENCE_TO_JAVA_SYNTHETIC_PROPERTY
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED_FEATURE
import org.jetbrains.kotlin.psi.KtPropertyDelegate
import org.jetbrains.kotlin.psi.psiUtil.unwrapParenthesesLabelsAndAnnotationsDeeply
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
@@ -37,16 +36,11 @@ class UnsupportedSyntheticCallableReferenceChecker : CallChecker {
if (callableReferenceExpression.unwrapParenthesesLabelsAndAnnotationsDeeply() is KtPropertyDelegate) return
if (resolvedCall.resultingDescriptor is SyntheticJavaPropertyDescriptor) {
val diagnostic = if (
context.languageVersionSettings.supportsFeature(LanguageFeature.NewInference) &&
context.languageVersionSettings.supportsFeature(LanguageFeature.ReferencesToSyntheticJavaProperties)
) {
CALLABLE_REFERENCE_TO_JAVA_SYNTHETIC_PROPERTY.on(reportOn)
} else {
UNSUPPORTED.on(reportOn, "reference to the synthetic extension property for a Java get/set method")
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.ReferencesToSyntheticJavaProperties)) {
context.trace.report(UNSUPPORTED_FEATURE.on(reportOn, LanguageFeature.ReferencesToSyntheticJavaProperties to context.languageVersionSettings))
} else if (!context.languageVersionSettings.supportsFeature(LanguageFeature.NewInference)) {
context.trace.report(UNSUPPORTED_FEATURE.on(reportOn, LanguageFeature.NewInference to context.languageVersionSettings))
}
context.trace.report(diagnostic)
}
}
}