Commit Graph

1659 Commits

Author SHA1 Message Date
Doug Gregor
18569e5f77 Merge pull request #16963 from DougGregor/evaluator-type-checker
[Type checker] Use the request-evaluator in the type checker.
2018-06-15 22:41:31 -07:00
Joe Groff
6257ebe2d4 Merge pull request #17203 from jckarter/rvalue-array-elements
Sema: Force the 'getElements' array of a type-checked ArrayExpr to contain rvalues.
2018-06-14 21:10:20 -07:00
Doug Gregor
b7fbe57bf9 [AST] Remove “validated” bit from TypeLoc.
TypeLocs have been “validated” when they have a non-null Type, so eliminate
the separate “validated” bit that was out-of-sync with the Type field.
2018-06-14 15:29:57 -07:00
Joe Groff
194f1f808b Sema: Force the 'getElements' array of a type-checked ArrayExpr to contain rvalues.
There are other parts of CSApply that attempt to peephole transform ArrayExprs (particularly bridging, which tries to turn `[x, y, ...] as T` into `[x as T, y as T, ...]`) and expect the elements to have already been rvalue-d. Fixes rdar://problem/40859007.
2018-06-14 12:08:44 -07:00
Slava Pestov
296ce3f312 AST: Remove hack-around for getInterfaceType() on ParamDecl returning InOutType
Most callers did not want the InOutType here, and checked
the ParamDecl's flags instead.
2018-06-13 15:38:52 -07:00
Slava Pestov
10b1755ccc Sema: Propagate noescape bit into closure passed to withoutActuallyEscaping
Fixes <rdar://problem/40853562>, <https://bugs.swift.org/browse/SR-7886>.
2018-06-11 22:36:08 -07:00
Robert Widmann
24abf3ea09 [NFC] Refactor default argument info
Refactor the interface to return a bit vector. Along the way, fix up
the callers and remove some dead usages of the defaults information
that were copied and pasted around Sema.
2018-05-31 17:28:04 -07:00
Lily Vulcano
63348bce6f Merge pull request #16736 from millenomi/LinuxAsBridging_2
Turn on 'as' bridging for Linux (2)
2018-05-31 09:23:45 -07:00
Lily Vulcano
1377ab7d7e Turn on ‘as’ bridging on Darwin. 2018-05-30 15:07:22 -07:00
Slava Pestov
ccc23c988b Sema: Fix bug in 'invalid dynamic constructor reference' check
If the base value was 'self', we were allowing a reference to a
non-required initializer, because you're allowed to do this inside
another initializer.

But if you're in a static method, 'self.init' should obey the same
restrictions as 'foo.init' for any other metatype value 'foo'.
2018-05-29 22:51:25 -07:00
Slava Pestov
d8fc9decf9 AST: Remove GenericSignature::getSubstitutionMap() 2018-05-28 19:45:28 -07:00
Pavel Yaskevich
d501b58f8c Merge pull request #16785 from brentdax/explicitly-implicit
Fix implicit UnresolvedMemberExpr crash
2018-05-24 00:23:23 -07:00
Brent Royal-Gordon
769bc80e64 Fix implicit UnresolvedMemberExpr crash
The isImplicit flag on an UnresolvedMemberExpr was not carried over to the CallExpr node generated after type checking, which caused later stages of compilation to try to use invalid SourceLocs. This change correctly propagates the flag.
2018-05-22 21:37:03 -07:00
swift-ci
81ce77d510 Merge pull request #16644 from ravikandhadai/LargeIntOverflowPR 2018-05-21 20:37:47 -07:00
Ravi Kandhadai
f1ff8a61a5 [Sema] Add Sema checks for detecting large integer literals that
overflow Builtin.Int2048 and add tests for checking the
correctness of the diagnostics.
2018-05-21 18:41:44 -07:00
David Zarzycki
3843d39297 Merge pull request #16741 from davezarzycki/nfc_create_abstract_LookupExpr
[AST] NFC: Create abstract class for MemberRefExpr/SubscriptExpr
2018-05-20 08:13:23 -04:00
David Zarzycki
6d52f434af [AST] NFC: Create abstract class for MemberRefExpr/SubscriptExpr
This consolidation includes two examples of where this useful. There are
probably more.
2018-05-19 12:33:35 -04:00
Slava Pestov
bd6281c558 AST: Change SubstitutionMap conformance lookup callbacks to take ProtocolDecl and not ProtocolType 2018-05-19 01:09:17 -07:00
Ben Langmuir
628b6a1fc7 Revert "Turn on ‘as’ bridging on Linux." 2018-05-17 14:54:35 -07:00
Lily Vulcano
b9455930ee Turn on ‘as’ bridging on Darwin. 2018-05-17 09:59:39 -07:00
Mark Lacey
bcb98fa29b Merge pull request #16623 from rudkx/rdar31538995
Disallow some implicit pointer conversions in autoclosures.
2018-05-16 16:07:33 -07:00
Mark Lacey
43775e817d Disallow some implicit pointer conversions in autoclosures.
Disallow implicit conversion or arguments from Array, String, and
InOut (formed by &) to pointer types if the argument is for an
@autoclosure parameter.

