Commit Graph

979 Commits

Author SHA1 Message Date
Joe Groff
4a81e48ef8 wip
Swift SVN r16662
2014-04-22 21:46:36 +00:00
Chris Lattner
78e8d3f0a9 rename the MetatypeExpr AST node to DynamicTypeExpr now that it is only
used by the "foo.dynamicType" syntax.


Swift SVN r16658
2014-04-22 20:10:11 +00:00
Chris Lattner
7f3d88632d Introduce a new AST node, named TypeExpr, which will be formed by sema
when resolving identifiers into types.  This will eventually allow us to
solve annoying issues like rdar://15295763&15588967 by better modeling
what we already have.


Swift SVN r16620
2014-04-21 16:10:11 +00:00
John McCall
9000278dcd Introduce MetatypeErasureExpr for erasing metatype
values into existential metatypes.  Erase thin metatypes
correctly in SILGen.

rdar://16610078

Swift SVN r16477
2014-04-17 22:31:47 +00:00
Ted Kremenek
d8c9a2ec8a Emit message for unavailable declarations (not just types).
Swift SVN r16401
2014-04-16 06:52:08 +00:00
Chris Lattner
7e121632ef Expand checking for implicit uses of self in closures to include method calls, and add
a fallback to catch anything else that is missed.  This resolve the rest of:
<rdar://problem/16193162> Require specifying self for locations in code where strong reference cycles are likely



Swift SVN r16319
2014-04-14 15:39:35 +00:00
Joe Groff
3bad92b342 AST: Remove the stopgap BridgeToBlockExpr and handle block <-> non-block conversions freely as function conversions.
Teach SILGen to handle function representation changes as part of function conversion instead of needing to be spoonfed a special expr for the purpose. Handle representation changes in both directions to and from blocks using the same logic as the bridging conversions.

Swift SVN r16318
2014-04-14 15:00:34 +00:00
Joe Groff
8f1c2d1e79 Sema: Implement type-checking for inout writeback conversion.
Add a third branch to the constraint system for '&x' expressions that allows conversion from an lvalue to a type via an additional writeback step:

- Add an LValueConversionExpr node that converts from @lvalue T to @lvalue U, given a pair of functions that convert T -> U and U -> T, to represent the writeback temporary.
- Allow conversion in an inout expression from @lvalue T to a type U that has the following members:

  static func __writeback_conversion(Builtin.RawPointer, T.Type) -> U
  static func __writeback_conversion_get(T) -> V
  static func __writeback_conversion_set(V) -> T

which builds a solution that produces an LValueConversion from the get/set pair before passing the pointer to the writeback temporary off to the conversion function.

Swift SVN r15764
2014-04-02 00:17:51 +00:00
Ted Kremenek
16ffbc6f3a Extend @availability(*,unavailable) checking to protocol methods.
Protocols can declare methods as being unavailable, as they do
in NSObjectProtocol (e.g., 'retain').  We both need to flag these
uses, but understand this for protocol conformance.  For protocol
conformance, treat unavailable methods as if they were marked
optional.  The compiler will not allow you to use these methods
anyway.

This finishes up support for:

    <rdar://problem/16331335> Ban ObjC ARC entry points

Swift SVN r15644
2014-03-30 07:11:39 +00:00
Joe Groff
46f77c6181 Sema: Build the AST for inout address conversions.
Add two new AST node types:

- InOutConversionExpr, which represents an '&x' expression that involves inout conversion. This will be a signal to SILGen not to introduce a writeback scope for the nested conversion call.

- LValueToPointerExpr, which represents the primitive '@lvalue T' to 'RawPointer' conversion that produces the argument to the inout conversion.

Build an InOutConversionExpr AST when an inout expression is resolved by a conversion to an BuiltinInOutAddressConvertible type.

Swift SVN r15594
2014-03-29 02:50:25 +00:00
Ted Kremenek
b9ac56302c Wire up initial diagnostics for checking 'unavailable' declarations.
There's a lot of detail work to do here, and obviously more
test cases.

Swift SVN r15510
2014-03-26 15:05:13 +00:00
Joe Groff
45eadd1d9b Rename AddressOfExpr to InOutExpr.
The "address" is an implementation detail; formally, it turns an lvalue into an inout parameter.

Swift SVN r15458
2014-03-25 16:28:28 +00:00
Chris Lattner
3348c46bf7 implement: <rdar://problem/16193162> Require specifying self for locations in code where strong reference cycles are likely
This requires that property references have an explicit "self." qualifier when in an
explicit closure expression, since self will be captured, not the property.

We don't do the same for autoclosures.  The logic here is that autoclosures can't 
practically be used in capturing situations anyway, since that would be extremely 
surprising to clients.  Further, forcing a syntactic requirement in an autoclosure
context would defeat the whole point of autoclosures: make them implicit.


