Commit Graph

1325 Commits

Author SHA1 Message Date
Doug Gregor
b85be28611 [Runtime] Print demangled names in conditional conformances warning. 2017-12-19 10:30:00 -08:00
Doug Gregor
ffb0d55b35 Eliminate extraneous uses of -enable-experimental-conditional-conformances 2017-12-18 22:56:22 -08:00
Doug Gregor
5c831a71ee Revert "[SE-0143] Put conditional conformances behind an "experimental" flag."
This reverts commit b59c30c1af.
2017-12-18 22:54:31 -08:00
Doug Gregor
7f09b36015 [Runtime] Warn about dynamically querying conditional conformances.
Rather than silently returning "false" when we are unable to attempt
to satisfy a conditional conformance at runtime, produce a runtime
warning first, to note to users that this behavior is incorrect and
will change in the future.
2017-12-18 22:52:39 -08:00
Doug Gregor
31723be232 Merge pull request #13264 from DougGregor/se-0143-better-fail-than-crash
[Runtime] Always fail to find a conditional conformance at runtime.
2017-12-04 21:50:25 -08:00
Doug Gregor
4f8edeb913 [Runtime] Always fail to find a conditional conformance at runtime.
Proper evaluation of conditional conformances at runtime (e.g., as part of
dynamic casting) is too large to tackle in the Swift 4.1 timeframe. For now,
record that a conformance is conditional in the protocol conformance record,
and always return "does not conform" to such types.

Fixes rdar://problem/35761301.
2017-12-04 16:51:52 -08:00
Pavel Yaskevich
6ca3d3fc72 Merge pull request #13138 from xedin/rdar-35702810
[CSSolver/SILGen] Fix solver to support function conversion with collection subtyping
2017-12-04 15:05:37 -08:00
Pavel Yaskevich
515520e524 [CSSolver/SILGen] Fix solver to support function conversion with collection subtyping
Fix collection subtyping relation in function argument position
by emiting special re-abstraction thunk with collection upcast.

