Commit Graph

117 Commits

Author SHA1 Message Date
Devin Coughlin
5a340026c9 [Sema] Update wording of diagnostics for useless #os() checks
For consistency with other diagnostics, they now say "will always be true"
instead of "will always pass."



Swift SVN r22730
2014-10-14 20:46:18 +00:00
Devin Coughlin
d562acb223 [Sema] Change diagnostic of useless #os() check to indicate why it is useless.
This commit updates diagnostic reporting for #os() checks that will always pass.
We now indicate whether the reason the check will always pass is because of the
minimum deployment target or is because of an enclosing scope. In the latter
case, we emit a note indicating the location of the enclosing scope.


Swift SVN r22729
2014-10-14 18:38:48 +00:00
Devin Coughlin
f4e061f2d5 [Sema] Add diagnostic for #os() used outside of if statement guard.
We restrict #os(...) to only the guard condition of if statements. We may want
to loosen this restriction in the future (to, e.g., IfExprs) -- but, in general,
we don't want #os() to appear where static analysis cannot easily determine
its effect.



Swift SVN r22720
2014-10-14 03:27:00 +00:00
Devin Coughlin
6ae6fa7552 [Sema] Add warning for #os() checks that always pass.
Swift SVN r22719
2014-10-14 02:44:11 +00:00
Devin Coughlin
71116b490b [Sema] Use type refinement context of storage as parent for accessor functions.
This commit changes building of type refinement contexts for accessor functions
to use the type refinement context of its associated storage as a parent
rather than its lexically-enclosing context. With this change, we now
associate new child contexts inside property accessors with the TRC of the
property rather than the TRC of the container of the anonymous function created
for the accessor. This commit also adds a dump() debug method to
TypeRefinementContext.


Swift SVN r22718
2014-10-14 01:47:01 +00:00
Devin Coughlin
863db9d962 [Sema] Add tests for unavailable types in inherits clauses.
This commit adds tests only; no additional functionality.


Swift SVN r22691
2014-10-11 20:58:35 +00:00
Devin Coughlin
8ab25ab263 [Sema] Make method availability version ranges contravariant.
Make method/property availability contravariant: the available range of an
override must contain the available range of the overriden declaration.


Swift SVN r22682
2014-10-11 00:44:51 +00:00
Devin Coughlin
4fcbf5a8bb [Sema] Add checking for declarations with potentially unavailable types.
This commit adds checking of declarations with potentially unavailable types to
the existing checking for explicitly unavailable types. At the moment, these
two checking mechanisms are separate -- I will unify them in a future commit.

This commit removes the TypeExpr-based checking added in r22651; such checks
are now superfluous.


Swift SVN r22679
2014-10-10 22:40:27 +00:00
Devin Coughlin
f8fe884e98 Add availability checking for references to classes to Sema.
This commit adds availability checking for references to classes in Sema. We
now emit a diagnostic when a potentially unavailable class is referenced
in an expression, either directly (via a TypeExpr) or as the result of being
substituted as a replacement type in a call to a generic function. This
latter check is needed at the callsite because the callee may use its
formal type parameter to get at the metadata for the type.

This commit does not check declarations of variables, etc., with unavailable
types -- this will come in a later patch.


Swift SVN r22651
2014-10-10 01:11:40 +00:00
Devin Coughlin
2e3acba163 Add availability checking for properties to Sema
This commit adds availability checking for properties to Sema. When
EnableExperimentalAvailabilityChecking is enabled, we now emit a diagnostic
when a potentially unavailable property is accessed. To support this, we
now build type refinement contexts for most ValueDecls.


Swift SVN r22622
2014-10-09 17:21:52 +00:00
Devin Coughlin
0aa115c09b Add diagnostics for potentially unavailable initializers.
This patch adds diagnostics for initializers that are potentially unavailable.
It does not treat such initializers as optionals, even when
EnableExperimentalUnavailableAsOptional is true -- there is some tricky
interaction with failable initializers that still needs to be worked out.



Swift SVN r22548
2014-10-06 19:50:08 +00:00
Devin Coughlin
59814bd140 Add type checking for potentially unavailable method references.
This commit modifies Sema to add type checking for potentially unavailable
method references. We now record the reason for method unavailability when
recording a potential overload choice during member constraint simplification
and either diagnose or lift to an optional type during CSApply. This commit also
generalizes UnavailableToOptionalExpr to take an arbitrary subexpression.

This commit does not address potentially unavailable properties, initializers,
or dynamic member references.


Swift SVN r22508
2014-10-03 23:23:13 +00:00
Devin Coughlin
2e8d4bc718 Add handling of potentially unavailable overloaded global functions to Sema.
This commit also factors out some common checking and diagnostic code; it
additionally moves diagnostic emission for unavailable references from CSGen to
CSApply.


Swift SVN r22447
2014-10-01 23:52:08 +00:00
Devin Coughlin
8cb8e150a2 Add Sema tests for potentially unavailable global functions.
This commit adds tests to demonstrate that availability checking works,
at the Sema level, for global functions. SILGen for potentially unavailable
global functions is not yet implemented.


Swift SVN r22406
2014-09-30 21:31:51 +00:00
Devin Coughlin
3749a98763 Record the reason a declaration is potentially unavailable.
This commit adds tracking of the reason a declaration reference is potentially
unavailable to the UnavailableToOptionalExpr AST node and to OverloadChoice. We
will use this reason during SILGen to emit the appropriate run-time check and
during typechecking to provide more helpful diagnostics.

To keep OverloadChoice as small as possible, we encode the reason as an index
into a vector of reasons stored in a given instance of ConstraintSystem (this is
the same approach that Fix takes).

This commit adds Sema/OverloadChoice.cpp (for the parts of OverloadChoice that
now rely on ConstraintSystem) and AST/Availability.h (to bring in
availability-related structures without TypeRefinementContext).


Swift SVN r22377
2014-09-30 01:53:59 +00:00
Devin Coughlin
ec7a4fa8d7 Construct type refinement contexts for #os(...).
This patch adds construction of type refinement contexts for the Then branch of
availability queries and adds diagnostics for ill-formed queries. For the
moment, we do not refine for the Else branch because the version range lattice
is not precise enough to do so helpfully.

This patch does not properly handle availability queries involving application
extension platforms (noted with a FIXME). I will add support for these platforms
in a future commit.


Swift SVN r22165
2014-09-22 01:32:07 +00:00
Devin Coughlin
0d4e945b3a Construct type refinement context hierarchy in Sema.
This patch adds the beginning of building the type refinement context tree for
availability checking in Sema, guarded by by the
-enable-experimental-availability-checking option. This tree parallels the AST
but is much more sparse: we introduce a new TypeRefinementContext only when
needed. Each context refines the range of potential OS versions that could be
encountered at run time. For the moment, we only refine contexts for function
bodies. I will add refinement contexts for #os(...) in a later commit.

The AST is not directly connected to the TRC tree except at the SourceFile
level; when type checking, we use source locations to look up the TRC
corresponding to an AST element. For the moment, we emit a diagnostic when the
programmer references a potentially unavailable declaration. We will later
change this to treat the declaration as if it had optional type.


Swift SVN r22145
2014-09-19 22:11:29 +00:00