Commit Graph

1145 Commits

Author SHA1 Message Date
David Zarzycki
31d8153097 [Sema] QoI: Report all tuple type resolution errors
This improves single pass diagnostics when more than one tuple type
element has problems.
2019-03-11 16:03:17 -04:00
Doug Gregor
a13ba3b8b9 Update test case for common-type reversion 2019-03-04 15:58:37 -08:00
Jordan Rose
d1140d2acd Merge pull request #22937 from AnthonyLatsis/override-open-with-public
https://bugs.swift.org/browse/SR-10004
2019-02-27 13:54:02 -08:00
fischertony
762eec38f3 [Sema] Always allow public overrides of open methods 2019-02-27 06:31:43 +03:00
Doug Gregor
86d14a8be8 Merge pull request #22858 from DougGregor/constraint-system-common-type-overloads
[Constraint system] Compute and use a common type among overloads.
2019-02-26 15:39:18 -08:00
Arnold Schwaighofer
78a9e45932 Merge pull request #22811 from aschwaighofer/infer_objc_dynamic_replacement
Sema: Infer @objc for dynamic replacement
2019-02-25 07:33:24 -08:00
Doug Gregor
1ab417cd8e [Constraint system] Compute and use a common type among overloads.
Given an overload set, attempt to compute a "common type" that
abstracts over all entries in the overload set, providing more
structure for the constraint solver.
2019-02-22 21:53:34 -10:00
Slava Pestov
c7f9e276c8 Sema: Fix crash with non-Optional weak @IBOutlet
We were skipping the diagnostic to allow @IBOutlet to diagnose the
non-Optional type, but we still have to mark our ownership attribute
as invalid so that we don't attempt to form the ReferenceStorageType
with a non-Optional underlying type.

Fixes <https://bugs.swift.org/browse/SR-9889>, <rdar://problem/48088046>.
2019-02-22 19:15:00 -05:00
Arnold Schwaighofer
8d9b9f328b SILGen: Fix the logic of dynamic replacements for class constructors
To correctly call designated super class initializers the designated
intializer (and not the allocator) is dynamically replaceable.
Convenience allocators are dynamically replaceable as before.
2019-02-22 10:15:06 -08:00
Arnold Schwaighofer
91810076e3 Sema: Infer @objc for dynamic replacement
rdar://48259565
2019-02-22 09:30:51 -08:00
Arnold Schwaighofer
315f47d19d Diagnostic: dynamic replacement and replaced function's @objc attribute must match
rdar://48259565
2019-02-21 08:12:51 -08:00
Slava Pestov
8fa74fabc3 Merge pull request #22664 from slavapestov/always-emit-into-client
SIL: Introduce '@_alwaysEmitIntoClient' attribute for use by standard library
2019-02-18 22:36:56 -05:00
Slava Pestov
bd6490b391 SIL: Introduce '@_alwaysEmitIntoClient' attribute for use by standard library
This is like '@inlinable', except that the symbol does not have a public
entry point in the generated binary at all; it is deserialized and a copy
is always emitted into the client binary, with shared linkage.

Just like '@inlinable', if you apply this to an internal declaration it
becomes '@usableFromInline' automatically.

This uses the same mechanism as default arguments ever since Swift 4, so
it should work reasonably well, but there are rough edges with diagnostics
and such. Don't use this if you are not the standard library.

Fixes <rdar://problem/33767512>, <https://bugs.swift.org/browse/SR-5646>.
2019-02-18 17:10:57 -05:00
Slava Pestov
112f6e027c Sema: Remove @noreturn attribute support
Swift 5 removed Swift 3 mode, but kept some diagnostic code around to emit
a fixit. It's time to remove that now.
2019-02-18 16:50:36 -05:00
Pavel Yaskevich
34f320c6b3 Merge pull request #22518 from theblixguy/fix/dont-discard-me
[Typechecker] Fix an issue with @discardableResult error not being emitted
2019-02-11 17:16:34 -08:00
Suyash Srijan
e5e5d134f5 [Typechecker] Fix an issue with discardableResult error not being emitted 2019-02-11 21:57:16 +00:00
Jordan Rose
cc1800d63e Merge pull request #22460 from jrose-apple/i-cannot-contain-my-excitement
Extend transitive availability checking to initial value expressions (better version)
2019-02-11 11:12:19 -08:00
Jordan Rose
722cb836f5 Extend transitive availability checking to initial value expressions
Because initial value expressions aren't actually considered /within/
the VarDecl or PatternBindingDecl they're initializing, the existing
logic to search for availability attributes wasn't kicking in, leading
to errors when a conditionally-unavailable value was used in an
initial value expression for a conditionally-unavailable binding. Fix
this by walking the enclosing type or extension to find the appropriate
PatternBindingDecl.

