Files
swift-mirror/test/ModuleInterface/skip-override-keyword.swift
Robert Widmann 89ae325d22 Use Formal Access To Compute Override Elision Check
The effective access of an overridden declaration is subject to
escalation by -enable-testing. When this is flag is enabled, an
interface containing an internal-overriding-public declaration will
still print `override`. This is because the effective access of the base
of the override is formally internal but effectively public.

Instead, use the formal access scope of the overridden declaration to
compute its access relative to the override. While I'm here, catch the
case where the base declaration is `@usableFromInline` and therefore
*will* be printed in the interface. We treat these declarations as
effectively public for the purpose of printing `override`.

Resolves rdar://64969741
2020-06-30 21:28:42 -07:00

25 lines
1.2 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -typecheck -module-name Foo -emit-module-interface-path %t/Foo.swiftinterface %s
// RUN: %target-swift-frontend -compile-module-from-interface %t/Foo.swiftinterface -o %t/Foo.swiftmodule
// RUN: %target-swift-frontend -typecheck -enable-testing -module-name FooWithTesting -emit-module-interface-path %t/FooWithTesting.swiftinterface %s
// RUN: %target-swift-frontend -compile-module-from-interface %t/FooWithTesting.swiftinterface -o %t/FooWithTesting.swiftmodule
public class BaseClass {
init() { }
var property: Int { return 1 }
func doSomething() { }
subscript(index: Int) -> Int { get { return 0 } set(newValue) {} }
@usableFromInline func doSomethingInline() {}
@usableFromInline func doSomethingUsableFromInline() {}
}
public class DerivedClass: BaseClass {
public override init() { super.init() }
public override var property : Int { return 0 }
public override func doSomething() { }
public override subscript(index: Int) -> Int { get {return 0} set(newValue) {} }
@inlinable public override func doSomethingInline() { super.doSomethingInline() }
@usableFromInline override func doSomethingUsableFromInline() { super.doSomethingUsableFromInline() }
}