Commit Graph

25 Commits

Author SHA1 Message Date
Chris Lattner
35bce55e62 When diagnosing some problems with associated types, mark the decl invalid. When forming a type reference to an invalid type decl, have validateType return ErrorType instead of an apparently valid type. This silences some bogus downstream errors in code that references the decl.
This exposes some wierdness with while_parsing_as_left_angle_bracket where
one case the note is being is when resolveType returns a failure.  However,
resolveType can produce a failure without emitting a diagnostic, and this
can lead to us generating a note unattached to an error.  Just remove this
case.
2016-02-02 14:01:43 -08:00
Doug Gregor
b34ace0942 Fix test harder :( 2016-02-02 10:38:01 -08:00
Doug Gregor
07a23d2394 Update test; this is a slight diagnostic regression due to 4b07e1b0fb. 2016-02-02 09:59:48 -08:00
Doug Gregor
6b0febf401 Merge pull request #1009 from gregomni/sr-547
[SR-547][Sema] Invalidate more parts of protocols involved in recursive definitions
2016-02-02 09:13:04 -08:00
gregomni
da93f6cc6d Stop emitting most duplicated only-as-generic-constraint errors.
Set type repr's as invalid after diagnosing an unsupported protocol
to stop duplicate diagnoses.

There were two causes here. First, top-level variable
declarations were being checked once by the Decl checker, and then
again by the Stmt checker. (This caused SR-38.)

Second, the Stmt checker is called by an AST visitor itself, which
already calls it once per statement. Using the
UnsupportedProtocolVisitor here meant that each interior sub statement
would get visited multiple times. Added a setRecurseIntoSubstatements()
on the visitor, and set it to false for the Stmt checker. This keeps
from revisiting statements multiple times.
2016-01-27 20:34:29 -08:00
gregomni
4b07e1b0fb [SR-547] Invalidate more parts of protocols involved in recursive definitions
The idea here is to do more marking of the generic parts of the
protocol as being invalid as soon as the recursiveness is diagnosed in
order to simplify checking (and avoid infinite loops) down the line.
2016-01-18 14:17:07 -08:00
Doug Gregor
38c1de69e4 Reinstate "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit ce7b2bcf09, tweaking
a few validation tests appropriately (1 crasher fixed, two -verify
tests that needed updating).
2016-01-14 00:21:48 -08:00
Erik Eckstein
ce7b2bcf09 Revert "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit 2b2e9dc80e.

It broke some compiler crasher tests
2016-01-13 20:42:58 -08:00
gregomni
2b2e9dc80e [SR-511][Parse] Add 'associatedtype' keyword and fixit
Adds an associatedtype keyword to the parser tokens, and accepts either
typealias or associatedtype to create an AssociatedTypeDecl, warning
that the former is deprecated. The ASTPrinter now emits associatedtype
for AssociatedTypeDecls.

Separated AssociatedType from TypeAlias as two different kinds of
CodeCompletionDeclKinds. This part probably doesn’t turn out to be
absolutely necessary currently, but it is nice cleanup from formerly
specifically glomming the two together.

And then many, many changes to tests. The actual new tests for the fixits
is at the end of Generics/associated_types.swift.
2016-01-13 17:54:31 -08:00
Doug Gregor
7a3f05a07a Reduce dependency on IdentTypeRepr::getBoundType().
Having bound types in TypeReprs causes trouble in several places
(mostly involving type-checking of generics), and doesn't really fit
with TypeReprs being a mostly syntactic construct. Eliminate some code
paths using getBoundType(), and make the others do the same thing for
getBoundDecl() and getBoundType(). As part of the latter, provide
TypeBase::getDirectlyReferencedTypeDecl() to more easily map from type
to the named declaration.

Swift SVN r32018
2015-09-16 23:25:19 +00:00
Slava Pestov
3bead78373 ArchetypeBuilder: Fix infinite recursion with recursive requirements
We have to check for cycles of length > 1 here. Also, add a bit to the
AssociatedTypeDecl to ensure the recursive requirement diagnostic is
only emitted once.

Fixes <rdar://problem/17986597>.

Swift SVN r30678
2015-07-27 00:40:47 +00:00
Chris Lattner
649e5f937d generalize the existing ? and + constraints on expected diagnostics to
a simpler and more general * constraint.  This paves the way for other improvements.



Swift SVN r30622
2015-07-25 05:23:30 +00:00
Doug Gregor
7c757528b8 Don't emit recursive-associated-type diagnostics from outside the protocol.
Reduces the number of duplicate diagnostics down to 2. Which is still
lame, but it's due to a different underlying issue. Finishes
rdar://problem/20682090.

Swift SVN r30043
2015-07-09 22:18:04 +00:00
Doug Gregor
bf143bf978 Detect recursive associated type requirements more robustly.
Replace some dodgy recursion-breaking code in the archetype builder
that was meant to deal with recursive associated type requirements
(which our model does not currently support) with a more robust
approach. Fixes rdar://problem/20682090 and rdar://problem/21738889.

Swift SVN r30039
2015-07-09 20:55:47 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Chris Lattner
7059871abf Convert some 'var' bindings to 'let' when they are not mutated, some
var/let bindings to _ when they are never used, and use some values that
are only written.  This is a testsuite cleanup, NFC. More to come.


Swift SVN r28406
2015-05-11 00:20:55 +00:00
Doug Gregor
7677a454ea Move "non-self-conforming protocol type" check out of type validation.
Having semantic checking in type validation introduces the potential for more recursion, triggering crashes. By moving this semantic restriction out to a later stage, we make it more robust. Fixes 6 compiler crashers, although it regressed one compiler crasher that hits a different known issue (assertions in addGenericParameters when we have multiple parameters at the same depth).

Swift SVN r26226
2015-03-17 16:34:28 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Joe Pamer
dd141c7cad Account for recursive validation when checking if an existential conforms to itself. (rdar://problem/18042380)
This can only occur when validating mutually recursive existentials in type reference expressions, so it's "safe" to avoid validating member value decls in this case. There are still potential holes in our mechanism for checking for unsupported existentials, but at least this will eliminate another common crasher. (Crash suite scenario 010.)

Swift SVN r22035
2014-09-17 20:23:41 +00:00
Jordan Rose
11befa8b3f [Sema] While checking if a protocol can be used as an existential, assume yes.
Breaks circular checking if two existential protocols reference each other.

rdar://problem/18061131

Swift SVN r21550
2014-08-28 23:30:53 +00:00
Dmitri Hrybenko
6a5f59831b Code completion: include access control keywords in override completion
When trying to implement deduplication of results, found and fixed an issue
with loose checks for generic overload checking.

rdar://17995317


Swift SVN r21276
2014-08-19 11:00:10 +00:00
Doug Gregor
9210cd5ff4 Replace T[] array syntax with [T] in the test suite
Swift SVN r19192
2014-06-25 23:39:24 +00:00
Joe Pamer
cc6e3e8d03 Fix some issues with type checking indirectly recursive protocol requirements
These changes prevent a certain class of bogus errors, as well as several crashers. Unfortunately, though, they don't quite get us to the point where we can broadly use recursively defined protocol requirements, in the standard library.  (To do so would require significant changes across the entire stack.)

Swift SVN r19019
2014-06-20 00:06:14 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Joe Pamer
484459b474 For 1.0, we're restricting the use of directly recursive protocol requirements. (They currently cause an infinite loop in the type checker.) We can look into opening this up post-1.0.
Swift SVN r14651
2014-03-04 21:02:26 +00:00