Commit Graph

1945 Commits

Author SHA1 Message Date
Pavel Yaskevich
87cc597d19 [ConstraintSystem] Stop using CheckedConformances cache
It was necessary only for `applySolutionToForEachStmt` in `CSApply`,
diagnostic can avoid it and use information stored in the locator
instead.
2021-01-08 11:36:34 -08:00
Pavel Yaskevich
33f34d15f6 Merge pull request #35281 from xedin/rdar-72819046
[Diagnostics] Special case requirement failures related to `return` statement/expression
2021-01-07 08:56:15 -08:00
Pavel Yaskevich
4917d4314b [ConstraintSystem] Use new ConformanceRequirement to record checked conformances and conditional requirements 2021-01-06 11:01:35 -08:00
Holly Borla
e75b7ef08a [Property Wrappers] Clarify the description of property wrapper handling
in adjustSelfTypeForMember in CSApply.
2020-12-23 11:02:32 -05:00
Slava Pestov
e675bee26c AST: Split off DependencyCollector.h from EvaluatorDependencies.h
Also remove some unnecessary #includes from DependencyCollector.h,
which necessitated adding #includes in various other files.
2020-12-23 00:00:25 -05:00
Luciano Almeida
3189d5c8b8 [CSApply] Removing warning diagnostic that will be moved to a fix format 2020-12-05 22:48:09 -03:00
zoecarver
24aa9ac75e [cxx-interop] Add support for templated member functions.
Essentially applying the same change as for supporting templated
constructors.
2020-12-04 13:07:22 -08:00
zoecarver
08e7160cec [cxx-interop] Support templated C++ constructors. 2020-11-11 09:38:10 -08:00
Pavel Yaskevich
6a753acd1e Merge pull request #34619 from xedin/autoclosure-application-loc
[CSApply] Adjust @autoclosure locator to point to argument expression…
2020-11-07 23:32:58 -08:00
Pavel Yaskevich
d675c7471b [CSApply] Adjust @autoclosure locator to point to argument expression being coerced to result type
While applying type inferred for autoclosure to argument use locator
that records argument/param indices to make it possible for
`coerceToType` to simplify it down to underlying argument expression
if necessary.
2020-11-06 17:56:22 -08:00
Doug Gregor
33cfbbdd72 [Concurrency] Don't diagnose missing "self." in async let autoclosures. 2020-11-04 23:18:51 -08:00
Doug Gregor
58b590aa3d [Concurrency] Wrap the initializer of 'async let' in an autoclosure call.
The initializer of an 'async let' is executed as a separate child task
that will run concurrently with the main body of the function. Model
the semantics of this operation by wrapping the initializer in an
async, escaping autoclosure (representing the evaluation of the child
task), and then a call to that autoclosure (to

This is useful both for actor isolation checking, which needs to treat
the initializer as executing in concurrent code, and also (eventually)
for code generation, which needs to have that code in a closure so
that it can be passed off to the task-creation functions.

There are a number of issues with this implementation producing
extraneous diagnostics due to this closure transformation, which will
be addressed in a follow-up commit.
2020-11-04 17:32:04 -08:00
Zoe Carver
f0f2246793 [cxx-interop] Support C++ function templates in Swift. (#33053)
This patch adds rudimentary support for C++ template functions in swift.
2020-10-21 20:42:25 -07:00
Pavel Yaskevich
64d446582b Merge pull request #34132 from Interfere/SR-12022-LiteralExpr-refactoring
SR-12022: refactor LiteralExpr to combine common initializer code
2020-10-12 12:10:40 -07:00
Pavel Yaskevich
461eafff54 [ConstraintSystem] NFC: Move ConstraintSystem.h to include/swift/Sema 2020-10-08 10:45:47 -07:00
Pavel Yaskevich
767c1a0ed6 [ConstraintSystem] NFC: Move SolutionResult.h to include/swift/Sema 2020-10-08 10:42:08 -07:00
Pavel Yaskevich
4175a01987 Merge pull request #34206 from xedin/decouple-cs-tc-headers
[Sema] Decouple ConstraintSystem and TypeChecker headers
2020-10-07 10:51:53 -07:00
Slava Pestov
d01e1ddd53 Sema: Fix type of MemberRefExpr for a VarDecl with DynamicSelfType
This fixes a regression from 33401ae147.

Fixes <rdar://problem/69804933>.
2020-10-06 15:36:00 -04:00
Pavel Yaskevich
05b223aa0b [Sema] Switch typeCheckExpression to use ContextualTypeInfo 2020-10-06 12:21:07 -07:00
Alexey Komnin
4fa17bf597 SR-12022: refactor LiteralExpr to combine common initializer code 2020-10-01 15:45:16 +03:00
Slava Pestov
2fb3c7c975 Merge pull request #34092 from slavapestov/didset-access-semantics-cycle
Sema: Simplify adjustSelfTypeForMember() a little bit to avoid a cycle
2020-09-26 10:15:52 -04:00
Slava Pestov
71a281c68e Sema: Rename coerceObjectArgumentToType() to coerceSelfArgumentToType()
Also remove the unused AccessSemantics parameter.
2020-09-26 00:02:42 -04:00
Slava Pestov
1a860cc99e Sema: Simplify adjustSelfTypeForMember() a little bit to avoid a cycle
We used to wrap the base expression in an InOutExpr when accessing a
computed property. This was a vestigial remnant of differences in the
SILGen code paths for stored vs computed property access.

These days SILGen doesn't care and is perfectly happy to call getters
and setters with an LValueType base as well.

This allows us to remove the call to getAccessSemantics(), which for
a 'didSet', had to kick off type checking of the body.

Fixes <rdar://problem/69532933>.
2020-09-26 00:02:42 -04:00
Slava Pestov
6a82f242ac Sema: Don't trigger ImplInfoRequest from TypeChecker::buildRefExpr()
It's too early to do that here, because we may be building a reference
to a ParamDecl that is not yet known to be inout, because the constraint
solver has not run yet.

Instead, always compute the access semantics in CSApply.
2020-09-25 17:59:20 -04:00
Anthony Latsis
d953fa646d Merge pull request #34005 from AnthonyLatsis/coself
Sema: Allow non-final classes to satisfy properties and subscripts with covariant Self
2020-09-25 05:23:34 +03:00
Doug Gregor
fc426405b7 [Concurrency] Prohibit partial application of actor-isolated methods. 2020-09-23 14:50:53 -07:00
Anthony Latsis
33401ae147 CS: Use the curried opened type when building a VarDecl member ref
This ensures that we erase opened archetypes before closing an existential result
2020-09-23 21:16:12 +03: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
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
Nathan Hawes
a1ef6e4dac Merge pull request #33749 from nathawes/new-member-completion
[CodeCompletion] Update member completion to handle ambiguous and invalid base expressions
2020-09-09 18:51:22 -07:00
tbkka
82c43a8ac7 [Dynamic Casting] Allow casts to "more optional" types (#33684)
Generally, casting consistency demands that we be able
to extract anything from an existential that can be put
into that existential.  (Which is why the casting spec
requires that casting permit arbitrary injection and
projection of optionals.)

This particular diagnostic prevented optionals from being
projected back out of existentials:
   let i: Int?
   let a: Any = i  // Inject Int? into Any
   // Error prevents projecting Int? back out of Any
   a as? Int?

This also broke certain uses of Mirror (weak variables get reflected as
optionals stored in Any existentials).
2020-08-31 17:52:22 -07:00
Doug Gregor
b62328be4f Merge pull request #33721 from DougGregor/forward-scan-unresolved-member
[Constraint solver] Fix backward trailing closures with ".member" expressions
2020-08-31 16:20:45 -07:00
Doug Gregor
cabcbc9270 [Constraint application] Find trailing closure direction more carefully.
Rather than trying to include each expression kind, which leaves us
open to errors of omission, exclude only the case where we don't record
locators for trailing closure directions.
2020-08-31 13:53:37 -07:00
Doug Gregor
0b2b7b58e8 [Constraint solver] Fix backward trailing closures with ".member" expressions
The introduction of forward-scan matching for trailing closures
(SE-0286) failed to account for unresolved member expressions,
sometimes causing a crash in SILGen. Fixes rdar://problem/67781123.
2020-08-31 11:18:27 -07:00
Pavel Yaskevich
7a9c59a4ca [ConstraintSystem] Add Solution::hasType(ASTNode) 2020-08-28 22:24:24 -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
a6c3e6f543 Merge pull request #33658 from xedin/introduce-hole-type
[ConstraintSystem] Introduce a new type to represent a type hole
2020-08-28 10:40:15 -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
5de23f5cfc [Sema] Rebase and address feedback for implicit member chains 2020-08-26 22:42:30 -04:00
Frederick Kellison-Linn
ed941314ff [Sema] Bail out early of solution application for UME
…when the deduced type is unresolved. Otherwise, we won’t be able to fetch the overload choice or do anything else useful.
2020-08-26 22:42:30 -04:00
Frederick Kellison-Linn
c33ad11ff6 [Sema] Apply clang-format 2020-08-26 22:42:29 -04:00
Frederick Kellison-Linn
5394e6b2d6 [Sema] Use getMetatypeInstanceType instead of casting to MetatypeType 2020-08-26 22:42:29 -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
Frederick Kellison-Linn
4e9b7b20db [Sema] Inject implicit ParenExpr for unresolved member chains
In order to give unresolved member chain result types visibility in the AST, we inject an implicit ParenExpr in CSGen that lives only for the duration of type checking, and gets removed during solution application.
2020-08-26 22:42:29 -04:00
Frederick Kellison-Linn
aedde34fec [Sema] Move unresolved base tracking into CSGen
Remove the tracking of unresolved base types from the constraint system, and place it entirely within the generation phase. We have other ways of getting at the base types after generation.
2020-08-26 22:42:29 -04:00
Frederick Kellison-Linn
5b5e30b6d7 Implement implicit member chains 2020-08-26 22:42:29 -04:00
Pavel Yaskevich
48c9767680 [CSApply] Make sure that hole type are not propagated to AST 2020-08-26 18:42:05 -07:00
Luciano Almeida
7815ecf2a0 [CSApply] Handle OptionalForce component when is initial component on key path expr 2020-08-25 19:31:02 -03:00