Commit Graph

64 Commits

Author SHA1 Message Date
Max Moiseev
cf4bafe9e3 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-03 13:22:03 -08:00
Slava Pestov
0b320a6d5b Sema: Implement DefaultWitnessChecker
Now that WitnessChecker is separate from ConformanceChecker, implement
a DefaultWitnessChecker subclass which performs default witness
resolution.

This populates the recently-added ProtocolDecl::DefaultWitnesses map.

Unlike ConformanceChecker, the DefaultWitnessChecker looks up the witness
in any protocol extensions of the protocol, matching the context archetypes
of the requirement against the witness.

For now, we infer default witnesses for all protocols, but don't do
anything with that information. An upcoming SILGen patch will start to
emit thunks and add tests.
2016-03-03 06:59:55 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Jordan Rose
e04487d5be Dependencies: Add test for a private member of a struct or class.
This affects layout, and so can't be treated as a non-cascading dependency
within the module.
2016-02-09 16:32:45 -08:00
Dmitri Gribenko
62f73f4469 Rename CollectionDefaultIterator to IndexingIterator 2016-01-21 11:49:03 -08:00
Max Moiseev
08e1e4a043 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-11 16:51:11 -08:00
Jordan Rose
f752ac5d2d [test] Remove stray FIXME that's actually behaving correctly. 2016-01-06 16:57:35 -08:00
Jordan Rose
33a6cce188 Dependencies: references in generic signatures create public dependencies.
Noticed by inspection (!). This logic could use some before/after fuzzing.
2016-01-06 16:13:02 -08:00
Jordan Rose
de7678118f Dependencies: lookups in subscript signatures count as dependencies.
Fills in Chris's placeholder in feace85d5. I'm not quite sure why a private
subscript doesn't produce a non-cascading dependency right now, but this is
at least conservatively correct.

(For more infomation on dependencies, check out "Dependency Analysis.rst".)
2016-01-06 16:13:02 -08:00
Maxim Moiseev
0e54467bfa Final bulk removal of Type suffix 2015-12-16 17:06:19 -08:00
Dmitri Gribenko
99d3f96c6d Rename IndexingGenerator to CollectionDefaultIterator 2015-12-09 17:12:07 -08:00
Dmitri Gribenko
2cf172160c Rename SequenceType.Generator associated type to SequenceType.Iterator 2015-12-09 17:11:05 -08:00
Dmitri Gribenko
31598d41bf Rename GeneratorType to IteratorProtocol 2015-12-07 17:08:32 -08:00
Joe Groff
0cd5aa8c7c Change mangling for the Swift module from 'Ss' to 's'.
'Ss' appears in manglings tens of thousands of times in the standard library and is also incredibly frequent in other modules. This alone is enough to shrink the standard library by 59KB.

Swift SVN r32409
2015-10-02 22:39:44 +00:00
Jordan Rose
66c8598c4b [test] Check another kind of cross-file dependency.
Swift SVN r31129
2015-08-11 01:54:58 +00:00
Jordan Rose
cfe20537d6 Dependencies: Make sure we count redeclaration checking as a dependency.
Also, checking protocol conformances doesn't depend on any members, just the type.
We don't track dependencies on types separately from members right now, though,
so instead there's now a dummy dependency on 'deinit'.

Swift SVN r30288
2015-07-16 23:36:35 +00:00
Jordan Rose
59ea2fcdbd Dependencies: Make sure we mark cascading depends-nominal entries correctly.
If any of the member accesses to a type are cascading, we have a cascading
(non-private) dependency on the type itself.

Swift SVN r30287
2015-07-16 23:36:34 +00:00
Jordan Rose
806aac2611 Dependencies: Break out provided members from other ways to provide/extend a type.
There's now a difference between "this file provides a particular type" and
"this file provides members on a particular type". Adding a conformance in
an extension is still considered "providing a type" because it can affect
things besides just lookups.

This modifies the swiftdeps file output (including the members used by a file),
but the driver hasn't been updated to take advantage of this yet.

Swift SVN r30285
2015-07-16 23:36:32 +00:00
Jordan Rose
c79952389c Dependencies: rename entries in the .swiftdeps file to something sensible.
- (depends|provides)-top-level for top-level names.
- (depends|provides)-nominal for access into nominal types.
- (depends|provides)-dynamic-lookup for @objc members available on AnyObject.
- depends-external for cross-module file-based dependencies.

