Surprising warning for non-@usableFromInline protocol witness

I was updating some tests and noticed this strange warning.

/Users/varun/foss-swift/swift/test/ModuleInterface/access-filter.swift:130:8: warning: instance method 'requirement()' should be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProto'
  func requirement() {}
       ^

The test also has a FIXME:

  // FIXME: Is it okay for this non-@usableFromInline implementation to satisfy
  // the protocol?

Why would this not be okay? Should we just remove the FIXME? I imagine we can't change this to an error anyways as that would break source compat.

Presumably the sense in which it would not be ok is that there is nothing to indicate that this method is a part of the ABI of the module, but it appears to be being used as one.

1 Like

Basically yeah. Normally adding a protocol conformance can’t expose any private or internal members as API, but there was a hole in access checking around protocol extension members. I don’t actually remember the specifics for @usableFromInline but I assume it’s that once you accept the former breakage, you now question whether the ABI-ness should be marked in some way.

1 Like
Terms of Service

Privacy Policy

Cookie Policy