Allow class metatypes (including class-constrained existential metatypes) to be treated as subtypes of AnyObject, and single-@objc protocol metatypes to be treated as subtypes of the Protocol class from objc. No codegen support yet, so this is hidden behind a frontend flag for now.
Swift SVN r18810
There's a bit of a reshuffle of the ExplicitCastExpr subclasses:
- The existing ConditionalCheckedCastExpr expression node now represents
"as?".
- A new ForcedCheckedCastExpr node represents "as" when it is a
downcast.
- CoerceExpr represents "as" when it is a coercion.
- A new UnresolvedCheckedCastExpr node describes "as" before it has
been type-checked down to ForcedCheckedCastExpr or CoerceExpr. This
wasn't a strictly necessary change, but it helps us detangle what's
going on.
There are a few new diagnostics to help users avoid getting bitten by
as/as? mistakes:
- Custom errors when a forced downcast (as) is used as the operand
of postfix '!' or '?', with Fix-Its to remove the '!' or make the
downcast conditional (with as?), respectively.
- A warning when a forced downcast is injected into an optional,
with a suggestion to use a conditional downcast.
- A new error when the postfix '!' is used for a contextual
downcast, with a Fix-It to replace it with "as T" with the
contextual type T.
Lots of test updates, none of which felt like regressions. The new
tests are in test/expr/cast/optionals.swift.
Addresses <rdar://problem/17000058>
Swift SVN r18556
Array downcast is an explicit cast written "x as U[]", not an implicit
conversion, so make it a subclass of ExplicitCastExpr. The only
effective change here is that we retain the location of the "as" and
the type as written in the AST. No semantic change.
Swift SVN r18391
We weren't diagnosing initializer delegation/chaining, subscripts, or
(the one that got me concerned) members accessed through AnyObject.
Swift SVN r18271
<rdar://problem/16264989> property not mutable in closure inside of its willSet
and:
<rdar://problem/16826319> willSet immutability behavior is incorrect
by changing how we handle immutability of an observing property within its willSet.
Instead of trying to model it as an rvalue, just model it as an lvalue (which it is)
and diagnose the problem with a warning in MiscDiagnostics.
Swift SVN r18184
- Continue adding support for checked downcasts of array types (rdar://problem/16535104)
- Fix non-bridged array conversions post-r17868
- Fix rdar://problem/16773693
- Add tests for NSArray coercions to and from Array<T>
Swift SVN r17957
when resolving identifiers into types. This will eventually allow us to
solve annoying issues like rdar://15295763&15588967 by better modeling
what we already have.
Swift SVN r16620
a fallback to catch anything else that is missed. This resolve the rest of:
<rdar://problem/16193162> Require specifying self for locations in code where strong reference cycles are likely
Swift SVN r16319
Teach SILGen to handle function representation changes as part of function conversion instead of needing to be spoonfed a special expr for the purpose. Handle representation changes in both directions to and from blocks using the same logic as the bridging conversions.
Swift SVN r16318
Add a third branch to the constraint system for '&x' expressions that allows conversion from an lvalue to a type via an additional writeback step:
- Add an LValueConversionExpr node that converts from @lvalue T to @lvalue U, given a pair of functions that convert T -> U and U -> T, to represent the writeback temporary.
- Allow conversion in an inout expression from @lvalue T to a type U that has the following members:
static func __writeback_conversion(Builtin.RawPointer, T.Type) -> U
static func __writeback_conversion_get(T) -> V
static func __writeback_conversion_set(V) -> T
which builds a solution that produces an LValueConversion from the get/set pair before passing the pointer to the writeback temporary off to the conversion function.
Swift SVN r15764
Protocols can declare methods as being unavailable, as they do
in NSObjectProtocol (e.g., 'retain'). We both need to flag these
uses, but understand this for protocol conformance. For protocol
conformance, treat unavailable methods as if they were marked
optional. The compiler will not allow you to use these methods
anyway.
This finishes up support for:
<rdar://problem/16331335> Ban ObjC ARC entry points
Swift SVN r15644
Add two new AST node types:
- InOutConversionExpr, which represents an '&x' expression that involves inout conversion. This will be a signal to SILGen not to introduce a writeback scope for the nested conversion call.
- LValueToPointerExpr, which represents the primitive '@lvalue T' to 'RawPointer' conversion that produces the argument to the inout conversion.
Build an InOutConversionExpr AST when an inout expression is resolved by a conversion to an BuiltinInOutAddressConvertible type.
Swift SVN r15594
This requires that property references have an explicit "self." qualifier when in an
explicit closure expression, since self will be captured, not the property.
We don't do the same for autoclosures. The logic here is that autoclosures can't
practically be used in capturing situations anyway, since that would be extremely
surprising to clients. Further, forcing a syntactic requirement in an autoclosure
context would defeat the whole point of autoclosures: make them implicit.
Swift SVN r14676
Diagnose a metatype reference that doesn't appear as part of a call or member reference, offering fixits to either default-construct the type or get at the metatype explicitly using '.self'. Also diagnose an attempt to refer to 'T.type' by fixiting it to '.self'.
Swift SVN r14433
Factor an IdentityExpr base class out of ParenExpr, and migrate most of the logic to see through ParenExprs to see through IdentityExprs instead. Add DotSelfExpr as a new subclass of IdentityExpr, produced by parsing 'x.self'.
Swift SVN r14381
- Add a "isDirectPropertyAccess" bit to DeclRefExpr, serving the
same purpose as MemberRefExprs for non-member properties.
- Teach sema to synthesize correct non-member get/set implementations
for observing properties.
- Teach silgen to handle the isDirectPropertyAccess bit.
Swift SVN r13600
that have both storage AND accessors are accessed by-default through
their accessors. This bit indicates that a specific MRE should access
the storage instead.
Use this new bit in the synthesized getter/setter for "StorageObjC"
properties (it will also be used for other things in the future).
This also teaches SILGen about it.
One interesting aspect of this representation is that it makes it trivial
to add some expression syntax for directly accessing a store+computed
property (e.g. ObjC properties, also someday didSet/willSet properties)
someday if we care. This would be analogous to the "self->ivar" syntax
in objc (vs self.ivar). No, we will not use "->" for this. :-)
NFC since this is the use is still hidden under the -enable-new-objc-properties
staging option.
Swift SVN r12965
There was a test for this but it wasn't really accurate. We now look for
MemberRefExprs where the base is literally just an implicit DeclRefExpr,
rather than something loaded from an implicit DeclRefExpr. This could break
with future AST refinement, but that will at least fail the test now.
Swift SVN r12456
We still want to allow line wrapping, so only issue the warning when the indentation of the expression and the return keyword is the same.
radar://11945406
Swift SVN r9984
rdar://14151649 suggests that it should be a warning, but I don’t see a reason
why it should not be an error. We have no legacy code that relies on this.
Swift SVN r9976