Commit Graph

184 Commits

Author SHA1 Message Date
Doug Gregor
332e4d14e7 Replace a manual crawl through conformances with a use of getAllConformances().
Also, improve duplicate detection by looking at the actual witnesses that have been recorded thus far.

Swift SVN r26325
2015-03-19 22:10:07 +00:00
Chris Lattner
59c22383fb Rework PatternBindingDecl to maintain a list of pattern/initexpr pairs inside of it.
Previously, a multi-pattern var/let decl like:
  var x = 4, y = 17

would produce two pattern binding decls (one for x=4 one for y=17).  This is convenient
in some ways, but is bad for source reproducibility from the ASTs (see, e.g. the improvements
in test/IDE/structure.swift and test/decl/inherit/initializer.swift).

The hardest part of this change was to get parseDeclVar to set up the AST in a way
compatible with our existing assumptions. I ended up with an approach that forms PBDs in 
more erroneous cases than before.  One downside of this is that we now produce a spurious
  "type annotation missing in pattern"
diagnostic in some cases.  I'll take care of that in a follow-on patch.





Swift SVN r26224
2015-03-17 16:14:18 +00:00
John McCall
0802e85975 Implement the naked 'do' statement.
For now, we assume that 'while' after the braces starts
a do/while rather than being an independent statement.
We should disambiguate this, or better, remove do/while.

Tests later.

Swift SVN r26079
2015-03-13 01:58:42 +00:00
Chris Lattner
9ac6c23c1d rename IsaPattern -> IsPattern to follow source syntax, NFC.
Swift SVN r25951
2015-03-10 20:09:02 +00:00
Chris Lattner
de808d1603 Progress on: <rdar://problem/19382878> Introduce new x? pattern
This introduces a new pattern, spelled "x?" which is sugar for
matching ".Some(x)".  It also changes the parser slightly so that
_ (the discard expr) is parsed as a unary expr instead of as an
expr.  This allows it to have postfix ? after it, which is important
in pattern contexts to support "case _?:".



Swift SVN r25907
2015-03-10 01:00:23 +00:00
Jordan Rose
93a89467b8 [ClangImporter] Hide old API from the Carbon days.
This affects the MacTypes.h header in the Darwin module as well as the
CarbonCore and OSServices sub-frameworks of the CoreServices framework.
API hidden in this way can still be accessed through qualified lookup
in case it's really needed, but will not appear in the module interface
or in code completion.

This is a hack, and it would be nice to remove it if/when all of this API
is officially marked as deprecated. I did check with Nick for MacTypes.h
and Chris Linn from CoreServices that this was a reasonable action to take.

rdar://problem/16806148

Swift SVN r24424
2015-01-14 19:27:45 +00:00
Chris Lattner
763bb6386f Implement parser, AST representation, type checker, etc support for generalized
if-let statements (also while and var, of course) that include multiple bindings
and where clauses.

SILGen support still remains, it currently just asserts on the new constructs.



Swift SVN r24239
2015-01-07 07:03:02 +00:00
Ben Langmuir
e9e1666ab0 Update for upstream LLVM changes
* removal of StringMap's GetOrCreateValue
* SmallSet::insert now returns a pair like std::set

Swift SVN r23435
2014-11-19 16:49:30 +00:00
Argyrios Kyrtzidis
9f8641f90e [IDE/CodeCompletion] Fix crash when picking up declarations from the protocol conformances
of a type declared in a non-primary source file.

rdar://18583883

Swift SVN r22689
2014-10-11 05:07:38 +00:00
Dmitri Hrybenko
457baf164b Remove dead code
Swift SVN r22318
2014-09-27 23:41:56 +00:00
Doug Gregor
344ecfd3f9 Add a new 'fail' statement to the AST for failing from an initializer.
The spelling of the 'fail' statement is simply 'return nil', but
distinguishing it in the AST clarifies intent for SILGen.

Swift SVN r21310
2014-08-20 17:22:36 +00:00
Dmitri Hrybenko
d02b55b288 Code completion: fix bugs that prevented completion for overrides to work in
extensions

rdar://17654014


Swift SVN r21305
2014-08-20 10:02:37 +00:00
Dmitri Hrybenko
6a5f59831b Code completion: include access control keywords in override completion
When trying to implement deduplication of results, found and fixed an issue
with loose checks for generic overload checking.

