Commit Graph

21693 Commits

Author SHA1 Message Date
Doug Gregor
087e9f7fad Member lookup: finding a superclass doesn't mean we should skip protocols.
Fixes <rdar://problem/15104554>.


Swift SVN r8975
2013-10-07 18:35:02 +00:00
Argyrios Kyrtzidis
b7e66f9111 [ASTDumper] Print the overridden decl.
Swift SVN r8961
2013-10-07 16:42:24 +00:00
Doug Gregor
abeaef8996 Track the generic parameters and requirements of nominal type declarations.
Put generic nominal type declarations through the same dependent-type
validation as generic functions, then capture their generic parameters
and requirements in their generic signature. This allows us to
re-instate the requirements in their dependent forms, before the
archetypes ruin them completely.


Swift SVN r8958
2013-10-07 16:21:25 +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
Anna Zaks
a19d7569cc Introduce Builtin.staticReport, which allows compiler diagnostic reporting.
- Introduces the Builtin
- If the first parameter evaluates to '1', the dataflow diagnostics pass produces a diagnostic.
- The Builtin gets cleaned up before IRGen, but not before SIL serialization.

This patch also removes the current, overflow warning and XFAILs one of the tests. The other test is switched to use Builtin.staticReport.

TODO:
 - Utilize the other parameters to the builtin - the Message and IsError flag.
 - Use this Builtin within the stdlib.

Swift SVN r8939
2013-10-05 00:12:23 +00:00
Doug Gregor
91173c903d Handle 'self' and nested generics in the interface type of generic functions.
When building the (dependent) interface type of generic functions,
don't resolve any generic parameter types to archetypes, even those at
outer levels. Instead, keep everything dependent.

As a special case, the type of 'self' gets baked into the parameter
patterns with archetypes, so reconstruct the 'self' type ourselves.

The actual output of this is still frustratingly untestable, but we
get decent coverage because all of the type checking of generic
functions goes through here first.



Swift SVN r8936
2013-10-04 23:07:51 +00:00
Argyrios Kyrtzidis
963b6f0579 [serialization] Introduce 'FailedImportModule', which is used to track of when a module file failed to load (e.g. because of missing dependencies).
Swift SVN r8934
2013-10-04 21:29:24 +00:00
Argyrios Kyrtzidis
3e2f360e45 [AST] In the ModuleKind enum class, shorten enumerators by removing 'Module'. No functionality change.
Swift SVN r8933
2013-10-04 21:29:22 +00:00
Joe Groff
0d8d756c83 Sema: Teach conformance checking to derive requirements if needed.
For derivable protocols, such as RawRepresentable on raw-typed enums, when checking the conformance, create a conforming decl if an explicit decl wasn't found. Refactor the conformance derivation for toRaw/fromRaw to be driven by conformance checking in this way.

Swift SVN r8930
2013-10-04 20:50:43 +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
Doug Gregor
36df570c15 Record the generic type of a generic function as its "interface" type.
We're still not using the interface type for anything, but record it
and serialize/deserialize it.


Swift SVN r8897
2013-10-04 00:14:04 +00:00
Doug Gregor
361447021c Canonicalize generic type parameters with depth/index.
Swift SVN r8893
2013-10-03 22:33:22 +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
Doug Gregor
12e228c0f1 Introduce a new representation of polymorphic function types.
Introduces a new kind of function type, GenericFunctionType, that
represents a polymorphic function type with all of its generic
parameters and requirements stored in a more readily canonicalizable
form. It is meant to eventually replace PolymorphicFunctionType, but
for now we build it up in parallel so we can switch over to it
pieacemeal.

Note: this representation is built and then thrown away. We'll start
recording it soon.


Swift SVN r8881
2013-10-03 17:59:35 +00:00
Argyrios Kyrtzidis
781dcf7b11 [AST] Store the TypeReprs of generic arguments used to specialize a decl reference in DeclRefExpr, to impove source fidelity.
Fixes rdar://15034958

