Commit Graph

918 Commits

Author SHA1 Message Date
Alex Hoppen
8f16139a8b Revert "Sema: Remove some unreachable code from CSApply"
This reverts commit 9d3c8ca396.
2021-03-19 19:38:52 +01:00
Holly Borla
c29eecd0b6 [Property Wrappers] Store the callee in AppliedPropertyWrapperExpr to use
the correct substitution map when emitting the property wrapper generator
application in SILGen.
2021-02-25 18:35:14 -08:00
Holly Borla
b821c8d76b [Sema] Add an implicit applied property wrapper expression and a new
dedicated initializer context for this expressions.
2021-02-25 18:35:14 -08:00
Holly Borla
4bdeed570b [ConstraintSystem] Use a wrapped value placeholder when matching property
wrapper arguments in the constraint system in order to avoid generating
constraints for the argument multiple times.
2021-02-25 18:35:13 -08:00
Holly Borla
11028350a7 Merge pull request #35589 from Jumhyn/placeholder-types
[AST, Sema] Replace HoleType with PlaceholderType
2021-02-22 08:35:37 -08:00
Slava Pestov
9d3c8ca396 Sema: Remove some unreachable code from CSApply
I believe these code paths could only be reached by re-typechecking
invalid code in the old CSDiag implementation.
2021-02-17 18:27:08 -05:00
Frederick Kellison-Linn
e4ea1678dc Rename HoleType to PlaceholderType
HoleType basically served the same purpose as PlaceholderType. This commit unifies the two.
2021-02-16 22:59:19 -05:00
Pavel Yaskevich
51bd8d93d6 Merge pull request #34510 from maustinstar/sr-11711
[SR-11711]  [Parse] Single-expression implicit returns within #if declarations
2020-11-05 21:14:44 -08:00
Doug Gregor
33cfbbdd72 [Concurrency] Don't diagnose missing "self." in async let autoclosures. 2020-11-04 23:18:51 -08:00
maustinstar
037edf3a8c [SR-11711] Refactor shared parser code for single-expression returns 2020-11-03 22:03:11 -05:00
maustinstar
37b17338e5 [SR-11711] Single-expression returns for #if declarations within functions 2020-11-03 12:47:39 -05:00
Alexey Komnin
4fa17bf597 SR-12022: refactor LiteralExpr to combine common initializer code 2020-10-01 15:45:16 +03:00
Slava Pestov
29ce77209c AST: Convert ConstructorDecl::getDelegatingOrChainedInitKind() into a request
This method had a messy contract:

- Setting the diags parameter to nullptr inhibited caching

- The initExpr out parameter could only used if no result
  had yet been cached

Let's instead use the request evaluator here.
2020-09-25 17:59:20 -04:00
Doug Gregor
63ed61db83 Clean up AutoClosureExpr::getUnwrappedCurryThunkExpr().
Replace a hand-rolled variant of the subject function used for actor
isolation checking with a call to it. This exposed some limitations of
the function, which would assert() when dealing with partial
applications that involved optionals. Fix those as well.
2020-09-23 21:02:12 -07:00
Doug Gregor
ec72db1d8a Merge pull request #34019 from DougGregor/curry-thunk-dot-syntax-call-source-locs
[Type checker] Use DotSyntaxCallExpr consistently for instance members.
2020-09-21 22:11:10 -07:00
Doug Gregor
6ce4eb2390 [Type checker] Use DotSyntaxCallExpr consistently for instance members.
When building a curry thunk for unapplied references to instance
methods, the type checker would build a CallExpr rather than a
DotSyntaxCallExpr to work around various issues with source locations.
Fix the underlying issues with source locations in DotSyntaxCallExpr
so we can consistently build DotSyntaxCallExpr here, and assert that
we don't do this again:

* DotSyntaxCallExpr wasn't able to reason about having just one of its
children having source location information; fix it.
* @dynamicCallable support was passing the declaration source location
for the call expression, which was nowhere in the expression itself.
The above mistake was covering for this one.
2020-09-21 16:57:25 -07:00
Slava Pestov
7cb809bf1d ASTScope: Remove old implementation of 'selfDC' computation 2020-09-18 16:11:06 -04:00
Slava Pestov
9c4c95943d AST: Generalize CaptureListEntry::isSimpleSelfCapture() to work without parse-time lookup
The DeclRefExpr here was resolved by parse-time lookup.
Without it, it's an UnresolvedDeclRefExpr.
2020-09-18 13:29:46 -04:00
Slava Pestov
d7f4b1a1bd AST: Capture list bindings now point back to their parent CaptureListExpr
We'll need this to get the right 'selfDC' when name lookup
finds a 'self' declaration in a capture list, eg

class C {
  func bar() {}
  func foo() {
    _ = { [self] in bar() }
  }
}
2020-09-18 02:59:15 -04:00
swift_jenkins
fb946baf59 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-28 11:08:22 -07:00
Rintaro Ishizaki
c48a676a1c Merge pull request #31679 from Jumhyn/implicit-member-chains-different-types
[SE-0287] [Sema] Implementation for implicit member chains
2020-08-28 10:47:53 -07:00
Pavel Yaskevich
4847ec9a6b [AST/TypeChecker] Add more asserts to make sure types don't get into AST 2020-08-27 13:18:45 -07:00
Frederick Kellison-Linn
352adc3b5d Remove Argument from UnresolvedMemberExpr
Instead, an expresison like `.foo()` is represented as an `UnresolvedMemberExpr` nested inside a `CallExpr`.
2020-08-26 22:42:30 -04:00
Frederick Kellison-Linn
f5845666e6 [AST] Introduce UnresolvedMemberChainResultExpr
Introduce a new expression type for representing the result of an unresolved member chain. Use this expression type instead of an implicit ParenExpr for giving unresolved member chain result types representation in the AST during type checking.
2020-08-26 22:42:29 -04:00
Nathan Hawes
f0c8b8e571 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	include/swift/AST/PrettyStackTrace.h
2020-08-14 11:06:27 -07:00
David Zarzycki
1e940c2c7e [NFC] Fix -Wsuggest-override warnings
LLVM, as of 77e0e9e17daf0865620abcd41f692ab0642367c4, now builds with
-Wsuggest-override. Let's clean up the swift sources rather than disable
the warning locally.
2020-08-13 16:17:46 -04:00
swift-ci
0dcbd763be Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-06 15:43:58 -07:00
Nathan Hawes
ef6c374516 [Sema/Index] Resolve #keyPath components so they can be indexed
Unlike \keypath expressions, only the property components of #keypath
expressions were being resolved, so index wouldn't pick up references for their
qualifying types.

Also fixes a code completion bug where it was reporting members from the Swift
rather than ObjC side of bridged types.

