Files
swift-mirror/test/attr/attr_usableFromInline_protocol_hole.swift
Jordan Rose cd22c5d546 Use access scopes for the hard cases in ValueDecl::isAccessibleFrom
This function (actually checkAccess) was relying on some implicit
assumptions that aren't actually valid in all cases. When they're not,
just fall back to a slower but more correct implementation; when they
are, assert that the two implementations get the same answer. This
allows us to get rid of adjustAccessLevelForProtocolExtension (see
previous commit), though unfortunately not all of the associated hack.

The diff is bigger than I'd like because it includes moving functions
from NameLookup.cpp into Decl.cpp, but most of those didn't change.

- checkAccess only changed in the one if branch for protocols
- ValueDecl::isAccessibleFrom just added the assertion
- AbstractStorageDecl::isSetterAccessibleFrom did not change

No expected functionality change.
2018-07-23 16:36:16 -07:00

24 lines
854 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -o %t/Lib.swiftmodule %S/Inputs/attr_usableFromInline_protocol_hole_helper.swift
// RUN: %target-typecheck-verify-swift -I %t -verify-ignore-unknown
import Lib
func test(_ obj: PublicProtocol) {
obj.publicExtensionMethod()
obj.ufiExtensionMethod() // expected-error {{inaccessible}}
obj.internalExtensionMethod() // expected-error {{inaccessible}}
}
func test(_ obj: PublicImpl) {
obj.publicExtensionMethod()
obj.ufiExtensionMethod() // expected-error {{inaccessible}}
obj.internalExtensionMethod() // expected-error {{inaccessible}}
}
func test(_ obj: UFIImpl) {
obj.publicExtensionMethod() // This being accessible is the "hole".
obj.ufiExtensionMethod() // expected-error {{inaccessible}}
obj.internalExtensionMethod() // expected-error {{inaccessible}}
}