Commit Graph

7859 Commits

Author SHA1 Message Date
Slava Pestov
b03a77f13c Sema: Fix some compiler crashes related to ErrorType handling
- NominalTypeDecl::computeInterfaceType() crash when parent decl
  has error type
- createMaterializeForSetPrototype() crash when parent decl
  has error type
- Crashes in ConformanceChecker when decl has error type

Fixes <rdar://problem/21583601>.

Swift SVN r29912
2015-07-04 01:53:36 +00:00
Chris Lattner
59527f0a0b Fix for 21643437. Because of weirdness in this test (tracked by 19434979), the diagnostics on these lines are
different on iOS and the Mac, so just relax the checks back to the way they were.


Swift SVN r29899
2015-07-02 21:15:28 +00:00
Doug Gregor
880ad409db Pick the potential archetype we use for the actual archetype more intelligently.
Archetypes either need to be a root, which corresponds to a type
parameter, or need to be parented by another archetype. When the
representative of an equivalence class of potential archetypes has a
parent, but that parent has been made equivalent to some concrete type
via a same-type constraint, choose a different potential archetype as
the "anchor", i.e., one that has no concrete types in its parent
chain. Fixes rdar://problem/21625478 and the canonical example in
rdar://problem/17619740.

Swift SVN r29898
2015-07-02 20:57:37 +00:00
Dmitri Hrybenko
1edcc49ff9 stdlib: remove Slice.Element typealias
It is misleading in generic code.  A testcase that was failing:

  expectEqualType(C.Generator.Element.self, Slice<C>.Element.self)

Swift SVN r29887
2015-07-02 06:44:38 +00:00
Dmitri Hrybenko
d16c27886a stdlib tests: Doug fixed the blocking bugs, so we can simplify tests
Swift SVN r29886
2015-07-02 05:24:46 +00:00
Doug Gregor
9f66a12a9c Add test from rdar://problem/21333511 that no longer crashes.
Swift SVN r29883
2015-07-02 04:53:10 +00:00
Doug Gregor
2038a8e837 Handle nested types of concrete types in the constraint solver.
... I have no idea why we were foolishly mapping such things to their
parent type, which made no sense whatsoever. Fixes
rdar://problem/21621421.

Swift SVN r29882
2015-07-02 04:45:15 +00:00
Chris Lattner
24eee303dc update for diagnostic change. Remove -verify, validation tests should not be checking diagnostics.
Swift SVN r29880
2015-07-02 03:25:12 +00:00
Doug Gregor
4ce98a2b0d Fix RUN line; this isn't passing
Swift SVN r29871
2015-07-02 00:11:23 +00:00
Doug Gregor
9479679e4e Add test from rdar://problem/21621421.
Swift SVN r29870
2015-07-02 00:08:27 +00:00
Doug Gregor
87b4eeccf3 Make same-type requirements prefer to be rooted at outer generic parameters.
All archetypes from outer scopes are fixed (as a lame implementation
restriction), so same-type constraints that involve archetypes from
outer scopres should treat the archetypes from outer scopes as the
representative. Do so, and start eliminating the notion of a "primary"
archetype that was preventing this fix from occurring earlier, so that
"all archetypes" and the set of requirements generated from the
archetype builder still line up.

Fixes rdar://problem/19519590.

Swift SVN r29869
2015-07-02 00:08:24 +00:00
Andrew Trick
59b6dff24e Temporarily disableFixedPointDiagnostics test on iOS.
<rdar://problem/21643437> FixedPointDiagnostics regression on iOS

Swift SVN r29865
2015-07-01 23:52:30 +00:00
David Farler
438119d558 Fold ExtensibleCollectionType into RangeRaplaceableCollectionType
ExtensibleCollectionType's operations can all be represented by the
primitive range replacement operation, so fold it into
RangeReplaceableCollectionType.

In addition, provide default implementations of
RangeReplaceableCollectionType's methods.

- New tests added for combinations of (static, generic) calls and
  (default, custom) implementations.
- Mark free Swift functions as unavailable with a message to direct the
  developer to the protocol methods.
- Mark ExtensibleCollectionType as available with a message added to
  direct the developer to the right protocol.

rdar://problem/18220295

Swift SVN r29857
2015-07-01 22:33:04 +00:00
Dmitri Hrybenko
fc0fa96371 stdlib: de-underscore Indexable and add tests for it
Swift SVN r29847
2015-07-01 18:31:31 +00:00
Dmitri Hrybenko
76f5706b50 stdlib: de-underscore the Slice type and add tests for it
Swift SVN r29846
2015-07-01 18:31:29 +00:00
Dmitri Hrybenko
80b1380fe8 stdlib: fold Sliceable into CollectionType and de-underscore SubSequence
Swift SVN r29845
2015-07-01 18:31:25 +00:00
Chris Lattner
762cb3fa62 start loosening up getTypeOfIndependentSubExpression() to walk into more kinds of
expressions.  Broadening from callexpr to apply expr (picking up operators) improves
several diagnostics in the testsuite, and is important to avoid regressions from an 
upcoming patch.


