Commit Graph

547 Commits

Author SHA1 Message Date
Luciano Almeida
27b01e3eb0 [test] Adding validation test for generic function match 2020-01-09 14:10:37 -03:00
Pavel Yaskevich
8bcc192591 [Diagnostics] Diagnose inability to infer (complex) closure return type 2019-12-19 12:16:30 -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
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
Pavel Yaskevich
94b4052321 [CSDiag] NFC: Remove all of the obsolete diagnoseGeneral*Failures logic 2019-12-03 12:07:16 -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
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
7a3d2307f7 [test] type_checker_perf test rdar33688063 still fails, let's disable it 2019-11-11 12:06:00 -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
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
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
Alexis Laferrière
fd191bff43 Fix test rdar56710317.swift for the iOS simulator
Fix rdar://problem/56999504
2019-11-07 15:19:46 -08:00
Doug Gregor
f4c45e8057 [Type check diagnostics] Add already-fixed test case from rdar://problem/56710317.
Ensures that we don't regress diagnostics for this case in the future.
2019-11-07 09:41:36 -08:00
David Zarzycki
cc8acdce93 [Tests] Fix REQUIRES for two tests
The non-gyb type checker performance tests tend to require non-assert
and release builds. This makes two tests consistent with the others.

This also fixes sr139.swift, which was needlessly running the type checker twice.
2019-11-05 11:15:25 +02:00
Robert Widmann
e95cc4981b Revert "Remove Some Users of -solver-enable-operator-designated-types"
This reverts commit 46ae4757d2.
2019-10-29 10:33:16 -07:00
Robert Widmann
46ae4757d2 Remove Some Users of -solver-enable-operator-designated-types
There are now two regression tests that need this feature enabled to
pass.
2019-10-24 16:50:45 -07:00
Pavel Yaskevich
10b1baebb2 Merge pull request #27362 from xedin/port-missing-args
[Diagnostics] Port missing argument(s) diagnostics
2019-09-25 21:08:54 -07:00
Pavel Yaskevich
ec6a874ac8 [TypeChecker] NFC: Update test-cases improved by new missing arguments diagnostic 2019-09-25 10:47:26 -07:00
Slava Pestov
0ade7b70d9 AST: Type::subst() preserves TypeAliasType sugar
Fixes <rdar://problem/45313760>.
2019-09-24 17:42:15 -04:00
Holly Borla
29044e5d34 Merge pull request #27176 from hborla/type-cannot-conform-diag
[Diagnostics] Generalize the "protocol type cannot conform" error to work for all types that cannot conform to protocols.
2019-09-18 10:38:00 -07:00
Jordan Rose
1eaa767407 [test] Run scale-tests on Linux too (#27223)
It's likely that these were listed as "REQUIRES: OS=macosx" to not
redundantly run them for iOS et al, but they don't take that long and
so it's more useful for Linux devs to be able to run them locally if
need be. Or to catch something that really is different on non-macOS.
2019-09-18 08:27:37 -07:00
Holly Borla
bf80250c84 Merge remote-tracking branch 'upstream/master' into type-cannot-conform-diag 2019-09-17 11:54:03 -07:00
Holly Borla
2a7e0099d2 [Diagnostics] Add notes for the type_cannot_conform error that point
to the declaration that requires protocol conformance.
2019-09-17 09:22:07 -07:00
Holly Borla
173e4526ee [Diagnostics] Adjust wording of type_cannot_conform error message. 2019-09-16 14:55:38 -07:00
Pavel Yaskevich
a1643d94f7 [Diagnostics] NFC: Update all of the improved test-cases 2019-09-13 22:35:52 -07:00
Holly Borla
40985b6eb7 [Diagnostics] Generalize the "protocol type cannot conform" error to
work for all types that cannot conform to protocols.
2019-09-13 14:51:17 -07:00
Holly Borla
0434d58ff0 Merge pull request #27123 from hborla/missing-conformance-diag
[ConstraintSystem] Allow fixing missing conformance failures for `Void` and uninhabited types.
2019-09-12 17:41:19 -07:00
Holly Borla
b2ec5b97b9 [Test] Update type_checker_crashers_fixed/rdar50869732.swift with missing
conformance diagnostics.
2019-09-12 15:41:11 -07:00
Varun Gandhi
51db51e796 Add reduced test case for rdar://problem/54926602. 2019-09-06 15:32:44 -07:00
Varun Gandhi
e4f0f78020 Add minimal test case for rdar://problem/54580427.
The scale test says the behavior is exponential, but it should be
linear, given that (1) we provide a contextual type outside and
(2) there is precisely 1 type which has the corresponding cases.
2019-08-29 15:24:08 -07:00
Doug Gregor
17691241e0 [Testing] Reinstate use of operator designated types in one test case.
It's an assertions-only test, which I failed to check locally.
2019-08-09 11:05:06 -07:00
Doug Gregor
566f156a27 Drop explicit use of -solver-enable-operator-designated-types in tests.
All of these tests are still "fast" even without operator designated
types. Test them in the normal type checker configuration.
2019-08-07 14:37:30 -07:00
Pavel Yaskevich
1b4f9c33eb [Diagnostic] In no exact match cases diagnose labeling mismatch as a note
Each candidate with incorrect labels (but everything else lined up)
gets a note on its declarationm which says what is expected and what
has been given.
2019-07-25 14:49:52 -07:00
Pavel Yaskevich
44f82f256f [TypeChecker] Adjust some of tests improved/regressed after removal of UR_LabelMismatch 2019-07-25 00:36:00 -07:00
Pavel Yaskevich
caf266f4b1 [CSDiagnostics] Use special error message when call didn't match exactly
For multiple solutions with fixes for the same call, replace
`ambiguous reference` diagnostic with the one that explicitly
mentions that there are no exact matches, and provide partially
matched candidates as notes.
2019-07-22 11:20:56 -07:00
Pavel Yaskevich
cd07652f22 [ConstraintSystem] Don't attempt dynamic member lookup on invalid base
If `subscript(dynamicMember:)` is unviable because it's either
an instance method referenced on type or static method
referenced on an instance of type, attempting dynamic
member lookup would be incorrect since it's unclear
what is intended.

Resolves: rdar://problem/48994658
2019-07-11 15:57:17 -07:00
Pavel Yaskevich
ebe0e42461 [Diagnostics] Don't suggest argument destructuring fix-it if closure is malformed
If closure expression is malformed don't try to suggest a fix-it
about destructuring, because there is no way to figure out where
it would actually go in the source.

Resolves: rdar://problem/51576862
2019-06-20 12:35:26 -07:00
Pavel Yaskevich
4fdc9fffe8 [TypeChecker] NFC: Add a test-case for rdar://problem/50869732 2019-06-17 16:02:00 -07:00
Doug Gregor
4ee4124228 Reduce end condition for type checker performance test.
This test is technically scaling linearly in the metrics being
checked, but it was still taking 5+ minutes to type check. Reduce the
upper bound so it finishes in a reasonable amount of time.
2019-03-06 10:14:21 -08:00
Doug Gregor
098470ddb7 Update tests for the removal of the strange "Any" preference rule 2019-03-06 08:58:56 -08:00
Doug Gregor
daf4610be1 [Constraint solver] Don't remove/reintroduce disjunction when favoring.
When favoring particular constraints in a disjunction, don't remove
the old disjunction and create a new one---it's just churn in the
constraint system. Instead, favor the constraints that need it.

This technically flips the SR-139 test case from "too complex" to
being fast enough, but it's still fairly slow.
2019-03-04 20:31:06 -08:00
Doug Gregor
a6902cc5a7 Add a "slow" type checker performance test for rdar://problem/46713933 2019-03-02 10:46:41 -08:00
Doug Gregor
6d8cdaf64c The test case from rdar://problem/20818064 is now scaling well. 2019-03-02 10:11:33 -08:00
David Zarzycki
51ef3c014a [Sema] NFC: fix assert-only crasher with overloaded generics 2019-02-18 08:49:42 -05:00
Pavel Yaskevich
43c547b0b8 [TypeChecker] Disable perf test-case for rdar://problem/21398466
Looks like obsoleted initializer has been removed,
and there are no solutions available for 'init(truncatingBitPattern:)'
which leads to performance regression with designated types enabled.

Resolves: rdar://problem/48061151
2019-02-13 21:07:42 -08:00
Pavel Yaskevich
0b29d9d4e6 [ConstraintSystem] Decouple designated types feature from Swift version
`selectApplyDisjunction` only makes sense in conjunction with
designated types feature because it's going to prioritize disjunctions
with arguments which are known to conform to literal protocols.

Prioritization like that is harmful without designated types feature
because it doesn't always lead to better constraint system splits,
and could prioritize bigger disjunctions which harms chances to
short-circuit solving.

Resolves: rdar://problem/47492691
2019-01-31 11:48:35 -08:00
Jordan Rose
37c30b1710 Merge pull request #21999 from jrose-apple/from-exponential-expletives-to-quadratic-quality
Cut down on exponential growth in checking switch exhaustivity.
2019-01-22 11:49:51 -08:00
Pavel Yaskevich
33cff97ab2 [Sema] Fix resolveDependentMemberType to properly handle nested types found in enum/struct/class
Currently if member has been found through same-type constraint
it would only be properly handled when it comes from a class type,
because that's the only time when base type gets replaced with
"concrete" type from equivalence class, but nested types could also
come from structs, enums and sometimes protocols (e.g. typealias)
which `resolveDependentMemberType` has to handle.

Resolves: rdar://problem/47334176
2019-01-20 01:59:40 -08:00