Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14526] Improve diagnostic on trying to call @usableFromInlinable method of internal protocol from @inlinable context #56878

Open
dnadoba opened this issue Apr 25, 2021 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@dnadoba
Copy link
Member

dnadoba commented Apr 25, 2021

Previous ID SR-14526
Radar rdar://problem/77164393
Original Reporter @dnadoba
Type Bug

Attachment: Download

Environment

Tested with Xcode 12.5 Beta 3 and swift-DEVELOPMENT-SNAPSHOT-2021-04-16-a

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: f55cec726812def89e1e0a8c7f35f382

Issue Description:

When calling an internal method which is marked with @usableFromInline inside a public @inlinable method but the Type on which the method is defined is internal and not marked with @usableFromInline, the compiler complains rightfully but gives an unhelpful error message.

Example code:

internal protocol InternalProtocol {}

extension InternalProtocol {
    @usableFromInline
    func internalMethod() {}
}

extension Int: InternalProtocol {}

@inlinable
public func publicMethod() {
    Int().internalMethod()
}

Error message: Instance method 'internalMethod()' is not '@usableFromInline' or public

``

The compiler should instead state that the problem is the protocol and not the method e.g.:
Protocol 'InternalProtocol' is internal and cannot be referenced from an '@inlinable' function
Protocol 'InternalProtocol' is not '@usableFromInline' or public

Example Project:
usableFromInline.zip

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants