Commit Graph

116 Commits

Author SHA1 Message Date
Arnold Schwaighofer
11c665715c Opaque types require the next Swift runtime
rdar://50503909
2019-05-08 09:50:53 -07:00
Arnold Schwaighofer
a793dfb451 Respect resilience when specializing opaque type archetypes 2019-05-01 09:31:07 -07:00
Arnold Schwaighofer
e113ef8c93 Add a mode to test implicit dynamic with private imports 2019-03-20 14:34:01 -07:00
Slava Pestov
b9bda84e28 SIL: Fix calls of @_weakLinked functions from serialized SIL
We have to set the SILFunction's 'weakLinked' flag in the defining
module too, so that it can be serialized. Otherwise when we
deserialize it we are not weak linking calls to the function.
2019-02-22 21:10:18 -05:00
Slava Pestov
71ab1bbe77 IRGen: Fix isResilientConformance() check
If the conforming type is generic, we have to treat the conformance as
resilient if it is defined outside of the current module.

This is because it can resiliently change from being non-dependent
to dependent.
2019-02-20 20:00:46 -05:00
Arnold Schwaighofer
c711181f83 Merge pull request #21256 from aschwaighofer/irgen_conditionally_test_weak_enum_cases
IRGen: Conditionally test weakly linked enum cases
2018-12-13 08:06:47 -08:00
swift-ci
f453092465 Merge pull request #21152 from compnerd/library-prefix-suffix 2018-12-12 12:45:21 -08:00
Arnold Schwaighofer
5ae00ee2a2 IRGen: Conditionally test weakly linked enum cases
rdar://46438568
2018-12-12 11:18:12 -08:00
Arnold Schwaighofer
0c01906218 Address review feedback 2018-12-12 08:22:09 -08:00
Saleem Abdulrasool
b212229db1 test: add and use prefix substitutions for libraries
The naming convention is different on Windows than on Unix-like
environments.  In order to follow the convention we need to substitute
the prefix and the suffix.  Take the opportunity to rename the
`target-dylib-extension` to the CMake-like variable
`target-shared-library-suffix` and introduce
`target-shared-library-prefix`.  This helps linking the test suite
binaries on Windows.
2018-12-11 15:56:06 -08:00
Arnold Schwaighofer
2f34bdcbbc IRGen: Don't hoist metadata for weakly linked types
rdar://46438608
2018-12-11 13:15:33 -08:00
Erik Eckstein
5c17f0f6f8 SILCombine: peephole to propagate resilient enum cases
Basically the pattern to optimize is:
    inject_enum_addr %stackloc, #SomeCase
    switch_enum_addr %stackloc ...

This works even if the enum is resilient and the case does not have a payload. As long as we don't have opaque values in SIL we need this peephole to optimize the pattern.
This change fixes the code generation for Float.rounded().

rdar://problem/46353885
2018-12-10 16:14:15 -08:00
Slava Pestov
a6f4c8a60d Evolution: Code review feedback for backward deployment tests 2018-12-04 15:13:44 -05:00
Slava Pestov
f5b448f75a Evolution: Add backward deployment tests 2018-12-03 20:36:03 -05:00
Slava Pestov
57c4dc3831 Evolution: Stylistic fixes for tests 2018-12-03 20:36:03 -05:00
Slava Pestov
a5abb9d7ed Evolution: Add some tests for @_fixed_layout classes
@_fixed_layout classes have resilient vtables now, so we can add and
re-order methods.

Removing overrides is not legal though because they are subject to
devirtualization.
2018-11-29 23:20:02 -05:00
Slava Pestov
9af20c71f0 Evolution: Clean up superclass insertion tests a bit
- We don't want to support changing a root class of a class, so don't
  pretend that works. Some of these tests got removed recently in
  d8104e7e43 but one still remained.

- For the tests that insert a non-root superclass in the inheritance
  hierarchy, also test calling a method of the derived class. This
  works now that we no longer hardcode vtable offsets and instead use
  dispatch thunks.
