Commit Graph

5277 Commits

Author SHA1 Message Date
Pavel Yaskevich
84cd99a3eb [Diagnostics] Enable extraneous/incorrect label diagnostics via solver fixes
This builds on initial commit which added `RelabelArguments` fix
to the solver that only supported `missingLabels` at that moment,
but now it supports all three posibilities - missing/extraneous and
incorrect labels.
2018-07-25 14:34:26 -07:00
Ben Cohen
345879429b [stdlib] Take several underscored stdlib functions private (#18134)
* Make _sanityCheck internal

* Make _debugPrecondition internal

* Make Optional._unsafelyUnwrappedUnchecked internal.

* Make _precondition internal

* Switch Foundation _sanityChecks to assertions

* Update file check tests

* Remove one more _debugPrecondition

* Update Optimization-with-check tests
2018-07-24 18:26:19 -07:00
swift-ci
23acb96cdc Merge pull request #18202 from DougGregor/no-subst-unresolved-type 2018-07-24 18:01:24 -07:00
Doug Gregor
5c008ab2ce [Type checker] Don't substitute into unresolved types.
Unresolved types are formed in a few specific places within the type
checker's recovery path; don't let them bleed into the substitution
logic. Fixes rdar://problem/42448618.
2018-07-24 16:56:43 -07:00
swift-ci
61c4e85f79 Merge pull request #18186 from gottesmm/pr-17a6d1e59533a646cfd8bb69ff9f7be24a5327dd 2018-07-24 14:05:59 -07:00
Michael Gottesman
be568902f2 [ownership] Always print out ownership argument annotations whether or not -enable-sil-ownership is passed in.
This is how we originally controlled whether or not we printed out ownership
annotations when we printed SIL. Since then, I have changed (a few months ago I
believe) the ownership model eliminator to know how to eliminate these
annotations from the SIL itself. So this hack can be removed.

As an additional benefit, this will let me rename -enable-sil-ownership to
-enable-sil-ownership-verifier. This will I hope eliminate confusion around this
option in the short term while I am preparing to work on semantic sil again.

rdar://42509812
2018-07-24 13:18:37 -07:00
Rintaro Ishizaki
21db9723e4 [Lexer] Don't include backtick length into comment length
Although backtick is a kind of trivia piece, Token::getCommentRange doesn't
take it into account. Invalid Token::getCommentRange used to cause
compiler crash.

rdar://problem/42492793
https://bugs.swift.org/browse/SR-8315
2018-07-24 04:37:07 +09:00
Rintaro Ishizaki
4a01a28282 [Lexer] Add crashing test case for SR-8315 2018-07-23 17:52:43 +09:00
Ben Cohen
34610780fd Break out conformances into extensions (#18098)
Replace LoggingRangeReplaceableCollection variants with typealiases

Replace LoggingMutableCollection variants with typealiases.

Collapse BufferAccessLoggingMutableCollection variants into typealiases

Turn LoggingRandomAccessCollection into a typealias

Turn LoggingBidirectionalCollection into a typealias
2018-07-20 12:50:12 -07:00
Mark Lacey
c0007f8168 Revert "[ConstraintSystem] Fix the ordering of functions with optional parame…" 2018-07-19 00:21:12 -07:00
Pavel Yaskevich
b156150cf2 Merge pull request #18058 from xedin/rdar-42304000
[TypeChecker] NFC: Make test-case for rdar://problem/33688063 more co…
2018-07-18 22:59:44 -07:00
Huon Wilson
7c088beadc Merge pull request #18057 from huonw/sr8240
[test] Stop a test relying on inconsistent formatting of an error message.
2018-07-19 13:24:20 +10:00
Pavel Yaskevich
e1ab6da7a9 [TypeChecker] NFC: Make test-case for rdar://problem/33688063 more complicated
SE-0213 improved cases like that but we still have problem with operator
overloads, so just need to make this a bit more complicated to reproduce again.

Resolves: rdar://problem/42304000
2018-07-18 17:02:20 -07:00
Huon Wilson
db04e817cc [test] Stop a test relying on inconsistent formatting of an error message.
Fixes rdar://problem/42351773.
2018-07-19 09:39:06 +10:00
Mark Lacey
eca92003bc Merge pull request #17855 from rudkx/rdar19748710
[ConstraintSystem] Fix the ordering of functions with optional parame…
2018-07-18 14:31:17 -07:00
Mark Lacey
d271f4b057 [ConstraintSystem] Ensure we prefer f(_: Any) to f(_: Any?) when both work.
...unless the argument is an `Any?`, in which case we prefer `f(_: Any?)`.

This change also results in our selecting f<T>(_: T) over f(_:
Any). Coercing with 'as Any' makes it possible to explicitly select
the Any overload. Previously there was no way to select the generic
overload.
2018-07-18 11:44:04 -07:00
Mark Lacey
5828a98874 Merge pull request #18032 from rudkx/restore-order
Return to the old disjunction ordering until some test regressions are addressed.
2018-07-17 20:19:35 -07:00
Ben Cohen
074dc43c3e Restore Sequence conformance to FlattenSequence.Iterator (#18024) 2018-07-17 20:00:30 -07:00
Huon Wilson
c12bb46145 Merge pull request #18004 from huonw/sr8240
[AST] Member lookup in the GSB needs to understand equivalence classes with concrete types.
2018-07-18 12:46:08 +10:00
Pavel Yaskevich
a9660c7bc5 Merge pull request #17860 from xedin/SE-0213
[TypeChecker] SE-0213: Implement literal init via coercion
2018-07-17 17:53:25 -07:00
Mark Lacey
7fd052efd8 Revert the effect of 6fa403dc7d.
For the moment, return to the old ordering for disjunctions as the new
ordering regressed some type checker performance tests.
2018-07-17 17:27:19 -07:00
Slava Pestov
42a3ad3bf0 AST: Fix over-eager collapseSpecializedConformance()
It's possible that the conforming type is equal to the generic
conformance type, but some of the substitutions replace an
abstract conformance with a concrete one.

In this case we cannot collapse away the specialized conformance,
because we lose information that way.

Fixes <rdar://problem/40164371>.
2018-07-17 14:41:49 -07:00
Ben Cohen
be894e4510 Replace Random.default with SystemRandomNumberGenerator (#17989) 2018-07-17 13:17:06 -07:00
Pavel Yaskevich
aa9b3d8474 [TypeChecker] SE-0213: Implement literal init via coercion
Implementation is as follows: In `preCheckExpression` try to
detect if there is `T(literal)` call in the AST, replace it with
implicit `literal as T`, while trying to form type-checked AST,
after constraint solving, restore source information and drop
unnecessary coercion expression.

Resolves: rdar://problem/17088188
Resolves: rdar://problem/39120081
Resolves: rdar://problem/23672697
Resolves: rdar://problem/40379985
2018-07-17 12:08:59 -07:00
Huon Wilson
ea1560f43b [AST] Member lookup in the GSB needs to understand equivalence classes with concrete types.
A constraint like `Parameter == SomethingConcrete` means references to
`Parameter` in that context behave like `SomethingConcrete`, including for name
resolution. Handling the parameter as just a parameter type means that it won't
find any non-protocol nested types (i.e. things other than associated types and
protocol typealiases are invisible).

Fixes rdar://problem/42136457 and SR-8240.
2018-07-17 22:54:22 +10:00
Mark Lacey
6fa403dc7d [ConstraintSystem] Change the order in which we attempt disjunctions
to be stable.

We currently will stop visiting the elements of a disjunction under
certain circumstances once we have found a solution. The result we get
is inherently dependent on the order in which we determine to visit
the disjunctions themselves (in addition to the elements of the
disjunction).

This change makes the order in which we visit disjunctions
stable. Future commits will create a stable ordering for the elements
of disjunctions. Once we also have that stable ordering in place we
can in theory short circuit more often as part of changing the way in
which we decide what the "best" solution is to a system.

This results in an expression in
validation-test/stdlib/AnyHashable.swift.gyb no longer being able to
typecheck in a reasonable amount of time, so I had to tweak that
expression.
2018-07-16 09:32:14 -07:00
Robert Widmann
c3867c8c48 Merge pull request #17964 from mdiep/enum-case-not-enum-element
Change "enum element" to "enum case" in diagnostics
2018-07-15 16:35:16 -07:00
Ben Cohen
bd7171bedf [stdlib] De-gyb Sort (#17954)
* [stdlib] De-gyb Sort
2018-07-15 14:23:06 -07:00
Matt Diephouse
35592747db Change "enum element" to "enum case" in diagnostics
From the perspective of the compiler implementation, they're elements. But users will think of these as cases—and many diagnostics already refer to these as enum cases.
2018-07-15 16:01:10 -04:00
Pavel Yaskevich
45634bd262 Merge pull request #17947 from xedin/rdar-42056741
[Diagnostics] Transfer previously resolved types directly from expressions
2018-07-14 12:14:42 -07:00
Pavel Yaskevich
939f6d402c [TypeChecker] NFC: Add test-case for rdar://problem/42056741 2018-07-13 23:47:09 -07:00
Pavel Yaskevich
d3249695a9 [Diagnostics] Transfer previously resolved types directly from expressions
While trying to diagnose the problem with previously type-checked
sub-expression, use its type-checked variant as a source of type
information, instead of transferring from its original constraint system,
because if expression was type-checked successfully it would
have all of the required information in AST, and that doesn't
rely on associated constraint system being present.

Resolves: rdar://problem/42056741
2018-07-13 16:38:48 -07:00
Michael Ilseman
c8ed8f9a2f [test] Update String tests for older iOS versions 2018-07-13 16:08:36 -07:00
Karoy Lorentey
d2861f779e [test] Re-add crash tests for getObjects:andKeys:count:
On some platforms, when a new process is started, ARC’s autoreleased return value optimization is expected to fail the first time it is used in each linked dylib. StdlibUnittest takes care of warming up ARC for the stdlib (libswiftCore.dylib), but for Dictionary.swift, we also need to do it for Foundation, or there will be spurious leaks reported for tests immediately following a crash test.

Add the necessary dummy operations to setUp, and re-add the crash tests that were removed in #17862. (As separate tests this time, so they don’t hide leaks in non-crashing test parts.)
2018-07-13 15:32:52 +01:00
Karoy Lorentey
520c645c51 Merge pull request #17905 from lorentey/crashes-scare-counters
[test] Fix leak and reenable getObjects:andKeys:count: tests
2018-07-12 22:58:01 +01:00
Karoy Lorentey
4832e0ed46 [test] Fix leak and reenable getObjects:andKeys:count: tests 2018-07-12 18:33:00 +01:00
swift-ci
90025ca491 Merge pull request #12415 from palimondo/empathy-test 2018-07-11 19:01:17 -07:00
Jordan Rose
b02d5543d4 Merge pull request #17843 from jrose-apple/batteries-included
[Driver] Always link compiler_rt on Darwin (when available)

rdar://problem/41911599
2018-07-11 17:35:06 -07:00
Jordan Rose
51f6e9a7c4 [test] Tidy up newly-added clang_rt Driver tests to be a bit clearer
Per feedback from David U.
2018-07-11 15:09:53 -07:00
swift-ci
1c34dbe027 Merge pull request #17872 from lorentey/crashes-scare-counters 2018-07-10 20:01:29 -07:00
Karoy Lorentey
d1fd33f9b0 [test] Disable getObjects:andKeys:count: tests.
Removing crash tests fixed optimized test runs, but exposed an issue in unoptimized i386 simulator tests.

Disable the two affected tests until we plug all their holes.
2018-07-11 01:42:30 +01:00
Slava Pestov
d4782b0fab Sema: Another validateDeclForNameLookup() state transition bug 2018-07-10 17:01:12 -07:00
Slava Pestov
8cd89bd709 Sema: Fix archetype vs interface type mixup with type in generic function 2018-07-10 17:01:12 -07:00
Slava Pestov
00b3ce18ca AST: Fix crash when doing name lookup into class with circular inheritance 2018-07-10 17:01:12 -07:00
Slava Pestov
559c0fd33d AST: Remove assertion in typo correction
CSDiag can try doing lookups on unbound generic types, so just remove this
assertion.
2018-07-10 17:01:12 -07:00
Slava Pestov
4878889c1e Sema: Better fix for <rdar://problem/36449760> 2018-07-10 17:01:12 -07:00
Slava Pestov
3ae11e6536 Sema: Fix a recusive validation crasher 2018-07-10 17:01:12 -07:00
Slava Pestov
ef864094b8 Sema: Fix crash when accessing nominal member of protocol 2018-07-10 17:01:12 -07:00
Slava Pestov
4fa4133134 Sema: Fix crash with UnresolvedType in coerceExistential()
Fixes <rdar://problem/34357545>.
2018-07-10 17:01:12 -07:00
Karoy Lorentey
5cbb3f74e2 Merge pull request #17862 from lorentey/crashes-scare-counters
[test] Fix test failures in optimized test runs
2018-07-11 00:36:18 +01:00