Commit Graph

481 Commits

Author SHA1 Message Date
Slava Pestov
5f51546480 Sema: Fix source range for curry thunks
Fixes <rdar://problem/61117301> / <https://bugs.swift.org/browse/SR-12496>.
2020-04-03 23:26:04 -04:00
Slava Pestov
d7d7e2d2ec Add test case for rdar://problem/60081992 2020-03-24 01:29:26 -04:00
Holly Borla
fce8738ea8 [ConstraintSystem] Replace dependent member types with holes when the base type
doesn't conform to the associatedtype's protocol (only in diagnostic mode).

This allows the solver to find solutions for more cases involving requirement
failures for dependent member types without special cases across the solver
that check for dependent member types with no type variables.
2020-03-03 15:45:24 -08:00
Pavel Yaskevich
df21cbf85c [ConstraintSystem] Ignore attempt to bind type var to dependent member with incorrect base
Just like in cases where both sides are dependent member types
with resolved base that can't be simplified to a concrete type
let's ignore this mismatch and mark affected type variable as a hole
because something else has to be fixed already for this to happen.
2020-02-17 16:09:11 -08:00
Pavel Yaskevich
ae79b0d0bd [CSApply] Always use String type for ObjC interop key path
If it's possible to build an Objective-C key path for key path
expression make sure that its implicitly generated string literal
expression has a `String` type.

Resolves: rdar://problem/57356196
2020-02-15 00:04:09 -08:00
Slava Pestov
134cab6156 Add regression test for https://bugs.swift.org/browse/SR-9225 2020-02-07 20:33:54 -05:00
Robert Widmann
88d6559722 [GSB] Map invalid subject types in requirement constraints to ErrorType
Resolves SR-12072 and rdar://58941114
2020-01-28 10:15:43 -08:00
Pavel Yaskevich
8bcc192591 [Diagnostics] Diagnose inability to infer (complex) closure return type 2019-12-19 12:16:30 -08:00
Suyash Srijan
f8dace593c [Typechecker] Fix a crash related to use of invalid @autoclosure parameter 2019-12-17 03:24:09 +00: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
Slava Pestov
8b112232f1 Add regression test for https://bugs.swift.org/browse/SR-4571 2019-12-05 08:45:55 -05: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
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
Slava Pestov
fb581fdc8f Add a regression test for https://bugs.swift.org/browse/SR-10612 2019-11-18 18:26:03 -05:00
Slava Pestov
0e06792642 Add regression test for SR-10201 2019-11-14 18:26:52 -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
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
Slava Pestov
88cbcea325 Add a regression test for SR-8469 / rdar://43888895 2019-11-07 22:59:07 -05: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
Robert Widmann
c75af38a7a Drop ConformanceContexts out of the TypeChecker 2019-11-06 11:41:03 -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
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
Robert Widmann
86e5ed18a0 Add a bailout path to protocol requirement source formation
The GSB will try to form and note invalid constraints, but there are
a few paths that aren't prepared for error types to pop up.  Add
a defensive check to formProtocolRelativeType to make sure we don't wind
up force-casting an error type.

Fixes rdar://56116278
2019-10-25 13:08:41 -07:00
Holly Borla
e5c99cace6 Merge pull request #27769 from hborla/anyobject-conformance-failure
[ConstraintSystem] Diagnose missing AnyObject conformance using the MissingConformance constraint fix.
2019-10-18 22:10:21 -04:00
Holly Borla
dca1373e46 [ConstraintSystem] Don't fail in matchTypes when two primary archetype types
are not equal when part of a type requirement. This allows the
SkipSameTypeRequirement constraint fix to be applied instead.
2019-10-18 17:34:03 -07:00
Brent Royal-Gordon
ca25640cc3 Merge branch 'master' into everything-evil 2019-10-14 13:24:03 -07:00
Doug Gregor
99d9c94ab9 Add now-fixed test case for rdar://problem/45590743 2019-10-11 20:54:52 -07:00
Brent Royal-Gordon
eca51d4d53 Fix keypath-as-function crasher
The autoclosures generated for the keypath-as-function feature were not added to the list of closures that needed captures computed. In top-level code, this caused a crash. Fixes rdar://problem/56055600.
2019-10-08 18:11:41 -07:00
Hamish Knight
e2096ae34d [CSDiagnostics] Tweak candidate note text for arg mismatch
Number the parameters starting at 1 in order to
match other diagnostics such as
diag::missing_argument_positional, and change the
text to make it explicit that we're referring to
the parameter position (rather than argument
position).
2019-10-03 15:26:31 -07:00
Brent Royal-Gordon
6456b39660 Fix StringInterpolationProtocol validation crasher
Some old circularity-breaking code caused an unexpected null type, which led to crashes in the decl checker when trying to check that an `appendInterpolation` method in a different file would satisfy the informal requirement for one in a StringInterpolationProtocol conformer. This code appears to now be unnecessary, so this commit removes it. Fixes rdar://problem/55864759.
2019-10-01 17:43:42 -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
Robert Widmann
a331dee8e4 Merge pull request #27340 from CodaFi/party-crashers
Extensions Do Not Have Parent Signatures
2019-09-24 15:24:56 -07:00
Robert Widmann
574a450537 Extensions Do Not Have Parent Signatures
Remove the parent signature from consideration when computing the
generic signature for an extension.  This cuts off a series of crashers
that involved nested extensions with trailing where clauses a la

extension Foo {
  extension Foo where Self.Undefined == Bar {
  }
}

The inner (invalid) extension technically has a parent signature from
Foo itself.  Adding that signature to the GSB means when we go to
register the inner extension's generic parameters we crash.

Since extensions have to occur at the top level, just remove the parent
signature from consideration.

Fixes rdar://55502661
2019-09-24 13:13:51 -07:00
Suyash Srijan
9c97153b2a [Test] Adds a test case 2019-09-24 00:45:29 +01:00