Commit Graph

11880 Commits

Author SHA1 Message Date
Owen Voorhees
0a84879c74 [Diagnostics] Add -enable-experimental-descriptive-diagnostics frontend flag
This flag will feature-gate work on producing more descriptive diagnostic messages.
It will remain a hidden frontend option until these improvements are ready to ship.
2019-10-18 18:13:19 -07:00
Dan Zheng
7b5dfd6cf6 [AutoDiff upstream] NFC: update IndexSubset print/dump utilities. (#27775)
Cherry-pick #27772 from tensorflow branch.
2019-10-18 14:01:28 -07:00
Robert Widmann
420cf6c18d Improve "reference-to" message somewhat 2019-10-18 11:35:12 -07:00
Holly Borla
0d95a84e91 [Diagnostics] Improve the error message for when a type fails to satisfy
`AnyObject` layout requirement.
2019-10-18 11:27:21 -07:00
Robert Widmann
48b8ba3614 Remove DeclValidationRAII
The last real client was precedence group validation.
2019-10-18 11:19:58 -07:00
Robert Widmann
6bb0e49eab Move precedence group cycle checking into requests
Use the request evaluator to get the easier in-module precedence group cycles.   Unfortunately, cross-module precedence group cycles are still a possibility, and do not actually cause cyclic request evaluation, so we cannot completely erase the old diagnostics machinery.

Move the machinery itself into the type checker and shift the request into that zone as well to appease the linker.
2019-10-18 11:19:25 -07:00
Michael Gottesman
f7b3e4bd92 Merge pull request #27770 from gottesmm/pr-fedc6e35f83040331ae2bec83b08320f3b31ba0e
[sil] Add support for adding _semantics attributes to nominal types.
2019-10-18 11:04:25 -07:00
Pavel Yaskevich
8d05192204 Merge pull request #27728 from xedin/port-extraneous-args
[Diagnostics] Diagnose extraneous argument(s) via fixes
2019-10-18 10:42:56 -07:00
Michael Gottesman
454dd00e43 [sil] Add support for adding _semantics attributes to nominal types.
This will make it easier to prototype diagnostics on specifically marked nominal
types. My intended usage would be to have a way to emit diagnostics if specific
instances of the nominal type are ever not on the stack.
2019-10-17 22:25:22 -07:00
Holly Borla
f998349815 [Diagnostics] Add a tailored note for when the Wrapped type of an
optional satisfies a failed requirement.
2019-10-17 19:59:07 -07:00
Robert Widmann
464aab67ec Define InterfaceTypeRequest
The moment you've all been waiting for...

Define InterfaceTypeRequest and use it to, well, compute the interface
type.  This naturally widens the few cycles that we pick up with the
request evaluator.

There is still a lot of work to get done here, mostly around scaling
back all of the ad-hoc circularity checks around the interface type
computation.  It would also be great to improve the circularity
diagnostics.
2019-10-17 16:01:56 -07:00
Robert Widmann
3b829943af Uniformly iterate over the pattern binding entry indices
Clarify a bunch of C-style for loops and remove a ton of references to getPatternList().
2019-10-17 13:39:07 -07:00
Robert Widmann
56b6e53dae Remove raw references to PatternBindingEntry APIs
Switch most callers to explicit indices.  The exceptions lie in things that needs to manipulate the parsed output directly including the Parser and components of the ASTScope.  These are included as friend class exceptions.
2019-10-17 13:31:14 -07:00
Robert Widmann
55047cd3bb Start hiding the interface to PatternBindingEntry
Force callers to go through the pattern binding decl so we can control the API surface more effectively.
2019-10-17 13:28:28 -07:00
Robert Widmann
c849652fa2 Merge pull request #27731 from CodaFi/validate-patterns
Requestify Pattern Validation
2019-10-17 13:26:46 -07:00
Arnold Schwaighofer
da0099e83f Merge pull request #27666 from aschwaighofer/fix_replace_opaque_types_with_underlying
ReplaceOpaqueTypesWithUnderlyingTypes: We can't look through opaque archetypes if the underlying type contains a type not accessible from the current context
2019-10-17 12:40:06 -07:00
Robert Widmann
69bd40cafd Replace the cycle breaker for pattern bindings 2019-10-17 10:55:13 -07:00
Robert Widmann
198601dbd4 Bitpack the transitional API 2019-10-17 09:40:45 -07:00
Robert Widmann
8c73b7db58 Define NamingPatternRequest
Use it to provide an idealized API for the VarDecl case in validateDecl.

In reality, a lot of work is needed to rationalize the dependency
structure of this request.  To start, the callers of
typeCheckPatternBinding must be eliminated piecemeal.  Once that is
done, the AST should introduce pattern binding decls along all the
places where getParentStmt() used to apply.
2019-10-17 09:40:45 -07:00
Robert Widmann
71a525512d Define PatternBindingEntryRequest
Define a request that can be used to grab the fully validated and
type-checked form of a given pattern binding entry.  Using this,
validation of pattern bindings is fully disconnected from validation of
bound variables, and cycles are now picked up by the request evaluator.

Using this, we can go clean up all the callers that are checking a bit
and calling back into typeCheckPatternBinding.  It will also serve as
the basis for a request for the naming pattern for a VarDecl which will
clean that part of validateDecl.
2019-10-17 09:40:45 -07:00
David Ungar
924da0c968 Merge pull request #27743 from davidungar/fix-opaque-decl-astscope
[NameLookup] Fix opaque decl astscope
2019-10-17 09:22:12 -07:00
David Ungar
2e8920ba64 Don't addUnvalidatedDeclWithOpaqueResultType when inside of an inactive clause environment. 2019-10-16 22:23:36 -07:00
Xi Ge
19b0a8a06a Merge pull request #27633 from nkcsgexi/get-loc-return-serialized-loc
AST: teach Decl::getLoc() to return serialized source loc.
2019-10-16 17:16:20 -07:00
David Ungar
3adfbd9b91 Make ifConfigClause::isActive const 2019-10-16 14:20:00 -07:00
Doug Gregor
64d0b18d3b Merge pull request #27716 from DougGregor/function-builders-build-expression
[Function builders] Add support for buildExpression().
2019-10-16 12:53:03 -07:00
Pavel Yaskevich
b214b8a2bf [Diagnostics] Introdduce multiple extraneous arguments diagnostic 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
9855b406a0 [Diagnostics] Fix typo in candidate_with_extraneous_args diagnostic formatting 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
c97603f5d4 [CSDiagnostics] Diagnose extraneous arguments 2019-10-16 10:19:25 -07:00
Doug Gregor
fd916f9db6 [Function builders] Add support for buildExpression().
If a function builder type has a static method buildExpression(), use
it to pass through each expression whose value will become part of the
final result. This is part of the function builders pitch that had not
yet been implemented.
2019-10-15 22:25:04 -07:00
Xi Ge
c8e18d4c19 AST: use a static allocated NullLocs to indicate no serialized source locations for a Decl, NFC 2019-10-15 16:48:20 -07:00
Xi Ge
c6035f68f0 AST: cache serialized source locations in Decl 2019-10-15 16:05:28 -07:00
Xi Ge
1e22e7c8aa AST: teach Decl::getLoc() to return serialized source loc.
When Decl::getLoc() is called upon a serialized AST and the
serialized source location is available, we lazily open the
external buffer and return a valid SourceLoc instance pointing
into the buffer.
2019-10-15 16:05:28 -07:00
Suyash Srijan
008374bd91 Merge pull request #27639 from theblixguy/fix/sr-11298-third-times-a-charm
[Typechecker] Reapply fix for SR-11298
2019-10-16 00:05:18 +01:00
Hamish Knight
3818a16bc8 A handful of independent changes from #27695 (#27696)
A handful of independent changes from #27695
2019-10-15 14:47:02 -07:00
Hamish Knight
2759ae29bb [AST] Add TypeBase::lookThroughSingleOptionalType 2019-10-15 10:12:48 -07:00
Hamish Knight
899f145475 [AST] Add Unsafe[...]Buffer types as known decls 2019-10-15 10:12:47 -07:00
Rintaro Ishizaki
f8209f2865 Merge pull request #27675 from rintaro/revert-syntaxparse
[SyntaxParse] Revert syntax parsing changes from the master branch
2019-10-15 18:33:36 +02:00
Suyash Srijan
6ca121dd2a [Typechecker] Do not incorrectly mark explicitly mutating methods as non-mutatingif we're in a class-constrained protocol extension 2019-10-15 01:35:46 +01:00
Suyash Srijan
70d77e9fe2 Revert "Revert "Merge pull request #27057 from theblixguy/unrevert/SR-11298""
This reverts commit 7725818275.
2019-10-15 01:35:46 +01:00
swift-ci
573a41253e Merge remote-tracking branch 'origin/master' into master-next 2019-10-14 17:09:39 -07:00
Rintaro Ishizaki
8bfb2320b1 [AST] Always initialize 'TypeRepr *' in TupleTypeElement 2019-10-14 15:39:09 -07:00
Robert Widmann
0082ba5abc Remove VarDecl::markInvalid
Inline the interface type reset into its callers and make sure they're
also setting the invalid bit - which this was not doing before.
Unfortunately, this is not enough to be able to simplify any part of var
decl validation.
2019-10-14 12:46:39 -07:00
Rintaro Ishizaki
2f40f2493b Revert "Merge pull request #27565 from rintaro/syntaxparse-exprcollection"
This reverts commit 1724f5b704, reversing
changes made to bc1a3eaaa5.
2019-10-14 12:16:31 -07:00
Rintaro Ishizaki
0e8010d8b9 Revert "Merge pull request #27592 from rintaro/syntaxparse-exprtuple"
This reverts commit cdfd1ab2cf, reversing
changes made to eb02f20f99.
2019-10-14 12:15:48 -07:00
Robert Widmann
742f6b2102 Drastically Simplify VarDecl Validation
This is an amalgam of simplifications to the way VarDecls are checked
and assigned interface types.

First, remove TypeCheckPattern's ability to assign the interface and
contextual types for a given var decl.  Instead, replace it with the
notion of a "naming pattern".  This is the pattern that semantically
binds a given VarDecl into scope, and whose type will be used to compute
the interface type. Note that not all VarDecls have a naming pattern
because they may not be canonical.

Second, remove VarDecl's separate contextual type member, and force the
contextual type to be computed the way it always was: by mapping the
interface type into the parent decl context.

Third, introduce a catch-all diagnostic to properly handle the change in
the way that circularity checking occurs.  This is also motivated by
TypeCheckPattern not being principled about which parts of the AST it
chooses to invalidate, especially the parent pattern and naming patterns
for a given VarDecl.  Once VarDecls are invalidated along with their
parent patterns, a large amount of this diagnostic churn can disappear.
Unfortunately, if this isn't here, we will fail to catch a number of
obviously circular cases and fail to emit a diagnostic.
2019-10-14 12:06:50 -07:00
Robert Widmann
dd82b63f6c Push VarDecl's TypeRepr into ParamDecl
VarDecls inherit their TypeRepr from their enclosing pattern, if any.
To retrieve the TypeRepr attached to a VarDecl or a ParamDecl in
a uniform way, the getTypeReprOrParentPatternTypeRepr API has been
provided.
2019-10-14 12:06:16 -07:00
swift-ci
f257616cf0 Merge remote-tracking branch 'origin/master' into master-next 2019-10-14 11:09:37 -07:00
Arnold Schwaighofer
b75691cdde ReplaceOpaqueTypesWithUnderlyingTypes: We can't look through opaque archetypes if the underlying type contains a type not accessible from the current context
We can't access types in the same module if they are private: they could
be in a different TU.
We can't access types from different modules if they are private or
internal.

Some more information can be gleaned from the resilience expansion: A
minimally resilient function can't reference private or internal types.

rdar://56093964
2019-10-14 10:54:21 -07:00
Hamish Knight
9061d3da71 CaptureInfo no longer needs to be passed by reference
Now that it's only a word in size, it can be passed
by value.
2019-10-13 12:10:26 -07:00
Hamish Knight
25015a5a5f [AST] Remove some dead code 2019-10-13 12:10:25 -07:00