Commit Graph

1145 Commits

Author SHA1 Message Date
Pavel Yaskevich
3d7306a066 Merge pull request #28630 from xedin/dynamic-member-diagnostics
[Diagnostics] Port/Improve diagnostics for `@dynamicCallable` and `callAsFunction`
2019-12-09 10:24:27 -08:00
Pavel Yaskevich
328143ad4d [ConstraintSystem] Align @dynamicCallable argument locators with regular calls
Having the same locators for `@dynamicCallable` and the regular calls
make it much easier to produce diagnostics.
2019-12-06 16:43:18 -08:00
Xi Ge
06d633370c test: re-enable attr_originally_definedin_backward_compatibility.swift
rdar://57701641
2019-12-06 13:58:42 -08:00
Jonas Devlieghere
05c128a9e2 Temporily disable attr_originally_definedin_backward_compatibility.swift 2019-12-06 09:46:00 -08:00
Xi Ge
310c56a0c2 Merge pull request #28571 from nkcsgexi/auto-reexport
test: add backward ABI compatibility test case for moving symbols using @_originallyDefinedIn
2019-12-05 15:31:48 -08:00
Xi Ge
ba95536533 test: add backward ABI compatibility test case for moving symbols using @_originallyDefinedIn 2019-12-05 13:40:59 -08:00
Pavel Yaskevich
1d393ebdd4 [ConstraintSystem] Guard against infinite recursion in key path dynamic member lookup
It's possible to construct subscript member responsible for key path
dynamic member lookup in a way which is going to be self-recursive
and an attempt to lookup any non-existent member is going to trigger
infine recursion.

Let's guard against that by making sure that the base type of the
member lookup is different from root type of the key path.

Resolves: rdar://problem/50420029
Resolves: rdar://problem/57410798
2019-12-05 12:42:17 -08:00
swift-ci
8ac1f349a1 Merge pull request #22098 from DaveAMoore/SR-9738 2019-12-02 14:15:49 -08:00
Hamish Knight
78bcb2e9ae [CS] Coerce dynamic member strings to their param type
Move `buildDynamicMemberLookupIndexExpr` into
ExprRewriter, and pass the string literal through
`handleStringLiteralExpr` to properly handle its
coercion to the parameter type.
2019-11-30 14:47:10 -08:00
David Moore
6a0d540949 Sema: Improve @dynamicCallable Diagnostics for Incorrect Parameter Types 2019-11-26 15:02:02 -05:00
Harlan Haskins
1b24c79fe4 [AST] Add attributes for hasMissingDesignatedInitializers and inheritsConvenienceInitializers
We're planning to emit these attributes in module interfaces, but until
we land that patch, we want to parse these attributes and ignore them.

Part of rdar://51249311
2019-11-21 15:45:34 -08:00
Slava Pestov
736343f068 Sema: Skip override checking for members of constrained extensions
When a method in an extension of a class looks like an
override of a method from the base class, we emit a
diagnostic.

However due to a bug we used to skip this diagnostic for
certain members of constrained extensions.

Indeed it feels like we should not be doing this check
at all for members of constrained extensions, so lets
explicitly skip it, fixing a source compatibility problem
that was introduced when the unrelated bug was fixed.

Fixes <rdar://problem/57029805>, <https://bugs.swift.org/browse/SR-11740>.
2019-11-11 23:08:47 -05:00
Michael Gottesman
fe257d58a7 [semantics] Add support for annotating VarDecls with @_semantics.
This is just for prototyping purposes. I also had to loosen a small restriction
where semantics functions were not allowed in local contexts. There really is no
reason to enforce this and I think since it came in the first commit that
introduced semanitcs it was most likely NadavR just being conservative and
careful.
2019-11-05 17:31:58 -08:00
Hamish Knight
65dda6d945 Address other review feedback 2019-11-03 08:42:26 -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
Robert Widmann
0267384e11 Fixup SourceKit and Tests
Patch up all the places that are making a syntactic judgement about the
isInvalid() bit in a ValueDecl.  They may continue to use that query,
but most guard themselves on whether the interface type has been set.
2019-10-30 15:09:14 -07:00
Robert Widmann
e95cc4981b Revert "Remove Some Users of -solver-enable-operator-designated-types"
This reverts commit 46ae4757d2.
2019-10-29 10:33:16 -07:00
Robert Widmann
46ae4757d2 Remove Some Users of -solver-enable-operator-designated-types
There are now two regression tests that need this feature enabled to
pass.
2019-10-24 16:50:45 -07:00
Pavel Yaskevich
74a7f3d8d0 [TypeChecker] Produce a tailored diagnostic for for-in sequence failures
`for-in` "sequence" expression is required to conform to `Sequence`.
2019-10-22 16:57:28 -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
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
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
Rintaro Ishizaki
4eadbaa9f6 Revert "Merge pull request #27466 from rintaro/syntaxparse-type"
This reverts commit a4fcd26b38, reversing
changes made to 88ecae4b9a.
2019-10-14 12:19:04 -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
Pavel Yaskevich
d90117bb8a [Diagnostics] Remove argument handling from conformance failures
Argument-to-Parameter mismatch handles conformance failures
related to arguments, so the logic in `MissingConformanceFailure`
which wasn't entirely correct is now completely obsolete.