rdar://17995317


Swift SVN r21276
2014-08-19 11:00:10 +00:00
Doug Gregor
ac332429d9 Give extensions generic parameters and signatures within the AST.
This adds generic parameters and generic signatures to extension
declarations. The actual generic parameters just mirror what is
available on the extended type; however, it is filled in via extension
validation, which is handled lazily.

This is a NFC step toward decoupling the archetypes of extensions from
the archetypes of the extended types <rdar://problem/16974298>.

Swift SVN r20675
2014-07-29 16:20:56 +00:00
Dmitri Hrybenko
7f2d50a134 Code completion: try harder to eliminate duplicate results in visible name
lookup

rdar://17826393


Swift SVN r20618
2014-07-28 11:01:18 +00:00
Jordan Rose
4b5ce8703f Fix r19963 to /not/ respect access control when it's disabled.
<rdar://problem/17684933>

Swift SVN r20223
2014-07-20 17:26:22 +00:00
Dmitri Hrybenko
154e79c32b Code completion: include variables declared in 'if' and 'while' conditions
rdar://17458271


Swift SVN r20162
2014-07-18 18:04:36 +00:00
Jordan Rose
67536dbb8a Respect access control in visible decl lookup (and code completion).
<rdar://problem/17648922>

Swift SVN r19963
2014-07-14 23:02:41 +00:00
Chris Lattner
35dcc3aa10 Move the @optional attribute to being a SIMPLE_DECL_ATTR, which
simplifies a bunch of code, makes them more consistent with the
other attributes, and is generally the newfangled way to do things.



Swift SVN r19779
2014-07-10 04:34:00 +00:00
Jordan Rose
5b80dc3d44 Respect accessibility for scoped imports.
"import var Foo.bar" should error if "Foo.bar" is not public.

Swift SVN r19747
2014-07-09 22:10:20 +00:00
Jordan Rose
132a29eb67 Remove unnecessary wrapper type GenericParam.
This always wrapped a single GenericTypeParamDecl *, and provided no benefit
over just using the decl directly.

No (intended) functionality change.

Swift SVN r19628
2014-07-07 20:51:50 +00:00
Jordan Rose
a7b563855e Add a mode in which access control is respected for module-scope lookups.
This applies to both qualified and unqualified lookups, and is controlled
by the -enable-access-control and -disable-access-control flags. I've
included both so that -disable-access-control can be put into specific tests
that will eventually need to bypass access control (e.g. stdlib unit tests).
The default is still -disable-access-control.

Swift SVN r19146
2014-06-24 21:32:21 +00:00
Dmitri Hrybenko
11b23bbf1a Code completion for overrides: complete @optional members
First half of rdar://15695863


Swift SVN r18741
2014-06-09 11:40:53 +00:00
Dmitri Hrybenko
df60e7751e Code completion for overrides: don't suggest to override members from outer
nominals in inner nominals


Swift SVN r16890
2014-04-26 20:08:11 +00:00
Dmitri Hrybenko
cd8ec9ef85 Fix grammar in function name
Swift SVN r16825
2014-04-25 17:41:42 +00:00
Dmitri Hrybenko
6bddd2962a Rename a function to accurately reflect what it does now
Swift SVN r16819
2014-04-25 14:19:17 +00:00
Dmitri Hrybenko
3ee34efee4 Code completion: complete declarations that are required for declared protocol
conformances

rdar://16539292

This is a hack in visible decl lookup.  The general solution that would also
improve type checker errors would be to make the type checker keep these broken
conformances and syntethize missing declarations to make downstream code type
check.  For that, see:

<rdar://problem/16723339> [QoI] Type checker should not be dropping protocol
conformances explicitly spelled in the source


Swift SVN r16818
2014-04-25 14:03:39 +00:00
Dmitri Hrybenko
35c587aadf Code completion: don't complete associated types on non-metatypes
Swift SVN r16817
2014-04-25 12:46:32 +00:00
Dmitri Hrybenko
7f6a109fd9 Code completion: fix crash while completing on AnyObject when Cocoa is imported
Swift SVN r16751
2014-04-24 09:55:04 +00:00
Doug Gregor
8bc2ea4ea1 Use designated/convenience initializer terminology throughout. NFC
Introduce CtorInitializerKind to describe the kind of an enum, rather
than a bool, to make way for more initializer kinds in the future.

