Files
kotlin-fork/compiler/testData/diagnostics/tests/testsWithExplicitApi/kt56505.kt
T
Marco Pennekamp 5d391bc261 [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
2023-02-16 10:50:48 +00:00

19 lines
452 B
Kotlin
Vendored

// FIR_IDENTICAL
// SKIP_TXT
// ISSUE: KT-56505
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>fun f1<!>() {
class LocalClass {
public var foo = 0
}
LocalClass().foo = 1
}
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>class J1<!> {
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>var buf<!>: Int = 0
<!GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY!>private<!> get() = 42
protected set(value) {
field = value
}
}