Commit Graph

1723 Commits

Author SHA1 Message Date
Slava Pestov
9b4f05d619 Merge pull request #24964 from slavapestov/more-test-stable-abi-tweaks
Split up a couple more tests into stable and pre-stable ABI deployment target versions
2019-05-21 22:22:29 -04:00
Doug Gregor
af7b461db2 Merge pull request #24959 from DougGregor/non-objc-dynamic-everywhere
Allow non-@objc ‘dynamic’ in all language modes.
2019-05-21 15:05:52 -07:00
Slava Pestov
6363961e90 Split up a couple more tests into stable and pre-stable ABI deployment target versions 2019-05-21 17:30:13 -04:00
Doug Gregor
22c0995046 Allow non-@objc ‘dynamic’ in all language modes.
Non-‘@objc’ ‘dynamic’ has been allowed since Swift 5, but there’s no
reason to tie it to the language mode (Swift >= 5).

Fixes rdar://problem/50348013.
2019-05-21 13:40:04 -07:00
Doug Gregor
d86907e095 [Property delegates] Fix crash involving generic uses of delegateValue.
Fixes rdar://problem/50873275.
2019-05-20 10:15:12 -07:00
Brent Royal-Gordon
91146d5293 Merge pull request #24881 from brentdax/crouching-module-hidden-method
Allow inheritance from resilient classes with missing members
2019-05-19 15:47:11 -07:00
Brent Royal-Gordon
9117c5728a Allow inheritance from resilient classes with missing members
When a class has missing vtable entries, we don’t allow it to be subclassed. This is unnecessarily restrictive for resilient classes, and @_implementationOnly imports now make missing vtable entries much more common. This commit carves out an exception to that rule for resilient classes.

Fixes <rdar://problem/50902125>.
2019-05-17 20:05:19 -07:00
Slava Pestov
5d66bb810a Run stable ABI tests on all Apple platforms
A number of tests exercise features only available in Apple OSes that
shipped with Swift 5.0 in the OS; this includes the following versions:

- macOS 10.14.4
- iOS 12.2
- tvOS 12.2
- watchOS 5.2

Previously these tests were restricted to running on macOS only, with
an explicit -target x86_64-apple-macosx10.14.4. To get better test
coverage, add a new %target-stable-abi-triple substitution which
expands to a triple with the correct OS version on all Apple platforms.

On non-Apple platforms, this is the same as %target-variant-triple,
but for now any test that uses this exercises Apple platform features
anyway.

