Commit Graph

2520 Commits

Author SHA1 Message Date
Dmitri Hrybenko
6d4f8adbf5 stdlib/String: fix a race in _StringBuffer.grow()
rdar://17855614


Swift SVN r20960
2014-08-02 22:50:45 +00:00
Dmitri Hrybenko
2688dd426f stdlib/Print test: simplify code
Swift SVN r20954
2014-08-02 17:11:50 +00:00
Dave Abrahams
f270a5b6f3 [stdlib] _StringCore : RangeReplaceable
Swift SVN r20947
2014-08-02 05:44:40 +00:00
Dave Abrahams
69482f3fdb [stdlib] make test workaround not platform-sensitive
Swift SVN r20937
2014-08-02 01:11:58 +00:00
Dave Abrahams
23ee8d34be [stdlib] Make Array RangeReplaceable test generic
...and uncover memory leaks in the process: <rdar://problem/17892507>

Swift SVN r20936
2014-08-02 01:08:57 +00:00
Doug Gregor
c593d49b08 Rework the _ObjectiveCBridgeable to use inout parameters rather than returns.
The _forceBridgeFromObjectiveC and _conditionallyBridgeFromObjectiveC
requirements of the _ObjectiveCBridgeable protocol previously returned
Self and Self?, respectively, where 'Self' is the value type that is
bridged. This use of returns is fairly hostile to the idea of calling
the witnesses for these requirements from the C++ part of the runtime,
leading to "interesting" tricks with OpaqueExistentialContainer that
made it hard to use these witnesses within the dynamic casting
infrastructure.

Replace the returns with inout Self? parameters, which are far easier
to deal with in the C++ part of the runtime. Despite the churn because
we're changing the _ObjectiveCBridgeable protocol, this is NFC.

Swift SVN r20934
2014-08-02 01:03:41 +00:00
Joe Pamer
0896a12197 Further improve type checker diagnostics through a variety of means.
Start capitalizing on some of the new diagnostic machinery in a few different ways:
- When mining constraints for type information, utilize constraints "favored" by the overload resolution process.
- When printing type variables, if the variable was created by opening a literal expression, utilize the literal
  default type or conformance if possible.
- Utilize syntactic information when crafting diagnostics:
	- If the constraint miner can produce a better diagnostic than the recorded failure, diagnose via constraints.
	- Factor in the expression kind when choosing which types to include in a diagnostic message.
- Start customizing diagnostics based on the amount of type data available.

What does all this mean?
- Fewer type variables leaking into diagnostic messages.
- Far better diagnostics for overload resolution failures. Specifically, we now print proper argument type data
  for failed function calls.
- No more "'Foo' is not convertible to 'Foo'" error messages
- A greater emphasis on type data means less dependence on the ordering of failed constraints. This means fewer
  inscrutable diagnostics complaining about 'UInt8' when all the constituent expressions are of type Float.

So we still have a ways to go, but these changes should greatly improve the number of head-scratchers served up
by the type checker.

These changes address the following radars:
rdar://problem/17618403
rdar://problem/17559042
rdar://problem/17007456
rdar://problem/17559042
rdar://problem/17590992
rdar://problem/17646988
rdar://problem/16979859
rdar://problem/16922560
rdar://problem/17144902
rdar://problem/16616948
rdar://problem/16756363
rdar://problem/16338509

Swift SVN r20927
2014-08-01 23:32:19 +00:00
Dave Abrahams
94623d6d3c [stdlib] ...and remove the stray printlns, too
Swift SVN r20926
2014-08-01 23:04:00 +00:00
Dave Abrahams
921045c7f8 [stdlib] Enable commented test part
As I was reducing a test case for a typechecker bug, I ended up
commenting out important test code in the regression suite.  This
restores it (and makes it work).

Swift SVN r20925
2014-08-01 23:01:02 +00:00
Dmitri Hrybenko
22044b09f3 stdlib/Assert test: don't run tests where we execute 'unreachable' LLVM
IR instruction; we are not guaranteed to crash, instead the code can
enter an infinite loop which will cause the test to time out

Swift SVN r20924
2014-08-01 22:51:26 +00:00
Dave Abrahams
1f8ec23ebe [stdlib] Correct/test _StringCore.reserveCapacity
The old one could never have worked.

Swift SVN r20916
2014-08-01 21:35:15 +00:00
Dave Abrahams
00dd90d9df [stdlib] Robustify _StringCore extensibility test
Swift SVN r20898
2014-08-01 17:27:28 +00:00
Dmitri Hrybenko
142a32a944 stdlib/Assert: allow string interpolation in assertion messages
rdar://17248446


Swift SVN r20892
2014-08-01 13:44:38 +00:00
Dmitri Hrybenko
a79339ee8f stdlib/Assert: adopt new names for trapping functions:
assert() / assertionFailure() -- debug mode
precondition() / preconditionFailure() -- debug and release modes
fatalError() -- always traps


