Commit Graph

43 Commits

Author SHA1 Message Date
Slava Pestov
feea84dc6c Sema: Ban uncallable protocol member operators
Member operators of concrete nominal types must declare at least
one parameter with that type, like

```
struct S {
  static func +(lhs: S, rhs: Int) -> S {}
}
```

For protocol member operators, we would look for a parameter of type
`Self`, or an existential type `any P`. While the latter was
consistent with the concrete nominal type case, it was actually
wrong because then the resulting interface type does not give the
type checker any way to bind the `Self` type parameter.

There were two existing test cases that now produce errors, which I
believe is now correct. While this is technically a source break,
because these bogus operators seemingly cannot be witnessed or called,
such a protocol probably had no conforming types.

Fixes https://github.com/apple/swift/issues/73201.
2024-04-23 15:28:16 -04:00
Allan Shortlidge
7dc313f1be NFC: Fix tests that mistakenly rely on unavailable stored properties.
Preparation for rdar://107449845
2023-04-04 08:52:39 -07:00
Xi Ge
0567a9b142 ABI checker: include SPI group names in ABI descriptor files 2022-06-04 21:45:14 -07:00
Xi Ge
e46b5f5966 ABIChecker: for decls with @_originallyDefinedIn, use original module names in ABI descriptors
rdar://93615410
2022-06-03 22:41:43 -07:00
Xi Ge
a870b06055 ABI Checker: include mangled names in ABI descriptor files
Previously, we use USR as a delegate for mangled name. However, USR won't incorporate name changes made
by attributes like @_silgen_name. Instead, we should add a dedicated field for canonical mangled names.

rdar://84202064
2021-10-20 20:58:00 -07:00
Xi Ge
1a44db3dcf ABIChecker: exclude decls with the @_alwaysEmitIntoClient attribute
Removing or updating @_alwaysEmitIntoClient functions are never ABI-breaking, thus
we should exclude them from the symbol set for ABI stability checking.

rdar://67883661
2020-08-27 10:58:48 -07:00
Xi Ge
6dd41f44db ABI checker: exclude unavailable decls from ABI descriptors
Framework authors usually have different schemes for different deployment
targets. We should exclude platform-unavailable ABIs from the Json file so
developers will only be warned of the breakages that are relevant to the current
scheme.

rdar://54273296
2019-08-28 16:02:03 -07:00
Xi Ge
6374d3676a ABI/API checker: diagnose ObjC name changes as breakages
rdar://54797695
2019-08-28 11:56:03 -07:00
Stephen Canon
ca1e808bde Replace all 9999 availability in non-stdlib tests. (#26109)
Replace all 9999 availability in non-stdlib tests with the appropriate platform availability.
2019-07-12 14:48:37 -04:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Xi Ge
7b445c3c98 api-digester: keep track of the introduced platforms and language versions for all APIs
These fields will be used to diagnose the missing of available
attributes for newly added APIs.

rdar://51089418
2019-05-23 17:23:30 -07:00
Xi Ge
747d9dfe3b swift-api-digester: add a field to indicate whether a decl or a conformance is ABI placeholder.
ABI placeholders are decls with attribute '@available(macOS 9999, iOS
9999, tvOS 9999, watchOS 9999, *)'. The diagnostics phase could be
forgiving for ABI breakages on these decls since they are added
recently. This patch adds a new flag to the json file indicating whether
a declaration or a conformance is an ABI placeholder. The checking of
placeholder is transitive, meaning a decl is an ABI placeholder if its
decl context is one.

rdar://49502365
2019-04-02 10:45:27 -07:00
Xi Ge
588391eb7e swift-api-digester: avoid synthesizing nominal types from the same module.
Synthesizing types from the same module may bring back types that are
not part the ABI/API, leading to false positives.