Swift SVN r14676
2014-03-05 06:50:56 +00:00
Joe Groff
363a324984 Parse: Start parsing selector member references.
Parse 'x.y:z:' for at least two selector pieces as an UnresolvedSelectorExpr, and declare it unimplemented in Sema.

Swift SVN r14492
2014-02-28 01:47:32 +00:00
Joe Groff
4e87971d81 Disallow bare type references.
Diagnose a metatype reference that doesn't appear as part of a call or member reference, offering fixits to either default-construct the type or get at the metatype explicitly using '.self'. Also diagnose an attempt to refer to 'T.type' by fixiting it to '.self'.

Swift SVN r14433
2014-02-27 00:22:02 +00:00
Joe Groff
c0d8ae7c13 Parse 'x.self' as an identity expression.
Factor an IdentityExpr base class out of ParenExpr, and migrate most of the logic to see through ParenExprs to see through IdentityExprs instead. Add DotSelfExpr as a new subclass of IdentityExpr, produced by parsing 'x.self'.

Swift SVN r14381
2014-02-26 06:23:55 +00:00
Chris Lattner
d690a63a87 progress towards non-member observing properties:
- Add a "isDirectPropertyAccess" bit to DeclRefExpr, serving the 
   same purpose as MemberRefExprs for non-member properties.
 - Teach sema to synthesize correct non-member get/set implementations
   for observing properties.
 - Teach silgen to handle the isDirectPropertyAccess bit.



Swift SVN r13600
2014-02-06 22:34:37 +00:00
Chris Lattner
929ad99f08 Clean up and generalize the code pertaining to how a FuncDecl accessor
knows about the AbstractStorageDecl it works on.  NFC.



Swift SVN r12994
2014-01-27 17:57:38 +00:00
Chris Lattner
0dfb1ec790 introduce a new "IsDirectIVarAccess" bit to MemberRefExpr. Properties
that have both storage AND accessors are accessed by-default through
their accessors.  This bit indicates that a specific MRE should access
the storage instead.

Use this new bit in the synthesized getter/setter for "StorageObjC"
properties (it will also be used for other things in the future).
This also teaches SILGen about it.

One interesting aspect of this representation is that it makes it trivial
to add some expression syntax for directly accessing a store+computed 
property (e.g. ObjC properties, also someday didSet/willSet properties) 
someday if we care.  This would be analogous to the "self->ivar" syntax
in objc (vs self.ivar).  No, we will not use "->" for this. :-)

NFC since this is the use is still hidden under the -enable-new-objc-properties
staging option.



Swift SVN r12965
2014-01-26 06:08:53 +00:00
Jordan Rose
ae2868b482 Clean up comments in MiscDiagnostics.cpp.
No functionality change.

Swift SVN r12457
2014-01-17 02:58:25 +00:00
Jordan Rose
a6b616ad9e Accessing a property on another instance within the property's getter is okay.
There was a test for this but it wasn't really accurate. We now look for
MemberRefExprs where the base is literally just an implicit DeclRefExpr,
rather than something loaded from an implicit DeclRefExpr. This could break
with future AST refinement, but that will at least fail the test now.

Swift SVN r12456
2014-01-17 02:58:24 +00:00
Jordan Rose
77d5385c5d Warn on recursive mutation within a property setter.
The other half of <rdar://problem/14083624>

Swift SVN r12455
2014-01-17 02:58:23 +00:00
Jordan Rose
890df62a16 Warn on recursive computed variable access within its own getter.
Part of <rdar://problem/14083624>

Swift SVN r12454
2014-01-17 02:58:22 +00:00
Dmitri Hrybenko
c2c15e401b Disallow use of module values
rdar://15000289


Swift SVN r10546
2013-11-18 20:45:50 +00:00
Dmitri Hrybenko
9329ef41a5 Assigning variable to itself: fix a bug where we did not handle member
experssions with a complex base correctly

rdar://15405383


Swift SVN r10002
2013-11-06 20:05:14 +00:00
Anna Zaks
f8a79a56fb Address the reviews for r9982
Swift SVN r9999
2013-11-06 19:46:20 +00:00
Anna Zaks
c8ed1954f2 Issue a warning when returned expression is on the next line after the return keyword.
We still want to allow line wrapping, so only issue the warning when the indentation of the expression and the return keyword is the same.

radar://11945406

Swift SVN r9984
2013-11-06 02:00:13 +00:00
Dmitri Hrybenko
25c0c1b3b0 Self-assignment diagnostic: pass 'const Expr' where possible
Swift SVN r9981
2013-11-06 00:44:54 +00:00
Dmitri Hrybenko
61c067fe5f Implement a check in Sema to find self-assignment
rdar://14151649 suggests that it should be a warning, but I don’t see a reason
why it should not be an error.  We have no legacy code that relies on this.


Swift SVN r9976
2013-11-05 23:43:54 +00:00