Swift SVN r20890
2014-08-01 10:22:23 +00:00
Dave Abrahams
8419d20f1c [stdlib] ImplicitlyUnwrappedOptional is not Boolean
Swift SVN r20839
2014-07-31 18:40:29 +00:00
Dmitri Hrybenko
c7a5b1daca stdlib/runtime: fix leaks in swift_bridgeNonVerbatimToObjectiveC
Swift SVN r20827
2014-07-31 15:49:17 +00:00
Dave Abrahams
ea21309150 [stdlib] _StringCore: ExtensibleCollectionType
Swift SVN r20825
2014-07-31 14:57:42 +00:00
Dmitri Hrybenko
8150b9296b stdlib: fix leaks of Swift.String when passing them from runtime to
Swift (in mirrors and demangling)

Swift SVN r20823
2014-07-31 14:48:54 +00:00
Dmitri Hrybenko
30749d9f69 stdlib/Reflection: really fix a leak when reflecting a class (turned out to be
in swift_ObjCMirror_count)

rdar://17840810


Swift SVN r20821
2014-07-31 13:11:55 +00:00
Dmitri Hrybenko
9c8d30ea11 stdlib/Reflection: fix over-release that I introduced in r20671 trying to fix a
leak.  The release was valid only for some code paths.

Added some comments explaining ownership and parameter passing conventions.

Fixes rdar://17855302, restores half of the leak in rdar://17840810 (only for
objects that inherit from NSObject).


Swift SVN r20820
2014-07-31 11:49:43 +00:00
Dmitri Hrybenko
ec4f8d37f7 stdlib: fix a heap overflow that colud happen when appending to a string
slice

rdar://17855908

Swift SVN r20762
2014-07-30 18:04:36 +00:00
Dmitri Hrybenko
391fb8802e TrapTestPrototype: pass environment to the child process to allow the
test to pass on 32-bit iOS simulator

Swift SVN r20760
2014-07-30 15:17:52 +00:00
Greg Parker
fe8618a3d2 Scrap the custom allocator until we have time to fix it.
The allocator's crimes include:
* It uses OS SPI that must not be used by non-OS apps.
* It does not play well with memory debugging tools like Instruments.
* It does not return memory to the OS in response to memory pressure.
* It is less tested than we would like because many configurations 
  inadvertently turn it off (such as running from Xcode).
* Its per-thread magazine implementation does not actually work.
* Its "try alloc" flag is incompletely implemented and never used.
* Its "zero fill" flag is unimplemented and inconsistently used.



Swift SVN r20757
2014-07-30 14:11:40 +00:00
Greg Parker
3add65de36 [test] Fix un-terminated cstring in test stdlib/NSStringAPI.swift.
Swift SVN r20756
2014-07-30 14:11:24 +00:00
Greg Parker
4a33110d9c [test] Disable tuple printing test pending rdar://17855302.
Swift SVN r20754
2014-07-30 12:39:04 +00:00
Dmitri Hrybenko
ac0d9b8175 stdlib/CGFloat: GYB'ify initializers that convert between CGFloat and
integer types.  Never miss an integer type again.

rdar://17853313

Swift SVN r20751
2014-07-30 11:24:11 +00:00
Dave Abrahams
6a80cbbaa2 [stdlib] Capitalize the cases of Bit
Fixes <rdar://problem/17821517>

Swift SVN r20718
2014-07-29 23:25:28 +00:00
Dave Abrahams
7c7fb3eea0 Restore "[Release note] deferred array cast checks"
I had just gone too far with the laziness; everything was already
working after only one change

Swift SVN r20717
2014-07-29 23:25:27 +00:00
Dave Abrahams
0b562db701 Revert "[Release note] deferred array cast checks"
This reverts commit r20700 and r20702

I'll bring these back when I work out the problems.

Swift SVN r20708
2014-07-29 22:52:28 +00:00
Dmitri Hrybenko
8db3907d54 NSStringAPI test: allow to pass under iOS simulator
Swift SVN r20704
2014-07-29 22:07:51 +00:00
Dave Abrahams
d9dc321ccd [stdlib] Tests shouldn't use internal entry points
There's no reason not to test the actual casting syntax here.

Swift SVN r20703
2014-07-29 22:01:46 +00:00
Dave Abrahams
18b81228d5 [stdlib] Defer array bridge cast checks
Part 2 (of 2) of <rdar://problem/17340393>

Swift SVN r20700
2014-07-29 21:41:11 +00:00
Dave Abrahams
5847a0f7c3 [stdlib] defer Array element down-cast checks
Part 1 of <rdar://problem/17340393>

