Commit Graph

3461 Commits

Author SHA1 Message Date
Chris Lattner
a2579527e9 rearrange how the get/set decls are synthesized for observing properties. Now the
parser creates the get/set decls, and sema fills them in, instead of having sema 
do all the work.  This makes it easier to update DeclContexts in all cases.


Swift SVN r13597
2014-02-06 21:36:01 +00:00
Chris Lattner
595817bd89 Rename data structures relating to WillSetDidSet properties to call them "Observing"
properties internally to the compiler.  NFC.


Swift SVN r13587
2014-02-06 17:51:45 +00:00
Chris Lattner
827acad533 Various inout improvements:
- purge @inout from comments in the compiler except for places talking about
   the SIL argument convention.
 - change diagnostics to not refer to @inout
 - Change the astprinter to print InoutType without the @, so it doesn't show
   up in diagnostics or in closure argument types in code completion.
 - Implement type parsing support for the new inout syntax (before we just 
   handled patterns).
 - Switch the last couple of uses in the stdlib (in types) to inout.
 - Various testcase updates (more to come).



Swift SVN r13564
2014-02-06 06:22:27 +00:00
Joe Pamer
e06f98cabd Protect against upstream errors when resolving the 'self' type of an initializer method.
When type checking constructors, ensure that any upstream errors in the resolution of the self type are accounted for (rather than assuming that the self type is always well-formed).  Not doing so can be especially problematic within the context of a type extension, since there may not even be a self type to resolve to.

Swift SVN r13506
2014-02-05 21:06:35 +00:00
Sonny Falk
35f7bdff0f Rename local variable startLoc to StartLoc. NFC.
Swift SVN r13438
2014-02-04 18:31:20 +00:00
Sonny Falk
3715f632cf Update the source range for FuncDecl to include the proper start location for type functions, using getStartLoc().
This addresses <rdar://problem/15969165>.

Swift SVN r13435
2014-02-04 18:11:32 +00:00
Chris Lattner
9f32d521a2 now that ctors and dtors have self patterns, we can unify and simplify the
implementation of AbstractFuncDecl::getImplicitSelfDecl() and eliminate
the ImplicitSelfDeclAndIsCached ivar.


Swift SVN r13351
2014-02-03 15:17:21 +00:00
Doug Gregor
995d8732f3 The self type behind a DynamicSelf for a protocol is 'Self', not the protocol.
We can now emit witness tables for conformances to protocols
containing DynamicSelf methods.

This temporarily "breaks" uses of DynamicSelf methods on
existentials. We'll come back to that.


Swift SVN r13310
2014-02-02 02:23:40 +00:00
Argyrios Kyrtzidis
48023490de [AST] Move AccessorKind enum to top-level so it can be forward declared.
No functionality change.

Swift SVN r13299
2014-02-01 08:50:15 +00:00
Doug Gregor
fe2ef0e5c6 Fix interface types and type lowering of DynamicSelf so archetypes don't creep in.
Allows us to invoke DynamicSelf methods of generic classes.


Swift SVN r13290
2014-02-01 05:12:39 +00:00
Chris Lattner
3e08673772 Introduce patterns for self arguments to ctors and dtors, making them uniform
with FuncDecls.  This allows us to eliminate special case code for handling
self in various parts of the compiler.

This also improves loc info (debug info and AST info) because 'self' now
has a location instead of being invalid.

I also took the opportunity to factor a bunch of places creating self decls
to use similar patterns and less copy and paste code.



Swift SVN r13196
2014-01-31 02:17:22 +00:00
Doug Gregor
bbf6f57b93 Properly handle type checking of references to DynamicSelf methods in generic classes.
Swift SVN r13154
2014-01-30 18:06:09 +00:00
Doug Gregor
030770a8c2 Make DynamicSelf into its own special type node.
Making DynamicSelf its own special type node makes it easier to opt-in
to the behavior we want rather than opting out of the behavior we
don't want. Some things already work better with this representation,
such as mangling and overriding; others are more broken, such as the
handling of DynamicSelf within generic classes and the lookup of the
DynamicSelf type.