2018-11-29 23:20:02 -05:00
Slava Pestov
547746719a Evolution: Test adding a new convenience init to an open class 2018-11-28 12:39:04 -05:00
Slava Pestov
e24c4c3f63 Evolution: Test that adding willSet/didSet to a stored property works 2018-11-28 12:39:04 -05:00
Slava Pestov
6028912131 Evolution: Test that adding or removing weak/unowned is a resilient change 2018-11-28 12:39:04 -05:00
Slava Pestov
890bf2eeed Evolution: Test adding a class deinit 2018-11-28 12:39:04 -05:00
Slava Pestov
16fccd6a51 Evolution: Test moving methods between class/struct and extension 2018-11-28 12:39:04 -05:00
Slava Pestov
0781ab85b6 Evolution: Add test changing a lazy property a computed property with a mutating getter 2018-11-28 12:39:04 -05:00
Slava Pestov
62d44a3a4f Evolution: Rename some tests in preparation for testing @_fixed_layout classes more 2018-11-28 12:39:04 -05:00
Slava Pestov
0e1b62dcad SILGen: Don't emit or reference property descriptors for overrides
We want removing a property override to be a resilient change, so
keypaths should not reference them, preferring to reference the
base declaration instead.
2018-11-16 23:18:30 -05:00
Slava Pestov
0a8ee10621 AST: Refactor AbstractStorageDecl::getAccessStrategy() for keypath resilience
Instead of passing in a DeclContext, which we don't have when emitting a keypath
accessor, pass in a ModuleDecl and ResilienceExpansion.

Keypaths now work well enough in inlinable contexts that we can check in an
end-to-end resilience test.
2018-11-16 23:18:30 -05:00
Slava Pestov
5243cc718d Evolution: Compare symbols before and after
A resilient change should not *remove* previously-public symbols.

Note that currently, the test_superclass_properties test does not
meet this critierion, because we always emit keypath property
descriptors, even when the property is an override. Fixing this
is a larger change that I'll address in a follow-on PR, so for now
I'm just going to disable the symbol check for this one test only.

Part of <rdar://problem/40432647>.
2018-11-15 19:55:46 -05:00
Slava Pestov
517f37088c Evolution: Tweak existing tests to not remove public symbols 2018-11-15 14:55:44 -05:00
Slava Pestov
57979d1f7c IRGen: Use @_weakLinked to test backward deployment of resilient protocols
Get the attribute working for more link entity kinds, which addresses
all the FIXME:s in the original test case.

Now the protocol resilience tests can be updated to use @_weakLinked
for all newly-added protocol requirements and default implementations.

This allows the tests to pass in the backward deployment test scenario
as well.

Eventually this will be based on availability instead of a special
attribute.

This completes <rdar://problem/29888071>.
2018-10-31 19:55:01 -04:00
Doug Gregor
3ed69d4ee7 [Runtime] Instantiate witness tables even with no resilient witnesses.
The witness table for an empty, resilient protocol might need to be
instantiated, if a newer version of the protocol contains defaulted
associated type requirements. In such cases, we would either fail to
instantiate or assert in the runtime. Replace the assertion with a
proper check (to require instantiation in such cases) and cope with
filling in defaults even when the provided generic witness table has
no resilient witnesses.
2018-09-19 14:00:28 -07:00
Doug Gregor
fb62977c2b [IRGen] Emit default associated conformance witnesses.
For a resilient protocol that has defaulted associated types, emit
default associated conformance witnesses that compute associated
conformances based on that default witness.

This completes the implementation of resilience protocols that
add new, defaulted associated types, rdar://problem/44167982.
2018-09-19 10:56:20 -07:00
Doug Gregor
2ef9363bd1 [ABI] Add default associated type witnesses to resilient protocols.
When an associated type witness has a default, record that as part of
the protocol and emit a default associated type metadata accessor into the
default witness table. This allows a defaulted associated type to be
added to a protocol resiliently.

This is another part of rdar://problem/44167982, but it’s still very
limiting because the new associated type cannot have any conformances.
2018-09-15 22:04:46 -07:00
Doug Gregor
350391db9d [ABI] Use associated type descriptors for generic parameter references.
Generic parameter references, which occur in generic requirement
metadata, were hardcoding associated type indices. Instead, use
relative references to associated type descriptors and perform the
index calculation at runtime.

Associated types can now be reordered resiliently (without relying on 
sorting), which is the first main step toward rdar://problem/44167982.
2018-09-14 20:59:03 -07:00
Slava Pestov
3808ae0d58 IRGen: Use method lookup function for resilient super method calls
Fixes <https://bugs.swift.org/browse/SR-3928>, <rdar://problem/31411193>.
2018-09-07 21:57:16 -07:00
Slava Pestov
b7449d5621 IRGen/Runtime: Method override descriptors 2018-09-04 14:46:34 -07:00
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