Commit Graph

5 Commits

Author SHA1 Message Date
Holly Borla
9ba481ad53 [Diagnostics] Clarify the wording of error_in_future_swift_version. 2024-03-01 12:05:51 -08:00
Becca Royal-Gordon
fca140211d Adopt warnUntilSwiftVersion for diag::witness_not_usable_from_inline_warn
This changes the wording of some diagnostics in Swift 4.2 and Swift 4 modes.
2023-07-19 13:08:12 -07:00
Pavel Yaskevich
46afe3bb41 [Diagnostics] NFC: Remove redundant "because" from witness_not_usable_from_inline 2018-12-20 00:53:51 -08:00
Jordan Rose
bda28ffb9b Require @usableFromInline on witnesses for non-type requirements too (#20485)
Follow-up to f33bf67dc9 for non-type requirements. We use non-type
witnesses for optimization purposes, so if we didn't enforce this we
might end up with something silently performing worse with parseable
interfaces than it would with swiftmodules. There's also a tricky case
where the client of the interface infers a different implementation:

    public protocol Foo {
      func foo()
    }
    extension Foo {
      public func foo() { print("default") }
    }
    @usableFromInline struct FooImpl: Foo {
      internal func foo() { print("actual") }
    }

There might be another solution to this in the future, but for now
this is the simplest answer. Like f33bf67dc9, it'll be a warning in
Swift 4 mode and an error in Swift 5 mode.

rdar://problem/43824161
2018-11-15 16:59:39 -08:00
Jordan Rose
f33bf67dc9 Require @usableFromInline on associated type witnesses
...when the protocol and the conforming type are not both public but
are both public-or-usableFromInline. It's possible to write inlinable
functions that depend on these types:

    public protocol HasAssoc {
      associatedtype Assoc
    }
    public func getAssoc<T: HasAssoc>(_: T) -> T.Assoc

    @usableFromInline struct Impl: HasAssoc {
      @usableFromInline typealias Assoc = Int
    }

    @inlinable func test() {
      let x: Int = getAssoc(Impl())
    }

rdar://problem/43824052
2018-11-06 17:00:46 -08:00