Swift SVN r29821
2015-06-30 23:25:47 +00:00
Chris Lattner
77fce6b76c update notes to go with r29810
Swift SVN r29820
2015-06-30 23:20:24 +00:00
Doug Gregor
a8b7ff86cd Add test case for rdar://problem/21598514.
Swift SVN r29811
2015-06-30 21:51:09 +00:00
Doug Gregor
8f31e03ebd Completely check the requirements of a protocol as part of validation.
We were doing piecemeal checking of the requirements of specific
associated type bindings, but such checking is incomplete: superclass
constraints and, although currently inexpressible, same-type
constraints are not validated by these early checks, so this is more
correct and more robust.

Swift SVN r29808
2015-06-30 21:11:20 +00:00
Doug Gregor
7ee8b36993 Be more defensive when looking up associated types.
The attempted invariants were too strong for ill-formed code. Fixes
rdar://problem/21511651.

Swift SVN r29801
2015-06-30 05:14:04 +00:00
Doug Gregor
8a26662368 Use the generic signature to check specialized uses of generic types.
Previously, we were simply walking over the requirements of each of
the associated types, which meant that we weren't considering
same-type constraints. Also cleans up the diagnostics a little bit and
eliminates some extra computation whose results were getting thrown
away.

Swift SVN r29793
2015-06-29 22:06:19 +00:00
Dave Abrahams
4b4510e79a [stdlib] Simplifying filter tests (WIP)
Swift SVN r29790
2015-06-29 20:45:51 +00:00
Dave Abrahams
8c855e1ecf [stdlibunittest] automatic LifetimeTracked checking/setup
In setup and teardown, we can initialize and check for leaks

Swift SVN r29789
2015-06-29 20:45:50 +00:00
Dave Abrahams
7aed41190f [stdlibunittest] Automatically reset common test environment
Swift SVN r29787
2015-06-29 20:45:48 +00:00
Dave Abrahams
a35204ca55 [stdlibunittest] logging sequence/generator wrappers
Swift SVN r29786
2015-06-29 20:45:46 +00:00
Dave Abrahams
dcd46ea6df [stdlib] A system for concise testing of customization points.
This approach should help us massively reduce the amount of code it
takes to verify that the architecture of our protocols works as
expected.  Pair-programmed with Dmitri Hrybenko.

Swift SVN r29752
2015-06-27 02:31:26 +00:00
Doug Gregor
025c35d541 Don't invalide Substitution invariants in ill-formed code.
Fixes the crasher in rdar://problem/21524144.

Swift SVN r29741
2015-06-26 17:12:07 +00:00
Slava Pestov
913a03cb0c Update test for r29737
Swift SVN r29739
2015-06-26 08:10:30 +00:00
Dave Abrahams
1c5f805074 [stdlib] Protocol Extension-ize CollectionType
Eliminates _CollectionDefaultsType and _CollectionGeneratorDefaultsType
and creates sanity that should allow us to Protocol Extension-ize the
lazy operations, which have been blocked on inscrutable errors due in
part to the existing complexity.

Note: names beginning with "_prext_" are intended to be public after API
review and removal of the "_prext_" prefix.

Swift SVN r29689
2015-06-25 21:34:28 +00:00
Dave Abrahams
4056d22a07 Squash warnings in tests
Swift SVN r29688
2015-06-25 21:34:26 +00:00
Doug Gregor
22c2585ac9 Add now-fixed test case from rdar://problem/21087186.
Swift SVN r29670
2015-06-25 16:39:06 +00:00
Slava Pestov
d919b45937 SILGen: DiverseStack defines stable iterators; let's use them
DeferCleanup pushes a new temporary cleanup to catch non-local returns
from the defer block, so we have to use stable iterators while emitting
cleanups.

There's no good deterministic test case for this -- it would manifest
as memory corruption if the underlying storage of the DiverseStack
grew beyond the inline storage. Add a reduced version of the original
user-reported test case that triggers it reliably -- I had a hard time
coming up with anything simpler.

Fixes <rdar://problem/21437203>.

Swift SVN r29658
2015-06-25 05:00:50 +00:00
Slava Pestov
7b2aa2c0a2 SILGen: Fix lvalue reabstraction
We didn't have any tests exercising SubstToOrigComponent and in
fact it was broken. Fix emitInOut() to remove a level of inout
from the origParam abstraction pattern and add some tests.

Fixes <rdar://problem/20985062>.

Swift SVN r29644
2015-06-24 22:27:54 +00:00
Dmitri Hrybenko
ba208cd672 stdlib: rename zip generator and collection to a common naming convention
// Renamed from `ZipGenerator2`.
  struct Zip2Generator<Generator1 : GeneratorType, Generator2 : GeneratorType> { ... }

  // Renamed from `Zip2`.
  struct Zip2Sequence<Sequence1 : SequenceType, Sequence2 : SequenceType> { ... }

Part of rdar://21429126

Swift SVN r29636
2015-06-24 20:42:03 +00:00
Dmitri Hrybenko
60ba7be3d1 stdlib: rename the generic parameter from T to Element on GeneratorSequence
Part of rdar://21429126

