Commit Graph

11880 Commits

Author SHA1 Message Date
swift-ci
d32b83a987 Merge remote-tracking branch 'origin/master' into master-next 2019-11-05 13:39:10 -08:00
Ben Langmuir
3c714bc525 Merge remote-tracking branch 'origin/master' into master-next 2019-11-05 13:32:25 -08:00
Robert Widmann
01d272073a Requestify Witness Resolution
Witness matching is a source of a lot of ad-hoc cycles, and mixes the
logic that performs resolution, caching, validation, and cycle detection into one
place.  To make matters worse, some checkers kick off other checks in
order to cache work for further declarations, and access an internal
cache on their subject conformance for many requirements at once, or
sometimes just one requirement.

None of this fits into the request evaluator's central view of the
caching.  This is further evidenced by the fact that if you attempt to
move the caching step into the evaluator, it overcaches the same
witness and trips asserts.

As a start, define requests for the resolution steps, and flush some
hacks around forcing witness resolution. The caching logic is mostly
untouched (the requests don't actually cache anything), but some cycle
breaking is now handled in the evaluator itself.  Once witness matching
has been refactored to cache with the evaluator, all of these hacks can
go away.

My urge to destroy the LazyResolver outweighs the compromises here.
2019-11-05 13:28:07 -08:00
Robert Widmann
0e1766e1cc Merge pull request #28068 from CodaFi/welcome-to-the-salty-spitoon
Rationalize Implicit Member Synthesis Somewhat
2019-11-05 13:05:55 -08:00
Joe Groff
27d7117f9f SIL: Type lowering for function values with substituted SIL function types.
After converting a function type to its corresponding SIL type by our usual rules, extract
the substituted generic signature and common interface type for all concrete function types
that the function could be called as. We don't currently have any use cases for distinguishing
types at finer granularity than generic class-constrained/generic unconstrained/not-generic, so
to reduce the amount of conversion noise in SIL, generate the most general generic signature
possible, by extracting every position with a dependent generic parameter or associated type thereof
into a separate generic parameter in the substituted signature, discarding all constraints except
for `AnyObject` layout constraints. This way, if `foo<T>(x: (T, T) -> ())` calls
`bar<T, U>(x: (T, U) -> ())` and forwards `x` along, the two closures that only vary in genericity
don't need a conversion even with substituted function types, because they'll both have the same
abstract lowering `<A, B> (A, B) -> ()` with different substitutions.
2019-11-05 12:48:11 -08:00
Pavel Yaskevich
30440d8235 [Diagnostics] Properly diagnose assignment mismatch in ambiguity cases 2019-11-05 12:38:13 -08:00
David Ungar
0838a6646d Provide hook to see if ASTScopes support lookups into inactive clauses 2019-11-05 12:10:43 -08:00
Holly Borla
e63f259f4f [ConstraintSystem] Bind holes to UnresolvedType instead of Any. 2019-11-05 09:15:13 -08:00
Robert Widmann
d4906ac10b Rationalize Implicit Member Synthesis Somewhat
Codable's deep magic currently forces conformance checks in the middle
of name lookup in order to inject CodingKeys into lookup results.  This
is compounded by the fact that this lookup fixup is occuring
incrementally, meaning depending on order of requirements being looked
up, Decl::getMembers() will give you a different answer.

Compounding this, NameLookup relied on the LazyResolver to formalize
this layering violation, and relied on implicit laziness to guard
against re-entrancy.

The approach is multi-pronged:
1) Shift the layering violation into the request evaluator
2) Spell out the kinds of resolution we support explicitly (make them
easier to find and kill)
3) Remove the LazyResolver entrypoint this was relying on
4) Split off the property wrappers part into its own utility
2019-11-05 09:10:13 -08:00
swift-ci
b6cfc01dc4 Merge remote-tracking branch 'origin/master' into master-next 2019-11-04 23:49:31 -08:00
marcrasi
ce756e3189 [AutoDiff upstream] parsing for @differentiable function type (#27708)
Adds parsing for a type attribute `@differentiable`, which is optionally allowed to have argument `@differentiable(linear)`.

The typechecker currently rejects all uses of `@differentiable` with "error: attribute does not apply to type". Future work (https://bugs.swift.org/browse/TF-871 https://bugs.swift.org/browse/TF-873) will update the typechecker to allow this attribute in places where it is allowed.

Resolves https://bugs.swift.org/browse/TF-822.
2019-11-04 23:40:04 -08:00
swift-ci
92b412acca Merge remote-tracking branch 'origin/master' into master-next 2019-11-04 22:50:02 -08:00
Holly Borla
d91e4747ac Merge pull request #28073 from hborla/nil-conditional-cast
[CSGen] Add a tailored diagnostic for conditional casting from a nil literal.
2019-11-04 22:33:23 -08:00
Holly Borla
b1638ce1ab [CSGen] Add a tailored diagnostic for conditional casting from a nil literal,
and diagnose in CSGen.
2019-11-04 20:49:36 -08:00
swift-ci
5f9e32b974 Merge remote-tracking branch 'origin/master' into master-next 2019-11-04 17:30:26 -08:00
Hamish Knight
40231991ae [Sema] Diagnose unsound pointer conversions (#27695)
[Sema] Diagnose unsound pointer conversions
2019-11-04 17:18:57 -08:00
swift-ci
9f6c8cbf3a Merge remote-tracking branch 'origin/master' into master-next 2019-11-04 12:50:07 -08:00
Robert Widmann
ce4b20c90d [Gardening] Remove dead LazyResolver members 2019-11-04 11:13:14 -08:00
swift-ci
f8b50e8fba Merge remote-tracking branch 'origin/master' into master-next 2019-11-03 19:49:24 -08:00
Robert Widmann
5076d71daf Merge pull request #28033 from RayZhao1998/master
[Diagnostics] Resolve SR-11677: Offer a better diagnostic when && is …
2019-11-03 19:33:52 -08:00
Hamish Knight
65dda6d945 Address other review feedback 2019-11-03 08:42:26 -08:00
Hamish Knight
8cccbe0118 [Sema] Infer @_nonEphemeral for various parameters
These include memberwise initializers for pointer properties and enum
case constructors for pointer payloads. In both cases, the pointer is
being immediately escaped, so don't allow the user to pass a temporary
pointer value.
2019-11-03 08:42:26 -08:00
Hamish Knight
d0dbbf9f89 [CSDiagnostics] Add ephemeralness ambiguity notes 2019-11-03 08:42:25 -08:00
Hamish Knight
7077a68b83 [Sema] Diagnose unsound pointer conversions
Diagnose ephemeral conversions that are passed to @_nonEphemeral
parameters. Currently, this defaults to a warning with a frontend flag
to upgrade to an error. Hopefully this will become an error by default
in a future language version.
2019-11-03 08:42:25 -08:00
Hamish Knight
92c42ec791 [AST] Add @_nonEphemeral parameter attribute
This non-user-facing attribute is used to denote pointer parameters
which do not accept pointers produced from temporary pointer conversions
such as array-to-pointer, string-to-pointer, and in some cases
inout-to-pointer.
2019-11-03 08:40:59 -08:00
ninjiacoder
06424ee6e5 [Diagnostics] Resolve SR-11677: Offer a better diagnostic when && is used in trailing where clause declaration 2019-11-03 23:50:09 +08:00
swift-ci
0c584d4bcd Merge remote-tracking branch 'origin/master' into master-next 2019-11-03 01:30:14 -07:00
zoecarver
a800c9ed42 fixup! Address review comments 2019-11-02 22:00:29 -07:00
zoecarver
2ca448b23d Address review comments
* add namespace
* fix block comment style
* SEMA_ATTR -> SEMANTICS_ATTR
* error when SEMANTICS_ATTR isn't defined
2019-11-02 21:58:26 -07:00
David Ungar
f162a84e01 Factoring 2019-11-02 20:44:03 -07:00
zoecarver
9c1a614efb Fix based on review comments 2019-11-02 13:07:20 -07:00
swift-ci
db21e20e34 Merge remote-tracking branch 'origin/master' into master-next 2019-11-01 19:50:27 -07:00
Robert Widmann
a29bfb4434 Fold resolveImplicitConstructors into resolveImplicitMember 2019-11-01 18:11:24 -07:00
Alberto Lagos Toro
d3477ddfc4 SR-11679: Incorrect FixIt suggestion for CFTypes
Convenience inits are only allowed on classes and in extensions thereof. And in CFTypes we are not allowed to put convenince inits since swift does not support this feature yet.

This PR solve the bad fix suggestion when a user declare a init method in an extension of CF Type.

Another bug (similar to this one) that i found and became visible when i was doing the test cases for SR-116779 was the fact that if you declare a convenience init that delegates the init function in self, a fix suggestion will appear. The same suggestion that is causing troubles in SR-11679. The fix for this was removing the fix suggestion when the class kind type was CFType since if we leave it as is, it will be the same problem as SR-11679.

SR-11679: PR Feedback

Formatting the new code with clang-format and using `isa` and `cast` instead of `dyn_cast`

SR-11679: PR Feedback

Inlining `cast

SR-11679: PR Feedback

Remove semi-colon

SR-11679: PR Feedback

Remove empty line & add mark to avoid fixit.

SR-11679: PR Feedback

Remove empty line.

SR-11679: PR Feedback

Move Diagnostics Info & Remove empty lines
2019-11-01 19:54:30 -03:00
swift-ci
c468d3fd32 Merge remote-tracking branch 'origin/master' into master-next 2019-11-01 10:29:36 -07:00
adrian-prantl
220715113d Merge pull request #28008 from adrian-prantl/nodebug
Add a hidden option to disable debugger shadow copies.
2019-11-01 10:11:11 -07:00
swift-ci
0b41d02a4d Merge remote-tracking branch 'origin/master' into master-next 2019-10-31 20:49:50 -07:00
Brent Royal-Gordon
17169fc1fe Merge pull request #27950 from brentdax/dumpster-fire
[NFC] Standardize dump() methods in frontend
2019-10-31 20:36:26 -07:00
Brent Royal-Gordon
99faa033fc [NFC] Standardize dump() methods in frontend
By convention, most structs and classes in the Swift compiler include a `dump()` method which prints debugging information. This method is meant to be called only from the debugger, but this means they’re often unused and may be eliminated from optimized binaries. On the other hand, some parts of the compiler call `dump()` methods directly despite them being intended as a pure debugging aid. clang supports attributes which can be used to avoid these problems, but they’re used very inconsistently across the compiler.

This commit adds `SWIFT_DEBUG_DUMP` and `SWIFT_DEBUG_DUMPER(<name>(<params>))` macros to declare `dump()` methods with the appropriate set of attributes and adopts this macro throughout the frontend. It does not pervasively adopt this macro in SILGen, SILOptimizer, or IRGen; these components use `dump()` methods in a different way where they’re frequently called from debugging code. Nor does it adopt it in runtime components like swiftRuntime and swiftReflection, because I’m a bit worried about size.

Despite the large number of files and lines affected, this change is NFC.
2019-10-31 18:37:42 -07:00
Adrian Prantl
ed8294247b Add a hidden option to disable debugger shadow copies.
This option is useful to debug the compiler itself, to simulate debug info as it
would be generated when producing optimized code, but without the unpredictable
output of an optimizing debugger.
2019-10-31 17:35:16 -07:00
swift-ci
5323db1cfc Merge remote-tracking branch 'origin/master' into master-next 2019-10-31 13:49:56 -07:00
Robert Widmann
8a69f886ad Merge pull request #27955 from AnthonyLatsis/bracestmt_cleanup
NFC: Solidify and tidy up the BraceStmt interface
2019-10-31 13:48:40 -07:00
Jordan Rose
43d290431f Merge pull request #27089 from Vercantez/warn-on-empty-optionset-static-constants
warn on empty OptionSet static constants
2019-10-31 13:32:34 -07:00
swift-ci
067dbed0c9 Merge remote-tracking branch 'origin/master' into master-next 2019-10-31 12:50:01 -07:00
Varun Gandhi
64401ac92c [NFC] Replace StringMap<char, A> with StringSet<A> (#27986) 2019-10-31 12:46:58 -07:00
swift-ci
7ceb357eb5 Merge remote-tracking branch 'origin/master' into master-next 2019-10-31 11:09:53 -07:00
Hamish Knight
16cff49e65 [Sema] Requestify inheritsSuperclassInitializers (#27936)
* [Sema] Factor out shouldAttemptInitializerSynthesis

This makes sure we don't attempt to synthesize
a memberwise or default initializer for an invalid
decl, or one in a module interface.

* [Sema] Requesify inheritsSuperclassInitializers

This commit introduces a request for computing
whether a class inherits both designated and
convenience initializers from its superclass.

The shared logic of finding initializers which the
subclass hasn't overriden has been factored out
into `collectNonOveriddenSuperclassInits`.

* Cleanup addImplicitInheritedConstructorsToClass

This commit removes some code that's no longer
needed. In addition, now that we've requestified
`inheritsSuperclassInitializers`, we can directly
diagnose on non-inherited required convenience
inits within the loop.

* Inherited init synthesis no longer deals with clang decls

Now that the computation of
`inheritsSuperclassInitializers` has been split off
into a request, we can avoid calling
`addImplicitInheritedConstructorsToClass` for clang
decls.

* Address review feedback

Continue to cache the InheritsSuperclassInits bit
on the AST.
2019-10-31 11:07:06 -07:00
Miguel Salinas
3d9573f25d Merge branch 'master' into warn-on-empty-optionset-static-constants 2019-10-31 07:56:06 -05:00
swift-ci
667e89279a Merge remote-tracking branch 'origin/master' into master-next 2019-10-30 17:09:44 -07:00
Robert Widmann
d9ea4ecc43 Merge pull request #27969 from CodaFi/witless-witnesses
[NFC] Strip Witness Matching of its TypeChecker
2019-10-30 17:00:12 -07:00