Resolves rdar://problem/61573935
2020-08-05 15:27:52 -07:00
swift-ci
ae09b1eb08 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-04 18:03:56 -07:00
Rintaro Ishizaki
f97d68f3a7 Merge pull request #33290 from apple/revert-33245-index-key-paths
Revert "[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc."
2020-08-04 15:48:09 -07:00
Anthony Latsis
78f0259bfb Merge pull request #33283 from AnthonyLatsis/type-locura-2
ASTWalker: Offload TypeLoc
2020-08-05 00:17:33 +03:00
Nathan Hawes
607e2b8822 Manually merge remote-tracking branch 'upstream/master' into HEAD 2020-08-04 13:47:48 -07:00
Rintaro Ishizaki
00e4a76ef0 Revert "[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc." 2020-08-04 12:51:52 -07:00
Anthony Latsis
b26310ee97 TypeLoc: Offload TypeLoc off the ASTWalker 2020-08-04 18:13:28 +03:00
Matei Oprea
f971b349b4 [NFC] Refactor manual size calculations in memory allocation (#33256) 2020-08-03 22:02:31 -07:00
Varun Gandhi
3882beb85d [NFC] Use consistent naming scheme for predicate methods. (#33265)
bool throws() -> isThrowing(), bool async() -> isAsync()
2020-08-03 16:37:29 -07:00
Nathan Hawes
4c7cd16c3f Merge pull request #33245 from nathawes/index-key-paths
[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc.
2020-08-03 10:28:48 -07:00
Nathan Hawes
1d78fe1211 [Sema/Index] Resolve #keyPath components so they can be indexed
Unlike \keypath expressions, only the property components of #keypath
expressions were being resolved, so index wouldn't pick up references for their
qualifying types.

Also fixes a code completion bug where it was reporting members from the Swift
rather than ObjC side of bridged types.

Resolves rdar://problem/61573935
2020-07-31 17:11:23 -07:00
swift-ci
3a299d5a76 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-30 08:23:18 -07:00
Chris Lattner
8bde04cc14 [Concurrency] Implement parsing and semantic analysis of await operator
Similar to `try`, await expressions have no specific semantics of their
own except to indicate that the subexpression contains calls to `async`
functions, which are suspension points. In this design, there can be
multiple such calls within the subexpression of a given `await`.

Note that we currently use the keyword `__await` because `await` in
this position introduces grammatical ambiguities. We'll wait until
later to sort out the specific grammar we want and evaluate
source-compatibility tradeoffs. It's possible that this kind of prefix
operator isn't what we want anyway.
2020-07-29 22:08:09 -07:00
swift-ci
adb31a9532 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-28 19:23:53 -07:00
Rintaro Ishizaki
59196975b7 Merge pull request #32696 from rintaro/ide-completion-typecheckatloc
[CodeCompletion] Only type check target statement and related decls in function body
2020-07-28 19:12:31 -07:00
swift-ci
0202740b0a Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-28 14:24:04 -07:00
Doug Gregor
73f07a6f0f Merge pull request #33092 from DougGregor/forward-trailing-closure-matching-sourcecompat-backward-bias
[SE-0286] Forward matching of trailing closure arguments
2020-07-28 14:11:15 -07:00
Nathan Hawes
b0a2230860 Manually merge remote-tracking branch 'upstream/master' into merge-in-master 2020-07-27 09:25:01 -07:00
Doug Gregor
3f96125edc [AST] Don't compute type in ClosureExpr::capturesSelfEnablingImplictSelf
This predicate can be determined without computing the full type of
the declaration.
2020-07-24 22:32:07 -07:00
Rintaro Ishizaki
7e402e1ec4 [Sema] Stop on-demand type checking for 'VarDecl' in 'TapExpr' 2020-07-24 10:48:51 -07:00
Rintaro Ishizaki
12762a2a30 [CodeCompletion] Only type check related statements in function body
Introduce 'TypeCheckSingleASTNode' mode that only type checks single body
element and dependent necessities (i.e. referencing ValueDecls and their
dependencies).

Renamed swift::typeCheckAbstractFunctionBodyAtLoc() to
swift::typeCheckASTNodeAtLoc(DeclContext *, SourceLoc). That type checks
innermost 'ASTNode' at the location. Also, 'TypeCheckSingleASTNode' mode
skips type checking any "body" of the node (i.e. BraceStmt elements for
function body, if statement body, closure body, etc.)

Added on-demand type checking using it:
 - VarDecl in TapExpr
 - ParamDecl in ClosureExpr
 - Return type of ClosureExpr
 - Binding value in control statements
   (e.g. ForEachStmt, SwitchStmt, DoCatchStmt, etc.)

rdar://problem/63932852
2020-07-24 10:48:51 -07:00
Rintaro Ishizaki
b1eec26653 [AST] Add a enum for type checking state of ClosureExpr's body 2020-07-24 10:46:03 -07:00
Rintaro Ishizaki
0ec7a91e38 [AST] Add a pointer to parent 'TapExpr' expression in 'VarDecl'
Preparation for on-demand 'VarDecl' type checking in interpolated string
literals.
2020-07-24 10:46:03 -07:00