These conversions were really only intended to be used for C/ObjC
interop, and in some contexts like autoclosures they are not safe.

Fixes: rdar://problem/31538995
2018-05-16 12:13:25 -07:00
Pavel Yaskevich
58fb0ac6a7 [CSApply] Make sure that indexing into an r-value tuple produces r-value
This is modeled in constraint system in a way
that when member type is resolved by `resolveOverload`
it would take r-value type of the element at
specified index, but if it's a type variable it
could still be bound to l-value later, so r-value
result has to be enforced by coercion if necessary.

Resolves: rdar://problem/39931475
2018-05-16 00:20:46 -07:00
Robert Widmann
6ed7e4af59 Merge pull request #16088 from orakaro/exp
More detail diagnostic when downcast to CoreFoundation Type
2018-05-08 21:46:06 -04:00
Doug Gregor
ebf9cdcc44 [AST] Collapse storage for ConcreteDeclRef.
Rather than ASTContext-allocating ConcreteDeclRef’s storage when there is a
non-empty substitution map, put the SubstitutionMap directly in the
ConcreteDeclRef. Simplify the various interfaces along the way.
2018-05-02 13:39:21 -07:00
Doug Gregor
192234415d [AST] Store SubstitutionMaps in ConcreteDeclRef and Witness data structures.
Replace two prominent uses of SubstitutionList, in ConcreteDeclRef and
Witness, with SubstitutionMap. Deal with the myriad places where we
now have substitution maps and need substitution lists (or vice versa)
caused by this change.

Overall, removes ~50 explicit uses of SubstitutionList (of ~400).
2018-05-02 13:38:14 -07:00
Slava Pestov
7b8359279d Sema: Eliminate typeCheckExpression() calls from convertLiteralInPlace()
This code dates back to the dark ages when forming substitutions
was something only the constraint solver could do.

