Commit Graph

5674 Commits

Author SHA1 Message Date
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
Slava Pestov
88cbcea325 Add a regression test for SR-8469 / rdar://43888895 2019-11-07 22:59:07 -05: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
Suyash Srijan
a2d0bf6f9c [PropertyWrappers] When finding the initial value for the property, properly handle the situation where we have multiple attached property wrappers
If a property has multiple property wrappers attached, we'll have multiple nested calls, where each call's argument is a call to construct the next wrapper in the chain. However, when we use multiple wrappers consecutively, we cannot just rely on the call's type matching the innermost wrapper's type, because it will match the first wrapper in the sequence of consective wrappers and we'll end up crashing in SILGen. So, we should check if the call's argument is another call and look into that before checking the types.
2019-11-07 21:27:52 +00:00
swift-ci
b51d363969 Merge pull request #28130 from DougGregor/diag-rdar56710317 2019-11-07 11:05:07 -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
Holly Borla
2394bab1fb Merge pull request #28116 from hborla/same-type-regression
[ConstraintSystem] Allow binding metatypes to succeed if one contains a hole
2019-11-06 16:22:39 -08:00
Holly Borla
b560261838 [ConstraintSystem] Allow binding metatypes to succeed if one contains
a hole.
2019-11-06 14:02:36 -08:00
Robert Widmann
c75af38a7a Drop ConformanceContexts out of the TypeChecker 2019-11-06 11:41:03 -08:00
Ben Langmuir
67592dbc1c Update diagnostic after CS change
rdar://56942731
2019-11-06 08:50:09 -08:00
Luciano Almeida
1184492d25 [Diagnostics] SR-11419 Diagnose protocol stub note in editor mode only (#28101)
* [TypeChecker] Enclosing stubs protocol note within editor mode

* [test] Removing note from test where there is no -diagnostics-editor-mode flag

* Formatting modified code

* [tests] Fixing tests under validation-tests
2019-11-06 07:42:48 -08:00
Holly Borla
e63f259f4f [ConstraintSystem] Bind holes to UnresolvedType instead of Any. 2019-11-05 09:15:13 -08:00
Holly Borla
561e527848 [ConstraintSystem] Extend the ExplicitlySpecifyGenericArguments fix to cover
all cases of missing generic parameters.

In `ComponentStep::take` when there are no bindings or disjunctions, use hole
propagation to default remaining free type variables that aren't for generic
parameters and continue solving. Rather than using a defaultable constraint for
holes, assign a fixed type directly when we have no bindings to try.
2019-11-05 09:15:13 -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
Suyash Srijan
d1e61a3000 [Test] Add test case for SR-11600 to compiler_crashers_2_fixed 2019-11-04 23:55:39 +00:00
Suyash Srijan
573aceeba3 [ConstraintSystem] Don't create a AllowArgumentMismatch fix when there is an argument type mismatch in synthesized wrappedValue init
This is because we already emit a diagostic to tell the user that the property's type does not match the wrappedValue type, so this diagnostic can be a bit confusing especially because the initializer is synthesized
2019-11-04 22:29:13 +00:00
Suyash Srijan
a5935d1ff7 [PropertyWrappers] Mark the property as invalid when it's type fails to match the type of the wrappedValue property
Otherwise, we will end up producing wrong diagnostics as well as crashing later on in certain cases
2019-11-04 22:29:13 +00:00
Slava Pestov
547fdaa3b8 Merge pull request #28026 from slavapestov/orts
Small cleanup to aid debugging and some regression tests
2019-11-02 09:00:44 -04:00
Andrew Trick
fd6497bbc7 SILCombine cleanup; replace null check with dyn_cast_or_null.
Remove 'not' and add '-emit-sil' to the corresponding lit test's run line.
2019-11-01 21:36:35 -07:00
Andrew Trick
4e106fb2e4 Merge pull request #28012 from zoecarver/fix/optimizer-and-SR-11624
Fix crash when optimizing protocol composition
2019-11-01 19:52:42 -07:00
Slava Pestov
07f8f551ed Add a regression test for SR-8968
Also rdar://problem/45217645.
2019-11-01 18:55:16 -04:00
Slava Pestov
116c5bfd5b Add a regression test for rdar://problem/56700017 2019-11-01 18:55:16 -04:00
zoecarver
ddade0a33d Add validation test under compiler crashers fixed 2019-11-01 10:29:34 -07:00
Robert Widmann
0af343469b Pre-Request Cleanup For Implicit Constructors
Push through an easy refactoring to the way we validate and install
implicit constructors.  This patch would be NFC but for a regression
test that now must diagnose.  #26159 changed validation order in such
a way that the code in validation-test-macosx-x86_64/compiler_crashers_2_fixed/0124-sr5825.swift
used to be accepted.  This patch once again changes validation order, so
we now reject this code, restoring the behavior seen on all prior
versions of Swift.

On its face, this test should work.  In order for it to do so, witness
matching has to be smarter about the declarations it asks for their
interface type, or it will risk these circular constructions
accidentally being accepted or rejected on a whim.
2019-10-31 13:13:08 -07:00
David Zarzycki
4097282ae2 Disable build system test that assumes standalone build 2019-10-30 07:36:22 +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