Resolves: rdar://problem/56234611
2019-10-14 00:34:37 -07:00
Pavel Yaskevich
f09b07be6c [Diagnostics] Extend use of argument mismatch fix to autoclosure parameters
When it comes to `@autoclosure` parameters we only detect and diagnose
mismatches related to invalid implicit conversions to pointer types. But
`@autoclosure` parameters just like regular ones can have type mismatches
as well which can be handled via recently introduced
`argument-to-parameter mismatch` fix.
2019-10-10 13:33:23 -07:00
Slava Pestov
044204a5d5 Sema: Don't synthesize null bodies for invalid accessors
We don't want hasBody() == true and getBody() == nullptr.
2019-10-03 17:11:44 -04:00
Rintaro Ishizaki
7b31d2b4fb [SyntaxParse] Finish type parsing
- Type attributes
- SIL types
2019-10-01 15:40:10 -07:00
Pavel Yaskevich
88c39db0c3 [Diagnostics] NFC: Fix improved test-cases related to argument-to-parameter mismatches 2019-09-13 22:35:53 -07:00
Pavel Yaskevich
a1643d94f7 [Diagnostics] NFC: Update all of the improved test-cases 2019-09-13 22:35:52 -07:00
Robert Widmann
2c5c4935f2 Merge pull request #27114 from CodaFi/formal-verification
[Gardening] Remove unnecessary options and files from tests
2019-09-10 22:26:12 -07:00
Robert Widmann
dce1e2ea32 [Gardening] Remove unnecessary options and files from tests 2019-09-10 18:15:16 -07:00
swift-ci
6663800cdc Merge pull request #27109 from DougGregor/sr-11393 2019-09-10 18:03:23 -07:00
Doug Gregor
b3790978d1 [Type checker] Fix assertion diagnosting a rename with a different # of arguments. 2019-09-10 10:33:03 -07:00
Luciano Almeida
28d3c6c668 Addressing CR comments 2019-09-07 15:06:45 -03:00
Luciano Almeida
ef8af2a057 Adding valid conventions on tests 2019-09-07 12:30:19 -03:00
Luciano Almeida
a23d6b5f0d Adding tests for message 2019-09-07 12:14:39 -03:00
Robert Widmann
12b157e2bc Restore two tests
Address review feedback on #26970
2019-09-06 09:57:18 -07:00
Robert Widmann
59687518e2 Reject nominal extensions (with a bit of indirection)
If the canonical type is a nominal type then we can offer a diagnostic
that rewrites to it.

Resolves rdar://54799560
2019-09-01 01:52:41 -05:00
Suyash Srijan
bb85ecb8b5 [Typechecker] Diagnose @dynamicMemberLookup subscript when it lacks an explicit argument label 2019-08-25 00:03:07 +01:00
Alexis Laferrière
075dd744e5 Merge pull request #26436 from xymus/fix-require-availability
Fix -require-explicit-availability to handle unavailable decls correctly
2019-08-23 10:24:11 -07:00
Slava Pestov
23edbcaf75 Sema: Merge validateAttributes() into checkDeclAttributes() 2019-08-20 14:47:52 -04:00
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Alexis Laferrière
c84e9df307 Frontend: -require-explicit-availability should not warn if marked unavailable 2019-08-14 13:01:07 -07:00
Pavel Yaskevich
da39eec95e Merge pull request #26602 from omochi/fix-lvalue-constrain
[Sema] Fix lvalue-ness control in matchTypesBindTypeVar
2019-08-13 08:52:27 -07:00
omochimetaru
47a254bfee [Sema] fix typevar attr for subscript 2019-08-13 12:32:06 +09:00
Pavel Yaskevich
075e92b182 Merge pull request #26576 from LucianoPAlmeida/SR-10597-name-lookup-failure-diagnostics
SR-10597 KeyPath dynamic member lookup
2019-08-12 18:00:45 -07:00
Luciano Almeida
55907fbd0f Adding no corrections diagnostic for dynamic member 2019-08-12 19:25:38 -03:00
Luciano Almeida
c62f83356a Fixing typo 2019-08-10 00:17:53 -03:00
Luciano Almeida
a7b5f714e4 Apply diagnostic message suggestion 2019-08-09 23:47:42 -03:00