Swift SVN r8880
2013-10-03 17:55:55 +00:00
Argyrios Kyrtzidis
883a9eec61 [ASTWalker] Walk the TypeReprs of UnresolvedSpecializeExprs so we can syntax-annotate them.
Swift SVN r8879
2013-10-03 17:55:54 +00:00
Argyrios Kyrtzidis
cb4e51c72b [ASTDumper] For UnresolvedSpecializeExpr, print out its TypeReprs.
Swift SVN r8878
2013-10-03 17:55:53 +00:00
Joe Groff
12ffb98156 AST: Give Stmts an independent 'implicit' bit.
Definitions for derived protocol conformances will need to be able to create implicit statements free of the rules formerly hardcoded in Stmt::isImplicit. This also follows Dmitri and Argyrios's "implicit" improvements to the other AST hierarchies.

Swift SVN r8876
2013-10-03 16:53:53 +00:00
John McCall
affefbe1e0 Remove the AllocSelfExpr from constructors and teach
alloc_ref how to call +allocWithZone: for classes that might
(i.e. probably do) use ObjC allocation.

Swift SVN r8874
2013-10-03 06:36:34 +00:00
Dmitri Hrybenko
fcb3dbe0e6 Lookup visible decls / code completion for DynamicLookup: don't report
declarations with the same signature multiple times


Swift SVN r8864
2013-10-03 00:17:13 +00:00
Joe Groff
3b0180b1b0 Allow '_' in assignments again.
Parse '_' as a DiscardAssignmentExpr. Type-check it as an lvalue, and check that it only appears in the LHS of AssignExprs. During matching pattern resolution, convert it into an AnyPattern. In SILGen, when we see '_' in the LHS of an assignment, ignore the corresponding RHS rvalue.

Swift SVN r8848
2013-10-02 18:43:20 +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
Doug Gregor
5148c12c39 Dump the declared result type of a function declaration.
Swift SVN r8845
2013-10-02 17:57:30 +00:00
Argyrios Kyrtzidis
1165ab2b6e [ASTDumper] Only print both argument and body params if the function has selector-style syntax.
Swift SVN r8841
2013-10-02 16:30:10 +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
John McCall
298577676e Introduce the monadic ? operator.
A ? operator is interpreted as this if it's left-bound,
so ternary operators now have to be spaced on the left.

Swift SVN r8832
2013-10-02 01:27:45 +00:00
Joe Groff
f1993cf231 Parse and type-check 'x as? T' conditional cast syntax.
Though we plan to revamp the casting syntax, our general plan is for this form of cast, which does a conditional cast and returns an Optional<T> result, to be the one that survives. Parse the status-quo syntax 'x as? T' and type-check it. While we're here, refresh some fixits for redundant casts that referred to the now defunct 'as T' coercion syntax to completely remove whatever cast was in the source code.

Swift SVN r8805
2013-10-01 17:00:54 +00:00
Argyrios Kyrtzidis
9b4c94d4c2 [AST] Walk body parameter patterns.
Swift SVN r8804
2013-10-01 15:37:47 +00:00
Joe Groff
911929f1dd Parse and type check initializer closures after 'new T[n]' exprs.
Require that either T be default constructible or that the user provide a closure that maps indices to initial values. We don't actually call the closure yet to initialize the array; that's blocked on function abstraction difference <rdar://problem/13251236>.

Swift SVN r8801
2013-10-01 05:12:54 +00:00
Dmitri Hrybenko
6f4cb05603 Code completion: basic support for completing memebrs of DynamicLookup (id)
Only tested with functions (instance/class functions) declared in swift
classes.  Need more testcases.


Swift SVN r8800
2013-10-01 02:14:25 +00:00
Doug Gregor
f5d4269f53 Parameterize the resolution of generic type parameter types to archetypes.
When type checking, allow the caller to customize the resolution of generic
type parameter types based on the context, for example, by choosing to
substitute in an archetype (or not) and allowing one to resolve a dependent
member reference via a specific archetype.

No actual functionality change here.