No functionality change.

Swift SVN r30283
2015-07-16 23:36:26 +00:00
Jordan Rose
cdb5ced75b Fix up r29815 to correctly handle properties in extensions.
My 'declIsPrivate' predicate was too conservative: it saw a PatternBindingDecl,
didn't know what it was, and decided that meant it might not be private. Now it's
actually checking the decl kind and doing something reasonable for non-ValueDecls.

Swift SVN r30282
2015-07-16 23:36:21 +00:00
Jordan Rose
f8f939d628 [Dependencies] Private extensions should not be considered part of a file's interface.
Swift SVN r29815
2015-06-30 22:37:13 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Jordan Rose
82beaf302d Dependencies: De-duplicate the list of extended nominals.
Very slight improvement for those who like to break their types up into
many extensions.

Swift SVN r28476
2015-05-12 18:18:15 +00:00
Jordan Rose
74f4827fb4 Dependencies: add tests for protocol extensions.
I think this is all working fine: we already say that a type adopting a
protocol depends on that protocol's members, and that an extension of a
protocol can supply members. It's a pretty conservative mechanism since
it doesn't take the constraints into account, but that's okay for now.

rdar://problem/20476867

Swift SVN r28475
2015-05-12 18:18:14 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +00:00
Dmitri Hrybenko
270ec3b67c stdlib: protocol extensions: de-underscore reduce()
Swift SVN r28237
2015-05-07 00:30:25 +00:00
Doug Gregor
59926f1a5c Acknowledge that extension declarations have inheritance clauses.
Swift SVN r26652
2015-03-27 23:57:37 +00:00
Jordan Rose
f10a4161c8 Don't include nameless decls (like accessors) in a file's provided decls.
(for dependency analysis)

rdar://problem/19773153

Swift SVN r25174
2015-02-11 07:20:37 +00:00
Jordan Rose
0a9d60485f Don't look into a type context to resolve types in the inheritance clause.
Instead, just check the generic parameters, then do a lookup as usual in the
enclosing context.