Swift SVN r13141
2014-01-30 05:36:20 +00:00
Doug Gregor
9ccaf820b8 Start making the method overriding rules a bit more sane.
When we type check the signature of a method, determine which method
it overrides (if any) at that time. This ensures that we always have
this information for name lookup (per <rdar://problem/15932845>). 

As part of this, start to make the overriding rules a little more
sane. John has worked out more of the model here, but this patch:
  - Considers an Objective-C method an override of another Objective-C
  method if the selectors match and the type vs. instance-ness of the
  methods match. The method types are checked for consistency
  (subtyping is okay).
  - Diagnoses when a method overrides more than one method from a
  superclass, and
  - Eliminates the "cannot overload method from a superclass"
  diagnostic, which is overly pedantic and oddly limiting.

Note that we lose some amount of checking here. Specifically, we don't
have a good place to check that one has not provided two different
methods that override the same superclass method. The older code did
that (somewhat), and it's not a trivial problem to solve efficiently.

This fixes the part of <rdar://problem/15597226> that is needed for
<rdar://problem/15932845>. It still doesn't handle properties,
subscripts, and undoubtedly other issues.



Swift SVN r13108
2014-01-29 11:08:56 +00:00
Chris Lattner
38c7decf66 fix <rdar://problem/15933538> let decl rejected in @objc class
When a let decl is in an @objc class, it is converted to StoredObjC
storage.  However, since it is not mutable, it should only have a getter
synthesized for it, not a setter.


Swift SVN r13096
2014-01-29 06:39:30 +00:00
Chris Lattner
a571d5800e Change the storage of a property to WillSetDidSet before touching
its willset/didset pieces, to avoid tripping assertions.


Swift SVN r13018
2014-01-28 00:05:24 +00:00
Chris Lattner
e668e86cc3 With many prerequisites out of the way, lets start actually working on didset/willset
properties.  This step provides AST support to model them.


Swift SVN r13011
2014-01-27 22:11:16 +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
170cf3fc8c Change computeInterfaceSelfType to abort if called on a function in a non-type context,
fix the two places that this broke.



Swift SVN r12986
2014-01-27 06:55:01 +00:00
Chris Lattner
9369d518ae merge all the common code between AFD::computeSelfType/computeInterfaceSelfType
into their implementation function.


Swift SVN r12985
2014-01-27 06:45:14 +00:00
Chris Lattner
0a88809fb6 now that there is only one caller of getSelfTypeInContext and
getInterfaceSelfType, inline them into their caller.  This
has the nice effect of moving getSelfTypeForContainer into
Decl.cpp instead of being in DeclContext.cpp (which never
made sense to me).


Swift SVN r12984
2014-01-27 06:32:21 +00:00
Chris Lattner
a945271aa8 Now that properties in protocols are always computed, and that StoredObjC
properties have accessors, we have an amazing property: everything that we
want to form a getter or setter for ... really has one! I suspect many things
can be simplified now, but the first on the chopping block is 
StorageDecl::getGetterType (and its three friends) which is now always exactly
just getGetter()->getType().



Swift SVN r12983
2014-01-27 06:17:28 +00:00
John McCall
2c320663a9 Add an accessor to get the generic parameters of an
extension.

Eventually, extensions won't necessarily have the same
parameter list as the declarations they extend, and this
makes it easier to make that work.

Swift SVN r12940
2014-01-24 22:46:19 +00:00
Chris Lattner
38698af3cc This is a WIP implementation of a major change to how ObjC properties are
represented: they should have an explicit getter and setter synthesized by
Sema, instead of by silgen and tenuously tied in by IRGen.

There is more work to be done on this (e.g. I need to figure out how to get
the bodies properly type checked), so it is hidden behind a new
-enable-new-objc-properties flag.



Swift SVN r12907
2014-01-24 07:04:42 +00:00
Chris Lattner
91fb51100d Introduce a new kind of StorageDecl called StoredObjC. These are
properties that are (usually) accessed through getters and setters, but
which have storage.  Nothing generates these yet.


Swift SVN r12902
2014-01-24 05:15:11 +00:00
Doug Gregor
feb101de35 Invalidate and recheck constraints on type parameters as part of the signature.
This allows us to have references to type parameters within the
generic type parameter list. This occurs, for example, with
DynamicSelf methods within generic classes.


Swift SVN r12809
2014-01-22 22:53:06 +00:00
Doug Gregor
3cd14d6643 Don't permit DynamicSelf outside the body or return type of a method.
Swift SVN r12761
2014-01-22 19:20:30 +00:00
Doug Gregor
88355dd322 Base the implicit 'self' parameter type on DynamicSelf when appropriate.
To get here, make the implicit 'self' parameter a bit more like a
parsed parameter, by giving it a trivial TypeRepr so that pattern
validation will validate the type. This latter piece is important for
DynamicSelf, because we need the interface type of the function to
refer to the implicit generic parameter while the actual type refers
to the archetype.



Swift SVN r12757
2014-01-22 18:36:38 +00:00
Doug Gregor
56b60d9726 Factor "self" type computation into one place within libAST.
Oh, and start creating the implicit generic parameter for
DynamicResult functions.




Swift SVN r12744
2014-01-22 16:03:26 +00:00
Doug Gregor
d52cec4b20 Eliminate a pile of literal identifiers for self, init, destructor, etc.
... because I can't stomach adding another one of these.


Swift SVN r12687
2014-01-22 01:09:49 +00:00
Joe Groff
e829d4e05c AST: Unique GenericSignatures in the ASTContext.
Make them cheap to compare. We may want to hang an ArchetypeBuilder off of them to cache archetypes within the signature context at some point too.

Swift SVN r12630
2014-01-21 01:27:09 +00:00
Chris Lattner
f5b85341a1 Expand out the "isComputed" property in AbstractStorageDecl to be an enum
with two kinds, and some more specific predicates that clients can use.

The notion of 'computed or not' isn't specific enough for how properties
are accessed.  We already have problems with ObjC properties that are 
stored but usually accessed through getters and setters, and a bool here
isn't helping matters.

NFC.



Swift SVN r12593
2014-01-20 18:16:30 +00:00
Chris Lattner
a02c399ff3 merge get[GS]etter[Interface]Type() for VarDecl and SubscriptDecl into AbstractStorageDecl
Swift SVN r12574
2014-01-20 15:32:30 +00:00
Chris Lattner
2cff46f7ab now that subscripts always have a getter/setter decl, the
getGetterType()/getSetterType() (and their 'interface' 
variants) all become trivial.  Lets let sema worry about this
stuff instead of duplicating the logic in libast. NFC



Swift SVN r12563
2014-01-19 05:27:13 +00:00
Argyrios Kyrtzidis
84e20a0620 [AST] Break down IdentTypeRepr to different subtypes.
This makes memory allocation for it more efficient and it's more convenient to handle.

Swift SVN r12541
2014-01-18 20:19:09 +00:00
Chris Lattner
20af73f973 hoist getter/setter information up to AbstractStorageDecl.
Subscripts are always computed, but otherwise fit the model
fine.


Swift SVN r12539
2014-01-18 20:14:01 +00:00
Chris Lattner
7e67fdb30a decls always can get to an ASTContext, remove the unneeded
ASTContext argument from VarDecl::setComputedAccessors.


Swift SVN r12538
2014-01-18 20:04:05 +00:00
Chris Lattner
8eabc75ba0 fix test/ClangModules/objc_ir.swift: subscriptdecls always have
function type.



Swift SVN r12537
2014-01-18 19:59:20 +00:00
Joe Groff
0776c4b6b8 SIL: Reorient function type lowering toward interface types.
Lower types for SILDeclRefs from the interface types of their referents, dragging the old type along for the ride so we can still offer the context to clients that haven't been weaned off of it. Make SILFunctionType's interface types and generic signature independent arguments of its  Derive the context types of SILFunctionType from the interface types, instead of the other way around. Do a bunch of annoying inseparable work in the AST and IRGen to accommodate the switchover.

Swift SVN r12536
2014-01-18 19:42:02 +00:00
Chris Lattner
a8d8e14254 introduce AbstractStorageDecl. Right now, just
move OverriddenDecl and usesObjCGetterAndSetter() up to it.
This allows usesObjCGetterAndSetter to subsume the logic
for subscript decls as well.



Swift SVN r12535
2014-01-18 19:08:39 +00:00
Chris Lattner
e85a6d673e move SubscriptDecl code up to be next to VarDecl code. Other than
rearranging, this doesn't change anything.


Swift SVN r12534
2014-01-18 18:21:10 +00:00
Chris Lattner
bb3c0d52dc Unfortunately, two conflated NFC patches:
1) Revert my change to give DeclContext a dump method, it confuses the debugger.
2) Refactor SILGen::requiresObjCPropertyEntryPoints out to 
   VarDecl::usesObjCGetterAndSetter.