Resolves: rdar://problem/35702810
2017-11-30 16:47:18 -08:00
Ben Cohen
dcab9493ae Removed some warnings (#12753) 2017-11-30 15:12:56 -08:00
Joe Groff
fb2fc93cbf IRGen: Followup fixes for handling subclasses of mixed-mode classes with missing ivars.
Following up on the fixes for rdar://problem/35330067. If a class inherits a class from another module with missing fields, we need to treat its size and alignment as opaque, just like the base class itself. We also need to lay out such  class at runtime, since we don't know the size, alignment, or field offsets at compile time; relying on the ObjC runtime alone will slide the ivar offsets, but not the Swift instance size and alignment. Fixes rdar://problem/35747485.
2017-11-29 19:21:36 -08:00
Arnold Schwaighofer
66d0daadff mixed_mode_class_with_missing_properties.swift: This test fails on i386 with an unoptimized stdlib
XFAIL it to unblock bots.

rdar://35747485
2017-11-29 10:22:45 -08:00
Arnold Schwaighofer
7a5a1e4535 Change test case to use LifetimeTracked as per review request 2017-11-28 20:01:00 -08:00
Arnold Schwaighofer
54f10c17d6 Merge pull request #13121 from aschwaighofer/fix_closure_capture_leak
IRGen: Indirect_In_Constant inside of partial apply forwarders is now…
2017-11-28 19:00:40 -08:00
swift-ci
cdab55a202 Merge pull request #13124 from DougGregor/se-0143-experimental-flag 2017-11-28 16:59:27 -08:00
Doug Gregor
b59c30c1af [SE-0143] Put conditional conformances behind an "experimental" flag.
Conditional conformances aren't quite ready yet for Swift 4.1, so
introduce the flag `-enable-experimental-conditional-conformances` to
enable conditional conformaces, and an error when one declares a
conditional conformance without specifying the flag.

Add this flag when building the standard library (which will vend
conditional conformances) and to all of the tests that need it.

Fixes rdar://problem/35728337.
2017-11-28 16:01:51 -08:00
Jordan Rose
5096801d7c Merge pull request #13114 from jrose-apple/host-with-the-most
Accept that swiftc should infer the running OS as the target
2017-11-28 15:48:47 -08:00
Arnold Schwaighofer
cac837548d IRGen: Indirect_In_Constant inside of partial apply forwarders is now assumed to be @guaranteed
Since closure captures are now @guaranteed. Previous to this fix we
assumed @owned which matched the old closure capture convention.

Neither version is proper of course:

The proper fix, I will follow up with, is that when the large loadable
types pass lowers @guaranteed/@owned to @indirect_in_constant it should
disambiguate to @indirect_in_constant_guaranteed/owned.

rdar://35674625
2017-11-28 15:18:17 -08:00
Jordan Rose
2818969c23 [test] Accept that swiftc should infer the running OS as the target
Specifically, this is about the /version/ of the running OS.
Previously, this was only autodetected for the interpreter, with the
compiler defaulting to the earliest version of macOS supported by
Swift (10.9); picking the current running OS seems more useful. LLVM
changed their default behavior recently, so this doesn't actually
require any implementation changes.

This only affects macOS today, because it only affects compiling
without an explicit target (i.e. not cross-compiling) on an OS with
cross-version binary compatibility (i.e. not Linux).

rdar://problem/29948658
2017-11-28 11:36:00 -08:00
Doug Gregor
5af0d814e8 Re-enable conditional conformances test in optimized build. 2017-11-28 10:43:15 -08:00
Doug Gregor
050fd9b0a4 Merge pull request #13032 from DougGregor/conditional-conformances-superclass
[AST] Properly adjust substitution type for inherited conformances.
2017-11-19 22:25:42 -08:00
Doug Gregor
8ad35e078a [SE-0143] Enable test for inherited conditional conformances.
Addressed by the previous work to use interface types in associated type
witnesses. Fixes rdar://problem/35480728.
2017-11-19 21:34:15 -08:00
ematejska
a00b0749c4 Merge pull request #12849 from rudkx/SE-0054
SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
2017-11-18 18:51:39 -08:00
Mark Lacey
8b55a0f61b SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
For Swift 3 / 4:

Deprecate the spelling "ImplicitlyUnwrappedOptional", emitting a warning
and suggesting "!" in places where they are allowed according to
SE-0054.

In places where SE-0054 disallowed IUOs but we continued to accept them
in previous compilers, emit a warning suggesting "Optional" or "?"  as
an alternative depending on context and treat the IUO as an Optional,
noting this in the diagnostic.

For Swift 5:

Treat "ImplicitlyUnwrappedOptional" as an error, suggesting
"!" in places where they are allowed by SE-0054.

In places where SE-0054 disallowed IUOs, emit an error suggestion
"Optional" or "?" as an alternative depending on context.
2017-11-18 11:41:53 +09:00
Joe Groff
39dfe07354 IRGen: Treat class layout for classes from other modules a bit more opaquely.
We would miscompile in mixed-language-version projects when a Swift class was compiled for one language version, while using Objective-C-imported types that are only available to that version, and then imported into a Swift module with a different language version that wasn't able to see all of the properties because of incompatible imported types. This manifested in a number of ways:

- We assumed we could re-derive the constant field offsets of the class's ivars from the layout, which is wrong if properties are missing, causing accesses to final properties or subclass properties to go to the wrong offsets.
- We assumed we could re-derive the instance size and alignment of a class instance in total, causing code to allocate the wrong amount of memory.
- We neglected to account for the space that stored properties take up in the field offset vector of the class object, causing us to load vtable entries for following subclass methods from the wrong offsets.

Eventually, resilience should reduce our exposure to these kinds of problems. As an incremental step in the right direction, when we look at a class from another module in IRGen, treat it as always variably-sized, so we don't try to hardcode offsets, size, or alignment of its instances. When we import a class, and we're unable to import a stored property, leave behind a new kind of MissingMemberDecl that records the number of field offset vector slots it will take up, so that we lay out subclass objects and compute vtable offsets correctly. Fixes rdar://problem/35330067.

A side effect of this is that the RemoteAST library is no longer able to provide fixed field offsets for class ivars. This doesn't appear to impact the lldb test suite, and they will ultimately need to use more abstract access patterns to get ivar offsets from resilient classes (if they aren't already), so I just removed the RemoteAST test cases that tested for class field offsets for now.
2017-11-17 14:38:08 -08:00
Erik Eckstein
76f281510f Remove @_semantics("optimize.sil.never")
The replacement is @_optimize(none)
2017-11-16 14:11:52 -08:00
Arnold Schwaighofer
e1700dee6e Disable conditional_conformances_smoke.swift in optimized mode
Fails on the bots.

rdar://35492657
2017-11-12 05:58:23 -08:00
Huon Wilson
5c0f158f88 [test] Fix conditional conformance tests for 32-bit platforms. 2017-11-10 19:22:03 -08:00
Huon Wilson
1372202cfa [test] More for conditional conformances; subclasses, devirtualization, etc. 2017-11-09 17:51:48 -08:00
Arnold Schwaighofer
7489bf717d runtime: Fix swift_deallocBox
We need to set the object into deallocating state (+1 -> +0).
2017-11-03 08:43:14 -07:00
Jordan Rose
85ccbb4990 [ClangImporter] Bridging can happen even without full bridgeability
Partially reverts f4f8349 (from July!) which caused us to start
importing global blocks with unbridged parameters, breaking source
compatibility. I'm still investigating whether there's an actual hole
in the logic; see next few commits.