Swift SVN r16525
2014-04-18 15:10:13 +00:00
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00
Joe Groff
9f7dab725c Make the ASTContext parameter to MetatypeType::get optional for type-checked types.
We can just get it from the instance type, if the instance type has been fully initialized, which is the case except during parsing of type decls when the decls' own types are being formed.

Swift SVN r15598
2014-03-29 02:50:30 +00:00
Dmitri Hrybenko
11fea869c1 Change 'switch' not to fall through between empty cases and always require at
least one statement per case

rdar://16301313


Swift SVN r15266
2014-03-20 11:44:59 +00:00
Dmitri Hrybenko
ef33f159e5 Code completion: implement completion for inherited initializers
<rdar://problem/16205994> Code completion: add tests for inherited initializers


Swift SVN r15114
2014-03-16 21:10:09 +00:00
Chris Lattner
7bbd9b05a5 Rename DynamicLookup -> AnyObject in a few more comments. This leaves
the DynamicLookupExpr expression and the DeclVisibilityKind::DynamicLookup
enum.  These seem right to me, more descriptive than renaming them AnyObject.
With this, I consider 13327098 to be done.



Swift SVN r14654
2014-03-04 22:17:38 +00:00
Chris Lattner
d758e0dfe3 Eliminate more "DynamicLookup" in favor of "AnyObject", this is the
bulk of finishing rdar://13327098.


Swift SVN r14653
2014-03-04 22:15:46 +00:00
Dmitri Hrybenko
0c4c291d20 Fix code completion in variable initializers that are not at the top level
Code completion used to suggest non-static members in member var initializer,
and incorrectly reported the reason why the declarations are visible from the
initializer.


Swift SVN r14457
2014-02-27 11:13:25 +00:00
Joe Pamer
988a5877f2 Some updates:
- Respond to Doug's code review feedback
   - Stop hacking around with scopes and use "emplace" to work around RAII in the inactive config case
   - Limit use of StringRef on the front-end, in favor of std::string
   - Use ArrayRef rather than SmallVector within IfConfigDecl
   - Reorder new property declarations on BraceStmt to prevent unnecessary alignment issues
- Update ParseBraceItems to better capture top-level declarations, rather than using token lookahead

Swift SVN r14306
2014-02-24 18:16:49 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Chris Lattner
b35858f131 Simplify more cases to use getSemanticsProvidingPattern.
Change Pattern::getBoundName to look through VarPatterns,
which means that the presence of var/let in an argument list no longer 
change the mangling of the function.



Swift SVN r11780
2013-12-31 22:25:43 +00:00
Dmitri Hrybenko
f9eacede74 Lookup visible decls: eliminate duplicate associated types that come from
different implemented protocols


Swift SVN r11534
2013-12-21 01:02:32 +00:00
Dmitri Hrybenko
94fac9f76a Lookup visible decls: collect associated types recursively
Swift SVN r11532
2013-12-21 00:31:31 +00:00
Dmitri Hrybenko
f106ad4685 Lookup visible decls: return associated types from protocols that the type
conforms to

This is not the final design that Doug and I discussed, but this is a strict
improvement over what we had previously (we did not report them at all).


Swift SVN r11530
2013-12-21 00:09:24 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
Jordan Rose
2881fd73c0 Convert a group of std::sets to DenseSets on principle.
Also, don't call count() and then insert(); just check the result of insert().

No functionality change.

Swift SVN r10838
2013-12-05 01:51:17 +00:00
Jordan Rose
f5eae17dd2 Move VectorDeclConsumer to swift/AST/NameLookup.h.
This started out life as a helper class, but it's been used in multiple places.
Better to just have a single copy.

No functionality change.

Swift SVN r10835
2013-12-05 01:51:12 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Dmitri Hrybenko
4d44c7e9df Visible decl lookup: clarify logic for functions, no functionality change
Swift SVN r10488
2013-11-15 02:02:42 +00:00
Dmitri Hrybenko
47951efcb9 Implement code completion support for static variables
Swift SVN r10487
2013-11-15 01:32:20 +00:00
Dmitri Hrybenko
022136ec2e Code completion: now frontend rejects accessing types through expressions
(rdar://14489286), adjust code completion results


Swift SVN r10398
2013-11-13 00:44:07 +00:00