With a few modifications:
- Changing computed get-only properties into 'let's breaks resilience in other ways we need to fix independent of key path resilience
- Fix the tests not to ask for impossible lib-before--client-after compatibility for changes that add API
Builds on 36eae9d4f6 to emit a message instead of just trapping
when a switch over a non-frozen enum ends up not matching anything.
If the enum is known to be an @objc enum, the message is
unexpected enum case 'MyEnum(rawValue: -42)'
and if it's anything else (a Swift enum, a tuple containing enums,
whatever), it's a more opaque
unexpected enum case while switching on value of type 'MyEnum'
The reason for this is to avoid calling String(describing:) or
String(reflecting:) an arbitrary value when the enum might conform to
CustomStringConvertible and therefore /itself/ have a switch that's
going to fall off the end. By handling plain @objc enums (using a
bitcast), we've at least covered the 90% case.
rdar://problem/37728359
In theory there could be a "fixed-layout" enum that's not exhaustive
but promises not to add any more cases with payloads, but we don't
need that distinction today.
(Note that @objc enums are still "fixed-layout" in the actual sense of
"having a compile-time known layout". There's just no special way to
spell that.)
We're okay with saying this is a binary-breaking change, and its
presence in these tests is interfering with testing other things.
rdar://problem/36932507
Since field offsets are now encoded after generic parameters, it
is useful to validate that using generic parameter metadata is now
more resilient in presence of new fields.
We don't want @_fixed_layout to apply to static properties, or you
get fun consequences like not being able to change static stored
properties defined in extensions of imported types to computed.
This used to fail because the property initializer had a public
symbol and was not serialized, so the struct's inlinable initializer
would reference it directly. Therefore, removing the property
initializer would break the client, which had inlined the
struct initializer.
Also pass flags to disable SIL optimization passes when merging
modules, since that's completely unnecessary.
An evolution test that used to fail with WMO disabled now passes
with this change.
FIxes <rdar://problem/18913977>.
Also pass flags to disable SIL optimization passes when merging
modules, since that's completely unnecessary.
An evolution test that used to fail with WMO disabled now passes
with this change.
FIxes <rdar://problem/18913977>.
We were inlining the size and alignment, which was not correct.
This was the cause of a long-standing ASAN failure in some
library evolution tests.
Fixes <rdar://problem/24540778>.
Also pass flags to disable SIL optimization passes when merging
modules, since that's completely unnecessary.
An evolution test that used to fail with WMO disabled now passes
with this change.
FIxes <rdar://problem/18913977>.
Subclasses of resilient and generic classes now dynamically initialize
the vtable by copying the vtable from the superclass, and filling in
method overrides.
This means we no longer emit references to the base class's methods
statically, which allows the base class to add or remove an overload
resiliently without invalidating vtables of subclasses already
compiled.
Note that we still don't know how to slide subclass metadata when
the size of superclass metadata changes, so we can't resiliently
add or remove vtable entries yet.
One minor revision: this lifts the proposed restriction against
overriding a non-open method with an open one. On reflection,
that was inconsistent with the existing rule permitting non-public
methods to be overridden with public ones. The restriction on
subclassing a non-open class with an open class remains, and is
in fact consistent with the existing access rule.
If a thunk is referenced from two different functions, the thunk inherits
the fragile attribute from the first function that forced it to be emitted.
This is wrong, in case the first function might not be fragile, while
the second one is. Copying the fragile attribute to an existing thunk when
checking if it has already been emitted is also wrong, because the thunk
might reference another thunk, and so on.
The correct fix is to have SIL serialization serialize the transitive
closure of all fragile functions and thunks referenced from fragile
functions. Re-work SIL function serialization to use a worklist so that
we can do this.
Part of https://bugs.swift.org/browse/SR-267.
A transparent function might be deserialized and inlined into a function
in another module, which would cause problems if the function referenced
local functions.
Previously we would force local functions to have public linkage instead,
which worked, but was not resilient if the body of the transparent
function changed in the module that contained it.
Add a library evolution test ensuring that such a change is resilient
now.
Part of https://bugs.swift.org/browse/SR-267.
This test ensures that the runtime correctly instantiates resilient conformances,
and that IRGen emits the correct metadata, allowing a conformance that was
compiled before a new requirement was added to present a default implementation
of this requirement.
For now, this runs with --no-backward-deployment, so we only test before/before,
before/after and after/after cases.
Getting after/before working is also an expected capability here, but requires
IRGen witness table emission to know which requirements were satisfied by
defaults, so that they can be dropped if they appear at the end of a witness
table. In turn, this requires serializing SILDefaultWitnessTables. This will
be added in a subsequent patch.
In addition to fixing the above case, I need to write additional tests and
possibly fix bugs related to more elaborate cases involving generics, as well as
default witnesses for properties and subscripts.