Commit Graph

131 Commits

Author SHA1 Message Date
Joe Groff
38e339db06 Enable key path resilience test suite.
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
2018-07-30 10:09:40 -07:00
Slava Pestov
e6c4a3825e Update a few tests to pass with -swift-version 4 2018-06-19 23:23:20 -07:00
Joe Groff
6154c0d2b9 Test cases for key path resilience. 2018-06-19 13:51:51 -07:00
Arnold Schwaighofer
c7d4bd962d Add resilience tests 2018-05-22 08:59:00 -07:00
Jordan Rose
6d30272bfd Merge pull request #14382 from jrose-apple/unknown-case
Implementation for `@unknown default`
2018-04-10 11:19:53 -07:00
Slava Pestov
ab6f20ad40 Add library evolution tests for re-ordering protocol requirements 2018-04-06 15:41:08 -07:00
Jordan Rose
db61a1c846 [test] '@unknown' should be ignored post-Sema 2018-04-05 16:35:14 -07:00
Jordan Rose
9be6519f5a [SILGen] Show a message when an unexpected enum value is switched on (#15614)
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
2018-04-03 11:21:36 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Jordan Rose
d150f96967 Merge pull request #14945 from jrose-apple/frozen-enums
Implementation for /most/ of SE-0192 (frozen and non-frozen enums)
2018-03-21 11:06:31 -07:00
Jordan Rose
9034ba617b Ban @_fixed_layout on enums in favor of @_frozen
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.)
2018-03-20 14:49:10 -07:00
Arnold Schwaighofer
5c827017f8 Add evolution test case for resiliently reordering enum cases 2018-03-20 13:19:56 -07:00
Jordan Rose
d8104e7e43 Evolution tests: Don't bother testing changing a class's superclass (#15000)
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
2018-03-06 08:48:49 -08:00
Jordan Rose
f9299e711c [test] rth: Use dynamic linking to properly test backwards-deployment (#14447)
The added test worked before as well; it's to make sure I didn't break
the existing behavior.
2018-02-08 17:14:10 -08:00
Pavel Yaskevich
6a45971c3c [IRGen/Resilience] Add a test case for rdar://problem/36560486
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.
2018-01-29 23:25:29 -08:00
Slava Pestov
8f9f7afc55 AST: Static properties of fixed-layout types are resilient
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.
2018-01-21 01:31:44 -08:00
Slava Pestov
bfe24472ea SIL: Use PublicNonABI linkage for default argument generators in Swift 4 mode
Fixes <rdar://problem/33767513>, <https://bugs.swift.org/browse/SR-5647>.
2018-01-14 22:59:41 -08:00
Slava Pestov
38baacae48 Evolution: Add test for adding a property initializer to a struct with an inlinable initializer
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.
2018-01-12 17:08:01 -08:00
Slava Pestov
82d0af2ba8 Evolution: Tests for class resilience 2018-01-03 22:12:43 -08:00
Slava Pestov
fb2a6d2025 SILOptimizer: Fix convert_function -> apply peephole for metatype conversions
Fixes <rdar://problem/35492775>.
2017-11-13 22:10:14 -08:00
Arnold Schwaighofer
76f538a684 Disable test_superclass_methods.swift and test_superclass_properties.swift
rdar://35492775
2017-11-12 06:24:12 -08:00
Slava Pestov
2146383697 SILGen: Resilient method dispatch thunks 2017-11-11 16:31:53 -08:00
Slava Pestov
c28ade7077 Driver: Pass the new -sil-merge-partial-modules flag
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>.
2017-09-18 21:18:07 -07:00
Slava Pestov
94be90bea3 Revert "Driver: Pass the new -sil-merge-partial-modules flag"
This reverts commit 86d241b38e.
2017-09-15 18:37:54 -07:00
Slava Pestov
86d241b38e Driver: Pass the new -sil-merge-partial-modules flag
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>.
2017-09-15 00:24:52 -07:00
Slava Pestov
9c6cd08a9b IRGen: Fix lowering of alloc_ref for resilient classes
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>.
2017-09-15 00:24:52 -07:00
Slava Pestov
7ea93d9ed0 Revert "Preserve SIL when merging modules" 2017-09-14 19:04:18 -07:00
Slava Pestov
ef583499a9 Driver: Pass the new -sil-merge-partial-modules flag
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>.
2017-09-14 15:54:06 -07:00
Slava Pestov
8de76da8e9 Add library evolution test for part of vtable resilience
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.
2017-08-24 19:15:43 -07:00
John McCall
afdda3d107 Implement SE-0117.
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.
2016-08-02 07:46:38 -07:00
Chris Lattner
87db7b4cf2 update validation tests to modern syntax. 2016-07-02 17:10:49 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Slava Pestov
1872a4ee28 AST: @_versioned types and storage are resilient
Use getEffectiveAccess() instead of getFormalAccess() in a few places.

This should be NFC without -enable-resilience.
2016-04-01 15:30:33 -07:00
Slava Pestov
49c54870c1 Serialization: Auto-linking recursively walks modules imported from -sil-serialize-all modules 2016-04-01 12:21:36 -07:00
Slava Pestov
37c461cc59 Serialization: Serialize shared thunks referenced from fragile functions
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.
2016-03-24 00:50:40 -07:00
Slava Pestov
3e2d7d40e0 SIL: Serialize bodies of local functions inside @_transparent functions
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.
2016-03-24 00:50:39 -07:00
Slava Pestov
c846ca3939 Add library evolution tests for constructor, computed property, subscript default implementations 2016-03-11 11:27:06 -08:00
Ben Langmuir
5ca1c72381 Revert "Add library evolution tests for constructor, computed property, subscript default implementations"
This reverts commit a504d57e85.
2016-03-10 11:37:52 -08:00
Slava Pestov
a504d57e85 Add library evolution tests for constructor, computed property, subscript default implementations 2016-03-09 22:55:53 -08:00
Max Moiseev
cf4bafe9e3 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-03 13:22:03 -08:00
Slava Pestov
6bf9ab19ff Add preliminary library evolution test for resiliently adding a new protocol requirement
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.
2016-03-03 07:37:00 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Daniel Duan
2bc78b8c09 [stdlib] update for 'inout' adjustment (SE-0031) 2016-02-26 12:02:29 -08:00
Max Moiseev
40b1a0b7e0 [stdlib] all sorts of require renamed back to precondition 2016-02-19 18:21:29 -08:00
Dmitri Gribenko
0f36bec31f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-18 16:41:35 -08:00
Dmitri Gribenko
65d840c0ae stdlib: lowercase cases in Optional and ImplicitlyUnwrappedOptional 2016-02-18 00:40:33 -08:00
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
Luke Larson
f53db0ebd3 [rth] Add resilience test helper utility 2016-02-16 18:52:34 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Dmitri Gribenko
7e9b8fe325 Fix Evolution tests in the mode when StdlibUnittest is built with -sil-serialize-all 2016-02-13 18:37:27 -08:00