diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt index b5371ca3d48..6580707818b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt @@ -18,12 +18,23 @@ package org.jetbrains.kotlin.psi.codeFragmentUtil import com.intellij.openapi.util.Key import org.jetbrains.kotlin.psi.KtCodeFragment +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.types.KotlinType val SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE: Key = Key.create("SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE") +fun KtElement.suppressDiagnosticsInDebugMode(): Boolean { + return if (this is KtFile) { + this.suppressDiagnosticsInDebugMode + } + else { + val file = this.containingFile + file is KtFile && file.suppressDiagnosticsInDebugMode + } +} + var KtFile.suppressDiagnosticsInDebugMode: Boolean get() = when (this) { is KtCodeFragment -> true diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index b07b29b3127..b9c1df1c649 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -78,7 +78,9 @@ class CandidateResolver( return } - checkVisibility() + if (!context.isDebuggerContext) { + checkVisibility() + } when (checkArguments) { CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS -> diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java index b6b57a59e78..4c0cbf2b78f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java @@ -42,11 +42,12 @@ public class BasicCallResolutionContext extends CallResolutionContext resolvedCall) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java index 1de0adc386e..aac1f46ef19 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java @@ -58,11 +58,12 @@ public final class CallCandidateResolutionContext @Nullable Receiver explicitExtensionReceiverForInvoke, @NotNull CandidateResolveMode candidateResolveMode, boolean isAnnotationContext, + boolean isDebuggerContext, boolean collectAllCandidates, @NotNull CallPosition callPosition ) { super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, - dataFlowInfoForArguments, callChecker, statementFilter, isAnnotationContext, + dataFlowInfoForArguments, callChecker, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition); this.candidateCall = candidateCall; this.tracing = tracing; @@ -80,7 +81,7 @@ public final class CallCandidateResolutionContext context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache, context.dataFlowInfoForArguments, context.callChecker, context.statementFilter, explicitExtensionReceiverForInvoke, - candidateResolveMode, context.isAnnotationContext, context.collectAllCandidates, context.callPosition); + candidateResolveMode, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates, context.callPosition); } @NotNull @@ -91,7 +92,7 @@ public final class CallCandidateResolutionContext candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache, context.dataFlowInfoForArguments, context.callChecker, context.statementFilter, - null, CandidateResolveMode.FULLY, context.isAnnotationContext, context.collectAllCandidates, + null, CandidateResolveMode.FULLY, context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates, context.callPosition); } @@ -110,6 +111,6 @@ public final class CallCandidateResolutionContext return new CallCandidateResolutionContext( candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, dataFlowInfoForArguments, callChecker, statementFilter, - explicitExtensionReceiverForInvoke, candidateResolveMode, isAnnotationContext, collectAllCandidates, callPosition); + explicitExtensionReceiverForInvoke, candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java index 3e095d57cfa..66fe0f7c10d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java @@ -50,11 +50,12 @@ public abstract class CallResolutionContext extends C @NotNull StatementFilter statementFilter, @NotNull Collection> resolvedCalls, boolean isAnnotationContext, + boolean isDebuggerContext, boolean collectAllCandidates, @NotNull CallPosition callPosition ) { super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, - dataFlowInfoForArguments, callChecker, statementFilter, isAnnotationContext, collectAllCandidates, callPosition); + dataFlowInfoForArguments, callChecker, statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition); this.lazyCandidates = lazyCandidates; this.resolvedCalls = resolvedCalls; this.tracing = tracing; @@ -79,7 +80,7 @@ public class ResolutionTask extends C context.resolutionResultsCache, context.dataFlowInfoForArguments, context.callChecker, context.statementFilter, new SmartList>(), - context.isAnnotationContext, context.collectAllCandidates, context.callPosition); + context.isAnnotationContext, context.isDebuggerContext, context.collectAllCandidates, context.callPosition); } @NotNull @@ -113,7 +114,7 @@ public class ResolutionTask extends C resolutionResultsCache, dataFlowInfoForArguments, callChecker, statementFilter, resolvedCalls, - isAnnotationContext, collectAllCandidates, callPosition); + isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition); } @Override diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt index e7d120fb1d8..86b9db7a72a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt @@ -21,13 +21,11 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory -import org.jetbrains.kotlin.resolve.scopes.ImportingScope import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy -import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.containsError import org.jetbrains.kotlin.utils.addToStdlib.check @@ -51,6 +49,8 @@ internal class ScopeTowerImpl( override val implicitReceivers = resolutionContext.scope.getImplicitReceiversHierarchy(). mapNotNull { it.value.check { !it.type.containsError() } } + + val isDebuggerContext = resolutionContext.isDebuggerContext } private class DataFlowDecoratorImpl(private val resolutionContext: ResolutionContext<*>): DataFlowDecorator { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt index 69fc9f1f9a3..cc191549c2b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt @@ -62,10 +62,13 @@ internal abstract class AbstractScopeTowerLevel( if (descriptor.isSynthesized) diagnostics.add(SynthesizedDescriptorDiagnostic) if (dispatchReceiverSmartCastType != null) diagnostics.add(UsedSmartCastForDispatchReceiver(dispatchReceiverSmartCastType)) - Visibilities.findInvisibleMember( - dispatchReceiver, descriptor, - scopeTower.lexicalScope.ownerDescriptor - )?.let { diagnostics.add(VisibilityError(it)) } + val shouldSkipVisibilityCheck = scopeTower is ScopeTowerImpl && scopeTower.isDebuggerContext + if (!shouldSkipVisibilityCheck) { + Visibilities.findInvisibleMember( + dispatchReceiver, descriptor, + scopeTower.lexicalScope.ownerDescriptor + )?.let { diagnostics.add(VisibilityError(it)) } + } } return CandidateWithBoundDispatchReceiverImpl(dispatchReceiver, descriptor, diagnostics) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java index d97c6e949a3..af0addd2002 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java @@ -58,7 +58,18 @@ public class ExpressionTypingContext extends ResolutionContext