rdar://problem/34913634
2017-11-02 14:40:39 -07:00
swift-ci
f1536bcc36 Merge pull request #12712 from compnerd/test-nullability 2017-11-02 10:36:50 -07:00
Saleem Abdulrasool
bdb7901a1c test: modernise nullability attributes (NFC)
Use the modern spelling for the nullability attributes in the test mock
headers.  Currently, this was relying on the predefined macros from
clang to work.  However, those are only available on Darwin targets.
This is needed to make the mock environments more portable.
2017-11-01 23:27:33 -07:00
Doug Gregor
77282a3e8a Merge pull request #12713 from DougGregor/remove-extensions-of-IUO
Remove extensions on ImplicitlyUnwrappedOptional from the stdlib.
2017-11-01 19:31:57 -07:00
Doug Gregor
2e2c7e8dd6 Update tests for removal of ImplicitlyUnwrappedOptional extensions. 2017-11-01 17:13:32 -07:00
Slava Pestov
4f1bda071f IRGen: Nested classes don't require runtime metadata instantiation
Fixes <rdar://problem/35221915>, <https://bugs.swift.org/browse/SR-6238>.
2017-11-01 15:58:23 -07:00
Arnold Schwaighofer
3947193578 Add a test case for the enum value witness fix 2017-11-01 10:54:53 -07:00
Slava Pestov
045c6496ff SILGen: Fix memory leak when calling constructor requirement of @objc protocol
Fixes <rdar://problem/30478887> / <https://bugs.swift.org/browse/SR-3935>.
2017-10-21 01:42:51 -07:00
Slava Pestov
c69686f102 DI: Use new 'self initialized' analysis in conditional destroy lowering
This changes code generation a bit, because now the conditional
state bitmap uses a bit to track if the 'self' box was stored,
not if the 'self' value was consumed. In some cases, this
eliminates an extra bit, in other places it introduces an
extra bit, but it really doesn't matter because LLVM will
optimize this bit manipulation easily.
2017-10-20 16:10:33 -07:00
Slava Pestov
09b59c5336 DI: More tests 2017-10-20 16:10:32 -07:00
Ben Cohen
a70e857d59 [stdlib] Fix issue with UTF16 index(_:offsetBy:limitedBy) (#12378)
* Fix issue with empty string ranges

* Add tests for basic offsetBy operation on UTF16View.Index
2017-10-16 13:44:51 -07:00
Slava Pestov
0c16aedb60 DI: All protocol extension initializers should be delegating
Previously protocol extension initializers which called 'self.init' were
considered 'delegating', and ones that assign to 'self' were considered
'root'.

Both have the same SIL lowering so the distinction is not useful, and
removing it simplifies some code.
2017-10-13 23:51:14 -07:00
Slava Pestov
c3cf4acbbf DI: For value types, handle self.init like an assignment instead of vice versa
This allows, for example, an initializer to conditionally assign
to self or call self.init, along different control flow paths.

It also means that it is legal to call self.init() multiple times
in a value type initializer, but this... is fine. The old 'self'
is destroyed.

Fixes <rdar://problem/33137910>.
2017-10-13 23:51:14 -07:00
Pavel Yaskevich
c5cff769c7 [IRGen] Update Function Metadata to use AnyFunctionType::Param
This changes layout of the parameter metadata from single tuple record
(in case of materializable type) to N records each corresponding to
invididual function parameter, where functions with no parameters
`() -> Void` get 0 records allocated.
2017-10-12 15:58:19 -07:00
Slava Pestov
124251cf2c Merge pull request #9619 from allevato/synthesize-equatable-hashable
Synthesize Equatable/Hashable for complex enums, structs
2017-10-10 18:22:40 -07:00
Arnold Schwaighofer
1832bcdfd5 Add test case that uses metadata of 'import as nested types' Objective-C types
This used to crash before we removed parent metadata references.

rdar://34846458
2017-10-10 09:32:14 -07:00
Tony Allevato
ddaa390a62 Merge branch 'master' into synthesize-equatable-hashable 2017-10-10 01:39:48 -07:00
Slava Pestov
5afaadfbc8 Sema: Requirement environments for protocol extension members in class conformances have an abstract 'Self'
Consider the following code:

protocol P {
  func foo<A>(_: A)
}

extension P {
  func foo<A>(_: A) {}
}

class C<T> : P {}

Before, the witness thunk for [C : P].foo() had the generic signature
<T, A>, and the witness P.foo() was called with a substitution
Self := C<T>.

This is incorrect because the caller might be using a subclass of C
as the 'Self' type, but this was being erased.

Now, the witness thunk for [C : P].foo() has the generic signature
<X : C<T>, T, A>, and the witness P.foo() is called with the
substitution Self := X.

Fixes <rdar://problem/33690383>, <https://bugs.swift.org/browse/SR-617>.
2017-10-09 19:53:50 -07:00
Tony Allevato
715ba632dd Merge branch 'master' into synthesize-equatable-hashable 2017-10-09 15:57:36 -07:00
Tony Allevato
a30c218b59 [test] Move executable tests into test/Interpreter 2017-10-09 15:39:40 -07:00
Jordan Rose
192b523a8e Revert "Fix issue with 'Self' metadata when class conforms to protocol with default implementations" (#12344)
It broke the 32-bit iOS simulator, and possibly the 64-bit simulator as well. Reverts 5618553.
2017-10-09 10:02:48 -07:00