Resolves: SR-9372
2018-12-12 11:26:07 -08:00
Xi Ge
da4fc05a0e swift-module-digester: model ProcotolConformance as a standalone node.
Modeling ProtocolConformance as a standalone node allows us to keep
track of all type witnesses and re-use existing matching algorithm
to diagnose type witness changes.
2018-10-25 15:14:17 -07:00
Xi Ge
3f58f1e6d3 swift-module-digester: add a flag to include Swift decls specifically.
This flag allows us to diagnose the overlay part exclusively without digesting
the entire SDK framework.
2018-10-09 12:57:22 -07:00
Xi Ge
8a769a0460 swift-module-digester: include non-resilient class decls when checking ABI stability. 2018-10-05 14:48:00 -07:00
Xi Ge
9cfc0dee79 swift-module-digester: keep track of whether a property/subscript has didSet and willSet. 2018-10-05 13:02:31 -07:00
Xi Ge
58b3c2173f swift-module-digester: use getEffectiveAccess() to get accessibility when checking ABI stability.
This allows us to include internal decls with @usableFromInline attribute, whose stored property
changes can effect ABI.
2018-10-03 14:06:53 -07:00
Xi Ge
b3614a4b6f swift-module-digester: include unavailable variables with fixed layout order when checking ABI stability. 2018-10-01 15:02:41 -07:00
Xi Ge
9fcc59bcaf swift-module-digester: include operator declarations in the module dump.
Their changes should have no impact on ABI, but can be source-breaking.
2018-10-01 12:28:54 -07:00
Xi Ge
a6f886c8b7 swift-module-digester: include operator overloads in the module dump. 2018-09-28 17:41:52 -07:00
Xi Ge
aa1ae1607a swift-module-digester: keep track of whether a VarDecl is let. 2018-09-27 12:52:58 -07:00
Xi Ge
52e05e1495 swift-module-digester: always canonicalize super class types. 2018-09-27 11:16:15 -07:00
Xi Ge
c0556cc4dd swift-module-digester: keep track of whether a decl overrides in the dump. 2018-09-25 11:04:55 -07:00
Xi Ge
a64ae05454 swift-module-digester: keep track of whether a protocol member is a requirement. 2018-09-23 08:25:07 -07:00
Xi Ge
01afc3395e swift-module-digester: include SubscriptDecl in the Json dump.
We model SubscriptDecl as an abstract function decl with a flag indicating
whether setter is defined.
2018-09-21 17:00:52 -07:00
Xi Ge
6500e321aa swift-module-digester: include AssociatedTypeDecl in module digests. 2018-09-21 14:04:21 -07:00
Xi Ge
6cc5855bcf swift-module-digester: when we have multiple extensions to a single external type, we should synthesize only one type decl node. 2018-09-20 16:13:40 -07:00
Xi Ge
971755d5a3 swift-module-digester: under ABI checking mode, include private decls with fixed binary order. 2018-09-19 12:10:00 -07:00
Xi Ge
05e15927a3 swift-module-digester: diagnose reordering of members in a fixed layout type under ABI mode. 2018-09-19 09:36:09 -07:00
Xi Ge
b78c9eb328 swift-api-digester: ensure the sdk-dump includes extensions from types of other modules. rdar://42266041 2018-07-20 17:26:22 -07:00
Xi Ge
20a48e5adb swift-api-digester: teach the tool to serialize USRs for nominal type. (#15463)
This allows us to map back from a type to the declaration in the dump,
so that we can perform more fine-grained analysis like whether a string
has been changed to string enum.
2018-03-23 16:29:54 -07:00
Xi Ge
f66dd8e59c swift-api-digester: keep track of type declarations with fixed layout. (#14991)
We need special logic to check abi-stability for decls with fixed
layout.
2018-03-05 15:08:06 -08:00
Xi Ge
66bb9ce4ba swift-api-digester: teach the tool to serialize conforming protocols. (#14923) 2018-03-01 15:57:59 -08:00
Xi Ge
60bd6b91e0 swift-api-digester: serialize and de-serialize whether a parameter has a default argument.
Removing default arguments can be source-breaking.
2018-02-27 13:18:58 -08:00
Xi Ge
1aa7816956 swift-api-digester: teach the tool to serialize and de-serialize generic requirements.
The tool should diagnose the change of extension's applicability since
such change can be source-breaking. We need first to support the
requirements in the module dump. Currently, we decorate each
member defined in extension with a field called extension info. The
field will keep track of the generic requirements that need to be satisfied
for this decorated member to be applicable. This patch doesn't implement the checking
of requirements change.
2018-02-23 15:30:57 -08:00
Xi Ge
87a0cfb910 swift-api-digester: teach the tool to serialize/deserialize super class Usrs. rdar://32778228
This can help us eliminate false positives when we report removed
declarations are actually moved to a newly-introduced super class.
2017-06-21 19:47:07 -07:00
Xi Ge
368247604f swift-api-digester: consider name alias type as a standalone node kind. (#5701)
* swift-api-digester: consider name alias type as a standalone node kind.

* [test] Update the swift-api-digester dump for stdlib to honor new name alias node.
2016-11-09 16:44:27 -08:00
Xi Ge
4475b07613 swift-api-digester: teach the tool to keep track of ownership attributes. 2016-10-27 11:55:24 -07:00
Xi Ge
b8ee47c80b [sdk-api-digester] Record whether a value decl is static.
Changing a static member to a non-static one, or the other way around,
can be source-breaking.
2016-10-21 14:08:39 -07:00
Xi Ge
87d22acb67 [swift-api-digester] Ensure we exclude decls of low accessibility from the API comparison. (#5382) 2016-10-20 12:02:37 -07:00
Xi Ge
55f194b3ef api-digester: in module dump, record whether a func decl is mutating. 2016-10-13 11:57:42 -07:00
Xi Ge
ab9b035dbc [test] api-digester: add a test to ensure the dumped module content is expected. 2016-10-13 11:53:07 -07:00