Commit Graph

7628 Commits

Author SHA1 Message Date
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
Slava Pestov
6a9790ed30 Sema: Fix compiler_crasher with FixKind::ForceOptional
We were using getRValueType() and getRValueObjectType() when
setting up the constraint, but getRValueType() when simplifying
it. This led to a crash if the type was a single-argument tuple
with a named argument.

Swift SVN r29376
2015-06-15 02:00:46 +00:00
Joe Groff
d7b9ae72aa Sema: Require '.init' when constructing from a dynamic metatype.
This makes it clearer that expressions like "foo.myType.init()" are creating new objects, instead of invoking a weird-looking method. The last part of rdar://problem/21375845.

Swift SVN r29375
2015-06-14 19:50:06 +00:00
Arnold Schwaighofer
f003bc754d validation-test: Make this test pass in optimized mode
Some test cases where assuming to be compiled in Debug assert configuration.

The test relies on return autorelease optimization to happen. This does not
happen reliable in optimize mode.

I ran the test case under the leaks runner and no leaks are reported yet the
object count is positive. This can happen if some objects are still in a
autorelease pool at the time we count them. Which seems to happen.

I surrounded the code with "autoreleasepool {}" and it would pass which confirms
this assumption. I have looked at both the generated LLVM IR and the otool -tvV
asssembly output and did not see anything that would block the return
autorelease optimization (i.e instructions between the returnautorelease
function call and the retain_returnautorelease call) so I don't believe there is
something the compiler could do better.

rdar://21193916

Swift SVN r29369
2015-06-12 18:41:50 +00:00
Slava Pestov
9e1f0c3855 Sema: Fix a compiler_crash when the generic signature is invalid
We might still try to call getDeclaredType(), which would
unexpectedly return nullptr.

Swift SVN r29358
2015-06-10 01:18:21 +00:00
Dmitri Hrybenko
d464a638f2 Annotate 0803-void.swift as passing on Linux
Swift SVN r29350
2015-06-08 08:59:57 +00:00
Slava Pestov
6550c7a858 Sema: Fix subtyping between metatypes and existential metatypes
X.Protocol is an instance of Y.Type only if X conforms to Y. Since X
is a protocol, this is only true if X contains Y and Y is
self-conforming.

Note that this updates some tests that actually contained invalid code.

Fixes <rdar://problem/20915927>.

Swift SVN r29349
2015-06-08 07:59:16 +00:00
Joe Groff
d9fbef1f2f Resolve fixed crashers.
Swift SVN r29348
2015-06-08 05:47:19 +00:00
Joe Groff
58af18748c Expect 'unused initialization' warnings in FixedPointDiagnostics.swift.gyb
Swift SVN r29347
2015-06-08 05:43:22 +00:00
Slava Pestov
fee95a3c06 AST: Fix a compiler_crash
Swift SVN r29341
2015-06-08 04:00:22 +00:00
Slava Pestov
322f58d8b1 Sema: Tighten up existential vs generic type parameter distinction
Rename existentialConformsToSelf() to existentialTypeSupported(). This
predicate is the "protocol has no Self or associated type requirements"
check, which is a looser condition than self-conformance. This was being
tested to see if the user could refer to the protocol via an existential
type.

The new existentialConformsToSelf() now checks for protocol being @objc,
and for the absence of static methods. This is used as part of the
argument type matching logic in matchType() to determine if the
existential can be bound to a generic type parameter.

The latter condition is stricter, for two reasons:

1) We allow binding existentials to multiple type parameters all sharing
   the same generic type parameter T, so we don't want the user to be
   able to see any static methods on T.
2) There is an IRGen limitation whereby only existentials without witness
   tables can be passed in this manner.

Using the above, the representsNonTrivialGenericParameter() function
has been renamed to canBindGenericParamToExistential(). It now allows
an existential type to be bound to a generic type parameter only under
the following circumstances:

A) If the generic type parameter has no conformances, the match is allowed.

B) If the generic type parameter has at least one conformance, then all
   of the conformances on the generic type parameter must be
   existentialConformsToSelf() (condition 1 above), and all conformances
   on the existential must be @objc (condition 2 above).

