Commit Graph

2716 Commits

Author SHA1 Message Date
Chris Lattner
be58684653 further detangle @inout and @lvalue types, making the code more specific
and simpler.


Swift SVN r11801
2014-01-01 21:35:31 +00:00
Chris Lattner
988270a066 eliminate the code copied and pasted from shouldTryUserConversion:
just call it instead.


Swift SVN r11791
2014-01-01 06:47:32 +00:00
Chris Lattner
f30dd51763 fix rdar://15735537: __conversion function not found in protocol if marked @mutating
- shouldTryUserConversion was not looking through @lvalue to determine if 
  the underlying type had a __conversion member, so we were only trying user
  conversions on lvalues through an lvalue-to-rvalue conversion.
- Similarly, fix the similar-but-different filter in tryUserConversion to look through
  lvalues as well.

This causes the QoI of some conversion diagnostics to get worse (the dreaded "does 
not type check error") because there are now two possible conversions instead of one 
in some cases and the diagnostics of the type checker doesn't handle this case well.


Swift SVN r11789
2014-01-01 06:40:48 +00:00
Chris Lattner
9ae289de46 Drive the semantic wedge harder into lvalues. Now, instead of having one LValueType
with qualifiers on it, we have two distinct types:
 - LValueType(T) aka @lvalue T, which is used for mutable values on the LHS of an
   assignment in the typechecker.
 - InOutType(T) aka @inout T, which is used for @inout arguments, and the implicit
   @inout self argument of mutable methods on value types.  This type is also used
   at the SIL level for address types.

While I detangled a number of cases that were checking for LValueType (without checking
qualifiers) and only meant @inout or @lvalue, there is more to be done here.  Notably,
getRValueType() still strips @inout, which is totally and unbearably wrong.



Swift SVN r11727
2013-12-29 22:23:11 +00:00
Chris Lattner
18a9193452 Redesign how @inout propagation works in the typechecker:
- Switch all the 'self' mutable arguments to take self as @inout, since
   binding methods to uncurried functions expose them as such.
 - Eliminate the subtype relationship between @inout and @inout(implicit),
   which means that we eliminate all sorts of weird cases where they get
   dropped (see the updated testcases).
 - Eliminate the logic in adjustLValueForReference that walks through functions
   converting @inout to @inout(implicit) in strange cases.
 - Introduce a new set of type checker constraints and conversion kinds to properly
   handle assignment operators: when rebound or curried, their input/result argument
   is exposed as @inout and requires an explicit &.  When applied directly (e.g. 
   as ++i), they get an implicit AddressOfExpr to bind the mutated lvalue as an
   @inout argument.

Overall, the short term effect of this is to fix a few old bugs handling lvalues.
The long term effect is to drive a larger wedge between implicit and explicit 
lvalues.


Swift SVN r11708
2013-12-29 04:38:26 +00:00
Chris Lattner
d3c91387e9 Substantially simplify the API to LValueType now that nonsettable is gone.
Swift SVN r11703
2013-12-28 22:48:44 +00:00
Chris Lattner
d7621b5a7b Remove the concept of a "nonsettable lvalue": Now everything that is
nonsettable is represented as an rvalue.  Yay for one less concept in
the AST.


Swift SVN r11640
2013-12-25 22:20:01 +00:00
Chris Lattner
b29748a6be remove the ASTContext argument from Type::transform,
(various) FunctionType::get's, ArrayType::get,
ArraySliceType::get, OptionalType::get, and a few
other places.

There is more to be done here, but this is all I plan to do
for now.


Swift SVN r11497
2013-12-20 02:23:21 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
Chris Lattner
42d0fdadcf - Introduce the ability for attributes to be inverted with !.
- Switch @mutable to be a tri-state attribute that is invertable with @!mutable.
- Move the semantic form of 'mutable' to being a bit on FuncDecl instead of
  something in DeclAttrs.  The former is a binary bit, the later is a tristate
  which differentiates between "not present", "present and set" "present and inverted".
- Diagnose some invalid uses of @mutable, e.g. on class methods.
- Make setters default to mutable, and allow them to be switched with @!mutable.



Swift SVN r11439
2013-12-18 21:38:53 +00:00
Chris Lattner
51862b91fd rename the inout decl attribute (not the type attribute) to @mutating.
Swift SVN r11416
2013-12-18 04:44:56 +00:00
Chris Lattner
b11903a6fc Reject calls to inout methods on rvalues and 'let' values.
Many thanks to Doug for helping with the constraint solver magic.


Swift SVN r11391
2013-12-17 21:15:44 +00:00
Doug Gregor
61318e33f0 Compute potential bindings with the help of the constraint graph.
Rather than performing a two-pass walk over all of the constraints in
the system to attach them to type variables, use the existing type
variable -> constraints mapping in the constraint graph to make this a
faster single-pass process. Also clarify the type bindings a little
bit. Improves type checking time for the standard library by ~3%.



Swift SVN r11098
2013-12-10 23:25:37 +00:00
Doug Gregor
79f8175e0b Solver: Keep track of a solution's score as we're computing it.
No functionality change here; just staging for some future optimizations.


Swift SVN r11028
2013-12-09 17:12:07 +00:00
Doug Gregor
5bb053c0dd Fix renamed file names
Swift SVN r11017
2013-12-09 14:20:33 +00:00
Doug Gregor
ee545e9f68 Rename TypeCheckConstraintsFoo.cpp to CSFoo.cpp.
It's more idiomatic and easier to type.


Swift SVN r11015
2013-12-09 14:09:54 +00:00