Commit Graph

2342 Commits

Author SHA1 Message Date
Morten Bek Ditlevsen
250090df2a Merge branch 'master' into jsoncodingkeys 2018-06-20 14:01:22 +02:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
swift-ci
eaa3d2c565 Merge pull request #16738 from ravikandhadai/FPTruncPR 2018-06-18 20:41:09 -07:00
Ravi Kandhadai
addae9bae4 [SIL Diagnostics] Add warnings for imprecision during assignment of
floating-point literals to variables of floating-point type.
2018-06-18 12:02:23 -07:00
Max Moiseev
d17d8d0bcc Only disable Network test on watchOS
Instead of wholesale disabling the test.
2018-06-14 11:03:55 -07:00
Erik Little
863f3a19ff Rename @effects to @_effects
@effects is too low a level, and not meant for general usage outside
the standard library. Therefore it deserves to be underscored like
other such attributes.
2018-06-06 12:53:03 -04:00
Mishal Shah
703f7653cb Disable Network test due to watchOS failure radar 40799651 2018-06-05 01:56:44 -07:00
Mishal Shah
3f8ce7d2f9 Update master to build with Xcode 10 beta 1, OS X 10.14, iOS 12, tvOS 12, and watchOS 5 SDKs. 2018-06-04 23:14:19 -07:00
Michael Ilseman
614016fecd [String.Index] Simplify and prepare for more resilience.
Simplify String.Index by sinking transcoded offsets into the .utf8
variant. This is in preparation for a more resilient index type
capable of supporting existential string indices.
2018-05-24 14:47:04 -07:00
Mike Ash
0dae9b3dc0 [Runtime] Have swift_dynamicCast unwrap multiple levels of optionals in the source.
The real work is done in checkDynamicCastFromOptional. This code tried to unwrap the source and returned the payload on success. It only did this once, so a type like Optional<Optional<Int>> would come out as Optional<Int> and then a cast to Int would fail.

This change makes checkDynamicCastFromOptional recursive, which makes it unwrap as many levels of Optional as it encounters.

Fixes rdar://problem/40171034 and SR-7664.
2018-05-22 15:05:09 -04:00
Mike Ash
5b991f30b8 [Runtime] Redo the ErrorObject/dlsym interface to use a struct containing all the bridging points. This allows for better static typing and reduces the amount of dynamic symbol lookups.
rdar://problem/39810532
2018-05-21 17:10:46 -04:00
Ben Langmuir
2e6c7ee76d Revert "[Runtime] Look up Error bridging symbols indirectly through special symbols that won't be stripped in static builds." 2018-05-19 10:05:00 -07:00
Michael Ilseman
1fe5fb717d [string] Skip allocation in reserveCapacity if smol
If the requested capacity is small enough to fit in our small string
representation, don't allocate a UTF-16 buffer, instead just return
early.
2018-05-18 21:26:59 -07:00
Joe Groff
f7fdc8ca31 Merge pull request #16714 from jckarter/decodeMangledType-node-checks
TypeDecoder: Be more forgiving of extra child nodes in demangled nominal types.
2018-05-18 13:52:47 -07:00
Joe Groff
80d9007f74 Add test for Mirror decoding a type parameterized on retroactive conformances. 2018-05-18 12:10:16 -07:00
Mike Ash
177f34cd0e Merge branch 'master' into fix-static-stripped-error-bridging 2018-05-17 14:13:00 -04:00
Mike Ash
3cc86eb836 [Runtime] Look up Error bridging symbols indirectly through special symbols that won't be stripped in static builds.
This fixes a problem where error bridging didn't work in stripped executables using the static versions of the Swift libraries. ErrorObject.mm looks up some symbols with dlsym, but stripping makes it so it can't find those. This change makes a separate set of symbols explicitly made for ErrorObject.mm to look up, and marks them as dynamically referenced so stripping won't remove them. Longer term, we'd like a better solution for looking up these symbols, but this will do for now.

rdar://problem/39810532
2018-05-17 11:43:15 -04:00
Michael Ilseman
7d64d49917 [tests] Add some quick new String index testing 2018-05-14 07:01:44 -07:00
Michael Ilseman
00e214ec50 [string] Clean up String.UTF8View
Extract slow paths into non-inlinable functions so that fast-paths can
be faster and we don't pay the large code bloat for the Unicode
parsers.

Some tests proactively extended to highlight UTF8View of multiple
kinds of Strings.
2018-05-14 07:01:38 -07:00
Michael Ilseman
459833725e [String] Streamline more String creation logic.
Streamline and de-genericize non-inlinable internal functions to
create a String from UTF-8 efficiently.
2018-05-13 07:38:55 -07:00
Jordan Rose
6bd7e5e5b4 Make sure protocol witness errors don't leave the conformance context
That is, if there's a problem with a witness, and the witness comes
from a different extension from the conformance (or the original type,
when the conformance is on an extension), put the main diagnostic on
the conformance, with a note on the witness. This involves some
shuffling and rephrasing of existing diagnostics too.