https://bugs.swift.org/browse/SR-9867
2019-02-08 11:39:32 -08:00
Ding Ye
0f493a68b3 [Sema] Improve diagnostics for access level of protocol witness in extension. (#22235)
If the access level of a protocol witness does not satisfies a requirement,
the compiler suggests marking it as the required level.  This is not suitable
when the witness is in an extension whose specified access level is less than
the required level, since the fixit fights with other warnings in this case.
This patch identifies such case and produces improved diagnostics.

Resolves: SR-9793
2019-02-08 09:31:01 -08:00
Jordan Rose
c8acb7e4c2 @objc extension makes even 'private' members '@objc' (#22436)
This regressed in a8fb416f9e, when we started using a helper function
in more places.

rdar://problem/47869562
2019-02-07 10:10:38 -08:00
Pavel Yaskevich
7f262a7003 [Sema] Extract @autoclosure diagnostics from type resolver
Since @autoclosure attribute is associated with declarations
it makes more sense to move diagnostics to where type of the
parameter has been completely resolved. This also helps to support
parameters with typealiases pointing to function types without
any extra logic in the resolver.
2019-02-05 10:57:05 -08:00
Pavel Yaskevich
6449e47e2c Merge pull request #22231 from theblixguy/fix/SR-9760
[Typechecker] Fix an issue with @escaping when used with a generic function
2019-01-31 15:38:25 -08:00
Suyash Srijan
be6dc7c84a [typechecker] handle typealias inside protocols when used with @escaping 2019-01-30 17:51:02 +00:00
Harlan Haskins
0a9b8fa37c Merge pull request #22191 from harlanhaskins/fatality
[Diagnostics] Mark invalid ‘@testable import’ as fatal
2019-01-29 15:57:30 -08:00
Harlan Haskins
f4b0e0e7b6 [Diagnostics] Mark invalid ‘@testable import’ as fatal
If this isn’t fatal, this will just end up cascading to a bunch of “could not find member … in …” errors, which hides the real issue.
2019-01-29 14:52:40 -08:00
Pavel Yaskevich
2e0c6db871 Merge pull request #22186 from xedin/rdar-47586626
[TypeChecker] Drop @autoclosure attribute from invalid parameters
2019-01-29 14:24:24 -08:00
Jordan Rose
15056ed695 Remove mistaken early exit from access checking
Warnings should not result in early exits because we might end up
missing an error!
2019-01-28 18:26:43 -08:00
Pavel Yaskevich
9da67c1897 [TypeChecker] Drop @autoclosure attribute from invalid parameters
While forming/validating parameters make sure that the type is indeed
a function type before marking it as `autoclosure` based on type
representative attributes, because parser doesn't change attributes
even after the error has been found and diagnosed.

Resolves: rdar://problem/47586626
2019-01-28 17:01:05 -08:00
Jordan Rose
aee0b4e675 Merge pull request #22006 from theblixguy/fix/SR-7601
[Typechecker] Allow @objc functions to return dynamic self
2019-01-23 13:41:57 -08:00
Suyash Srijan
7dcb14f86c [typechecker] allow @autoclosure closure to be a typealias 2019-01-21 13:30:46 +00:00
Suyash Srijan
e65014e1ce [typechecker] allow @objc functions to return dynamic self 2019-01-20 03:49:50 +00:00
Suyash Srijan
54a53c2286 [sema] Look through OpenExistentialExpr in checkIgnoreExpr() 2019-01-14 01:51:26 +00:00
Pavel Yaskevich
fc22ba6b59 [TypeChecker] Don't verify override access control if it has been disabled by a flag 2019-01-08 18:13:04 -08:00
Ankit Aggarwal
45290837b4 Merge pull request #21110 from aciidb0mb3r/swiftpm-manifest-version
Extend @available to support PackageDescription
2019-01-07 12:20:23 -08:00
swift-ci
bbfc0649ed Merge pull request #21657 from DougGregor/objc-read-modify 2019-01-05 00:28:14 -08:00
Doug Gregor
a8fb416f9e [Type checker] Don't implicitly propagate @objc to read/modify accessors.
Fixes rdar://problem/46699152.
2019-01-04 23:29:57 -08:00
Doug Gregor
0295e044cd Merge pull request #21638 from DougGregor/unowned-optional-let
[Type checker] Allow unowned/unowned(unsafe) optional lets.
2019-01-04 14:10:03 -08:00
Doug Gregor
7ea7d3252e [Type checker] Allow unowned/unowned(unsafe) optional lets.
Unlike weak values of optional type, an unowned or unowned(unsafe)
value of optional type will not silently become 'nil' when the
referenced instance goes away: rather, the program will trap. Don't
reject unowned or unowned(unsafe) optional lets.

Fixes rdar://problem/45732251.
2019-01-04 09:56:13 -08:00
Slava Pestov
2e635e9603 Sema: Add @_hasInitialValue and @_hasStorage in typeCheckDecl() not validateDecl()
We only ever use this in TBDGen and interface printing, and we only ever
generate TBD files or print interfaces for declarations in primary files,
so let's avoid unnecessary work in validateDecl().

Eventually we want validateDecl() to be replaced with a getInterfaceType()
request, so adding new attributes in this path (or other side effects in
general) is a big no-no.
2019-01-02 15:12:02 -05:00
Slava Pestov
04ce7abead Merge pull request #21504 from slavapestov/sil-verifier-checks
Minor improvements to SIL verifier
2019-01-02 15:09:08 -05:00
Slava Pestov
ae21b8b80f Sema: Resilient classes cannot have @inlinable deinits 2018-12-21 17:51:32 -05:00
swift-ci
36c0ebfe1d Merge pull request #21502 from DougGregor/dynamic-replacement-ambiguity 2018-12-21 12:50:30 -08:00
Doug Gregor
5d968621d7 [Type checker] Basic ambiguity resolution + diagnostics for dynamic replacement.
We weren't doing much validation when dynamically replacing storage
declarations, and has an assert() that should be an error. Clean up this
area a bit, dealing with simple ambiguities (i.e., there are two
properties or subscripts with different type signatures; pick the
matching one) and reporting an error when there is a true ambiguity.

Fixes rdar://problem/46737657.
2018-12-21 11:47:59 -08:00
Pavel Yaskevich
46afe3bb41 [Diagnostics] NFC: Remove redundant "because" from witness_not_usable_from_inline 2018-12-20 00:53:51 -08:00
Saleem Abdulrasool
c446b1e9be Merge pull request #21373 from compnerd/what-are-your-best-attributes
attr: fix test on Windows
2018-12-18 10:02:47 -08:00
Saleem Abdulrasool
e94abbca4b Merge pull request #21279 from compnerd/rpath
test: define and use `%target-rpath`
2018-12-17 12:37:30 -08:00
Saleem Abdulrasool
5ed2d75cd0 attr: fix test on Windows
`Int` on Windows x86_64 is different from `Int` on other targets due to
it being a LLP64 target.  Explicitly use the `Int32` type for the
enumeration to fix the test.
2018-12-16 22:22:14 -08:00
Saleem Abdulrasool
d77801abaf test: define and use %target-rpath
Create a new capturing substitution for adding a rpath to a target
library.  This is needed as Windows doesn't really support the concept
of a rpath.  This also makes it possible to remove the parameter from
the command line on windows.
2018-12-12 19:51:08 -08:00
Slava Pestov
4f0f11f6bb Merge pull request #21260 from slavapestov/objc-members-transitivity
AST: Rework @objcMembers inheritance to not depend on validation order
2018-12-12 20:39:05 -05:00
Slava Pestov
bfcf24ee4e AST: Rework @objcMembers inheritance to not depend on validation order
Sema would directly check for the presence of the @objcMembers attribute,
and inherit it from the immediate superclass in validateDecl().

We don't want validateDecl() to have side effects like this and this was
already a problem, because it would not inherit the attribute transitively
in some cases.

Instead, add a ClassDecl::hasObjCMembers() method that walks over all
ancestors and caches the result.

<rdar://problem/46420252>
2018-12-12 15:12:38 -05:00