Commit Graph

596 Commits

Author SHA1 Message Date
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
78b202ccdf [ASTWalker] Support configurating whether or not to visit the original
value of a property wrapper placeholder expression.
2021-02-25 18:35:13 -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
Frederick Kellison-Linn
0f7ec99b52 [AST] Add PlaceholderTypeRepr 2021-02-16 22:59:18 -05:00
Slava Pestov
faae25a8bb AST: The body of a CaseStmt is always a BraceStmt 2020-10-06 15:39:10 -04:00
Slava Pestov
0e276456bd AST: The body of a GuardStmt is always a BraceStmt 2020-10-06 15:39:09 -04:00
Slava Pestov
445d747622 AST: Move GenericParamList and friends to GenericParamList.{h,cpp} 2020-09-29 19:51:03 -04:00
Slava Pestov
fec67d68a8 AST: Add a GenericParamList::walk() method 2020-09-11 17:45:58 -04: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
Anthony Latsis
492156c10f Remove SubscriptDecl::getBodyResultTypeLoc 2020-08-19 00:09:10 +03:00
Anthony Latsis
21faa48298 Remove FuncDecl::getBodyResultTypeLoc 2020-08-19 00:09:10 +03: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
Doug Gregor
6c3ad1046f [Statement checker] Always wire up case vars with bindSwitchCasePatternVars
bindSwitchCasePatternVars() was introduced as a simpler way to wire up
the "parent" links for case variables with same-named case variables
from the previous case item, and is used in the function builders code
to handle switch statements. It duplicated some logic from the
statement checker that did the same thing using a more complicated
algorithm.

Switch (ha ha) the logic in the statement checker over to using
bindSwitchCasePatternVars(), fixing a bug involving unresolved
patterns along the way, and remove the old code that incrementally
wired up the parent links. The resulting code is simpler and is
unified across the various code paths.
2020-08-04 22:34:23 -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
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
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
Slava Pestov
6364a99123 Merge pull request #33176 from slavapestov/apply-generic-arguments-cleanup
Clean up declaration checker's modeling of generic arguments and parameter lists
2020-07-29 11:03:14 -04: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
Slava Pestov
c46eb22fcd AST: Don't attach trailing where clause requirements to the GenericParamList
Previously we had two representations for the 'where' clause of a
parsed declaration; if the declaration had generic parameters of
its own, we would store them in the GenericParamList, otherwise
we would store them separately in a TrailingWhereClause instance.

Since the latter is more general and also used for protocols and
extensions, let's just use it for everything and simplify
GenericParamList in the process.
2020-07-28 02:07:16 -04:00
Slava Pestov
14dd4eef2d AST: Add a way to distinguish a parsed generic parameter list from a synthesized one
Add a new GenericContext::getParsedGenericParams(). This produces
the same value as GenericContext::getGenericParams() if the generic
parameter list was written in source. For extensions and protocols,
this returns nullptr without synthesizing anything.
2020-07-28 02:07:16 -04:00
Doug Gregor
05c4cee9e2 [Constraint solver] Type check captures as part of the constraint system
Rather than type-checking captures as separate declarations during
pre-check, generate constraints and apply solutions to captures in
the same manner as other pattern bindings within a constraint
system.

Fixes SR-3186 / rdar://problem/64647232.
2020-07-25 00:20:05 -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
Robert Widmann
cb82a46e6e [NFC] Stash Syntactic Information in EnumIsCaseExpr
After the TypeLocs were removed here, the TypeRepr from the IsExpr was
the only thing providing access to syntactic information from the parent
IsExpr. In order to support this, it was possible to construct a bizarre
ConditionalCheckedCastExpr that contained both semantic and syntactic
information. This doesn't comport with the rest of the casting nodes,
which force you to pick one or the other.