There's a few reasons for this change:

- More context. It may not be obvious why a declaration in file
  A.swift needs to be marked 'public' if you can't see the conformance
  in B.swift.

- Better locations for imported declarations. If you're checking a
  conformance in a source file but the witness came from an imported
  module, it's better to put the diagnostic on the part you have
  control over. (This is especially true in Xcode, which can't display
  diagnostics on imported declarations in the source editor.)

- Plays better with batch mode. Without this change, you can have
  diagnostics being reported in file A.swift that are tied to a
  conformance declared in file B.swift. Of course the contents of
  A.swift also affect the diagnostic, but compiling A.swift on its
  own wouldn't produce the diagnostic, and so putting it there is
  problematic.

The change does in some cases make for a worse user experience,
though; if you just want to apply the changes and move on, the main
diagnostic isn't in the "right place". It's the note that has the info
and possible fix-it. It's also a slightly more complicated
implementation.
2018-05-10 19:31:12 -07:00
swift-ci
0eb5131669 Merge pull request #15519 from jckarter/key-path-offset 2018-05-09 18:00:21 -07:00
Morten Bek Ditlevsen
904c0789c9 Added tests to ensure that coding key path are set correctly on encoding and decoding error contexts. 2018-05-08 09:16:10 +02:00
Stephen Canon
a5c91f65f1 Disable testing printing of subnormals on 32b ARM. (#16433)
On Darwin (and most other OSes), subnormal support is turned off for armv7, which causes these tests to fail. Longer-term, instead of gating this on architecture we may want to be able to query if subnormals are supported for a BinaryFloatingPoint type, and then we could key off of that instead.
2018-05-07 21:07:20 -04:00
Morten Bek Ditlevsen
b94c4c512b Merge branch 'master' of https://github.com/apple/swift 2018-05-05 10:23:28 +02:00
Michael Ilseman
5f1ba83e8d [String] Only bridge tagged NSStrings to small string form.
Non-tagged NSStrings carry identity separate from their
value. Continue to bridge them lazily, even if they could fit in small
form, to respect this and avoid potential information loss.

Temporarily disable invariant that all natives strings that could be
small, are.
2018-05-03 10:45:19 -07:00
Morten Bek Ditlevsen
8a3bc0b73b Make JSONEncoder and JSONDecoder circumvent keyEncodingStrategies and keyDecodingStrategies for String keyed Dictionaries. 2018-04-25 22:40:31 +02:00
Michael Ilseman
8ef98b8dd2 Merge pull request #16119 from milseman/unicode_mistake
[string] Comparison bug fix: Kelvin
2018-04-24 09:18:15 -07:00
Arnold Schwaighofer
0799683707 Merge pull request #16101 from apple/revert-16072-disable_failing_test
Revert "Disable test/stdlib/ErrorBridgedStatic.swift on no_asserts builds"
2018-04-24 06:43:43 -07:00
Michael Ilseman
ebbfd8c639 [string] Comparison bug fix: Kelvin
Unicode Kelvin sign normalizes to ASCII 'K', but our comparison logic
didn't handle this situation when the other side was single-byte all
ASCII. Fall back to the slow comparison path if the point of
difference between an all-ASCII string and a UTF-16 string falls on
such a non-ASCII-yet-normalizes-to-ASCII scalar (rare).
2018-04-23 17:45:04 -07:00
Doug Gregor
d755b38ee5 [Runtime] Teach BridgeObjectBox::retain() not to drop the "not native" bit.
The "not native" bit in a BridgeObject is important, because it tells
us when we need to go through the Objective-C -retain method
vs. swift_retain. Losing the bit means that swift_retain() will stomp
on some memory within an Objective-C object, thinking its the inline
reference count.

Co-debugged with Arnold, who then found where this bit was getting dropped.
Fixes rdar://problem/39629937.
2018-04-23 14:04:22 -07:00
Ben Cohen
23eab71023 Revert "Disable test/stdlib/ErrorBridgedStatic.swift on no_asserts builds" 2018-04-23 10:04:44 -07:00
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
Slava Pestov
c86d797c85 stdlib: Move Mirrors tests from Runtime.swift.gyb to Mirror.swift 2018-04-20 21:55:45 -07:00
Slava Pestov
902c0d3586 Runtime: Handle symbolic references inside other mangling nodes
Previously we could only handle symbolic references at the
top level, but this is insufficient; for example, you can
have a nested type X.Y where X is defined in the current
translation unit and Y is defined in an extension of X in
a different translation unit. In this case, X.Y mangles as
a tree where the child contains a symbolic reference to X.

Handle this by adding a new form of Demangle::mangleNode()
which takes a callback for resolving symbolic references.

Fixes <rdar://problem/39613190>.
2018-04-20 21:55:45 -07:00
Slava Pestov
b0454ca982 Merge pull request #16057 from slavapestov/codable-vtable-layout
Fix Codable vtable layout
2018-04-20 14:07:30 -07:00
Arnold Schwaighofer
e75f69ba46 Disable test/stdlib/ErrorBridgedStatic.swift on no_asserts builds
For some reason this test fails on the bots.
I could not reproduce the failure locally.
rdar://39473208
2018-04-20 13:04:26 -07:00
Slava Pestov
1602580303 SIL: Sort vtable entries for synthesized methods
Completes the fix for <rdar://problem/35647420> and
<https://bugs.swift.org/browse/SR-6468>.
2018-04-20 12:36:02 -07:00
Michael Ilseman
46b88ed906 Merge pull request #15928 from milseman/boilerplate_generated
[test] De-gyb stdlib unittest.
2018-04-19 16:25:00 -07:00
Michael Ilseman
c4614a9208 [test] De-gyb stdlib unittest.
StdlibUnittest uses gyb to avoid duplicating many source-context
arguments. However, this means that any test that wishes to add new
expect helpers has to also be gybbed. Given that this structure hasn't
changed in years, and we should have a real language support
eventually, de-gyb it.
2018-04-19 13:06:14 -07:00
Morten Bek Ditlevsen
a5a68ca25d Fix negation of 0 length Decimal (#15986)
A Decimal value with _length 0 and _isNegative set to 1 is interpreted as a NaN. The 'negate()' function however, flipped the _isNegative flag without regard for the _length 0 case. This meant that -0 would become NaN. The fix checks for the _length 0 special case. In NSDecimalSubtract() the same check was performed. Since this now happens in negate(), it is removed from the NSDecimalSubtract() function.
2018-04-18 10:18:34 -07:00
tbkka
72140eb6a5 Use run-time parsing to work around a compiler bug (#15923)
Due to SR-7124, some float literals are inconsistently handled
across architectures.  That's a problem for a test which is
trying to verify that certain exact floating-point values are
formatted in specific ways.

Fortunately, the run-time float parsing does not have this
problem, so I've changed this test to make sparing use of
run-time parsing (`Float("1.234")`) instead of compile-time
parsing (`1.234 as Float`).

This is admittedly slower, but the test isn't particularly
performance critical, and I don't want to use a hex literal
here since I feel that would make the test case harder to
understand.
2018-04-16 12:27:29 -07:00
tbkka
e0c091a012 Strictly test debug NaN printing only on x86_64 (#15910)
NaNs are mangled in various ways on various platforms.  Some
of the fun possibilities:
* sign bits can be cleared
* payloads get zeroed
* NaNs get forced to quiet
* Merely passing a value into a function can trigger these behaviors
* Trivial changes to the generated assembly can change this

This makes it very hard to validate the printing of NaN
details, since we can't be certain what value the formatter
actually saw.

So now I only do exact checks of the NaN formatter on x86_64,
which has pretty well-understood NaN support.  On all other
platforms, I just check that the debugDescription output
has the expected format:
```
   -?s?nan(\(0x[0-9a-f]+\))?
```
2018-04-13 09:34:14 -07:00
Max Moiseev
02aef12281 Merge pull request #15815 from Moximillian/SR-7266-avoid-nesting-reversed
SR-7266: Avoid nesting of ReversedCollection
2018-04-12 15:05:54 -07:00
tbkka
1cc1832b96 SR-3131: Adjust choice of decimal vs. exponential format (#15805)
Merge SR-3131 fix:

For each floating-point type, there is a range of integers which
can be exactly represented in that type.  Adjust the formatting
logic so that we use decimal format for integers within this
range, exponential format for numbers outside of this range.

For example, Double has a 53-bit significand so can exactly
represent every integer from `-(2^53)...(2^53)`.  With this
change, we now use decimal format for these integers and
exponential format for values outside of this range.  This is
a relatively small change from the previous logic -- we've
basically just moved the cutoff from 10^15 to 2^53 (about 10^17).

The decision for using exponential format for small numbers is
not changed.
2018-04-12 09:35:49 -07:00
tbkka
dad8b73334 Merge pull request #15852 from tbkka/tbkka-fix-float80-in-tests
Avoid Float80 test data on platforms that lack Float80
2018-04-11 17:26:34 -07:00
Joe Groff
4f26ef749c Merge pull request #15841 from jckarter/box-error-as-nserror
Runtime: Bridge Error-conforming types to id as NSError instances.
2018-04-10 18:19:50 -07:00
Joe Groff
6349dea762 Regression test for https://bugs.swift.org/browse/SR-7357 2018-04-10 14:22:04 -07:00
Joe Groff
78b5ff8b6b Runtime: Bridge Error-conforming types to id as NSError instances.
NSError is a more useful box for a swift Error than the generic box. Fixes rdar://problem/38631791 | SR-7232.
2018-04-10 12:23:49 -07:00
Tim Kientzle
339eddac98 Avoid Float80 test data on platforms that lack Float80
This was an oversight from PR #15474.  Most of the Float80
tests were correctly compiled only on `!Windows && (x86 || i386)`
but I failed to mark some Float80 test data.

Fixes: Radar 39246292
2018-04-10 12:07:38 -07:00