Swift SVN r20699
2014-07-29 21:41:10 +00:00
Dmitri Hrybenko
fca8237688 TrapTestPrototype: relax CHECK line to allow this test to pass on iOS
Swift SVN r20688
2014-07-29 20:37:32 +00:00
Dave Abrahams
c91e0f98a0 [stdlib] bugfix: Copy bridged NSMutableArray's
When NSArrays are bridged into Array<T>, they weren't being .copy()'d.
As a result, changes to an NSMutableArray (cast to NSArray), could cause
"unrelated" Swift Arrays to mutate.  Found by inspection while
bottlenecking unsafeBitCast's in Array implementation, which also
happens in this commit.

Swift SVN r20678
2014-07-29 17:59:41 +00:00
Dmitri Hrybenko
3e32ff188f stdlib/String: change String.stringByAbbreviatingWithTildeInPath into a
property, to match recent Foundation headers


Swift SVN r20674
2014-07-29 16:08:39 +00:00
Dmitri Hrybenko
98188d1da9 NSString APIs on String: add more tests
Swift SVN r20673
2014-07-29 16:06:36 +00:00
Dmitri Hrybenko
a0c8140529 Reflection: fix a leak in TupleMirror
rdar://17840810


Swift SVN r20671
2014-07-29 15:08:48 +00:00
Dmitri Hrybenko
bdc78be4e5 Reflection: reorder dump() arguments so that one can print to a stream and take
advantage of default values

Also, fix dump() to actually print everything into the supplied stream.


Swift SVN r20670
2014-07-29 15:07:25 +00:00
Dmitri Hrybenko
35344b72c2 TrapTestPrototype: relax assertion for iOS
Swift SVN r20669
2014-07-29 13:57:41 +00:00
Dmitri Hrybenko
8c277e35e9 StdlibUnittest: add a prototype of a Swift-based driver for trapping tests
This technique is about 10x faster than using lit as the driver.


Swift SVN r20668
2014-07-29 10:26:32 +00:00
Dave Abrahams
9a13a7148b [stdlib] Consolidate bridging protocols
Squash _[Conditionally]BridgedToObjectiveC into one protocol.  This
change results in simpler bridging code with fewer dynamic protocol
conformance checks, and solves the nasty naming/semantics problem that
resulted from having _ConditionallyBridgedToObjectiveC refining
_BridgedToObjectiveC.

Also, rename things so they're more symmetrical and less confusing.

Swift SVN r20664
2014-07-29 01:30:27 +00:00
Dave Abrahams
5496c4beac [stdlib] Default == for Strideables
...which we can provide now that <rdar://problem/17620349> is fixed.
Thanks, JoeP!

Swift SVN r20645
2014-07-28 21:14:53 +00:00
Dave Abrahams
f467efe289 [stdlib] Un-break a test
This got missed in the big de-Bool-ification of Optionals

Swift SVN r20643
2014-07-28 20:34:09 +00:00
Joe Pamer
f55c751958 Add a fixit for optional-typed expressions used in conditional expression positions.
Swift SVN r20639
2014-07-28 19:20:42 +00:00
Joe Pamer
94dac129d4 Remove the BooleanType conformance from optional types (rdar://problem/17110911)
To limit user confusion when using conditional expressions of type Bool?, we've decided to remove the BooleanType (aka "LogicValue") conformance from optional types. (If users would like to use an expression of type Bool? as a conditional, they'll need to check against nil.)

Note: This change effectively regresses the "case is" pattern over types, since it currently demands a BooleanType conformance. I've filed rdar://problem/17791533 to track reinstating it if necessary.

Swift SVN r20637
2014-07-28 19:20:39 +00:00
Doug Gregor
9f93d94dc6 Eliminate the ~> hack in the type checker I introduced in r20626.
We don't need to permit non-final classes and ForwardIndexTypes
<rdar://problem/17828741>.

Swift SVN r20633
2014-07-28 18:26:29 +00:00
Doug Gregor
3cb58e833a Restrict non-final class protocol conformance when Self is part of the requirement signature.
When a non-final class satisfies a method requirement that returns
Self, it must do so with a method that also returns (dynamic)
Self. This ensures conformance will be inheritable, closing off an
awful type-safety hole <rdar://problem/16880016>. Other
non-contravariant uses of Self in the signatures of requirements cause
the protocol to be unusable by non-final classes.

I had to leave a tiny little gaping hole for the ~> operator, whose
removal is covered by <rdar://problem/17828741>. We can possibly put
this on firm footing with clever handling of generic witnesses, but
it's not important right now.



Swift SVN r20626
2014-07-28 16:15:16 +00:00
Dmitri Hrybenko
f75968d9cd stdlib: add a trap() function that traps in debug and release modes
rdar://17792445


Swift SVN r20620
2014-07-28 11:30:42 +00:00
Dmitri Hrybenko
ca07053adc stdlib: rename fatalError() to debugTrap()
Part of rdar://17792445


Swift SVN r20619
2014-07-28 11:14:52 +00:00