Commit Graph

22 Commits

Author SHA1 Message Date
Alexis Laferrière
2d339c1260 Sema: Custom diagnostic for var decls referencing a restricted type
Replace the `here` part of the generic exportability diagnostic for
variables with: `in a property declaration marked public or in a
'@frozen' or '@usableFromInline' context`.

The full diagnostic now looks like:
```
error: cannot use struct 'ImportedType' in a property declaration marked
public or in a '@frozen' or '@usableFromInline' context;
'HiddenDependency' has been imported as implementation-only
```

This should be improved further to support implicitly exported memory
layouts in non-library-evolution and embedded.
2025-10-21 11:30:52 -07:00
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Allan Shortlidge
7e6e8ed7b5 Sema: Fully check the availability of wrappedValue.
Call `checkDeclarationAvailability()`, instead of just diagnosing
unavailability.
2024-10-25 16:50:20 -07:00
Alexis Laferrière
67694c2ab0 Sema: Report public conformances to non-publicly imported protocols
Exportability checking for non-public imports relies on classic
access-level checks for some of the work. However while conforming
to a local internal protocol from a public type is allow we should
disallow it for imported types, even when imported as internal.

Track exportability issues on conformances to protocols separately
from the general category. Use that information to improve the
diagnostics and report these issues for access-level on imports.

rdar://128420980
2024-06-12 14:48:46 -07:00
Alexis Laferrière
3d611e2a85 Sema: Simplify warning about @_implementationOnly being deprecated 2024-04-22 14:44:44 -07:00
Alexis Laferrière
0a25248e4b Test: Expect warning on deprecated @_implementationOnly in tests 2024-04-22 13:08:20 -07:00
Harlan Haskins
4ac34a40ea @retroactive conformance syntax and checking (#36068) 2023-10-20 14:27:03 -07:00
Alexis Laferrière
d221c1310f [Tests] Update tests using @_implementationOnly imports to use library-evolution 2023-07-05 16:20:42 -07:00
Slava Pestov
6934857417 Sema: Tweak associated conformance exportability diagnostics
Let's point out the associated type with a separate note, so
that we can diagnose other availability failures, such as
deprecation and OS version availability.
2020-11-09 23:43:51 -05:00
Slava Pestov
587a8dafb9 Sema: Don't forget to visit conformances introduced by non-generic types
Even if a nominal type does not have its own generic parameters,
we need to visit its conformances, because it might be defined
in a constrained extension or have a 'where' clause of its own.
2020-10-22 02:07:06 -04:00
Slava Pestov
fa50221d35 Sema: Use VarDecl::isLayoutExposedToClients() when checking VarDecl exportability 2020-10-22 01:45:56 -04:00
Slava Pestov
78d2cf2ee9 Sema: Teach ExportContext to compute whether we're inside an implicit declaration 2020-10-20 23:39:05 -04:00
Slava Pestov
8fd29a57cc Sema: Add some missing checks for where clauses on non-generic declarations
Access control, availability and exportability checking missed these
because of a baked-in assumption that getGenericParams() == nullptr
rules out the presence of a trailing where clause.
2020-10-16 00:34:56 -04:00
Artem Chikin
efdfceeb9b [Sema] Diagnose use of implementation-only property wrappers
We already ban all structs from declaring storage that comes from implementation-only imports. Until now we missed property wrappers, they were just dropped in deserialization.

Resolves rdar://problem/59403617
2020-04-10 11:19:42 -07:00
Jordan Rose
3b4bb1960d @_implementationOnly: fix over-eager checking for vars in extensions (#24629)
The logic I had here checked whether an extension used an
implementation-only type whenever there was a declaration within that
extension that needed checking...but unfortunately that included not
just PatternBindingDecls (whose access is filtered at a later step)
but things like IfConfigDecls (#if). Change this to only check
signatures of extensions with ABI-public members, something that is
tested once when visiting an ExtensionDecl.

Additionally, skip AccessorDecls entirely, since they'll be tested
as part of the corresponding subscript or var. This saves a duplicate
diagnostic.

rdar://problem/50541589
2019-05-16 13:13:48 -07:00
Jordan Rose
a4606111af Adjust the implementation-only diagnostics to sound more similar
John and I had slightly different styles when adding these; better
to keep them in harmony.
2019-04-11 16:33:23 -07:00
Jordan Rose
bcde0f8292 [test] Add additional implementation-only conformance test cases
...suggested by Brent and Slava. Thanks, both!
2019-04-11 11:07:52 -07:00
Jordan Rose
7006aa0b9f Check for use of implementation-only conformances in inlinable code
This includes both the types and the values (generic functions, etc)
used in the inlinable code. We get some effectively duplicate
diagnostics at this point because of this, but we can deal with that
at a future date.

Last part of rdar://problem/48991061
2019-04-10 11:09:07 -07:00
Jordan Rose
5c27568738 Check assoc types for conformances from implementation-only imports
Okay, strictly we're checking the "signature conformances" of a newly-
declared conformance, but that wouldn't have fit on one line. This is
making sure that we don't have a requirement on an associated type (or
on the conforming type) that can only be satisfied using a conformance
in an implementation-only import.
2019-04-10 11:09:07 -07:00
Jordan Rose
519fa00adc Check signatures for conformances from implementation-only imports
These also create a dependency on the implementation module, even if
both the type and the protocol are public. As John puts it, a
conformance is basically a declaration that we name as part of another
declaration.

More rdar://problem/48991061
2019-04-10 11:09:07 -07:00
Jordan Rose
4972351b3c Fix implementation-only checking for members of frozen structs/classes
...which I had exactly backwards.
2019-04-05 20:10:10 -07:00
Jordan Rose
a9b0a6661a Implementation-only import checking for types used in decls
Based on the existing access checker for types used in decls. There's
a common skeleton here but we can't seem to get it out, so for now
add a third DeclVisitor to this file. On the plus side, checking this
alongside access is an easy way to make sure everything gets checked.

Part of rdar://problem/48991061
2019-04-05 20:10:10 -07:00