Commit Graph

283 Commits

Author SHA1 Message Date
Doug Gregor
fbdfc7b1ab Eliminate a few places where we were willfully faking the "full opened type".
Tighten up AST verification: all DeclRefExprs to non-protocol
functions have embedded (complete) substitutions now.



Swift SVN r9620
2013-10-23 15:06:00 +00:00
Doug Gregor
6f87c8c908 Eliminate SpecializeExpr for qualified references to free functions.
Start verifying that we don't have any non-directly-specialized
DeclRefExprs referring to free functions.


Swift SVN r9619
2013-10-23 14:26:14 +00:00
Joe Groff
0644879533 Quell 'dump' deprecation warning in AST verifier.
Swift SVN r9592
2013-10-22 16:08:21 +00:00
Argyrios Kyrtzidis
549dfb882a [AST] Record and report the protocol requirement decls that a ValueDecl conforms to.
Swift SVN r9587
2013-10-22 15:47:37 +00:00
Dmitri Hrybenko
acdd5b120a Make type checker debug output redirectable
Introduce a replaceable TypeCheckerDebugConsumer for this.


Swift SVN r9555
2013-10-21 20:26:32 +00:00
Doug Gregor
d7a1d536b4 Introduce value witness markers into the generic set of requirements.
Value witness markers note the location within a generic function
type's list of requirements where the value witness table will be
placed when calling a generic function with that type. It allows one
to get the same effect from walking the requirements of a generic
function that one would get from walking all levels of a
GenericParamList, with all archetypes of each generic parameter list,
along with all of the protocols to which each archetype conforms,
which SILGen and IRGen both do.

AST verification ensures that the property above holds; we're not
making use of it just yet.


Swift SVN r9509
2013-10-19 00:19:01 +00:00
Doug Gregor
1c826fb506 Synchronize a generic function type's requirements with archetype requirements.
The list of requirements within a generic function type is
functionally identical to the list of conformances in the list of "all
archetypes" that a given function carries. Synchronize these lists so
they have identical requirements in the same order, which allows us to
substitute the former for the latter.


Swift SVN r9472
2013-10-17 23:29:57 +00:00
Dmitri Hrybenko
b17f51262e AST Verifier: Check that non-static member functions have the correct type set
for the "self" parametr.


Swift SVN r9415
2013-10-16 18:33:40 +00:00
Joe Groff
1bdbc97056 Drop the 'x as! T' cast syntax.
Now that we have a solid Optional-based story for dynamic casts, it's no longer needed, and can be expressed as '(x as T)!'. Future refinement of the 'as' syntax will deal with the unfortunate extra parens.

Swift SVN r9181
2013-10-10 23:47:59 +00:00
Jordan Rose
0d2ccf7cb3 Adopt SourceFile in name-binding.
Swift SVN r9105
2013-10-09 22:44:32 +00:00
Doug Gregor
fba128e191 Axle: Implement Vec<T, N> syntactic sugar for the VecTxN structs.
Implements the first part of <rdar://problem/15100137>.


Swift SVN r9092
2013-10-09 21:12:19 +00:00
Jordan Rose
266c445b3c Push ASTStage down into SourceFile.
This was only meaningful for TranslationUnit anyway, and it may help
avoid repeating work in the future.

Swift SVN r9079
2013-10-09 18:38:28 +00:00
Doug Gregor
86fdde35f6 Verify that we have interface types wherever we expect them.
Swift SVN r8998
2013-10-07 22:15:33 +00:00
Doug Gregor
611a5cce4b Replace the library-defined postfix '!' with an expr-postfix production.
As with the monadic '?', we treat any left-bound '!' as a postfix
operator. Currently, it extracts the value of its optional
subexpression, failing at run-time if the optional is empty.


Swift SVN r8948
2013-10-06 23:09:58 +00:00
Doug Gregor
a2980ed7f1 Move the check for unresolved dependent member types into the verifier.
Swift SVN r8899
2013-10-04 00:21:36 +00:00
Joe Groff
fb7fb33be6 Sema: Synthesize raw type methods for enums.
If an enum has a valid raw type, synthesize a RawType associated type along with fromRaw and toRaw methods.

An implicit conformance to RawRepresentable is not yet set up. This synthesis may need to be done earlier in order for the names to be available during type-checking of definitions in the enum too.

Swift SVN r8890
2013-10-03 21:55:53 +00:00
Dmitri Hrybenko
7e61978a22 Clang importer: don't import ObjC method decls twice
(This did not happen all the time, but it did happen for subscript operators
while enumerating all decls in a class.)


