Commit Graph

15871 Commits

Author SHA1 Message Date
Robert Widmann
21cfcfef2c Merge pull request #30505 from CodaFi/ligated-legacy
[NFC] Remove the Legacy Semantic Queries Bit
2020-03-19 13:45:27 -07:00
Hassan El Desouky
5ff6fe20a9 Remove incorrect comment 2020-03-19 22:31:01 +02:00
Doug Gregor
06196e09c0 Merge pull request #30496 from DougGregor/contextual-pattern-binding-decl
[Constraint system] Use the PatternBindingDecl context when possible.
2020-03-19 13:21:50 -07:00
Hassan El Desouky
a72ea640e6 Handle nil with any number of parentheses 2020-03-19 21:41:22 +02:00
Robert Widmann
6d60d01420 [NFC] Remove the Legacy Semantic Queries Bit
Clients that wish to avoid semantic requests should decline to register
those requests.
2020-03-19 11:04:12 -07:00
Doug Gregor
f2e581c7fc [Type checker] Look through reference storage types for typed patterns.
Fixes a regression caused by properly setting the context for checking
the type in a typed pattern.
2020-03-19 11:01:56 -07:00
Doug Gregor
3abea6be65 [Constraint system] Use the PatternBindingDecl context when possible.
Make sure that we're resolving types and patterns using the
PatternBindingDecl context, both for the type resolver context and the
contextual pattern used for pattern resolution.

Fixes a regression with implicitly-unwrapped options reported as
SR-11998 / rdar://problem/58455441.
2020-03-18 21:09:06 -07:00
Pavel Yaskevich
c72940f2c7 [ConstraintSystem] Default multi-statement closure result to Void only after resolving
Let's remove a side-effect from `ConstraintGenerator::inferClosureType`
and default result type to `Void` for multi-statement closures after
closure has been resolved.
2020-03-18 17:48:56 -07:00
Pavel Yaskevich
2d6170b847 [TypeChecker] Requestify check to determine if closure has explicit result
Determine whether closure body has any explicit `return`
statements which could produce a non-void result.
2020-03-18 17:06:15 -07:00
Slava Pestov
f6187e520a Sema: Don't devirtualize partially applied operator references 2020-03-18 19:23:18 -04:00
Slava Pestov
6412581751 Merge pull request #28698 from slavapestov/sr-75
Sema: Rewrite partial applications into closures
2020-03-18 14:24:37 -04:00
Pavel Yaskevich
2df9bb509e Merge pull request #30440 from LucianoPAlmeida/SR-11540-ambiguos-closure-inference
[SR-11540] Fix ambiguos overload apply to argument for contextual closure
2020-03-18 08:26:34 -07:00
Slava Pestov
c543838854 Sema: Rewrite partial applications into closures
When a method is called with fewer than two parameter lists,
transform it into a fully-applied call by wrapping it in a
closure.

Eg,

Foo.bar => { self in { args... self.bar(args...) } }
foo.bar => { self in { args... self.bar(args...) } }(self)

super.bar => { args... in super.bar(args...) }

With this change, SILGen only ever sees fully-applied calls,
which will allow ripping out some code.

This new way of doing curry thunks fixes a long-standing bug
where unbound references to protocol methods did not work.

This is because such a reference must open the existential
*inside* the closure, after 'self' has been applied, whereas
the old SILGen implementation of curry thunks really wanted
the type of the method reference to match the opened type of
the method.

A follow-up cleanup will remove the SILGen curry thunk
implementation.

Fixes rdar://21289579 and https://bugs.swift.org/browse/SR-75.
2020-03-18 09:29:22 -04:00
Luciano Almeida
3b2dd8cc98 [CSSimplify] Increase the score with SK_FunctionConversion whenever we have to implode parameters to support SE-110 cases 2020-03-17 20:40:07 -03:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Robert Widmann
44ec753893 Remove outdated documentation 2020-03-16 19:20:23 -07:00
Robert Widmann
70b6bbcb13 Remove swift::createTypeChecker
Replace it with the "legacy semantic queries" bit. The remaining client
of this bit is SourceKit, which appears to require this bit be set
conditionally so certain semantic property wrapper requests return
a sentinel value.

We should migrate these requests to a syntactic interface as soon as
possible.

rdar://60516325
2020-03-16 19:20:22 -07:00
Robert Widmann
e79ac7e611 Break TypeChecker down into a namespace 2020-03-16 19:20:22 -07:00
Robert Widmann
14c073ba0b Remove friend references to TypeChecker
TypeChecker has no friends
2020-03-16 19:19:02 -07:00
Robert Widmann
4be0e4a2bd Strip Forward-Declararations of TypeChecker 2020-03-16 19:19:02 -07:00
Robert Widmann
c3c490efb0 Remove the ability to reference instances of TypeChecker 2020-03-16 19:19:02 -07:00
Robert Widmann
52c808648f Move the defined functions list onto SourceFile 2020-03-16 19:19:01 -07:00
Robert Widmann
5d37c9b568 Merge pull request #30431 from gribozavr/LookUpConformance
Updated a comment on LookUpConformance to reflect current implementation
2020-03-16 19:18:28 -07:00
Luciano Almeida
1cccbc8f94 [CSSimplify] Difavor function type overload when trying to match no arg function type with a closure with a anonimous implicit var closure 2020-03-16 22:59:40 -03:00
Pavel Yaskevich
01073be9d6 Merge pull request #30436 from xedin/rdar-60501780
[CSBindings] Refactor a check to produce follow-up direct supertype b…
2020-03-16 16:22:05 -07:00
Pavel Yaskevich
059a3602f8 [CSBindings] Refactor a check to produce follow-up direct supertype bindings
This is a follow-up to https://github.com/apple/swift/pull/30113
which cased a regression because it was placed under a check which
allows direct supertypes to be inferred if previous (failing) binding
has a supertype as well which has nothing to do with collection
inference.

