Commit Graph

7 Commits

Author SHA1 Message Date
Slava Pestov
0bc802e7ad SourceKit: Fix indexing crash with protocol typealiases
The root cause is that NormalProtocolConformance::forEachValueWitness()
needs to skip protocol members that are not requirements.

Otherwise we end up passing such a non-requirement member down to
NormalProtocolConformance::getWitness() and hit an assert when we
cannot find it.

It looks like this code path was only ever hit from SourceKit.
The fix moves TypeChecker::isRequirement() to a method on ValueDecl,
and calls it in the right places.

Fixes <https://bugs.swift.org/browse/SR-3815>.
2017-02-20 03:35:19 -08:00
Slava Pestov
fd40597d90 Sema: Extend prohibition of @_inlineable designated initializers to classes
This check only applied to struct and enum initializers previously,
but that was an oversight.
2017-02-14 15:48:26 -08:00
Slava Pestov
f0ecd1c1a3 Sema: Lift unnecessary restriction on initializers defined in extensions of resilient protocols
The restriction only applies to initializers in extensions of
concrete types; protocol extension initializers are OK.

Fixes <rdar://problem/30351393>.
2017-02-13 00:24:13 -08:00
Slava Pestov
b83bb7d614 Sema: Fix bug where enum cases could not be referenced from inlineable context
Enum cases do not have their own accessibility or @_versioned
attribute, and we already diagnose invalid references to the
enum type itself.
2017-01-29 22:34:47 -08:00
Slava Pestov
0c294314d0 Sema: Diagnose invalid initializers on resilient types
Value type initializers must initialize stored properties directly
if they do not delegate to another initializer via self.init().

Since direct stored property access is not permitted for resilient
value types from outside their resilience domain, this means that
such initializers are prohibited in two cases:

- If the initializer is defined in an extension from outside the
  value type's resilience domain

- If the initializer is public and @_inlineable, since it might get
  inlined outside the value type's resilience domain

Right now, such initializers cannot *assign* to self either;
I filed <https://bugs.swift.org/browse/SR-3686> to track the issue.
2017-01-20 01:22:51 -08:00
Slava Pestov
ec028235be Sema: Fix incorrect diagnostic when referencing members of a @_versioned protocol
Protocol members can be directly referenced from protocol extensions
and generic functions. Since protocol members do not have accessibility
distinct from the protocol itself, ignore them, since they won't carry
the @_versioned attribute.

While workign on this I uncovered an interesting bug where we allow
members of protocol extensions to be more accessible than the protocol
itself, but then we give the symbols hidden visibility at the SIL level
anyway.

I filed <https://bugs.swift.org/browse/SR-3684> to track this issue.
2017-01-20 01:22:50 -08:00
Slava Pestov
d65d1d25f9 Sema: Diagnostics for @_inlineable, @_versioned and Swift 4 default arguments model
Piggybacks some resilience diagnostics onto the availability
checking code.

Public and versioned functions with inlineable bodies can only
reference other public and internal entities, since the SIL code
for the function body is serialized and stored as part of the
module.

This includes @_transparent functions, @_inlineable functions,
accessors for @_inlineable storage, @inline(__always) functions,
and in Swift 4 mode, default argument expressions.

The new checks are a source-breaking change, however we don't
guarantee source compatibility for underscored attributes.

The new ABI and tests for the default argument model will come in
subsequent commits.
2017-01-09 16:59:13 -08:00