Since we're rewriting an IsExpr into a EnumIsCaseExpr, let's just stash
the syntactic information there. This unblocks a bit of cleanup.
2020-07-22 11:08:52 -07:00
Michael Gottesman
092edd6621 [ast] Rename VarPattern -> BindingPattern.
VarPattern is today used to implement both 'let' and 'var' pattern bindings, so
today is already misleading. The reason why the name Var was chosen was done b/c
it is meant to represent a pattern that performs 'variable binding'. Given that
I am going to add a new 'inout' pattern binding to this, it makes sense to
give it now a better fitting name before I make things more confusing.
2020-07-16 18:56:01 -07:00
Robert Widmann
8be08b16a8 [NFC] Remove Trivial Projections from TypeLocs in RequirementRepr 2020-06-11 16:03:43 -07:00
Robert Widmann
426d930d10 Merge pull request #32301 from CodaFi/location-location-location
Strip TypeLoc out of Patterns
2020-06-10 19:25:56 -07:00
Rintaro Ishizaki
4205e46959 Merge pull request #32184 from rintaro/ide-completion-rdar63965160
[CodeCompletion] Wrap base expression with CodeCompletionExpr
2020-06-10 16:19:35 -07:00
Robert Widmann
2371e5c260 Strip TypeLoc from EnumElementPattern 2020-06-10 14:22:46 -07:00
Robert Widmann
fc9070c072 Strip TypeLoc from IsPattern 2020-06-10 13:29:39 -07:00
Robert Widmann
ca728917e1 Merge pull request #32138 from AnthonyLatsis/eliminate-typeloc
Sema: Remove TypeLoc from ExplicitCastExpr (via TypeExpr)
2020-06-10 11:28:50 -07:00
Anthony Latsis
4b4634141f Sema: Remove TypeLoc from ExplicitCast 2020-06-09 15:20:25 +03:00
Rintaro Ishizaki
3ec250f701 [CodeCompletion] Wrap base expression with CodeCompletionExpr
For example for:

  funcName(base.<HERE>)

Wrap 'base' with 'CodeCompletionExpr' so that type checker can check
'base' independently without preventing the overload choice of 'funcName'.

This increases the chance of successful type checking.

rdar://problem/63965160
2020-06-05 15:51:07 -07:00
Doug Gregor
a115ad9f5c [AST] Record "separately checked" in ClosureExpr.
Reverse the polarity of the "checked in context" bit for ClosureExpr
to "separately checked", which simplifies the AST walker logic (to
"should we walk separately type-checked closure bodies?") and
eliminates single-expression closures as a separate case to consider.
2020-06-05 00:05:11 -07:00
Doug Gregor
836bc57fe5 [AST Walker] Stop visiting the bodies of closures as expressions.
Single-expression closures have always been traversed differently
from multi-statement closures. The former were traversed as if the
expression was their only child, skipping the BraceStmt and implicit
return, while the later was traversed as a normal BraceStmt.
Unify on the latter treatment, so that traversal

There are a few places where we unintentionally relied on this
expression-as-child behavior. Clean those up to work with arbitrary
closures, which is an overall simplification in the logic.
2020-06-04 23:06:32 -07:00
Doug Gregor
fa2d4dc6e6 [AST] DoStmt always contains a BraceStmt 2020-05-29 15:28:30 -07:00
Robert Widmann
1319b53528 Hide the TypeExpr in ClosureExpr 2020-04-29 13:40:39 -07:00
Robert Widmann
5b3060318e [NFC] Strip ClosureExpr of its TypeLoc 2020-04-28 20:10:10 -07:00
Robert Widmann
09db2902d2 Strip TypeExpr of its TypeLoc
Remove duplication in the modeling of TypeExpr. The type of a TypeExpr
node is always a metatype corresponding to the contextual
type of the type it's referencing. For some reason, the instance type
was also stored in this TypeLoc at random points in semantic analysis.

Under the assumption that this instance type is always going to be the
instance type of the contextual type of the expression, introduce
a number of simplifications:

1) Explicit TypeExpr nodes must be created with a TypeRepr node
2) Implicit TypeExpr nodes must be created with a contextual type
3) The typing rules for implicit TypeExpr simply opens this type
2020-04-23 17:04:38 -07:00
Holly Borla
66e85721cb Merge pull request #30807 from hborla/property-wrapper-refactoring
[Property Wrappers] Refactor property wrappers so the synthesized backing init is only type checked once
2020-04-14 10:48:22 -07:00
Holly Borla
65105f3a26 [Property Wrappers] Introduce a new Expr node for the property wrapper
wrapped value placeholder in an init(wrappedValue:) call that was previously
injected as an OpaqueValueExpr. This commit also restores the old design of
OpaqueValueExpr.
2020-04-09 16:00:57 -07:00
Owen Voorhees
43e2d107e1 [SE-0276] Implement multi-pattern catch clauses
Like switch cases, a catch clause may now include a comma-
separated list of patterns. The body will be executed if any
one of those patterns is matched.

This patch replaces `CatchStmt` with `CaseStmt` as the children
of `DoCatchStmt` in the AST. This necessitates a number of changes
throughout the compiler, including:
- Parser & libsyntax support for the new syntax and AST structure
- Typechecking of multi-pattern catches, including those which
  contain bindings.
- SILGen support
- Code completion updates
- Profiler updates
- Name lookup changes
2020-04-04 09:28:26 -07:00
Holly Borla
d22b984a93 [Expr] Allow OpaqueValueExpr to store an underlying expression 2020-04-03 13:47:56 -07:00
Anthony Latsis
016d3bbfae [ASTWalker] Associated type defaults deserve syntax coloring 2020-03-21 08:37:53 +03:00
Nathan Hawes
a368434432 [SourceKit/CodeFormat] Re-work and improve the indentation implementation.
This restructures the indentation logic around producing a single IndentContext
for the line being indented. An IndentContext has:
- a ContextLoc, which points to a source location to indent relative to,
- a Kind, indicating whether we should align with that location exactly, or
  with the start of the content on its containing line, and
- an IndentLevel with the relative number of levels to indent by.

It also improves the handling of:
- chained and nested parens, braces, square brackets and angle brackets, and
  how those interact with the exact alignment of parameters, call arguments,
  and tuple, array and dictionary elements.
- Indenting to the correct level after an incomplete expression, statement or
  decl.

Resolves:
rdar://problem/59135010
rdar://problem/25519439
rdar://problem/50137394
rdar://problem/48410444
rdar://problem/48643521
rdar://problem/42171947
rdar://problem/40130724
rdar://problem/41405163
rdar://problem/39367027
rdar://problem/36332430
rdar://problem/34464828
rdar://problem/33113738
rdar://problem/32314354
rdar://problem/30106520
rdar://problem/29773848
rdar://problem/27301544
rdar://problem/27776466
rdar://problem/27230819
rdar://problem/25490868
rdar://problem/23482354
rdar://problem/20193017
rdar://problem/47117735
rdar://problem/55950781
rdar://problem/55939440
rdar://problem/53247352
rdar://problem/54326612
rdar://problem/53131527
rdar://problem/48399673
rdar://problem/51361639
rdar://problem/58285950
rdar://problem/58286076
rdar://problem/53828204
rdar://problem/58286182
rdar://problem/58504167
rdar://problem/58286327
rdar://problem/53828026
rdar://problem/57623821
rdar://problem/56965360
rdar://problem/54470937
rdar://problem/55580761
rdar://problem/46928002
rdar://problem/35807378
rdar://problem/39397252
rdar://problem/26692035
rdar://problem/33760223
rdar://problem/48934744
rdar://problem/43315903
rdar://problem/24630624
2020-03-10 21:04:21 -07:00
fischertony
c498ad0283 IDE: Ensure syntax coloring for contextual where clauses 2020-03-05 07:29:28 +03:00
Ben Langmuir
5f3a1a397b [cursorinfo] Avoid use of null raw value in enum element decl
SR-12283
rdar://59857568
2020-03-02 16:29:17 -08:00
Holly Borla
778f8941ee [MiscDiagnostics] Walk into the body of a non single-statement closure
if the closure had a function builder transform applied.

This way, function builder closures can have syntactic restrictions
diagnosed the same way as other expressions.
2020-02-04 16:29:02 -08:00