Let's combine supertype check and inference logic to avoid such
confusion in the future.

Resolves: rdar://problem/60501780
2020-03-16 12:17:55 -07:00
Robert Widmann
7926880268 Merge pull request #30427 from CodaFi/an-enumeration-of-grievances
Do a little extra validation of RawRepresentable.RawValue
2020-03-16 12:09:42 -07:00
Dmitri Gribenko
97855c9e29 Updated a comment on LookUpConformance to reflect current implementation
LookUpConformance does not depend on a type checker instance anymore.
2020-03-16 19:05:58 +01:00
Robert Widmann
2966a38ee1 Do a little extra validation of RawRepresentable.RawValue
* In the DeclChecker, duplicate the check that we have a reasonable
RawValue type so we do not attempt to form an invalid key. The interface
to the autoincrementer has this as invariant, but it was not previously
checked as a precondition.

* In the deriver, try to check for the case where the user has written
a mismatched explicit declaration of RawValue, or a type sharing that
name, and check type equality with the declared raw type to make this
pass resilient to mismatches as well.

Resolves rdar://57072148, rdar://59703784
2020-03-16 09:59:09 -07:00
Anthony Latsis
d688710fb3 [Diag] Move invalid where clause on top-level decl diagnostic to Sema 2020-03-15 13:38:49 +03:00
Pavel Yaskevich
5bb2a62b70 Merge pull request #30409 from HassanElDesouky/SR-12309
[CSGen] Force unwrapping 'nil' compiles without warning
2020-03-14 11:41:02 -07:00
HassanElDesouky
e747dc25b1 Resolve issues 2020-03-14 08:02:23 +02:00
HassanElDesouky
8d5a33ee89 Move to visitNilLiteralExpr 2020-03-14 07:39:44 +02:00
Pavel Yaskevich
2dd74706c9 Merge pull request #30411 from xedin/diags-to-use-solution-instead-of-cs
[Diagnostics] Switch `FailureDiagnostic` to use a solution
2020-03-13 20:20:58 -07:00
HassanElDesouky
ceb3f3842f [SR-12309] Add more tests 2020-03-14 03:06:10 +02:00
Pavel Yaskevich
7800a04de3 [Diagnostics] Adjust "missing arguments" diagnostic to store parameter indices directly
This helps to avoid allocating new type variables (which shouldn't be done regardless)
to store parameter indices when `missing arguments` diagnostic is used by other diagnostics.
2020-03-13 16:55:37 -07:00
HassanElDesouky
8195cce1d3 [SR-12309] Cannot force unwrap 'nil' 2020-03-14 01:28:28 +02:00
Pavel Yaskevich
3ab8710329 [Diagnostics] Cleanup use of constraint system by ConstraintFix/FailureDiagnostic 2020-03-13 15:02:10 -07:00
Pavel Yaskevich
52cf60122b [Diagnostics] Switch isMisplacedMissingArgument to use a solution 2020-03-13 12:46:38 -07:00
Pavel Yaskevich
0fc9d1b84a [Diagnostics] Move getFunctionArgApplyInfo to Solution
Instead of relying on constraint system having solution applied
let's pass a solution directly to `getFunctionArgApplyInfo`.
2020-03-13 12:46:25 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Pavel Yaskevich
af4afe3fbc [Diagnostics] Switch FailureDiagnostic to use a solution
Make diagnostics stateless by providing them with a solution
instead of applying a solution back to constraint system and
using constraint system. Latter doesn't work well when there
is an ambiguity and multiple solutions are available instead
of one.
2020-03-13 10:37:23 -07:00
Nathan Hawes
fcf95eae16 Merge pull request #30187 from nathawes/indentation
[SourceKit/CodeFormat] Re-work and improve the indentation implementation
2020-03-13 08:01:29 -07:00
Brent Royal-Gordon
0be8357dcc Merge pull request #29950 from brentdax/less-crossover
Make cross-importing faster
2020-03-13 01:45:02 -07:00
Pavel Yaskevich
1fc0ea6b0e [CSFix] Allow diagnose to accept a solution to diagnose
Instead of always applying solution back to constraint system
before diagnostics, let's pass solution directly to `ConstaintFix::diagnose`
method to be used by `FailureDiagnostic` which paves a way for
stateless diagnostics.
2020-03-12 11:41:36 -07:00
Shoaib Meenai
e506e4ac02 Merge pull request #30375 from smeenai/master
Update for LLVM changes
2020-03-12 11:16:06 -07:00
Pavel Yaskevich
7c1df6ad51 [ConstraintSystem] Remove getType(Expr*) accessor from Solution
It's obsolete and has been superseded by `getType(TypedNode)`.
2020-03-12 10:28:18 -07:00
Pavel Yaskevich
126065821a Merge pull request #30348 from omochi/fix-arg-reorder
[ConstraintSystem] Fix bug of argument reordering in matchCallArguments
2020-03-12 09:29:11 -07:00
Dmitri Gribenko
be80642fe8 Removed a catch-all default implementation of ASTVisitor::visitTypeRepr
Other AST nodes don't have such functionality now, and it was removed
from them previously. Not having a default implementation means that
users of ASTVisitor have to either explicitly write a catch-all default,
or handle all cases. Making this decision consciously is a good
practice.
2020-03-12 11:29:11 +01:00
Shoaib Meenai
8b8650770e Include Host.h for getProcessTriple
https://github.com/llvm/llvm-project/commit/213aea4c5836 means this
header doesn't get implicitly transitively included anymore, so we have
to include it explicitly.
2020-03-11 23:36:59 -07:00