Swift SVN r8847
2013-10-02 18:38:24 +00:00
John McCall
6df6897756 Add an InjectIntoOptional implicit conversion expression
instead of generating ugly artificial calls to
_injectValueIntoOptional in the AST.

Swift SVN r8837
2013-10-02 05:48:30 +00:00
Argyrios Kyrtzidis
3b5990fbe1 [AST] Verify that a type variable has not escaped the type checker.
Swift SVN r8762
2013-09-29 00:12:21 +00:00
Argyrios Kyrtzidis
4a91e28d11 [AST] For the ASTWalker add Module and Decl as a parent kind, and make ParentTy a class.
Swift SVN r8756
2013-09-29 00:12:11 +00:00
Argyrios Kyrtzidis
f32167d166 [AST] Introduce a walk() method for TranslationUnit.
Swift SVN r8729
2013-09-27 17:24:35 +00:00
Doug Gregor
0d33ff3f40 Teach SILGen to directly emit optional injection operations for dynamic lookup.
... rather than synthesizing expressions in the AST.


Swift SVN r8723
2013-09-27 14:12:33 +00:00
Dmitri Hrybenko
448d7cff8e AST Printer: add tests for printing deserialized modules
...and fix bugs found by this.


Swift SVN r8706
2013-09-26 23:17:32 +00:00
Dmitri Hrybenko
f46dd5e91c AST Verifier: remove a redundant check (now we verify all Patterns)
Swift SVN r8676
2013-09-25 23:41:08 +00:00
Dmitri Hrybenko
f10947654e AST Verifier: verify source locations on Patterns and fix bugs found by this
Swift SVN r8660
2013-09-25 20:53:28 +00:00
Dmitri Hrybenko
33aada4b16 Set DeclContext for argument parameter patterns
Fixes a crash in Serializer, when processing a function with a selector-style signature.

Also added an AST verifier check that all Decls have a non-null DeclContext.


Swift SVN r8621
2013-09-25 01:47:27 +00:00
Argyrios Kyrtzidis
e224667315 Refactor Implicit'ness of expressions.
Introduce a bit in Expr to indicate whether the expression is implicit and decouple the implicitness
of an expression from whether it has a source location or not.

This allows implicit expressions to be able to point at the source location where they originated from.
It also allows decoupling the implicitness of a parent from its children, so for example, an implicit CallExpr
can have an explicit parameter value.

Swift SVN r8600
2013-09-24 20:42:29 +00:00
Doug Gregor
f67aa78d69 Dynamic lookup for subscripts: semantic analysis and ASTs.
Swift SVN r8591
2013-09-24 05:51:30 +00:00
Dmitri Hrybenko
10d8fdc64f AST/AbstractFunctionDecl: Remember if a function had a selector-style signature
... and use this information in AST printing


Swift SVN r8583
2013-09-24 00:56:33 +00:00
Dmitri Hrybenko
c9d1aa3f96 AST Printer: fix parameter name printing in setters
Also, add an AST verifier check that the parameter patterns in getters/setters
are sane.


Swift SVN r8574
2013-09-23 22:25:35 +00:00
Dmitri Hrybenko
7dedb7048f AST Verifier: add a check that AssociatedTypeDecl has a protocol DeclContext
Swift SVN r8562
2013-09-23 18:56:55 +00:00
Dmitri Hrybenko
429633b18a Let the type checker create implicit DestructorDecls
Improve the type checker to create implicit DestructorDecls, tighten the
assertion in ImplicitReturnLocation::getImplicitReturnLoc(), and add a verifier
check that a class in a type checked AST always has exactly one destructor.

SILGen used to generate a destructor if the class does not have a
DestructorDecl.  SILGen used to put the ClassDecl inside the SILLocation for
the destructor SIL code.  This is not a very clean solution: in this case
ImplicitReturnLocation SILLocations contain ClassDecl, which is surprising.

rdar://14970972 Implicit destructors should have AST nodes


Swift SVN r8498
2013-09-20 17:34:22 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Dmitri Hrybenko
37b7284e0c Code completion: don't crash when completing in constructors/destructors placed
in contexts where they are not allowed

We used to throw away the ConstrutorDecl/DestructorDecl, but code completion
captured the pointer as a DeclContext for the code completion point.  Then code
completion passed that AST node to type checker, which crashed.  Now we
properly mark the decl as invalid, pass it to the type checker, and have the
type checker set its type to ErrorType.


Swift SVN r8466
2013-09-19 23:01:26 +00:00
Dmitri Hrybenko
5b1c412e70 Use 'override' when overriding ASTWalker functions
Swift SVN r8345
2013-09-17 19:31:24 +00:00
Dmitri Hrybenko
f1f189f4e0 Rename PipeClosureExpr -> ClosureExpr
Swift SVN r8321
2013-09-17 01:37:36 +00:00
Dmitri Hrybenko
d26cc5bd2e Tighten verifier check and cast in AbstractClosureExpr::getResultType()
Closure can only have a FunctionType (not a PolymorphicFunctionType).