Swift SVN r12526
2014-01-18 02:00:23 +00:00
Chris Lattner
a7d2f83c44 improve a comment.
Swift SVN r12510
2014-01-17 22:31:19 +00:00
Chris Lattner
f50d1f5b48 with the plumbing complete, it is now simple to implement:
<rdar://problem/15785677> allow 'let' declarations in structs/classes be initialized in init()

Our model is that 'let' ivars are fully mutable in init() but are immutable everywhere else.



Swift SVN r12509
2014-01-17 22:26:53 +00:00
Chris Lattner
b4735381d0 Plumb the DeclContext of the use site down to the "doesVarDeclMemberProduceLValue"
function.  Pretty soon, whether something is an lvalue or not will depend on who is
asking.


Swift SVN r12507
2014-01-17 22:14:02 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00
Chris Lattner
261b21a10f various random cleanups to pattern processing stuff, NFC.
Swift SVN r12335
2014-01-15 19:12:45 +00:00
Doug Gregor
bc89a04d12 Disallow non-delegating initializers outside of the class's defining module.
An initializer outside of the class's defining module won't
necessarily have access to all of the stored properties of the class
to initialize them (and wouldn't be resilient against changes even if
it did), so it must delegate.

Swift SVN r12302
2014-01-15 00:11:38 +00:00
John McCall
817e80bde5 Implicit conversions for UncheckedOptional.
rdar://15189000
rdar://15189009

Swift SVN r12260
2014-01-13 23:15:03 +00:00
Doug Gregor
a534f6978a Add a new class attribute requires_stored_property_inits.
This attribute states that all stored properties within the class must
provide initial values. This will allow us to move stored property
initialization into Objective-C's post-allocation initialization hook,
.cxx_construct.

Swift SVN r12228
2014-01-13 16:31:22 +00:00