Commit Graph

30 Commits

Author SHA1 Message Date
Jordan Rose
91be25ffb4 Dependency analysis: treat member operators as top-level "provides". (#3986)
We still do a global lookup for operators even though they are
syntactically declared within types now, so for dependency-tracking
purposes continue to treat that as declared at the top level.

This isn't where we actually want to be---ideally we can use the types
of the arguments to limit the dependencies to a member lookup (or pair
of member lookups)---but since the operator overloads /themselves/
participate in type-checking an expression, I'm not sure that's 100%
correct. For now, it's better to be conservative. (This means
dependency analysis for operators remains as lousy as it was in Swift
2, but it's not a regression.)

rdar://problem/27659972
2016-08-04 08:40:26 -07:00
Robert Widmann
f97e5dcb0e [SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration.  A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
Dmitri Gribenko
f0633ce5a9 stdlib: Sequence.iterator() => .makeIterator() 2016-02-23 13:52:30 -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
Max Moiseev
08e1e4a043 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-11 16:51:11 -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
844b81c46b SequenceType => Sequence 2015-12-09 17:16:56 -08:00
Dmitri Gribenko
1c0047829a Rename SequenceType.generate() to SequenceType.iterator() 2015-12-09 17:11:17 -08:00
Dmitri Gribenko
2cf172160c Rename SequenceType.Generator associated type to SequenceType.Iterator 2015-12-09 17:11:05 -08: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
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
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
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
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
8200baa508 Dependencies: types in PatternBindingDecls can't affect function signatures.
Swift SVN r23528
2014-11-21 19:32:22 +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
Jordan Rose
ce995a8f67 Dependencies: conformances on private decls are themselves private.
This does reveal an overly conservative case: lookup in the inheritance
clause of extensions is always considered a non-private lookup, even if
it's extending a private type, because we haven't yet resolved what it's
extending. Won't lead to incorrect behavior, just more compilation than
is strictly necessary.

Swift SVN r23481
2014-11-20 20:58:15 +00:00
Jordan Rose
c712c51d4a Dependencies: start tracking whether a lookup is private to a file or not.
This is sort of two commits squashed into one: first, update
ReferencedNameTracker to record whether a name or type is non-private,
along with changing all clients to assume non-private; and second,
actually try to (conservatively) decide if a particular unqualified lookup can
be considered private.

What does "private" mean? That means that a dependency does not affect
"downstream" files. For example, if file A depends on B, and B depends on C,
then a change in C normally means A will get rebuilt. But if B's dependencies
on C are all private dependencies (e.g. lookups from within function bodies),
then A does not need to be rebuilt.

In practice there are several rules about when we can make this assumption,
and a few places where our current DeclContext model is not good enough to
distinguish private uses from non-private uses. In these cases we have to
be conservative and assume that the use is non-private (and thus that
downstream files will need to be rebuilt).

Part of rdar://problem/15353101

Swift SVN r23447
2014-11-19 22:28:30 +00:00
Jordan Rose
6961c08b47 Dependencies: use of a conformance is a use of the conforming type.
...even if we don't explicitly do any lookups into the type.

Part of rdar://problem/15353101

Swift SVN r23393
2014-11-18 01:38:20 +00:00
Jordan Rose
22c41e005b Add adopted protocols to the type dependency list.
This isn't so interesting because we already depend on the top-level name
of a protocol, but it becomes more interesting if/when we start allowing
protocol extensions.

Part of rdar://problem/15353101

Swift SVN r23392
2014-11-18 01:38:19 +00:00
Jordan Rose
d6c7c522a7 Add operator lookups to the set of top-level names being used.
Part of rdar://problem/15353101

Swift SVN r22931
2014-10-24 22:23:09 +00:00
Jordan Rose
ca6639cf97 Track types that we perform qualified lookup on from the primary file.
We need to do this mainly to figure out when extensions can affect this file.
This is part of the intra-module dependency tracking work to implement
incremental rebuilds.

Part of rdar://problem/15353101

Swift SVN r22927
2014-10-24 22:23:05 +00:00
Jordan Rose
9afdd1bc2f Print the top-level names "provided" by a file along with its references.
Every name a file declares is something that another file in the same module
might depend on. The driver will need this information too to correctly
decide what files need to be rebuilt. This is part of the intra-module
dependency tracking work to implement incremental rebuilds.

This doesn't handle extensions yet, which are a bit trickier. Need to
figure out how to handle the interaction between extensions and typealiases.

Part of rdar://problem/15353101

Swift SVN r22926
2014-10-24 22:23:04 +00:00
Jordan Rose
fc09bd4585 Add basic reference tracking based on name lookups.
This tracks top-level qualified and unqualified lookups in the primary
source file, meaning we see all top-level names used in the file. This
is part of the intra-module dependency tracking work that can enable
incremental rebuilds.

This doesn't quite cover all of a file's dependencies. In particular, it
misses cases involving extensions  defined in terms of typealiases, and
it doesn't yet track operator lookups. The whole scheme is also very
dependent on being used to track file-level dependencies; if C is a subclass
of B and B is a subclass of A, C doesn't appear to depend on A. It only
works because changing A will mark B as dirty.

Part of rdar://problem/15353101

Swift SVN r22925
2014-10-24 22:23:03 +00:00