Files
swift-mirror/lib/AST/Module.cpp
Slava Pestov 322f58d8b1 Sema: Tighten up existential vs generic type parameter distinction
Rename existentialConformsToSelf() to existentialTypeSupported(). This
predicate is the "protocol has no Self or associated type requirements"
check, which is a looser condition than self-conformance. This was being
tested to see if the user could refer to the protocol via an existential
type.

The new existentialConformsToSelf() now checks for protocol being @objc,
and for the absence of static methods. This is used as part of the
argument type matching logic in matchType() to determine if the
existential can be bound to a generic type parameter.

The latter condition is stricter, for two reasons:

1) We allow binding existentials to multiple type parameters all sharing
   the same generic type parameter T, so we don't want the user to be
   able to see any static methods on T.
2) There is an IRGen limitation whereby only existentials without witness
   tables can be passed in this manner.

Using the above, the representsNonTrivialGenericParameter() function
has been renamed to canBindGenericParamToExistential(). It now allows
an existential type to be bound to a generic type parameter only under
the following circumstances:

A) If the generic type parameter has no conformances, the match is allowed.

B) If the generic type parameter has at least one conformance, then all
   of the conformances on the generic type parameter must be
   existentialConformsToSelf() (condition 1 above), and all conformances
   on the existential must be @objc (condition 2 above).

Fixes <rdar://problem/18378390> and <rdar://problem/18683843>, and lays
the groundwork for fixing a few other related issues.

Swift SVN r29337
2015-06-07 10:16:21 +00:00

54 KiB