[FIR] Fix incorrect context usages with withSuppressedDiagnostics call
This commit is contained in:
committed by
teamcity
parent
ccb74b6477
commit
b47cc86c57
+6
@@ -30312,6 +30312,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
public void testOnTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/onTypeParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suppressOnDeclarationItself.kt")
|
||||
public void testSuppressOnDeclarationItself() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -30312,6 +30312,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
public void testOnTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/onTypeParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suppressOnDeclarationItself.kt")
|
||||
public void testSuppressOnDeclarationItself() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -30312,6 +30312,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
public void testOnTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/onTypeParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suppressOnDeclarationItself.kt")
|
||||
public void testSuppressOnDeclarationItself() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -88,13 +88,13 @@ object FirRepeatableAnnotationChecker : FirBasicDeclarationChecker() {
|
||||
val javaRepeatable = annotations.find { it.classId == StandardClassIds.Annotations.Java.Repeatable }
|
||||
if (javaRepeatable != null) {
|
||||
withSuppressedDiagnostics(javaRepeatable, context) {
|
||||
checkJavaRepeatableAnnotationDeclaration(javaRepeatable, declaration, context, reporter)
|
||||
checkJavaRepeatableAnnotationDeclaration(javaRepeatable, declaration, it, reporter)
|
||||
}
|
||||
} else {
|
||||
val kotlinRepeatable = annotations.find { it.classId == StandardClassIds.Annotations.Repeatable }
|
||||
if (kotlinRepeatable != null) {
|
||||
withSuppressedDiagnostics(kotlinRepeatable, context) {
|
||||
checkKotlinRepeatableAnnotationDeclaration(kotlinRepeatable, declaration, context, reporter)
|
||||
checkKotlinRepeatableAnnotationDeclaration(kotlinRepeatable, declaration, it, reporter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ fun checkRepeatedAnnotation(
|
||||
val existingTargetsForAnnotation = annotationsMap.getOrPut(annotation.annotationTypeRef.coneType) { arrayListOf() }
|
||||
|
||||
withSuppressedDiagnostics(annotation, context) {
|
||||
checkRepeatedAnnotation(useSiteTarget, existingTargetsForAnnotation, annotation, context, reporter)
|
||||
checkRepeatedAnnotation(useSiteTarget, existingTargetsForAnnotation, annotation, it, reporter)
|
||||
}
|
||||
|
||||
existingTargetsForAnnotation.add(useSiteTarget)
|
||||
|
||||
+3
-3
@@ -62,7 +62,7 @@ private fun buildDeepSubstitutionMultimap(
|
||||
val session = context.session
|
||||
val typeContext = session.typeContext
|
||||
|
||||
fun fillInDeepSubstitutor(typeArguments: Array<out ConeTypeProjection>?, classSymbol: FirRegularClassSymbol) {
|
||||
fun fillInDeepSubstitutor(typeArguments: Array<out ConeTypeProjection>?, classSymbol: FirRegularClassSymbol, context: CheckerContext) {
|
||||
if (typeArguments != null) {
|
||||
val typeParameterSymbols = classSymbol.typeParameterSymbols
|
||||
val count = minOf(typeArguments.size, typeParameterSymbols.size)
|
||||
@@ -106,14 +106,14 @@ private fun buildDeepSubstitutionMultimap(
|
||||
val superClassSymbol = fullyExpandedType.toRegularClassSymbol(session)
|
||||
withSuppressedDiagnostics(superTypeRef, context) {
|
||||
if (!fullyExpandedType.isEnum && superClassSymbol != null) {
|
||||
fillInDeepSubstitutor(fullyExpandedType.typeArguments, superClassSymbol)
|
||||
fillInDeepSubstitutor(fullyExpandedType.typeArguments, superClassSymbol, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (firTypeRefClass in firTypeRefClasses) {
|
||||
fillInDeepSubstitutor(firTypeRefClass.first?.coneType?.fullyExpandedType(session)?.typeArguments, firTypeRefClass.second)
|
||||
fillInDeepSubstitutor(firTypeRefClass.first?.coneType?.fullyExpandedType(session)?.typeArguments, firTypeRefClass.second, context)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,12 +53,12 @@ object FirAnnotationChecker : FirBasicDeclarationChecker() {
|
||||
}
|
||||
|
||||
withSuppressedDiagnostics(annotation, context) {
|
||||
checkAnnotationTarget(declaration, annotation, context, reporter)
|
||||
checkAnnotationTarget(declaration, annotation, it, reporter)
|
||||
}
|
||||
}
|
||||
if (deprecatedSinceKotlin != null) {
|
||||
withSuppressedDiagnostics(deprecatedSinceKotlin, context) {
|
||||
checkDeprecatedCalls(deprecatedSinceKotlin, deprecated, context, reporter)
|
||||
checkDeprecatedCalls(deprecatedSinceKotlin, deprecated, it, reporter)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -169,17 +169,17 @@ object FirMemberPropertiesChecker : FirClassChecker() {
|
||||
// So, our source of truth should be the full modifier list retrieved from the source.
|
||||
val modifierList = property.source.getModifierList()
|
||||
|
||||
withSuppressedDiagnostics(property, context) {
|
||||
withSuppressedDiagnostics(property, context) { ctx ->
|
||||
checkPropertyInitializer(
|
||||
containingDeclaration,
|
||||
property,
|
||||
modifierList,
|
||||
isInitialized,
|
||||
reporter,
|
||||
context,
|
||||
ctx,
|
||||
reachable
|
||||
)
|
||||
checkExpectDeclarationVisibilityAndBody(property, source, reporter, context)
|
||||
checkExpectDeclarationVisibilityAndBody(property, source, reporter, ctx)
|
||||
|
||||
val hasAbstractModifier = KtTokens.ABSTRACT_KEYWORD in modifierList
|
||||
val isAbstract = property.isAbstract || hasAbstractModifier
|
||||
@@ -189,7 +189,7 @@ object FirMemberPropertiesChecker : FirClassChecker() {
|
||||
(property.getter == null || property.getter is FirDefaultPropertyAccessor)
|
||||
) {
|
||||
property.source?.let {
|
||||
reporter.reportOn(it, FirErrors.PRIVATE_PROPERTY_IN_INTERFACE, context)
|
||||
reporter.reportOn(it, FirErrors.PRIVATE_PROPERTY_IN_INTERFACE, ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,16 +201,16 @@ object FirMemberPropertiesChecker : FirClassChecker() {
|
||||
FirErrors.ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS,
|
||||
property.symbol,
|
||||
containingDeclaration.symbol,
|
||||
context
|
||||
ctx
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
property.initializer?.source?.let {
|
||||
reporter.reportOn(it, FirErrors.ABSTRACT_PROPERTY_WITH_INITIALIZER, context)
|
||||
reporter.reportOn(it, FirErrors.ABSTRACT_PROPERTY_WITH_INITIALIZER, ctx)
|
||||
}
|
||||
property.delegate?.source?.let {
|
||||
reporter.reportOn(it, FirErrors.ABSTRACT_DELEGATED_PROPERTY, context)
|
||||
reporter.reportOn(it, FirErrors.ABSTRACT_DELEGATED_PROPERTY, ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,10 +219,10 @@ object FirMemberPropertiesChecker : FirClassChecker() {
|
||||
containingDeclaration.isInterface &&
|
||||
!hasAbstractModifier &&
|
||||
property.isAbstract &&
|
||||
!isInsideExpectClass(containingDeclaration, context)
|
||||
!isInsideExpectClass(containingDeclaration, ctx)
|
||||
) {
|
||||
property.source?.let {
|
||||
reporter.reportOn(it, FirErrors.REDUNDANT_OPEN_IN_INTERFACE, context)
|
||||
reporter.reportOn(it, FirErrors.REDUNDANT_OPEN_IN_INTERFACE, ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ object FirMethodOfAnyImplementedInInterfaceChecker : FirRegularClassChecker(), F
|
||||
|
||||
if (methodOfAny) {
|
||||
withSuppressedDiagnostics(function, context) {
|
||||
reporter.reportOn(function.source, FirErrors.METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, context)
|
||||
reporter.reportOn(function.source, FirErrors.METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -23,22 +23,22 @@ object FirOptInMarkedDeclarationChecker : FirBasicDeclarationChecker() {
|
||||
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
for (annotation in declaration.annotations) {
|
||||
val annotationClass = annotation.getAnnotationClassForOptInMarker(context.session) ?: continue
|
||||
withSuppressedDiagnostics(annotation, context) {
|
||||
withSuppressedDiagnostics(annotation, context) { ctx ->
|
||||
val useSiteTarget = annotation.useSiteTarget
|
||||
if ((declaration is FirPropertyAccessor && declaration.isGetter) || useSiteTarget == PROPERTY_GETTER) {
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "getter", context)
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "getter", ctx)
|
||||
}
|
||||
if (useSiteTarget == SETTER_PARAMETER ||
|
||||
(useSiteTarget != PROPERTY && useSiteTarget != PROPERTY_SETTER && declaration is FirValueParameter &&
|
||||
KotlinTarget.VALUE_PARAMETER in annotationClass.getAllowedAnnotationTargets())
|
||||
) {
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "parameter", context)
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "parameter", ctx)
|
||||
}
|
||||
if (declaration is FirProperty && declaration.isLocal) {
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "variable", context)
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "variable", ctx)
|
||||
}
|
||||
if (useSiteTarget == FIELD || useSiteTarget == PROPERTY_DELEGATE_FIELD) {
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "field", context)
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "field", ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ object FirOverrideChecker : FirClassChecker() {
|
||||
if (it is FirSimpleFunction || it is FirProperty) {
|
||||
val callable = it as FirCallableDeclaration
|
||||
withSuppressedDiagnostics(callable, context) {
|
||||
checkMember(callable.symbol, declaration, reporter, typeCheckerState, firTypeScope, context)
|
||||
checkMember(callable.symbol, declaration, reporter, typeCheckerState, firTypeScope, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
-19
@@ -34,14 +34,14 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
val getter = property.getter ?: return
|
||||
val propertyType = property.returnTypeRef.coneType
|
||||
|
||||
withSuppressedDiagnostics(getter, context) {
|
||||
checkAccessorForDelegatedProperty(property, getter, context, reporter)
|
||||
withSuppressedDiagnostics(getter, context) { ctx ->
|
||||
checkAccessorForDelegatedProperty(property, getter, ctx, reporter)
|
||||
if (getter.visibility != property.visibility) {
|
||||
reporter.reportOn(getter.source, FirErrors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY, context)
|
||||
reporter.reportOn(getter.source, FirErrors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY, ctx)
|
||||
}
|
||||
if (property.symbol.callableId.classId != null && getter.body != null && property.delegate == null) {
|
||||
if (isLegallyAbstract(property, context)) {
|
||||
reporter.reportOn(getter.source, FirErrors.ABSTRACT_PROPERTY_WITH_GETTER, context)
|
||||
if (isLegallyAbstract(property, ctx)) {
|
||||
reporter.reportOn(getter.source, FirErrors.ABSTRACT_PROPERTY_WITH_GETTER, ctx)
|
||||
}
|
||||
}
|
||||
val getterReturnTypeRef = getter.returnTypeRef
|
||||
@@ -54,8 +54,8 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
}
|
||||
if (getterReturnType != property.returnTypeRef.coneType) {
|
||||
val getterReturnTypeSource = getterReturnTypeRef.source
|
||||
withSuppressedDiagnostics(getterReturnTypeRef, context) {
|
||||
reporter.reportOn(getterReturnTypeSource, FirErrors.WRONG_GETTER_RETURN_TYPE, propertyType, getterReturnType, context)
|
||||
withSuppressedDiagnostics(getterReturnTypeRef, ctx) {
|
||||
reporter.reportOn(getterReturnTypeSource, FirErrors.WRONG_GETTER_RETURN_TYPE, propertyType, getterReturnType, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,26 +65,26 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
val setter = property.setter ?: return
|
||||
val propertyType = property.returnTypeRef.coneType
|
||||
|
||||
withSuppressedDiagnostics(setter, context) {
|
||||
withSuppressedDiagnostics(setter, context) { ctx ->
|
||||
if (property.isVal) {
|
||||
reporter.reportOn(setter.source, FirErrors.VAL_WITH_SETTER, context)
|
||||
reporter.reportOn(setter.source, FirErrors.VAL_WITH_SETTER, ctx)
|
||||
}
|
||||
checkAccessorForDelegatedProperty(property, setter, context, reporter)
|
||||
checkAccessorForDelegatedProperty(property, setter, ctx, reporter)
|
||||
val visibilityCompareResult = setter.visibility.compareTo(property.visibility)
|
||||
if (visibilityCompareResult == null || visibilityCompareResult > 0) {
|
||||
reporter.reportOn(setter.source, FirErrors.SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY, context)
|
||||
reporter.reportOn(setter.source, FirErrors.SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY, ctx)
|
||||
}
|
||||
if (property.symbol.callableId.classId != null && property.delegate == null) {
|
||||
val isLegallyAbstract = isLegallyAbstract(property, context)
|
||||
val isLegallyAbstract = isLegallyAbstract(property, ctx)
|
||||
if (setter.visibility == Visibilities.Private && property.visibility != Visibilities.Private) {
|
||||
if (isLegallyAbstract) {
|
||||
reporter.reportOn(setter.source, FirErrors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY, context)
|
||||
reporter.reportOn(setter.source, FirErrors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY, ctx)
|
||||
} else if (property.isOpen) {
|
||||
reporter.reportOn(setter.source, FirErrors.PRIVATE_SETTER_FOR_OPEN_PROPERTY, context)
|
||||
reporter.reportOn(setter.source, FirErrors.PRIVATE_SETTER_FOR_OPEN_PROPERTY, ctx)
|
||||
}
|
||||
}
|
||||
if (isLegallyAbstract && setter.body != null) {
|
||||
reporter.reportOn(setter.source, FirErrors.ABSTRACT_PROPERTY_WITH_SETTER, context)
|
||||
reporter.reportOn(setter.source, FirErrors.ABSTRACT_PROPERTY_WITH_SETTER, ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
}
|
||||
|
||||
if (valueSetterType != propertyType) {
|
||||
withSuppressedDiagnostics(valueSetterParameter, context) {
|
||||
reporter.reportOn(valueSetterTypeSource, FirErrors.WRONG_SETTER_PARAMETER_TYPE, propertyType, valueSetterType, context)
|
||||
withSuppressedDiagnostics(valueSetterParameter, ctx) {
|
||||
reporter.reportOn(valueSetterTypeSource, FirErrors.WRONG_SETTER_PARAMETER_TYPE, propertyType, valueSetterType, ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
|
||||
}
|
||||
|
||||
if (!setterReturnType.isUnit) {
|
||||
withSuppressedDiagnostics(setter.returnTypeRef, context) {
|
||||
reporter.reportOn(setter.returnTypeRef.source, FirErrors.WRONG_SETTER_RETURN_TYPE, context)
|
||||
withSuppressedDiagnostics(setter.returnTypeRef, ctx) {
|
||||
reporter.reportOn(setter.returnTypeRef.source, FirErrors.WRONG_SETTER_RETURN_TYPE, ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -41,58 +41,58 @@ object FirSupertypesChecker : FirClassChecker() {
|
||||
var classAppeared = false
|
||||
val superClassSymbols = hashSetOf<FirRegularClassSymbol>()
|
||||
for (superTypeRef in declaration.superTypeRefs) {
|
||||
withSuppressedDiagnostics(superTypeRef, context) {
|
||||
withSuppressedDiagnostics(superTypeRef, context) { ctx ->
|
||||
val coneType = superTypeRef.coneType
|
||||
if (!nullableSupertypeReported && coneType.nullability == ConeNullability.NULLABLE) {
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.NULLABLE_SUPERTYPE, context)
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.NULLABLE_SUPERTYPE, ctx)
|
||||
nullableSupertypeReported = true
|
||||
}
|
||||
if (!extensionFunctionSupertypeReported && coneType.isExtensionFunctionType &&
|
||||
!context.session.languageVersionSettings.supportsFeature(LanguageFeature.FunctionalTypeWithExtensionAsSupertype)
|
||||
!ctx.session.languageVersionSettings.supportsFeature(LanguageFeature.FunctionalTypeWithExtensionAsSupertype)
|
||||
) {
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE, context)
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE, ctx)
|
||||
extensionFunctionSupertypeReported = true
|
||||
}
|
||||
val lookupTag = coneType.safeAs<ConeClassLikeType>()?.lookupTag ?: return@withSuppressedDiagnostics
|
||||
val superTypeSymbol = lookupTag.toSymbol(context.session)
|
||||
val superTypeSymbol = lookupTag.toSymbol(ctx.session)
|
||||
|
||||
if (superTypeSymbol is FirRegularClassSymbol) {
|
||||
if (!superClassSymbols.add(superTypeSymbol)) {
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.SUPERTYPE_APPEARS_TWICE, context)
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.SUPERTYPE_APPEARS_TWICE, ctx)
|
||||
}
|
||||
if (superTypeSymbol.classKind != ClassKind.INTERFACE) {
|
||||
if (classAppeared) {
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.MANY_CLASSES_IN_SUPERTYPE_LIST, context)
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.MANY_CLASSES_IN_SUPERTYPE_LIST, ctx)
|
||||
} else {
|
||||
classAppeared = true
|
||||
}
|
||||
if (!interfaceWithSuperclassReported) {
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.INTERFACE_WITH_SUPERCLASS, context)
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.INTERFACE_WITH_SUPERCLASS, ctx)
|
||||
interfaceWithSuperclassReported = true
|
||||
}
|
||||
}
|
||||
val isObject = superTypeSymbol.classKind == ClassKind.OBJECT
|
||||
if (!finalSupertypeReported && !isObject && superTypeSymbol.modality == Modality.FINAL) {
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.FINAL_SUPERTYPE, context)
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.FINAL_SUPERTYPE, ctx)
|
||||
finalSupertypeReported = true
|
||||
}
|
||||
if (!singletonInSupertypeReported && isObject) {
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.SINGLETON_IN_SUPERTYPE, context)
|
||||
reporter.reportOn(superTypeRef.source, FirErrors.SINGLETON_IN_SUPERTYPE, ctx)
|
||||
singletonInSupertypeReported = true
|
||||
}
|
||||
}
|
||||
|
||||
checkAnnotationOnSuperclass(superTypeRef, context, reporter)
|
||||
checkAnnotationOnSuperclass(superTypeRef, ctx, reporter)
|
||||
|
||||
val fullyExpandedType = coneType.fullyExpandedType(context.session)
|
||||
val symbol = fullyExpandedType.toSymbol(context.session)
|
||||
val fullyExpandedType = coneType.fullyExpandedType(ctx.session)
|
||||
val symbol = fullyExpandedType.toSymbol(ctx.session)
|
||||
|
||||
checkClassCannotBeExtendedDirectly(symbol, reporter, superTypeRef, context)
|
||||
checkClassCannotBeExtendedDirectly(symbol, reporter, superTypeRef, ctx)
|
||||
|
||||
if (coneType.typeArguments.isNotEmpty()) {
|
||||
checkProjectionInImmediateArgumentToSupertype(coneType, superTypeRef, reporter, context)
|
||||
checkProjectionInImmediateArgumentToSupertype(coneType, superTypeRef, reporter, ctx)
|
||||
} else {
|
||||
checkExpandedTypeCannotBeInherited(symbol, fullyExpandedType, reporter, superTypeRef, coneType, context)
|
||||
checkExpandedTypeCannotBeInherited(symbol, fullyExpandedType, reporter, superTypeRef, coneType, ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ object FirSupertypesChecker : FirClassChecker() {
|
||||
for (annotation in superTypeRef.annotations) {
|
||||
withSuppressedDiagnostics(annotation, context) {
|
||||
if (annotation.useSiteTarget != null) {
|
||||
reporter.reportOn(annotation.source, FirErrors.ANNOTATION_ON_SUPERCLASS, context)
|
||||
reporter.reportOn(annotation.source, FirErrors.ANNOTATION_ON_SUPERCLASS, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -38,16 +38,16 @@ object FirTopLevelPropertiesChecker : FirPropertyChecker() {
|
||||
// So, our source of truth should be the full modifier list retrieved from the source.
|
||||
val modifierList = source.getModifierList()
|
||||
|
||||
withSuppressedDiagnostics(declaration, context) {
|
||||
withSuppressedDiagnostics(declaration, context) { ctx ->
|
||||
checkPropertyInitializer(
|
||||
containingClass = null,
|
||||
declaration,
|
||||
modifierList,
|
||||
isInitialized = declaration.initializer != null,
|
||||
reporter,
|
||||
context
|
||||
ctx
|
||||
)
|
||||
checkExpectDeclarationVisibilityAndBody(declaration, source, reporter, context)
|
||||
checkExpectDeclarationVisibilityAndBody(declaration, source, reporter, ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -41,12 +41,12 @@ object FirExpressionAnnotationChecker : FirBasicExpressionChecker() {
|
||||
val useSiteTarget = annotation.useSiteTarget ?: expression.getDefaultUseSiteTarget(annotation, context)
|
||||
val existingTargetsForAnnotation = annotationsMap.getOrPut(annotation.annotationTypeRef.coneType) { arrayListOf() }
|
||||
|
||||
withSuppressedDiagnostics(annotation, context) {
|
||||
if (KotlinTarget.EXPRESSION !in annotation.getAllowedAnnotationTargets(context.session)) {
|
||||
reporter.reportOn(annotation.source, FirErrors.WRONG_ANNOTATION_TARGET, "expression", context)
|
||||
withSuppressedDiagnostics(annotation, context) { ctx ->
|
||||
if (KotlinTarget.EXPRESSION !in annotation.getAllowedAnnotationTargets(ctx.session)) {
|
||||
reporter.reportOn(annotation.source, FirErrors.WRONG_ANNOTATION_TARGET, "expression", ctx)
|
||||
}
|
||||
|
||||
checkRepeatedAnnotation(useSiteTarget, existingTargetsForAnnotation, annotation, context, reporter)
|
||||
checkRepeatedAnnotation(useSiteTarget, existingTargetsForAnnotation, annotation, ctx, reporter)
|
||||
}
|
||||
|
||||
existingTargetsForAnnotation.add(useSiteTarget)
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ object FirLoopConditionChecker : FirLoopExpressionChecker() {
|
||||
if (expression is FirErrorLoop) return
|
||||
val condition = expression.condition
|
||||
withSuppressedDiagnostics(condition, context) {
|
||||
checkCondition(condition, context, reporter)
|
||||
checkCondition(condition, it, reporter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ object FirWhenConditionChecker : FirWhenExpressionChecker() {
|
||||
val condition = branch.condition
|
||||
if (condition is FirElseIfTrueCondition) continue
|
||||
withSuppressedDiagnostics(condition, context) {
|
||||
checkCondition(condition, context, reporter)
|
||||
checkCondition(condition, it, reporter)
|
||||
}
|
||||
}
|
||||
if (expression.subject != null) {
|
||||
@@ -66,4 +66,4 @@ object FirWhenConditionChecker : FirWhenExpressionChecker() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ object FirOptInUsageTypeRefChecker : FirTypeRefChecker() {
|
||||
if (annotation.getAnnotationClassForOptInMarker(context.session) != null) {
|
||||
if (annotation.useSiteTarget == AnnotationUseSiteTarget.RECEIVER) {
|
||||
withSuppressedDiagnostics(annotation, context) {
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "parameter", context)
|
||||
reporter.reportOn(annotation.source, FirErrors.OPT_IN_MARKER_ON_WRONG_TARGET, "parameter", it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ object FirTypeAnnotationChecker : FirTypeRefChecker() {
|
||||
if (KotlinTarget.TYPE !in annotationTargets) {
|
||||
val useSiteTarget = annotation.useSiteTarget
|
||||
if (useSiteTarget == null || KotlinTarget.USE_SITE_MAPPING[useSiteTarget] !in annotationTargets) {
|
||||
reporter.reportOn(annotation.source, FirErrors.WRONG_ANNOTATION_TARGET, "type usage", context)
|
||||
reporter.reportOn(annotation.source, FirErrors.WRONG_ANNOTATION_TARGET, "type usage", it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
class A {
|
||||
@Suppress("NOTHING_TO_OVERRIDE")
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.Suppress(names = {"NOTHING_TO_OVERRIDE"}) public open fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Generated
+6
@@ -30402,6 +30402,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
public void testOnTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/onTypeParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suppressOnDeclarationItself.kt")
|
||||
public void testSuppressOnDeclarationItself() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ object FirParcelizeClassChecker : FirClassChecker() {
|
||||
} else {
|
||||
SourceElementPositioningStrategies.NAME_IDENTIFIER
|
||||
}
|
||||
reporter.reportOn(klass.source, KtErrorsParcelize.DEPRECATED_PARCELER, context, positioningStrategy = strategy)
|
||||
reporter.reportOn(klass.source, KtErrorsParcelize.DEPRECATED_PARCELER, it, positioningStrategy = strategy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user