mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
24 lines
854 B
Swift
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}}
|
|
}
|