Provide additional information about missing supertypes

Add -X flag to report extra compiler diagnostics which migth break compatibility.
Use the flag to unconditionally check constructors without fear of
prematurely evaluating lazy supertypes.

KT-19234
KT-42404
KT-44583
This commit is contained in:
Pavel Kirpichenkov
2021-02-04 20:46:49 +03:00
parent 4a381d4b83
commit 2a46da906c
17 changed files with 109 additions and 1 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.resolve.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtDeclaration
@@ -48,7 +49,11 @@ object MissingDependencySupertypeChecker {
descriptor.dispatchReceiverParameter?.declaration, reportOn,
context.trace, context.missingSupertypesResolver
)
if (descriptor !is ConstructorDescriptor && descriptor !is FakeCallableDescriptorForObject && !errorReported) {
val eagerChecksAllowed = context.languageVersionSettings.supportsFeature(LanguageFeature.ExtendedCompilerChecks)
val unresolvedLazySupertypesByDefault = descriptor is ConstructorDescriptor || descriptor is FakeCallableDescriptorForObject
if (eagerChecksAllowed || !unresolvedLazySupertypesByDefault && !errorReported) {
// The constructed class' own supertypes are not resolved after constructor call,
// so its containing declaration should not be checked.
// Dispatch receiver is checked before for case of inner class constructor call.