Commit Graph

5277 Commits

Author SHA1 Message Date
Huon Wilson
10b30fef78 [GSB] Explicit error on unsupported conditional conformance recursion.
This doesn't fix the fundamental problem of correctly handling such cases, but
it is better than the "error message" that occurred previously:

    Assertion failed: ((bool)typeSig == (bool)extensionSig && "unexpected generic-ness mismatch on conformance").

Fixes the crash rdar://problem/41281406 (that in
https://bugs.swift.org/browse/SR-6569 (rdar://problem/36068136)),
https://bugs.swift.org/browse/SR-8019 (rdar://problem/41216423) and
https://bugs.swift.org/browse/SR-7989 (rdar://problem/41126254).
2018-06-21 10:53:30 +10:00
Mark Lacey
40b4eda258 Merge pull request #17352 from rudkx/reenable-perf-hack-attempt-2
[ConstraintSystem] Reinstate favoring more specialized of two generic…
2018-06-20 16:52:30 -07:00
Jordan Rose
8abaaea2c9 Keep more ParenType parameter flags when canonicalizing function types (#17369)
This will also preserve @escaping and @autoclosure, which were previously
dropped. This could lead to mismatches between expected and actual
canonical types for serialization cross-references.

https://bugs.swift.org/browse/SR-8045, likely others
2018-06-20 16:35:55 -07:00
Slava Pestov
33f1af8a72 Update Sanitizers/witness_table_lookup.swift test for Swift 4
I missed this with my previous patch.
2018-06-20 15:23:50 -07:00
Jordan Rose
6b894154d3 [Serialization] Track whether a cross-reference came from Clang (#17333)
Cross-references are identified by their containing module, with the
assumption that two modules will never have the same name. However, an
overlay has the same name as its underlying Clang module, which means
that there can be two declarations with the same name, the same type,
and the same module name. This is the underlying cause of the
'UIEdgeInsetsZero' problem, but it also affects the CloudKit overlay.

By tracking a bit that just says "this came from Clang", we're able
to resolve otherwise ambiguous cross-references.

(Why didn't we do it this way all along? Because if a declaration
moves from Clang to Swift or vice versa, that would break the
cross-reference. But that's only interesting if the swiftmodule format
is meant to be persistent across changing dependencies, and it looks
like we're moving away from that anyway. It's also a little weird for
SerializedModuleLoader to have special cases for Clang, but this isn't
the first.)

Note that I'm not reverting the UIEdgeInsetsZero workaround here; the
end state will have that coming just from UIKit as originally
described.

rdar://problem/40839486
2018-06-20 14:51:17 -07:00
Mark Lacey
1a2d7f5e99 [ConstraintSystem] Reinstate favoring more specialized of two generic overloads.
This was originally commited in
3d32e89e33, and then backed out in
c40fd3966c due to concern over
behavioral changes.

This version avoids the optimization when there are any optional types
involved in the signatures of the functions.

For these cases, compareDeclarations can return the wrong order at the
moment.

I have another PR in the works that attempts to begin unraveling some
of the issues around fixing the overload comparisons.
2018-06-19 23:42:51 -07: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
Slava Pestov
e6c4a3825e Update a few tests to pass with -swift-version 4 2018-06-19 23:23:20 -07:00
Joe Groff
3084458908 Merge pull request #17332 from jckarter/keypath-resilience-tests
Test cases for key path resilience.
2018-06-19 14:35:42 -07:00
Joe Groff
6154c0d2b9 Test cases for key path resilience. 2018-06-19 13:51:51 -07:00
Robert Widmann
0b33a69540 Merge pull request #17195 from brentdax/label-fable
Implicit tuple interpolations, take two
2018-06-18 15:54:30 -07:00
Jordan Rose
e5cec5fdd9 Merge pull request #17186 from jrose-apple/bridge-over-troubled-imports
[Serialization] Always list the bridging header before any imports

rdar://problem/40471329
2018-06-18 10:42:09 -07:00
Doug Gregor
9586cd7fa7 Merge pull request #17278 from DougGregor/inherited-protos-recurse
[AST] Block recursion through ProtocolDecl::getInheritedProtocols().
2018-06-16 07:49:26 -07:00
Doug Gregor
ac9b3cb936 Update a few recently-resolved crashers. 2018-06-16 08:41:00 -06:00
Pavel Yaskevich
969fb35f60 Merge pull request #17270 from xedin/rdar-41141944
[TypeChecker] When formatting witness type for diagnostics don't assu…
2018-06-16 01:21:35 -07:00
Pavel Yaskevich
235ed55004 [TypeChecker] When formatting witness type for diagnostics don't assume it's always valid
Sometimes witness candidates have error type e.g. when re-declaration checking
marks them as `invalid`, so formatting of the diagnostic
should account of potential witnesses not having a valid type.

Resolves: rdar://problem/41141944
2018-06-15 19:50:25 -07:00
Doug Gregor
ebd774bcd1 [Sema] Eliminate the last use of the IterativeTypeChecker.
Implement TypeChecker::resolveInheritedProtocols() in terms of
"getInheritedType()" queries, instead.

[Sema] Put back resolveInheritedProtocols().

We're still depending on it to update state in some cases.
2018-06-14 15:29:57 -07:00
Doug Gregor
2b2e143f59 [Request-Evaluator] Introduce a request for getting an "inherited type". 2018-06-14 15:29:57 -07:00
Doug Gregor
99e540f588 [Evaluator] Add an “enum raw type” request and use it consistently.
Similar to get “superclass of class” request, introduce an “enum raw type”
request that is accessed via EnumDecl::getRawType().
2018-06-14 15:29:57 -07:00
Doug Gregor
ef337bb8ba [Evaluator] Use the request-evaluator for the superclass of a class.
Wire up the request-evaluator with an instance in ASTContext, and
introduce two request kinds: one to retrieve the superclass of a class
declaration, and one to compute the type of an entry in the
inheritance clause.

Teach ClassDecl::getSuperclass() to go through the request-evaluator,
centralizing the logic to compute and extract the superclass
type.

Fixes the crasher from rdar://problem/26498438.
2018-06-14 15:28:36 -07:00
Brent Royal-Gordon
9ede961daa Correct run line on fixed crasher
Lesson learned: the script is not infallible.
2018-06-14 02:05:28 -07:00
Brent Royal-Gordon
27dfa51be5 Wrap interpolated tuples in parens
Keeps them from being interpreted as parameter lists. Fixes SR-7958.
2018-06-13 22:55:48 -07:00
Jordan Rose
6dcda937f0 [Serialization] Always list the bridging header before any imports
This mirrors how a bridging header is processed when compiling source
files: before any of the imports. This is important for LLDB to
recreate the source environment as closely as possible to how the
compiler does it; in the test case being added involving a non-modular
header file, failure to do so resulted in a deserialization
cross-reference crash.

Note that Serialization still sorts imports, which normal resolution
of imports in source does not do. So we're still not consistent. But
this is less important than handling textual includes (bridging
headers) before modular imports.

rdar://problem/40471329
2018-06-13 16:20:31 -07:00
Robert Widmann
dfe42d2e55 Revert "Reject bad string interpolations (#17074)"
This reverts commit fc23f3404d.
2018-06-13 15:06:33 -07:00
Brent Royal-Gordon
fc23f3404d Reject bad string interpolations (#17074)
* Reject bad string interpolations

String interpolations with multiple comma-separate expressions or argument labels were being incorrectly accepted.

* Tweak error name to match message

* Diagnose empty interpolations more clearly

* Don’t double-diagnose parse errors

Fixes a test at Parse/recovery.swift:799 which the previous commit broke.

* Fix incorrect test RUN: line

A previous version of this test used FileCheck instead of -verify, and the run line wasn’t properly corrected to use -verify.

* Update comment

* Add more argument label tests

Ensures that we don’t get different results from an initializer that doesn’t exist or doesn’t take a String.

* Resolve the SR-7958 crasher test

We now diagnose the error and remove the label before it has an opportunity to crash.
2018-06-12 18:46:52 -07:00
Jordan Rose
a6ae2d7742 Hack: Force UIEdgeInsets.zero to always come from the SDK (#17122)
...instead of relying on the one in the overlay in pre-4.2 versions of
Swift. This caused crashes in deserialization, which (deliberately)
doesn't respect availability.

There are three changes here:

- Remove UIEdgeInsets.zero and UIOffset.zero from the UIKit overlay.
- Always use the 4.2 name for UIEdgeInsetsZero and UIOffsetZero from
  the underlying UIKit framework. (This is the nested name.)
- Ignore the unavailability messages for those two constants in
  pre-4.2 Swift, since we're now relying on them being present.

The latter two, the compiler changes, can go away once UIKit's API
notes no longer specify different pre-4.2 behavior, but meanwhile we
need to keep compatibility with the SDKs released in Xcode 10b1.

https://bugs.swift.org/browse/SR-7879
2018-06-12 13:40:23 -07:00
Jordan Rose
7567a15921 [test] Add test for deserialization of generic protocol witnesses (#17141)
This failed in Swift 4.1 because of a problem with Substitutions,
but that whole model's been ripped out and redone in Swift 4.2.

https://bugs.swift.org/browse/SR-7978
2018-06-12 11:53:20 -07:00
Brent Royal-Gordon
16cc543eb3 Correct run line on unfixed crasher 2018-06-10 22:52:03 -07:00
Brent Royal-Gordon
2e8d0925fb Add reduced crasher for SR-7958
Trying to use an argument label in an interpolation can cause various crashes. In swiftlang-1000.0.16.7, these are usually in SILGen; in master at 8f6028d, they’re in CSApply.
2018-06-10 21:44:24 -07:00
Mark Lacey
7601d50ad4 Merge pull request #17042 from rudkx/sr7884
[ConstraintSystem] Remove an unsound optimization hack for generic fu…
2018-06-07 11:22:56 -07:00
Mark Lacey
c40fd3966c [ConstraintSystem] Remove an unsound optimization hack for generic functions.
I think there is something far more narrow we could do here, but I'm
not sure if there is real code that such a hack would benefit from. We
can leave that to consider another day.

Fixes rdar://problem/40819547 (aka https://bugs.swift.org/browse/SR-7884).
2018-06-06 23:59:08 -07:00
Huon Wilson
ec1ed4ca57 Merge pull request #16893 from huonw/errors-are-unresolved-equivalence-class
[GSB] Error types end up as unresolved equivalence classes.
2018-06-04 16:27:48 -07:00
Michael Gottesman
b77a47ed83 [bug_reducer] Update/fix for mangling/bitrot.
rdar://31044019
2018-06-03 18:50:35 -07:00
Huon Wilson
10c3e6cea9 [GSB] Error types end up as unresolved equivalence classes.
We need to make sure they don't end up as "concrete" equivalence
classes, because they behave more like unresolved ones.

Fixes rdar://problem/40009245.
2018-05-29 16:21:31 -07:00
Pavel Yaskevich
11ba7e0f42 [CSSimplify] When trying to simplify bind with error type fail gracefully
Since member lookup doesn't check requirements
it might sometimes return types which are not
visible in the current context e.g. typealias
defined in constrained extension, substitution
of which might produce error type for base, so
assignement should thead lightly and just fail
if it encounters such types.

Resolves: rdar://problem/39931339
Resolves: SR-5013
2018-05-28 00:24:54 -07:00
Mark Lacey
b92649a013 [ConstraintSystem] Attempt to select disjunctions that split constraint systems.
When selecting the next disjunction to attempt, try to find one that
is a disjunction of bindings where the type being bound is the
converted-to type in a conversion constraint. Attempting these early
makes it possible to split constraint systems, eliminating exponential
behavior.

Fixes: rdar://problem/40344044
2018-05-23 16:52:43 -07:00
Mark Lacey
35cd6023b4 Add a test case for which we currently end up with exponential type checking. 2018-05-22 23:41:31 -07:00
Arnold Schwaighofer
c7d4bd962d Add resilience tests 2018-05-22 08:59: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
swift-ci
64ef2f58d8 Merge pull request #16688 from aschwaighofer/codesign_microstdlib 2018-05-17 13:35:38 -07:00
Arnold Schwaighofer
8a36d2d8ce Codesign the executable in test MicroStdlib
rdar://40339165
2018-05-17 11:51:53 -07:00
Pavel Yaskevich
3daecc9c4f [TypeChecker] Add test-case for rdar://problem/40165062 2018-05-17 01:49:20 -07:00
Pavel Yaskevich
e6f3e7dc5a Merge pull request #16560 from xedin/rdar-29358447
[ConstraintGraph] Fix `contractEdges` to gather constraints only once
2018-05-14 11:41:54 -07:00
Michael Ilseman
4a368ab46c [string] Drop many @inlinable from big API.
Drop append-related @inlinable annotations for String, StringGuts,
StringStorage, and the Views. Drop several for larger operations, such
as case conversion. Drop as many as we can from StringGuts for now.
2018-05-13 07:38:55 -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
Pavel Yaskevich
3e254678a2 [Sema] Add counter to track number of constraints considered by each edge contraction attempt 2018-05-12 02:37:52 -07:00
Huon Wilson
6015709a92 Merge pull request #16523 from huonw/conditionalize-float80
[test] Float80 only exists on some platforms.
2018-05-11 13:14:49 +10:00
Huon Wilson
6de8b18689 [test] Float80 only exists on some platforms. 2018-05-11 12:23:21 +10:00
Huon Wilson
8178807ca0 [test] Non-determinism down to 0.999999 (1-in-a-million) rather than 0.999.
With the number of tests Swift does, this had a relatively high chance to fail
regularly somewhere.

Also, rejecting the lower tail means rejecting things that are perfectly
uniform, which I don't think should be the purpose of this test.
2018-05-11 09:56:12 +10:00
Andrew Trick
6a48b2d02d Merge pull request #16491 from atrick/enforce-keypath-exclusivity-as-error
Enforce keypath exclusivity as an error.
2018-05-10 16:03:01 -07:00