FIR: Fix FP error on a call to constructor of a private inner class
Do not check dispatch receiver applicability when checking visibility for containing class of a callee constructor
This commit is contained in:
+6
@@ -33496,6 +33496,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("innerConstructorThroughSubclass.kt")
|
||||||
|
public void testInnerConstructorThroughSubclass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/innerConstructorThroughSubclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
||||||
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
||||||
|
|||||||
+6
@@ -33496,6 +33496,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("innerConstructorThroughSubclass.kt")
|
||||||
|
public void testInnerConstructorThroughSubclass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/innerConstructorThroughSubclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
||||||
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
||||||
|
|||||||
+6
@@ -33496,6 +33496,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("innerConstructorThroughSubclass.kt")
|
||||||
|
public void testInnerConstructorThroughSubclass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/innerConstructorThroughSubclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
||||||
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
||||||
|
|||||||
+9
-16
@@ -9,7 +9,9 @@ import org.jetbrains.kotlin.config.LanguageFeature
|
|||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.fir.FirVisibilityChecker
|
import org.jetbrains.kotlin.fir.FirVisibilityChecker
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
import org.jetbrains.kotlin.fir.declarations.utils.isInfix
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.isOperator
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.modality
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.fir.matchingParameterFunctionType
|
import org.jetbrains.kotlin.fir.matchingParameterFunctionType
|
||||||
@@ -516,7 +518,8 @@ internal object CheckVisibility : CheckerStage() {
|
|||||||
val symbol = candidate.symbol
|
val symbol = candidate.symbol
|
||||||
val declaration = symbol.fir
|
val declaration = symbol.fir
|
||||||
if (declaration is FirMemberDeclaration) {
|
if (declaration is FirMemberDeclaration) {
|
||||||
if (!checkVisibility(declaration, sink, candidate, visibilityChecker)) {
|
if (!visibilityChecker.isVisible(declaration, candidate)) {
|
||||||
|
sink.yieldDiagnostic(VisibilityError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -529,23 +532,13 @@ internal object CheckVisibility : CheckerStage() {
|
|||||||
if (classSymbol.fir.classKind.isSingleton) {
|
if (classSymbol.fir.classKind.isSingleton) {
|
||||||
sink.yieldDiagnostic(VisibilityError)
|
sink.yieldDiagnostic(VisibilityError)
|
||||||
}
|
}
|
||||||
checkVisibility(classSymbol.fir, sink, candidate, visibilityChecker)
|
|
||||||
|
if (!visibilityChecker.isVisible(declaration, candidate.callInfo, dispatchReceiverValue = null)) {
|
||||||
|
sink.yieldDiagnostic(VisibilityError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun <T : FirMemberDeclaration> checkVisibility(
|
|
||||||
declaration: T,
|
|
||||||
sink: CheckerSink,
|
|
||||||
candidate: Candidate,
|
|
||||||
visibilityChecker: FirVisibilityChecker
|
|
||||||
): Boolean {
|
|
||||||
if (!visibilityChecker.isVisible(declaration, candidate)) {
|
|
||||||
sink.yieldDiagnostic(VisibilityError)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object CheckLowPriorityInOverloadResolution : CheckerStage() {
|
internal object CheckLowPriorityInOverloadResolution : CheckerStage() {
|
||||||
|
|||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
sealed class Outer {
|
||||||
|
class NestedSubClass : Outer() {
|
||||||
|
fun foo() {
|
||||||
|
Inner()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class Inner
|
||||||
|
}
|
||||||
Generated
+6
@@ -33586,6 +33586,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/visibility"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("innerConstructorThroughSubclass.kt")
|
||||||
|
public void testInnerConstructorThroughSubclass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/visibility/innerConstructorThroughSubclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
@TestMetadata("innerNestedAndAnonymousClasses.kt")
|
||||||
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
public void testInnerNestedAndAnonymousClasses() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user