[FE 1.0] Report warning about conflict in inherited members from deserialized dependencies

^KT-51194
^KT-51223 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-02-09 14:33:59 +03:00
committed by teamcity
parent c6994768d7
commit 0eb526a8b4
16 changed files with 273 additions and 1 deletions
@@ -597,6 +597,8 @@ public interface Errors {
DiagnosticFactory2<KtClassOrObject, ClassDescriptor, Collection<CallableMemberDescriptor>> CONFLICTING_INHERITED_MEMBERS =
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
DiagnosticFactory2<KtClassOrObject, ClassDescriptor, Collection<CallableMemberDescriptor>> CONFLICTING_INHERITED_MEMBERS_WARNING =
DiagnosticFactory2.create(WARNING, DECLARATION_NAME);
DiagnosticFactory2<KtClassOrObject, KtClassOrObject, CallableMemberDescriptor> ABSTRACT_MEMBER_NOT_IMPLEMENTED =
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
DiagnosticFactory2<KtClassOrObject, KtClassOrObject, CallableMemberDescriptor> ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED =
@@ -887,6 +887,7 @@ public class DefaultErrorMessages {
FQ_NAMES_IN_TYPES);
MAP.put(CONFLICTING_INHERITED_MEMBERS, "{0} inherits conflicting members: {1}", NAME, CommonRenderers.commaSeparated(FQ_NAMES_IN_TYPES));
MAP.put(CONFLICTING_INHERITED_MEMBERS_WARNING, "{0} inherits conflicting members: {1}; This warning will became error in future releases. See https://youtrack.jetbrains.com/issue/KT-51194", NAME, CommonRenderers.commaSeparated(FQ_NAMES_IN_TYPES));
MAP.put(ABSTRACT_MEMBER_NOT_IMPLEMENTED, "{0} is not abstract and does not implement abstract member {1}", RENDER_CLASS_OR_OBJECT,
FQ_NAMES_IN_TYPES);
MAP.put(ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED, "{0} is not abstract and does not implement abstract base class member {1}",
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.FAKE_OVERRIDE
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.diagnostics.reportOnDeclarationAs
@@ -254,6 +255,23 @@ open class LazyClassMemberScope(
}
}
})
for (descriptor in result) {
if (descriptor !is FunctionDescriptorImpl) continue
for (overriddenFunction in descriptor.overriddenDescriptors) {
if (overriddenFunction !is FunctionDescriptorImpl) continue
val conflictedDescriptor = overriddenFunction.getUserData(DeserializedDeclarationsFromSupertypeConflictDataKey) ?: continue
reportOnDeclarationAs<KtClassOrObject>(
trace,
thisDescriptor
) { ktClassOrObject ->
Errors.CONFLICTING_INHERITED_MEMBERS_WARNING.on(
ktClassOrObject,
thisDescriptor,
listOf(overriddenFunction, conflictedDescriptor)
)
}
}
}
OverrideResolver.resolveUnknownVisibilities(result, trace)
}