Fixes crash suite #58 and quite a few others (~200). This looks way more
impressive than it is; in most of these test cases it's the exact same
pattern causing the crash, and that pattern was just the last outstanding
crash trigger in a sea of garbage. (The few deleted tests were identical
to #58.)

Swift SVN r24748
2015-01-27 02:45:29 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Jordan Rose
9abf77d59a Operator lookups may be private (non-cascading) dependencies.
This helps reduce the impact when touching a file that, say,
defines a custom ==.

Swift SVN r23718
2014-12-05 02:24:35 +00:00
Jordan Rose
9f34d34e2e Sometimes protocol /non/-conformance can be a dependency.
...don't forget to record it!

Swift SVN r23709
2014-12-05 00:59:36 +00:00
Jordan Rose
ef0bd901be Since conformances are global, they may not be dependencies at all.
If a conformance is found for a type in another module, that conformance
will never change in response to what happens in this module, so we don't
need to treat it as a dependency at all.

Swift SVN r23702
2014-12-05 00:23:30 +00:00
Jordan Rose
f0582e27b9 Testing whether a type is bridged to ObjC isn't always a public use.
Push the "in expression" flag up through TypeChecker::getBridgedToObjC and
TypeChecker::getDynamicBridgedThroughObjCClass.

Swift SVN r23701
2014-12-05 00:23:29 +00:00
Jordan Rose
2b0fbcbe80 Looking up conformances for a type isn't always a public use of the type.
Specifically, it's not when
- the conformance is being used within a function body (test included)
- the conformance is being used for or within a private type (test included)
- the conformance is being used to generate a diagnostic string

We're still a bit imprecise in some places (checking ObjC bridging), but
in general this means less of an issue for checking literals.

Swift SVN r23700
2014-12-05 00:23:24 +00:00
Jordan Rose
caf22106d2 [test] Operator requirements in protocols may be private lookups.
...for example, if the type conforming to the protocol is itself private,
as in this test.

Swift SVN r23672
2014-12-04 00:35:10 +00:00
Jordan Rose
c567f365fd [test] The ~= in a pattern match is never a public dependency.
(because pattern matches can never affect type resolution)

Test for previous commit.

Swift SVN r23671
2014-12-04 00:35:10 +00:00
Jordan Rose
51b273b113 Add a flag to UnqualifiedLookup to say that a lookup is known-private.
...and thus does not affect downstream files...

...and adopt it in several places:
- when looking up the default type for a literal (test included)
- when looking up the first component in an IdentTypeRepr (test included)
- when deciding which ~= to use in a switch (test forthcoming)
- when a protocol has an operator function requirement (test forthcoming)
- when validating @NSApplicationMain and @UIApplicationMain
- when an enum element shows up unqualified in a switch
- several places where it doesn't matter because we're looking something up
  in the standard library.

Part of rdar://problem/15353101

Swift SVN r23670
2014-12-04 00:35:08 +00:00
Jordan Rose
7d4f12daa7 Decide if an extension is private before checking its conformances.
Extensions of private types can't affect anything outside the current file,
so we shouldn't treat them as having cascading dependencies on protocols
they add conformances for. However, the previous commits didn't actually
make sure we'd computed an extension's default access by the time we start
checking its conformances.

Swift SVN r23634
2014-12-03 02:56:01 +00:00
Jordan Rose
5033d915a3 Dependencies: Private functions do not affect downstream files.
This adds a check to isPrivateContextForLookup, and also changes Sema to
use a function itself as the lookup context for non-generic functions'
result types (like generic functions already do). It also moves
isPrivateContextForLookup onto DeclContext itself, to be used in the next
commits.

Swift SVN r23633
2014-12-03 02:56:00 +00:00
Jordan Rose
470706eb61 Dependencies: Push isKnownPrivate up to TypeChecker::lookupConstructor.
Some initializer lookups are known to be private dependencies.

Swift SVN r23632
2014-12-03 02:55:59 +00:00
Jordan Rose
02a286821f Dependencies: member lookups in constraint systems are usually private.
This adds a new parameter to TypeChecker::lookupMember to specify when
something is known-private, which can then be passed along to
DeclContext::lookupQualified. This makes many of the existing member
lookup dependencies in the reference-dependencies.swift test correctly
count as private.

Swift SVN r23631
2014-12-03 02:55:58 +00:00
Jordan Rose
8200baa508 Dependencies: types in PatternBindingDecls can't affect function signatures.
Swift SVN r23528
2014-11-21 19:32:22 +00:00
Jordan Rose
f5f1f99cf5 Dependencies: types in for-each patterns count as in-expression types.
Swift SVN r23527
2014-11-21 19:32:21 +00:00
Jordan Rose
db4a23be2d Dependencies: "is" patterns are always in expression contexts.
Swift SVN r23525
2014-11-21 19:32:20 +00:00
Jordan Rose
4285661c8c Dependencies: private typealiases never cause non-private dependencies.
This adds a new flag TR_KnownPrivateDependency, which is a bit stronger than
TR_InExpression. The latter only results in private dependencies when the
decl context is a function, or when the context is otherwise private.

Swift SVN r23524
2014-11-21 19:32:19 +00:00
Jordan Rose
2ef14c2a49 Dependencies: closure signatures are always in expression contexts.
Again, expression contexts are those that can't show up in a function
signature, so type resolution in a function decl context can assume
that all resulting type dependencies are private.

Swift SVN r23523
2014-11-21 19:32:18 +00:00
Jordan Rose
d1c5c5ddac Dependencies: Not all identifier types are non-private dependencies.
This commit treats all TypeExprs and casts as private if the decl context
is a function. In other cases we fall back to the general rules about the
current context (from r23447).

Swift SVN r23522
2014-11-21 19:32:16 +00:00
Jordan Rose
1e3b6f7463 Resolving enum element patterns counts as a use of the enum type.
Previously we were using the enum itself as the decl context to look up
enum members in switch case patterns. This meant that we weren't respecting
access control rules (not an issue, since enum cases currently don't have
access control), nor recording the dependency on the enum (oops).

Swift SVN r23521
2014-11-21 19:32:14 +00:00
Jordan Rose
e97764fbd8 Dependencies: Type lookups are private in constraint systems within functions.
This is the start of distinguishing qualified lookups within function bodies
from qualified lookups in a function signature. Both of these use the
function itself as the decl context, so we need to distinguish them manually.

This particular commit doesn't change much because expressions don't often
use TypeMember constraints. But it does help with for-loops!

Swift SVN r23484
2014-11-20 20:58:19 +00:00