Swift SVN r29635
2015-06-24 20:42:02 +00:00
Dmitri Hrybenko
71022a46c1 stdlib: rename mapping sequence and collection wrappers to a common naming convention
struct ReverseIndex<Base : BidirectionalIndexType> { ... }
  struct ReverseRandomAccessIndex<Base : RandomAccessIndexType> { ... }

  // Renamed from `BidirectionalReverseView`.
  struct ReverseCollection<Base : CollectionType where T.Index : BidirectionalIndexType> { ... }

  // Renamed from `RandomAccessReverseView`.
  struct ReverseRandomAccessCollection<Base : CollectionType where T.Index : RandomAccessIndexType> { ... }

Also fixed a bug (found by the new tests I added in this commit) in
LazyRandomAccessCollection.reverse(), which mistakenly returned a bidirectional
reversed collection.

Part of rdar://21429126

Swift SVN r29634
2015-06-24 20:42:01 +00:00
Dmitri Hrybenko
fdd73a57b4 stdlib: add tests for generic parameter names on EnumerateGenerator,
EnumerateSequence

Part of rdar://21429126

Swift SVN r29629
2015-06-24 20:41:58 +00:00
Dmitri Hrybenko
d9726efbb2 stdlib: rename Set's generic parameter from T to Element
Same for SetGenerator and SetIndex.

Part of rdar://21429126

Swift SVN r29619
2015-06-24 20:41:51 +00:00
Dmitri Hrybenko
51e236c609 stdlib: rename Array's generic parameter from T to Element
Same for ArraySlice and ContiguousArray.

Part of rdar://21429126

Swift SVN r29618
2015-06-24 20:41:49 +00:00
Doug Gregor
54979b70a7 Remove uses of complete-unnamed function parameters from the testsuite.
Support for "func f(Int)" is going away.

Swift SVN r29608
2015-06-24 16:01:37 +00:00
Slava Pestov
665b870f7f Sema: Fix yet another crash when accessing nested types of an existential
We diagnose usage of invalid existential types but we might still
try to compute substitutions. Just whip up an ErrorType instead.

Fixes <rdar://problem/16803384>.

Swift SVN r29567
2015-06-23 06:39:22 +00:00
Chris Lattner
9d5a5a90a0 XFAIL this on linux to bring the bot back.
Swift SVN r29540
2015-06-21 13:53:27 +00:00
Chris Lattner
9a65afff8d Two changes:
- In name lookup, if we find a decl that is already being type checked 
   (which only occurs on illegal code) just assume it is acceptable instead
   of blowing up with an assertion checking access control that hasn't been
   evaluated yet.
 - In checkInheritanceClause, make sure that the we mark the decl being
   resolved as being type checked when resolving the types involved.  That way,
   cyclic references are detected as invalid, instead of causing assertions and
   other explosions.

This fixes some compiler crashers.



Swift SVN r29538
2015-06-20 23:50:31 +00:00
Dave Abrahams
7d0f0dc461 [stdlib] internal Box<T> should be final
Swift SVN r29533
2015-06-20 02:50:07 +00:00
Chris Lattner
0e20f24b95 fix <rdar://problem/18734297> Reject access to local variables from local types
init()'s implicitly evaluate the initial values for properties, and we aren't modeling
that correctly in the AST.  This prevented the closure checker from noticing these 
accesses, leading to SILGen crashing later.  In the absence of proper AST modeling of
this, add special case handling for them.



Swift SVN r29508
2015-06-19 06:15:19 +00:00
Chris Willmore
0e05470e5f Take care to preserve parentheses when opening generic types. Consider
lvalues when compiling list of partial-match overloads in diagnosis.
(This is a reapplication of commits r29462 and r29469.)

Also, fix the following tests:

    stdlib/FixedPointDiagnostics.swift.gyb
    stdlib/NumericDiagnostics.swift.gyb

<rdar://problem/17875634> can't append to array of tuples

Swift SVN r29493
2015-06-18 18:58:49 +00:00
Dave Abrahams
f7e0f31627 [stdlib] WIP Refactoring tests
Swift SVN r29479
2015-06-18 05:05:09 +00:00
Dave Abrahams
e8dbf7b38c [stdlib] Squash a warning in a test
Swift SVN r29477
2015-06-18 05:05:07 +00:00
Slava Pestov
9deaf6c851 Sema: Fixes for partial application of protocol methods
Previously the placement of the OpenExistentialExpr was determined
entirely from the natural argument count of the function.

There was a hack to add any missing OpenExistentialExprs at the top
level, but this didn't work if the method had a Self return value
and there were intermediate expressions, eg, if someMethod has a
Self return, foo(anExistential.someMethod) would generate a
diagnostic about open existentials.

Change ExprRewriter to use a new existential placement algorithm
that instead walks up the expression stack to determine the outermost
function application of an existential base, and insert the
OpenExistentialExpr there.

Progress on <rdar://problem/21289579>.

Swift SVN r29448
2015-06-17 07:42:47 +00:00