Swift SVN r8797
2013-09-30 23:24:53 +00:00
Dmitri Hrybenko
b884b17891 AST Printer: don't print a space before a colon in a tuple label
For example:

  func f(a: Int)

instead of:

  func f(a : Int)


Swift SVN r8795
2013-09-30 22:58:16 +00:00
Argyrios Kyrtzidis
e461b3f267 [ASTDumper] Print the 'implicit'ness of a pattern.
Swift SVN r8794
2013-09-30 22:07:47 +00:00
Argyrios Kyrtzidis
2dfa03717c [ASTDumper] Print argument and body patterns of abstract function decls.
Swift SVN r8793
2013-09-30 22:07:45 +00:00
Dmitri Hrybenko
4a0c050d81 Store the standard library module name as ASTContext::StdlibModuleName
... instead of repeating it everywhere


Swift SVN r8792
2013-09-30 21:07:35 +00:00
Dmitri Hrybenko
ca57debb65 Lookup visible decls: rename doMemberLookup() -> lookupVisibleMemberDeclsImpl()
It was just an implementation detail of lookupVisibleMemberDecls(), so make
this intention clear in the name.


Swift SVN r8790
2013-09-30 20:00:37 +00:00
Argyrios Kyrtzidis
603521aeae [AST] When cloning a NamedPattern, make the var implicit if we are propagating implicit'ness.
Swift SVN r8789
2013-09-30 19:54:22 +00:00
Dmitri Hrybenko
33d77d7184 Lookup visible decls: rearrange code to remove forward declarations
Also, update comments.


Swift SVN r8786
2013-09-30 19:00:52 +00:00
Dmitri Hrybenko
93c1ac3727 Visible decl lookup: simplify code
Swift SVN r8785
2013-09-30 18:18:40 +00:00
Dmitri Hrybenko
bdc3da4f0c Visible decl lookup: update comments (we don't have a specific name to look up)
Swift SVN r8784
2013-09-30 18:11:47 +00:00
Argyrios Kyrtzidis
7bfebfbe03 [AST] Have the ASTWalker visit the indices pattern and element TypeRepr of a subscript decl.
Swift SVN r8782
2013-09-30 17:59:04 +00:00
Argyrios Kyrtzidis
8b76b30931 [AST] Add 'Implicit' boolean parameter in Pattern::clone(), which if true propagates 'implicitness' in the cloned pattern and its subpatterns.
Use it for the patterns of getter/setter of a subscript decl.

Swift SVN r8780
2013-09-30 17:59:01 +00:00
Argyrios Kyrtzidis
5bec0390dd Syntax-annotate 'get'/set' in a getter/setter as keywords.
Also make sure that ColorASTWalker passes SyntaxNodes in source order.
This is a patch by Sonny with some modifications.

Swift SVN r8777
2013-09-30 16:26:00 +00:00
Argyrios Kyrtzidis
efe3d94e6b [AST] Introduce DeclContext::walkContext(), used for ASTWalking a DeclContext.
Swift SVN r8776
2013-09-30 15:43:09 +00:00
Argyrios Kyrtzidis
bded52492e [AST] Introduce DeclContext::getLocalContext(), which returns the first local parent context.
Swift SVN r8775
2013-09-30 15:43:08 +00:00
Joe Groff
92cce69e15 AST: Give NominalTypePattern a better AST-level representation.
Instead of relying on the subpattern being a well-formed TuplePattern, let's track our own subelements so we can associate them to properties and validate them ourselves.

Swift SVN r8771
2013-09-30 01:03:18 +00:00
Joe Groff
6b80e1c008 AST: Add a TypeBase::isSuperclassOf convenience method.
Swift SVN r8768
2013-09-29 18:23:40 +00:00
Argyrios Kyrtzidis
b4d0d01071 [AST] Enable walking of all VarDecls.
This allows:
-The verifier to verify them.
-swiftIDE to annotate them.

Swift SVN r8767
2013-09-29 00:12:27 +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
3d7cf2072d [AST] If a ValueDecl is given an error type, also make it invalid.
Swift SVN r8760
2013-09-29 00:12:17 +00:00