One caveat is that since iOS 12.2 does not have a 32-bit slice, we
have to skip any tests that use -target %target-stable-abi-triple
on this platform. A new swift_stable_abi feature flag can be tested
with 'REQUIRES: swift_stable_abi'. To get maximum test coverage,
I split off a 'stable_abi' version of a few tests that build with both
an old and new deployment target. This allows the old deployment
target case to still be tested on 32-bit iOS.
2019-05-16 17:02:06 -04:00
Jordan Rose
9647483aee Warn when using '@_implementationOnly' inconsistently in a module (#24800)
I thought it would be useful to allow some uses of a module to be
'@_implementationOnly' and others to not be in case someone wanted to
change from one to the other gradually, but it turns out that if
you're trying to /make/ an import implementation-only, you want to
know everywhere you used it.

rdar://problem/50748157
2019-05-16 09:13:34 -07:00
Pavel Yaskevich
30be693913 Merge pull request #24808 from xedin/cleaner-foreach
[TypeChecker] Simplify for ... in ... type checking
2019-05-16 00:16:46 -07:00
Doug Gregor
90859ad6aa [Type checker] Fix assertion/spin with ill-formed property delegate initialization
Fixes rdar://problem/50822051.
2019-05-15 16:42:38 -07:00
Slava Pestov
744850749b Sema: Fix 'for ... in ...' over a sequence of DynamicSelfType 2019-05-15 14:34:10 -07:00
Slava Pestov
4643cbd8e9 GSB: Remove another call to resolveDeclSignature()
The GSB should avoid triggering declaration validation where
possible, to avoid problems resulting from circularity and as
a general performance rule-of-thumb.

This last call was there to catch self-recursive protocol
typealiases. However, we can diagnose this problem elsewhere,
which allows us to emit a more accurate diagnostic as well.
2019-05-10 15:00:48 -04:00
Slava Pestov
c954dfa6a9 Sema: Tweak test/decl/protocol/conforms/nscoding.swift a bit
Make sure we test on both an "old" and "new" deployment target.
2019-05-03 18:56:46 -04:00
Doug Gregor
bf2c4d951b Prevent less-visible properties with delegates from affecting memberwise initializer
When a property with an attached delegate has less-than-internal visibility
and is initialized, don’t put it into the memberwise initializer because
doing so lowers the access level of the memberwise initializer, making it
fairly useless.

Longer term, it probably makes sense to have several memberwise initializers
at different access levels, so adding an initialized `private var` make
the memberwise initializer useless throughout the rest of the module.

Addresses rdar://problem/50266245.
2019-05-01 14:10:56 -07:00
Sam Lazarus
3d9b6396a1 Merge pull request #24059 from sl/sl/sr-10293
Allow var / let as parameter names but provide a warning and fixit to add backticks.
2019-04-26 09:30:23 -04:00
Sam Lazarus
ede8127adf Test: Add and update tests for allowing var and let as argument labels 2019-04-26 04:08:27 -04:00
Pavel Yaskevich
d5fcf1a665 Merge pull request #24274 from theblixguy/fix/computed-prop-fix-it-lazy
[CSDiagnostics] Removes lazy when applying computed property fix-it
2019-04-25 13:22:25 -07:00
Suyash Srijan
20cfa14423 [CSDiagnostics] Removes lazy attributes when applying computed property fix-it 2019-04-25 17:59:07 +01:00
nate-chandler
155a155000 Merge pull request #23251 from nate-chandler/nate/omit-return
Allow return to be omitted from single expression functions.
2019-04-25 08:36:34 -07:00
swift-ci
d24bc38797 Merge pull request #23701 from DougGregor/property-delegates-as-custom-attributes 2019-04-24 22:51:18 -07:00
Doug Gregor
0c26e4349e Underscore the @propertyDelegate attribute to indicate that it's experimental 2019-04-24 21:25:33 -07:00
Slava Pestov
04ac33dd2b Sema: Fix order dependency in @objc inference from witnessed protocol requirement
If we haven't validated the declaration yet, the 'witnesses @objc
requirement' check would immediately fail. Move the validateDecl()
call to matchWitness() to fix this.

Fixes <rdar://problem/49482328>, <https://bugs.swift.org/browse/SR-10257>.
2019-04-24 17:35:05 -04:00
Nate Chandler
3139d3e061 Tweaked remaining failing tests.
Modified so that single-expression implicit return does not throw off
tests.
2019-04-24 10:04:20 -07:00
Doug Gregor
6218673ead [Property delegates] Use $$foo for the backing storage and make it private.
When the property delegate type overrides the delegate value by providing
a delegateValue property, name the backing storage $$foo and make it private.
2019-04-23 21:56:03 -07:00
Doug Gregor
56d450b595 [Property delegates] Contextualize direct initializers of custom attributes
When a custom attribute is given a direct initializer, save and re-use
the initializer context we create so that it can be associated with the
enclosing pattern binding. Fixes assertions involving explicit closures
in property delegates.
2019-04-23 11:32:29 -07:00
Doug Gregor
fcd2fd97e8 [Property delegates] Don't create backing var for ill-formed delegate type.
Fixes the crash-on-invalid in rdar://problem/49982937.
2019-04-23 11:32:29 -07:00
Doug Gregor
261b879b54 [Property delegates] Rename storageValue to delegateValue 2019-04-23 11:32:28 -07:00
Doug Gregor
f187d9218e [Type checker] Don't allow a 'let' to have a property delegate. 2019-04-23 11:32:28 -07:00
Doug Gregor
4f56db2653 [Property delegates] Implement support for storageValue 2019-04-23 11:32:28 -07:00
Doug Gregor
cc68b12d1a [SILGen] Initialization of instance properties with property delegates
The initialization of an instance property that has an attached
property delegate involves the initial value written on the property
declaration, the implicit memberwise initializer, and the default
arguments to the implicit memberwise initializer. Implement SILGen
support for each of these cases.

There is a small semantic change to the creation of the implicit
memberwise initializer due to SE-0242 (default arguments for the
memberwise initializer). Specifically, the memberwise initializer will
use the original property type for the parameter to memberwise
initializer when either of the following is true:

  - The corresponding property has an initial value specified with the
    `=` syntax, e.g., `@Lazy var i = 17`, or
  - The corresponding property has no initial value, but the property
    delegate type has an `init(initialValue:)`.

The specific case that changed is when a property has an initial value
specified as a direct initialization of the delegate *and* the
property delegate type has an `init(initialValue:)`, e.g.,

```swift
struct X {
  @Lazy(closure: { ... })
  var i: Int
}
```

Previously, this would have synthesized an initializer:

```swift
init(i: Int = ???) { ... }
```

However, there is no way for the initialization specified within the
declaration of i to be expressed via the default argument. Now, it
synthesizes an initializer:

```swift
init(i: Lazy<Int> = Lazy(closure: { ... }))
```
2019-04-23 11:31:59 -07:00
Doug Gregor
198751e6c0 Improve test for nonmutating due to a reference-type delegate 2019-04-23 11:31:58 -07:00
Doug Gregor
6526cfa8d4 Memberwise initializer synthesis for properties with attached delegates. 2019-04-23 11:31:58 -07:00
Doug Gregor
b18a2902e5 Implement access control for property delegates 2019-04-23 11:31:58 -07:00
Doug Gregor
b8061eab34 Synthesize backing storage property for properties with attached delegates.
When a property has an attached property delegate, a backing storage
property of the corresponding delegate type will be
synthesized. Perform this synthesis, and also synthesize the
getter/setter for the original property to reference the backing
storage property.
2019-04-23 11:31:58 -07:00
Doug Gregor
53b9e25502 Implement initialization of properties with attached delegates.
A property with an attached delegate can be initialized in one of two ways:

* By directly specifying initialization arguments on the attribute,
  e.g., "@SomeDelegate(x: 17, y: 42) var a".
* By initializing the original property itself, which goes through the
  delegate type's init(initialValue:) initializer, e.g.,
  "@Lazy var x = 17".

Implement support for both forms of initialization, including type
inference and checking for inconsistencies (e.g., if the annotation on
the property type doesn't match what the delegate type would
provide).
2019-04-23 11:31:58 -07:00
Doug Gregor
96279c7044 Use custom attributes to apply property delegates to variables.
A custom attribute can be resolved to a property delegate type. Allow
this for property declarations (only), and diagnose the various places
where properties cannot have property delegates.
2019-04-23 11:31:58 -07:00
Slava Pestov
3f5a06bc3e AST: Always diagnose request evaluator cycles 2019-04-22 22:22:23 -04:00
Slava Pestov
8ec0e39ce8 Merge pull request #24151 from AnthonyLatsis/cleanup-func-subscript-validation
TypeChecker: consolidate func & subscript signature validation
2019-04-20 21:34:53 -04:00
fischertony
00e6ae1bf3 consolidate func & subscript signature validation 2019-04-20 00:15:12 +03:00
Jordan Rose
79bd38ba44 Merge pull request #24090 from AnthonyLatsis/synth-init-conflict-diag
Sema: Improve redeclaration error for synthesized inits
2019-04-19 08:51:07 -07:00
Anthony Latsis
e229fbd25f Update basic_init.swift 2019-04-19 03:13:14 +03:00
Slava Pestov
06c819d46e Sema: Allow protocols to inherit from subclass existentials
This was a regression from 7566f98a45.

Fixes <rdar://problem/50022955>.
2019-04-18 17:48:28 -04:00
fischertony
78f4b9dba9 Skip redecl errors for inits that conflict with an inherited init
This can only happen when the conflicting init is within an extension.
It is the override checker's responsibility to emit a sensible diagnostic here.
2019-04-18 22:04:29 +03:00
fischertony
a9fe0a6b9a Improve redeclaration error for implicit inits 2019-04-18 00:19:41 +03:00
kitasuke
543ddbceee Remove NSKeyedArchiver family support for decl attributes 2019-04-15 17:33:51 +09:00
Slava Pestov
1889d5aa45 Sema: Correctly simplify member types with a DynamicSelfType base
Fixes <https://bugs.swift.org/browse/SR-10434>, <rdar://problem/49779783>.
2019-04-12 01:00:19 -04:00
Brent Royal-Gordon
c37fee1719 Add parallel tests for static subscripts
This commit modifies various subscript-related test files to add static subscript equivalents of existing tests.
2019-04-10 23:17:04 -07:00
Brent Royal-Gordon
473fe7027e Make sure we don’t support @objc class subscripts
Obj-C subscripts don’t work on class objects, but you can declare class methods with the appropriate names. We don’t want to half-support this. Emit an error if you try to write “@objc class subscript” and test that we don’t import the methods as subscripts.
2019-04-10 23:17:04 -07:00
Brent Royal-Gordon
8b0e61aae0 Infer final on static subscripts 2019-04-10 23:17:04 -07:00