Now that findNamedWitnessImpl() returns a ConcreteDeclRef instead
of a ValueDecl, we don't have to build a whole constraint system
and type check it just to form substitutions for the call.
2018-05-01 17:40:52 -06:00
Slava Pestov
2db629368e Sema: Support for abstract conformance in findNamedWitnessImpl() 2018-05-01 17:40:51 -06:00
Slava Pestov
7c6fc5ab8b Sema: Remove some obsolete logic from adjustSelfTypeForMember() 2018-04-30 18:59:20 -06:00
Slava Pestov
1da4430ecb Sema: Refactor findNamedWitnessImpl() to return a ConcreteDeclRef 2018-04-30 18:57:16 -06:00
Slava Pestov
754e8e2716 Sema: Eradicate uses of typeCheckExpressionShallow() from IfExpr and IfStmt rewriting
Instead of spinning up a new ConstraintSystem and solving it, we can
just directly construct a call to getBuiltinLogicValue().
2018-04-30 18:57:16 -06:00
Huon Wilson
d4fbca1183 [Sema/CS] std::function -> llvm::function_ref for some non-escaping params. 2018-05-01 08:29:08 +10:00
Slava Pestov
17c9b2b74a IDE: Don't store TypeVariableTypes into CodeCompletionExprs
Instead, generate the type variable in ConstraintGenerator.
However, we only want to generate it if we're type checking
from inside TypeChecker::typeCheckCompletionSequence(), so
add an isActivated() flag to CodeCompletionExpr. If it is
not set, constraint generation will simply fail on an
expression containing a CodeCompletionExpr.
2018-04-27 22:33:07 -07:00
Orakaro
305dcbc27a Check null of getReferencedDecl() 2018-04-28 00:24:58 +09:00
Pavel Yaskevich
aa2b25b3dd Merge pull request #15868 from xedin/solver-get-params
[Sema] Attempt to replace usages of `getInput()` with `getParams()`
2018-04-26 23:32:15 -07:00
Pavel Yaskevich
3de6b3decb [Sema] NFC: remove AnyFunction::equalParams which takes type as a parameter 2018-04-26 20:00:57 -07:00
Pavel Yaskevich
3c64680a91 [Diagnostics] Switch CalleeCandidateInfo to use FunctionType::getParams() 2018-04-26 17:33:08 -07:00
Pavel Yaskevich
9f55371aac [CSApply] Switch to use AnyFunctionType::getParams() instead of getInput() 2018-04-26 17:33:08 -07:00
Pavel Yaskevich
57ad592844 [Sema] Switch computeDefaultMap to use AnyFunctionType::getParams() 2018-04-26 17:33:08 -07:00
Orakaro
05b78bd984 Reword Note message and use variable name instead 2018-04-27 02:48:44 +09:00
Slava Pestov
e31bd92eee Sema: Fix crash in IfExpr diagnostics
Fixes <rdar://problem/39586166>.
2018-04-25 22:09:14 -07:00
Orakaro
cf68bfb3dd Separate suggestion into different NOTE 2018-04-25 22:07:44 +09:00
Orakaro
cd4c11a034 Fix SR-7015 2018-04-21 23:02:35 +09:00
Huon Wilson
18683f305d Merge pull request #15587 from huonw/minmax
[Sema] Perform name lookup in outer scopes in some cases involving conditional conformances
2018-04-20 22:33:07 +10:00
Huon Wilson
0c53d44e53 [Sema] Consider outer max/min selection deprecated.
We warn and provide fixits, so that we're able restrict this behaviour to Swift
4 only by eagerly migrating people off of it.
2018-04-20 17:27:32 +10:00
Huon Wilson
285c2a469b [CS] Add decl-ref outer alternatives as non-favored options.
Given something like `max(1, 2)` inside a type that conforms to Sequence, this
allows the compiler to consider Swift.max as well as the two methods with that
name on Sequence.
2018-04-20 00:55:11 +10:00
Doug Gregor
3b896e0a41 [Collection upcast optimization] Address review feedback.
All NFC cleanups.
2018-04-18 09:26:52 -07:00
Doug Gregor
eaba3b3192 [Type checker] Factor out the collection upcast peephole code.
While here, cope with extra parentheses as well. They shouldn't
inhibit this optimization.
2018-04-17 15:21:48 -07:00
Doug Gregor
10c53f4cd8 [Type checker] Extend the upcast-of-literal peephole to dictionary literals.
When the operand of a collection upcast is a dictionary literal,
upcast the elements of the collection instead. This avoids going
through the dynamic-casting machinery.
2018-04-17 14:50:46 -07:00
Doug Gregor
4acbf586eb [AST] Optimize collection upcasts of array literals.
When we form a collection upcast of an array literal, upcast the
individual elements directly so we avoid a call through the
runtime. This both improves code generation and sidesteps a regression
involving the inability to dynamically cast function types.

Fixes SR-7362 / rdar://problem/39218656.
2018-04-17 14:08:14 -07:00