Commit Graph

5899 Commits

Author SHA1 Message Date
Pavel Yaskevich
b03b356bfa Merge pull request #28880 from xedin/port-multi-stmt-closure-diags
[Diagnostics] Diagnose inability to infer (complex) closure return type
2019-12-19 14:17:34 -08:00
Mike Ash
8e7c6a5c14 [Test] Disable reflect_Enum_(254|Two)CaseNoPayloads.swift when testing the OS stdlib.
rdar://problem/58087442
2019-12-19 15:41:29 -05:00
Pavel Yaskevich
8bcc192591 [Diagnostics] Diagnose inability to infer (complex) closure return type 2019-12-19 12:16:30 -08:00
David Ungar
69d1060df1 Merge pull request #28867 from davidungar/enable-disable-off-by-default
[Driver, Incremental] Add enable- and disable- only-one-dependency-file flags off-by-default
2019-12-19 00:52:33 -08:00
David Ungar
0291b36739 off-by-default & fix tests 2019-12-18 22:35:26 -08:00
David Ungar
2a79331ac3 add -enable/disable-only-one-dependency-file flag, on by default 2019-12-18 16:07:51 -08:00
tbkka
2b5ada11cb Correctly calculate extra inhabitants for no-payload enums (#28830)
In particular, this fixes the size calculation for nested enums,
specifically enums within Optionals.  Without this, the
reflection library computes `v` below as requiring two bytes
instead of one.

```
enum E {
case a
case b
}

let v = Optional<E>
```

This also adds a number of test cases for enums alone and
wrapped in optionals, including:
* Zero-case enums are allocated zero size and have zero extra inhabitants
* Zero-case enums in optionals also get zero size
* One-case no-payload enums are allocated zero size and have zero extra inhabitants
* One-case no-payload enums in optionals get one byte allocated and have zero extra inhabitants
* 254-case enums have only two extra inhabitants, so putting them in thrice-nested optionals requires an extra byte
* Various cases where each nested optional gets an extra byte

Resolves rdar://31154770
2019-12-17 14:52:35 -08:00
Suyash Srijan
f8dace593c [Typechecker] Fix a crash related to use of invalid @autoclosure parameter 2019-12-17 03:24:09 +00:00
Saleem Abdulrasool
3cefb7b3f7 validation-test: mark test as XFAIL
TBD generation is not constrained to Darwin and it trips on the linker
synthetic `__ImageBase`.  XFAIL this until the TBD generation is either
constrained or is taught to ignore the synthetic.  This should
temporarily allow us to enable validation tests on Windows.
2019-12-14 22:15:01 -08:00
Pavel Yaskevich
fa77285c62 Revert "[TypeChecker] NFC: Disable SwiftUI test-case due to possible infinite…" 2019-12-09 12:12:51 -08:00
Pavel Yaskevich
e0aa646310 [TypeChecker] NFC: Disable SwiftUI test-case due to possible infinite loop
Resolves: rdar://problem/57756956
2019-12-09 10:58:05 -08:00
Pavel Yaskevich
cafa338ae3 Merge pull request #28594 from xedin/rdar-50420029
[ConstraintSystem] Guard against infinite recursion in key path dynam…
2019-12-05 14:34:10 -08:00
Doug Gregor
f19ca59317 Merge pull request #28449 from DougGregor/sr11599-testcase
[Test] Add already-fixed test from SR-11599 / rdar://problem/56190608
2019-12-05 13:39:10 -08:00
Pavel Yaskevich
1d393ebdd4 [ConstraintSystem] Guard against infinite recursion in key path dynamic member lookup
It's possible to construct subscript member responsible for key path
dynamic member lookup in a way which is going to be self-recursive
and an attempt to lookup any non-existent member is going to trigger
infine recursion.

Let's guard against that by making sure that the base type of the
member lookup is different from root type of the key path.

Resolves: rdar://problem/50420029
Resolves: rdar://problem/57410798
2019-12-05 12:42:17 -08:00
Slava Pestov
8b112232f1 Add regression test for https://bugs.swift.org/browse/SR-4571 2019-12-05 08:45:55 -05:00
Slava Pestov
39f392c39d Add regression test for https://bugs.swift.org/browse/SR-4211 2019-12-05 08:45:55 -05:00
Pavel Yaskevich
94b4052321 [CSDiag] NFC: Remove all of the obsolete diagnoseGeneral*Failures logic 2019-12-03 12:07:16 -08:00
Pavel Yaskevich
34f5b52db1 [Diagnostics] Diagnose ambiguities related to contextual type mismatch
If none of the candidates produce expected contextual type, record
all of the posibilities to produce a note per and diagnose this as
contextual type mismatch instead of a reference ambiguity.
2019-12-03 12:07:15 -08:00
swift-ci
31370df8f8 Merge pull request #28364 from apple/all-your-nsbase 2019-12-03 10:20:01 -08:00
swift-ci
19395d6a4d Merge pull request #28446 from DougGregor/rdar57040259 2019-12-02 18:33:39 -08:00
Hamish Knight
19e199e567 Use DefaultArgumentExpr for caller-side defaults (#28279)
Use DefaultArgumentExpr for caller-side defaults
2019-12-02 13:57:17 -08:00
Doug Gregor
929edd3cb3 [Test] Add already-fixed test from SR-11599 / rdar://problem/56190608 2019-11-22 16:14:04 -08:00
Doug Gregor
c4ed40dc15 [Type checker] Fix crash with invalid overriding property.
When an overriding property containing willSet or didSet is not within
a type, the type checker could crash due to a missing "self"
declaration. Check this condition. Fixes rdar://problem/57040259.
2019-11-22 15:38:05 -08:00
David Ungar
62ae2bfd2f Merge pull request #28164 from davidungar/WIP-custom-diff
[Incremental compilation] Source-range-based dependencies
2019-11-21 23:47:52 -08:00
Pavel Yaskevich
f7ee402d2f Merge pull request #28400 from xedin/rdar-57201781
[ConstraintSystem] Introduce notion of constraint system phase
2019-11-21 13:17:34 -08:00
Pavel Yaskevich
addc2b06ab [ConstraintSystem] Introduce notion of constraint system phase
Some constraint transformations require knowledge about what state
constraint system is currently in e.g. `constraint generation`,
`solving` or `diagnostics` to make a decision whether simplication
is possible. Notable example is `keypath dynamic member lookup`
which requires a presence of `applicable fn` constraint to retrieve
some contextual information.

Currently presence or absence of solver state is used to determine
whether constraint system is in `constraint generation` or `solving`
phase, but it's incorrect in case of `diagnoseFailureForExpr` which
tries to simplify leftover "active" constraints before it can attempt
type-check based diagnostics.

To make this more robust let's introduce (maybe temporarily until
type-check based diagnostics are completely obsoleted) a proper
notion of "phase" to constraint system so it is always clear what
transitions are allowed and what state constraint system is
currently in.

Resolves: rdar://problem/57201781
2019-11-20 18:34:51 -08:00
Robert Widmann
c83c0f4cb7 Filter out invalid nested types from typealias override checking
The lookupDirect means that we can see type declarations nested inside of a protocol. If we do not filter these invalid declarations, we will offer a bogus fixit on top of a cycle diagnostic.  Remove these types from consideration entirely so we don't crash and don't offer bogus fixits.

Resolves rdar://57003317
2019-11-20 15:17:09 -08:00
Hamish Knight
c667d2b361 Use DefaultArgumentExpr for caller-side defaults
This commit changes how we represent caller-side
default arguments within the AST. Instead of
directly inserting them into the call-site, use
a DefaultArgumentExpr to refer to them indirectly.

The main goal of this change is to make it such
that the expression type-checker no longer cares
about the difference between caller-side and
callee-side default arguments. In particular, it
no longer cares about whether a caller-side
default argument is well-formed when type-checking
an apply. This is important because any
conversions introduced by the default argument
shouldn't affect the score of the resulting
solution.

Instead, caller-side defaults are now lazily
type-checked when we want to emit them in SILGen.
This is done through introducing a request, and
adjusting the logic in SILGen to be more lenient
with ErrorExprs. Caller-side defaults in primary
files are still also currently checked as a part
of the declaration by `checkDefaultArguments`.

Resolves SR-11085.
Resolves rdar://problem/56144412.
2019-11-20 15:07:32 -08:00
Karoy Lorentey
41cf1e77f6 [test] Adjust SwiftNativeNSBase conditions 2019-11-19 14:11:30 -08:00
Slava Pestov
fb581fdc8f Add a regression test for https://bugs.swift.org/browse/SR-10612 2019-11-18 18:26:03 -05:00
Mike Ash
8499a7f4fb Merge pull request #28183 from mikeash/zero-size-builtin-type-descriptors-remote-mirror
[Reflection] Ignore BuiltinTypeDescriptors with zero size, alignment, or stride.
2019-11-15 13:15:38 -08:00
Slava Pestov
0e06792642 Add regression test for SR-10201 2019-11-14 18:26:52 -05:00
Mike Ash
e7163006ee [Reflection] Accept BuiltinTypeDescriptors with zero size.
rdar://problem/56784375
2019-11-14 16:43:51 -05:00
Mike Ash
c81141af1d [Reflection] Add a test for reflecting empty structs.
rdar://problem/56784375
2019-11-14 16:22:32 -05:00
Slava Pestov
686ddd7cf7 Sema: Tighten up getReferencedAssociatedTypes()
If a protocol requirement has a type that's a nested member
type of another member type, eg,

protocol P {
  associatedtype A : Q
  func f(_: A.B)
}

Then we don't actually want to use 'f()' to infer the witness
for 'A'. By avoiding doing so, we eliminate some cycles which
can allow some programs to type check that didn't before.
2019-11-13 23:42:08 -05:00
Slava Pestov
e35a068265 Sema: Add test case for https://bugs.swift.org/browse/SR-11392 2019-11-13 23:42:08 -05:00
David Ungar
a3403f5f56 Fix tests. 2019-11-12 20:41:04 -08:00
Alexis Laferrière
a8afb84031 [test] Disable sometimes slow test rdar54580427.swift
rdar://problem/57138194
https://bugs.swift.org/browse/SR-11770
2019-11-12 17:43:09 -08:00
Alexis Laferrière
72350d8b25 Merge pull request #28195 from xymus/nah-way-too-slow
[test] Disable type_checker_perf test rdar33688063 as it still fails sometimes
2019-11-11 13:06:39 -08:00
swift-ci
5602b54c62 Merge pull request #28189 from CodaFi/unmaterialized-equality 2019-11-11 12:44:33 -08:00
Alexis Laferrière
7a3d2307f7 [test] type_checker_perf test rdar33688063 still fails, let's disable it 2019-11-11 12:06:00 -08:00
Robert Widmann
3f36ecf5ba Add a regression test for a GSB crasher
From rdar://56673657
2019-11-11 10:27:33 -08:00
Alexis Laferrière
40f556e0a5 type_checker_perf test rdar33688063 is often too slow for the fast dir
rdar://problem/57050532
2019-11-11 09:19:10 -08:00
Robert Widmann
5a1cae119e Merge pull request #28171 from CodaFi/one-one-ten-ded-consequences
Partially Revert #27862
2019-11-10 23:47:05 -08:00
Robert Widmann
dd1b15775d Partially Revert #27862
When SE-110 was being implemented, we accidentally began to accept
closure parameter declarations that had no associated parameter names,
e.g.

foo { ([Int]) in /**/ }

This syntax has never been sanctioned by any version of Swift and should
be banned.  However, the change was made long enough ago and there are
enough clients relying on this, that we cannot accept the source break
at the moment.  For now, add a bit to ParamDecl that marks a parameter
as destructured, and back out setting the invalid bit on the type repr
for these kinds of declarations.

To prevent further spread of this syntax, stub in a warning that offers
to insert an anonymous parameter.

Resolves part of rdar://56673657 and improves QoI for errors like
rdar://56911630
2019-11-10 22:10:53 -08:00
David Zarzycki
db78b3214b [Testing] Disable sema perf tests during ASAN testing
Also, add `-solver-expression-time-threshold=1` to a few tests.

This forces sr139, rdar25866240, and rdar23327871 to be moved from the
"fast" directory to the "slow" directory.
2019-11-09 15:31:20 +02:00
David Zarzycki
a3c19254c2 Merge pull request #28149 from davezarzycki/pr28149
[Tests] Remove `no_asserts` from sema perf tests
2019-11-09 08:41:04 +02:00
Suyash Srijan
7e1ed77a9e Merge pull request #28099 from theblixguy/fix/SR-10937
[PropertyWrappers] Fix a crash when using multiple wrappers of the same type
2019-11-08 10:52:15 +00:00
David Zarzycki
b1e253ee85 [Tests] Remove no_asserts from sema perf tests
This discourages regressions. Also add a timeout to a slow test.
2019-11-08 11:53:00 +02:00
David Zarzycki
b8122db49d Merge pull request #28078 from davezarzycki/pr28078
[Tests] Fix REQUIRES for two type checker perf tests
2019-11-08 10:49:55 +02:00