[FIR] KT-56505 Fix checkVisibilityModifier taking wrong modifier list

- KT-56505 occurred because `source.getChild(KtNodeTypes.MODIFIER_LIST)`
  returns any modifier list in the subtree of the source element, not
  necessarily the modifier list belonging to the checked element.
  `depth = 1` restricts the search to the modifier list belonging to the
  checked element itself.
- For example, given `f1` from KT-56505, `getChild` would return the
  modifier list of `public var foo = 0`. Because it contains a
  visibility modifier, `f1` wasn't marked with
  `NO_EXPLICIT_VISIBILITY_IN_API_MODE`.

^KT-56505 fixed
This commit is contained in:
Marco Pennekamp
2023-02-08 18:41:43 +01:00
committed by Space Team
parent e86c877733
commit 5d391bc261
7 changed files with 48 additions and 7 deletions
@@ -32720,6 +32720,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/interfaces.kt");
}
@Test
@TestMetadata("kt56505.kt")
public void testKt56505() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/kt56505.kt");
}
@Test
@TestMetadata("localFunctions.kt")
public void testLocalFunctions() throws Exception {