Swift SVN r8311
2013-09-17 00:04:09 +00:00
Dmitri Hrybenko
7a3d43a918 Add a verifier check that the type of closure is sane
Swift SVN r8307
2013-09-16 23:40:16 +00:00
Doug Gregor
25bec36f9e Allow dynamic lookup through DynamicLookup.metatype.
Given an object of type DynamicLookup.metatype, allow us to find both
static and instance methods. 

Sema only; SILGen and IRGen changes to come.


Swift SVN r8290
2013-09-16 20:26:02 +00:00
Dmitri Hrybenko
536ed954ad Remove FuncExpr. Add CaptureInfo to FuncDecl. Introduce AnyFunctionRef.
AnyFunctionRef is a universal function reference that can wrap all AST nodes
that represent functions and exposes a common interface to them.  Use it in two
places in SIL where CapturingExpr was used previously.

AnyFunctionRef allows further simplifications in other places, but these will
be done separately.


Swift SVN r8239
2013-09-14 02:15:48 +00:00
Doug Gregor
978eaab5c6 Introduce lazy computation of a BoundGenericType's substitutions.
Teach a BoundGenericType to compute its own substitutions, which
allows AST clients to create new bound generic types without the aid
of the type checker. 

This eliminates the TypeChecker::validateTypeSimple() abomination as
well as the need for the BoundGenericType AST validation step. There
is still more cleanup to do in this area.

Note that BoundGenericType::getSubstitutions() now accepts a module
parameter, which is the place from which we will look for
conformances. This is a baby step toward properly modeling the
conformances as part of the bound generic type, and is nowhere near
complete.


Swift SVN r8193
2013-09-13 14:25:36 +00:00
Doug Gregor
12c365e643 Allow type substitution with a null resolver.
This allows AST clients to perform type substitutions without
requiring a type checker. Test this by performing substitutions within
the AST verifier.


Swift SVN r8166
2013-09-12 21:53:22 +00:00
Dmitri Hrybenko
c69c79084a Move result typeloc and body result type from FuncExpr to FuncDecl
Swift SVN r8153
2013-09-12 18:40:57 +00:00
Dmitri Hrybenko
abfa512c4f Sink getArgParamPatterns() and getBodyParamPatterns() into AbstractFunctionDecl
Swift SVN r8097
2013-09-11 18:42:28 +00:00
Dmitri Hrybenko
2c8e7e45a5 Sink GenericParamList to AbstractFunctionDecl from derived classes
Swift SVN r8092
2013-09-11 17:27:59 +00:00
Dmitri Hrybenko
3cc01cf7d6 Introduce AbstractFunctionDecl -- a base class for ConstructorDecl,
DestructorDecl, FuncDecl -- and move some of the common concepts and logic
into it

No functionality change.


Swift SVN r8090
2013-09-11 04:04:01 +00:00
Dmitri Hrybenko
88c310ae5e Verifier: add verifyCheckedAlways() family of functions, that is run on
typechecked ASTs even if there were errors.


Swift SVN r8080
2013-09-10 21:19:18 +00:00
Dmitri Hrybenko
37ee3a210c Run AST verifier on modules produced by Clang importer and fix bugs found by it
Fixes two bugs in Clang importer and deserialization code that were found by
the verifier:

(1) FuncExprs were created with a null FuncDecl

(2) BoundGenericType that was created by Clang importer for UnsafePtr<> and
    other magic types did not have substitutions.


Swift SVN r8073
2013-09-10 18:22:12 +00:00
Doug Gregor
cdf160ecbd Introduce and optimize for uniquely-referenced opaque values.
If an OpaqueValueExpr is only used in one place, mark it as such. SIL
generation will then elide the retain/release pair associated with
each reference to the opaque value, instead consuming the value at the
point of use.


Swift SVN r8072
2013-09-10 18:03:55 +00:00
Doug Gregor
8c60d88f5a Provide DynamicMemberRefExpr with .Some(fn)/.None helper expressions.
These helper expressions will eventually be used by SILGen to help
package up the optional values. I expect that we'll eventually have
library builtins for this, so consider this a stop-gap until those
appear.

As part of this, make OpaqueValueExpr a bit more usable: it can now
persist in the AST as a placeholder, but its uses must be within AST
subtrees of some specific introduction point (similarly to how Clang's
OpaqueValueExpr works).


Swift SVN r8051
2013-09-09 19:58:51 +00:00