Commit Graph

1723 Commits

Author SHA1 Message Date
Joe Pamer
c81656e837 Fix type checking of self-recursive enum element members. We can now type check them without crashing, but we still can't IRGen. (Though, in that case we'll print a decent error message. Implementing IRGen for recursive enums is covered by rdar://problem/16178426)
Swift SVN r14473
2014-02-27 21:19:01 +00:00
Doug Gregor
96be672daf Allow initializer requirements on protocols and check conformance to them.
Swift SVN r14320
2014-02-24 23:17:09 +00:00
Doug Gregor
926e3711d0 Only permit inheritance of protocol conformance when it is semantically valid.
A protocol conformance of a class A to a protocol P can be inherited
by a subclass B of A unless
  - A requirement of P refers to Self (not an associated type thereof)
  in its signature, 
    + *except* when Self is the result type of the method in P and the
    corresponding witness for A's conformance to B is a DynamicSelf
    method.

Remove the uses of DynamicSelf from the literal protocols, going back
to Self. The fact that the conformances of NSDictionary, NSArray,
NSString, etc. to the corresponding literal protocols use witnesses
that return DynamicSelf makes NSMutableDictionary, NSMutableArray,
NSMutableString, and other subclasses still conform to the
protocol. We also correctly reject attempts to (for example) create an
NSDecimalNumber from a numeric literal, because NSNumber doesn't
provide a suitable factory method by which any subclass can be literal
convertible.



Swift SVN r14204
2014-02-21 07:48:28 +00:00
Dmitri Hrybenko
571c9b3c5e Split 'type' keyword into 'static' and 'class'
rdar://15911697


Swift SVN r13908
2014-02-14 14:50:32 +00:00
Chris Lattner
72073014da fix <rdar://problem/15626843> Stored global and static properties should require an initializer
Swift SVN r13360
2014-02-03 17:30:28 +00:00
Chris Lattner
e3fcd5399e rename this test to work around rdar://15969147.
Swift SVN r13358
2014-02-03 17:20:54 +00:00
Chris Lattner
b000ce2ec8 'data' got renamed to 'enum' a long long time ago, update test to match.
Swift SVN r13357
2014-02-03 16:51:49 +00:00
Doug Gregor
692d024c4a Protocol conformance checking for DynamicSelf protocols.
Swift SVN r13293
2014-02-01 05:57:53 +00:00
Dave Zarzycki
0e833a326e 15936764 swift.sin is ambiguous with Darwin.sin
Swift SVN r13180
2014-01-30 23:17:12 +00:00
John McCall
0202def792 Optional conversions on class types are trivial and
therefore permitted in overrides.

rdar://15189051

Swift SVN r12870
2014-01-23 19:39:14 +00:00
Doug Gregor
6f42f69876 Parse DynamicSelf as a type, restricted to contexts in which it is allowed.
Take DynamicSelf as a keyword, but parse it as a type-identifier.
Teach function declaration checking to sniff out and validate
DynamicSelf early, with appropriate QoI for references to DynamicSelf
that appear in other places.

As a temporary hack, DynamicSelf resolves to an alias for 'Self' in a
protocol or the enclosing nominal type.

Swift SVN r12708
2014-01-22 05:54:11 +00:00
Jordan Rose
41b56a5aba Disallow use of associated types on existentials.
protocol BaseProto {
    typealias AssocTy
  }
  var a: BaseProto.AssocTy // error!

While this could be interpreted to mean "a is an existential bounded by
whatever AssocTy is bounded by", we don't actually support this in any
other contexts; if a protocol has a function that returns an associated type,
it can only be used in a concrete or generic context, not an existential one.

<rdar://problem/15850024>

Swift SVN r12600
2014-01-20 18:45:49 +00:00
Doug Gregor
bc89a04d12 Disallow non-delegating initializers outside of the class's defining module.
An initializer outside of the class's defining module won't
necessarily have access to all of the stored properties of the class
to initialize them (and wouldn't be resilient against changes even if
it did), so it must delegate.

Swift SVN r12302
2014-01-15 00:11:38 +00:00
Doug Gregor
2bb0b57682 Add an error on "static" with a Fix-It to "type".
Swift SVN r12049
2014-01-08 05:29:04 +00:00
Doug Gregor
7cf688123b Allow "type var" and "type func" as synonyms for "static var" and "static func".
Swift SVN r12025
2014-01-08 00:59:22 +00:00
Doug Gregor
256b946a83 Record protocol conformance when we start checking, rather than at the end.
As part of this, take away the poor attempt at recovering by adding an
explicit protocol conformance. The recovery mode isn't all that useful
in a system with only explicit conformance, and it messes with
diagnostics further down the line. We can bring it back later once
we're happy with explicit conformance checking.


Swift SVN r11503
2013-12-20 15:46:31 +00:00
Doug Gregor
ec4913b0ea Implement default definitions for associated types.
Addresses <rdar://problem/14292873>.


Swift SVN r11422
2013-12-18 06:24:53 +00:00
Doug Gregor
a7a0a59c6e Fix matching of subscript witnesses to requirements.
Swift SVN r9963
2013-11-05 16:36:02 +00:00
Doug Gregor
964ed46f32 Add test missing from r9957.
Swift SVN r9960
2013-11-05 15:58:38 +00:00
Doug Gregor
faf1c45d14 Shuffle the files in the testsuite a bit to try to reflect language structure.
There's a lot more work to do here, but start to categorize tests
along the lines of what a specification might look like, with
directories (chapters) for basic concepts, declarations, expressions,
statements, etc.


Swift SVN r9958
2013-11-05 15:12:57 +00:00
Doug Gregor
6c80f64c6e Diagnostic circular class inheritance.
Break cycles agressively when we find circular class inheritance. The
stronger AST invariants prevent us from having to check for loops
everywhere in the front end.


Swift SVN r7325
2013-08-19 15:31:13 +00:00
Doug Gregor
81a5a41944 Move test for inheritance.
Swift SVN r6726
2013-07-29 23:50:18 +00:00
Doug Gregor
4aa4887343 Rework and centralize checking of inheritance clauses.
Detect duplicate and multiple inheritance, clean up diagnostics, and
unify the code that checks the types in the inheritance clause with
the code that sets the superclass and protocol lists.


Swift SVN r6706
2013-07-29 21:23:56 +00:00