Fixes <rdar://problem/18378390> and <rdar://problem/18683843>, and lays
the groundwork for fixing a few other related issues.

Swift SVN r29337
2015-06-07 10:16:21 +00:00
Dmitri Hrybenko
41934b5433 stdlib: Add some basic array bridging tests
Swift SVN r29307
2015-06-04 20:13:11 +00:00
Dmitri Hrybenko
572b08bd43 Dictionary test: use more precise autorelease pool placement
Swift SVN r29296
2015-06-04 09:06:17 +00:00
Dmitri Hrybenko
8387fc45b5 StdlibUnittest: add a facility to activate autorelease pools only on platforms that don't implement the return-autoreleased optimization
Swift SVN r29295
2015-06-04 09:06:16 +00:00
Arnold Schwaighofer
edf20fb43a Change test to not depend on being compiled with -Onone
Swift SVN r29288
2015-06-04 01:55:49 +00:00
Arnold Schwaighofer
e0d434ff8e This fails in optimized mode
rdar://212311525

Swift SVN r29283
2015-06-03 23:28:54 +00:00
Arnold Schwaighofer
b9b00326f6 This fails in optimized mode
rdar://21231163

Swift SVN r29282
2015-06-03 23:28:54 +00:00
Arnold Schwaighofer
2c617bf75b This test case assumes to be compiled without optimizations
Swift SVN r29281
2015-06-03 23:28:53 +00:00
Arnold Schwaighofer
ee0a1d1a58 More executable tests in validation-test
Swift SVN r29279
2015-06-03 23:28:45 +00:00
Arnold Schwaighofer
4d4329b0e0 Add executable_test to the validation test suite
Swift SVN r29278
2015-06-03 23:28:43 +00:00
Dmitri Hrybenko
cca4f4e3ff Revert "stdlib: Add some basic array bridging tests"
This reverts commit 29268.  The tests don't pass on the 32-bit
simulator.

Swift SVN r29273
2015-06-03 05:07:42 +00:00
Dmitri Hrybenko
6b9e73aa09 stdlib: Add some basic array bridging tests
Swift SVN r29268
2015-06-03 03:10:06 +00:00
Dmitri Hrybenko
04549ce1d5 Dictionary test: add more assertions
Swift SVN r29267
2015-06-03 03:10:05 +00:00
Slava Pestov
0c88c13c0d IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag
The last remaining case was apparently @objc generic classes, which
seem to work now.

Also nuke the IRGen/unimplemented_objc_generic_class.swift test,
this is now implemented and we have other tests that test this
functionality.

Swift SVN r29260
2015-06-03 00:01:29 +00:00
Dmitri Hrybenko
dc29fca37f Update the Dictionary test for a performance improvement in Foundation
Swift SVN r29254
2015-06-02 20:59:15 +00:00
Dmitri Hrybenko
854a197845 Update to the new GameplayKit API
Swift SVN r29253
2015-06-02 20:59:14 +00:00
Arnold Schwaighofer
6c936235d4 This test no longer fails
rdar://21204610

Swift SVN r29250
2015-06-02 20:58:14 +00:00
Arnold Schwaighofer
45686daeb4 This test case fails with an optimized stdlib on armv7
rdar://21204610

Swift SVN r29246
2015-06-02 18:52:35 +00:00
Jordan Rose
2cd2d9ceb2 [test] Remove XFAIL lines from still-crashing compiler_crashers.
This is handled by the directory's lit.local.cfg.

Swift SVN r29238
2015-06-02 17:45:20 +00:00
Arnold Schwaighofer
9ac6b9bd83 This is an executable test
Swift SVN r29235
2015-06-02 16:16:07 +00:00
Greg Parker
d97b76e0a1 [test] Un-XFAIL a test that no longer fails on asan.
Swift SVN r29231
2015-06-02 09:40:14 +00:00
Chris Lattner
b6a15d6828 My error recovery fix improved types, likely because something wasn't handling a tok::invalid correctly.
Swift SVN r29225
2015-06-02 05:02:53 +00:00