Commit Graph

2532 Commits

Author SHA1 Message Date
Pavel Yaskevich
043d2aa3dd [CSSimplify] NFC: Straighten checking of type variable passed to resolvePackExpansion
The type variable should always be one for pack expansion type which
implies that locator always ends at `PackExpansionType`.
2023-08-03 14:11:09 -07:00
Hamish Knight
e22180ba2e [CS] Add missing break 2023-08-03 13:00:12 +01:00
Amritpan Kaur
3604551172 [CSSimplify] Handle keypathvalue constraint locator 2023-07-31 09:50:32 -07:00
Amritpan Kaur
36031f3b3d [CSSimplify] Prevent contextual type failure fix record 2023-07-31 09:50:27 -07:00
Pavel Yaskevich
9b3980573f Merge pull request #67297 from amritpan/build-out-resolve-kp
[ConstraintSystem] Set up keypath expressions typechecking
2023-07-27 09:52:09 -07:00
Amritpan Kaur
3140c12691 [CSSimplify] If keypath is malformed, do not attempt to 2023-07-26 20:32:30 -07:00
Amritpan Kaur
6296be7464 [CSSimplify] If bound type var is more optional
than a binding type var, attempt to match
types and solve.
2023-07-26 20:32:26 -07:00
Amritpan Kaur
5fa54dfc4d [CSSimplify] Delay matchTypes for key path values
until they are directly bound.
2023-07-25 22:16:28 -07:00
Pavel Yaskevich
b8915fa39a [CSSimplify] Repair should ignore situations where assignment source or destination are a hole
If either source or destination type is a hole conversion should
just be ignored because there is no r-value or other mismatch that
could be diagnosed in this case.
2023-07-24 12:09:04 -07:00
Pavel Yaskevich
9e388b40e1 [CSSimplify] Check that raw type is not a hole before checking RawRepresentable conformance
Placeholder types just like type variables are set up to return
a conformance ref which, in this case, would mean that we'd produce
an invalid diagnostic.
2023-07-24 11:15:50 -07:00
Pavel Yaskevich
33a37b9516 Merge pull request #67377 from xedin/rdar-112090069
[CSSimplify] Extend same-shape detection to account for pack archetypes
2023-07-24 10:01:29 -07:00
Pavel Yaskevich
eb86497493 [CSSimplify] Deplay member lookup until single-element tuple with pack expansion is sufficiently resolved
Such tuples should be treated specially because once pack expansion
is sufficiently resolved they'd get exploded and the resulting type
is what member lookup should use as a base.

Resolves: rdar://110721928
2023-07-21 13:10:34 -07:00
Pavel Yaskevich
5a5edcafc3 [CSSimplify] Extend same-shape detection to account for pack archetypes
`same-shape` mismatch detection logic shouldn't expect that types are
always packs because they could be either invalid (i.e. Void) or pack
archetypes too.

Resolves: rdar://112090069
2023-07-20 22:50:22 -07:00
Pavel Yaskevich
59908eeb0d [CSGen] Suppress favoring in presence of non-disfavored variadic generic overloads
Since this type of early favoring checks number of arguments and matches
labels it would always favor non-variadic overloads which is incorrect.
2023-07-20 10:02:59 -07:00
Sophia Poirier
8173c721eb [ConstraintSystem] remove TupleType::isSingleUnlabeledPackExpansion in favor of constraints::getPatternTypeOfSingleUnlabeledPackExpansionTuple 2023-07-19 15:10:40 -07:00
Amritpan Kaur
e7853368db [CSSimplify] Resolve key path expression
by creating a BoundGenericType for the keypath expr
with the keypath base and replacing the value with
the value typeVar that will be resolved when the value
typeVar is directly bound.
2023-07-18 15:16:07 -07:00
Sophia Poirier
6e47a36808 Merge pull request #67292 from sophiapoirier/pack-stored-propety-shadows-global
[ConstraintSystem] implement implicit pack materialization for abstract tuples instead of explicit '.element'
2023-07-14 15:11:05 -07:00
Sophia Poirier
fa41015ae4 [ConstraintSystem] implement implicit pack materialization for abstract tuples instead of explicit '.element' 2023-07-14 10:32:38 -07:00
Slava Pestov
8a132c0248 Sema: Replace some usages of mapPackTypeIntoElementContext() with mapContextualPackTypeIntoElementContext() 2023-07-12 18:02:14 -04:00
Pavel Yaskevich
4760b95282 Merge pull request #67183 from xedin/convert-effects-into-storageRestrictions
[AST/Sema] Implement @storageRestrictions attribute
2023-07-11 11:57:14 -07:00
Pavel Yaskevich
62719b05ac Merge pull request #67157 from amritpan/kp-declcontext
[Constraint System] Store key path root, value, and decl context for use across constraint system.
2023-07-10 23:09:09 -07:00
Amritpan Kaur
1d8e7ef2fe [CSGen] Record keypath for use across constraint system. 2023-07-10 15:54:22 -07:00
Sima Nerush
83a7e05608 [Sema] Record a fix about extra parens for computed properties (#67042)
Co-authored-by: Sima Nerush <sima_nerush@apple.com>
2023-07-10 14:34:32 -07:00
Alex Hoppen
6cec68e302 [IDE] Ignore score kinds that represent implicit conversions when solving for code completion
Ignore conversion score increases during code completion to make sure we don't filter solutions that might start receiving the best score based on a choice of the code completion token.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
e337a3947d [ConstraintSystem] Implement tap expression checking in the solver
Generate a conjunction for each tap expression body as soon as it
gets a contextual type instead of separate post-factum type-checking
via `typeCheckTapBody`.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
28a39d6df1 [AST] NFC: Add a way to request initialized/accesses properties from init accessor 2023-07-07 10:00:36 -07:00
Andrew Savonichev
b6acb6fbef [AutoDiff] Check @noDerivative for function type comparison (#67121)
As described in the issue #62922, the compiler should not allow to discard @noDerivative attribute and keep @differentiable. The patch adds a diagnostic for this case.

Resolves #62922.
2023-07-06 15:21:30 -07:00
Pavel Yaskevich
c50263c730 Merge pull request #66971 from xedin/fix-specialization-issues
[ConstraintSystem] Fix a couple of issues related to generic specialization
2023-06-29 12:25:11 -07:00
Pavel Yaskevich
de729e2a0c [CSSimplify] Adjust typalias declaration handling for generic specialization 2023-06-29 00:06:00 -07:00
Pavel Yaskevich
b9b21fc597 [CSSimplify] Detect and diagnose attempts to specialize types with invalid number of arguments 2023-06-27 17:24:39 -07:00
Pavel Yaskevich
cd057bba27 [CSFix] Add a fix to detect type specialization arity mismatches
The situations where number of parameters and arguments didn't match.
2023-06-27 17:24:39 -07:00
Pavel Yaskevich
2bbda09043 [CSSimplify] Detect and diagnose attempts to specialize non-generic types/aliases 2023-06-27 17:24:38 -07:00
Pavel Yaskevich
ab2f47b92f [CSFix] Add a fix to detect invalid specialization of non-generic types 2023-06-27 17:24:38 -07:00
Pavel Yaskevich
42f80fbe43 [CSSimplify] Teach specialization constraint to look through non-generic typealiases
If type alias declaration doesn't add new generic parameters
refer to its underlying type to find them.
2023-06-27 17:24:20 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
swift-ci
44ab03a90b Merge pull request #66871 from kavon/generics-error-noncopyable
Be more specific than "noncopyable type T can't be used with generics yet"
2023-06-26 18:32:26 -07:00
Kavon Farvardin
c40985dfb3 describe how generic parameters implicitly require Copyable 2023-06-26 16:55:06 -07:00
Pavel Yaskevich
3122440842 Merge pull request #66766 from amritpan/key-path-backward-diag
[ConstraintSystem] Fix keyPath diagnostic error for value convert to contextual types
2023-06-26 08:52:18 -07:00
Kavon Farvardin
66bf3c03fc describe illegal casts to existentials 2023-06-23 20:15:01 -07:00
Amritpan Kaur
dda0f50034 Switch types for keypath diagnostics where
where contextual type and value types capabilities do not match.
2023-06-21 20:49:44 -07:00
Pavel Yaskevich
5e30445495 [CSSimplify] Add special handling if specialized type comes from TypeExpr
Add a special case for `TypeExpr` due to i.e. context specialization,
in such cases there is nothing for the solver to "open" so we need
to form opened type map manually.

Resolves: rdar://111059036
2023-06-20 21:58:04 -07:00
Pavel Yaskevich
199616a49b Merge pull request #66708 from xedin/generalize-default-closure-type-constraint
[ConstraintSystem] Use fallback type constraint to default pack expansion
2023-06-19 00:47:18 -07:00
Pavel Yaskevich
2ee646f47b [ConstraintSystem] NFC: Generalize DefaultClosureType constraint
This constraint is useful in more places than closures because
it gives a way to provide a "fallback type" without it having
effect on inference.
2023-06-16 11:15:15 -07:00
Hamish Knight
f10d0df62f Merge pull request #66593 from hamishknight/pattern-error 2023-06-16 18:06:47 +01:00
Holly Borla
612a2e79fa Merge pull request #66657 from hborla/variadic-macro-specialization
[ConstraintSystem] Use an explicit generic argument constraint for `UnresolvedSpecializeExpr`.
2023-06-15 09:35:25 -07:00
Holly Borla
d357315661 [ConstraintSystem] Handle typealiases in ExplicitGenericArguments
constraint simplification.
2023-06-15 00:27:18 -07:00
Holly Borla
eb858d938e [ConstraintSystem] Use an explicit generic argument constraint for
UnresolvedSpecializeExpr.

The eager generic argument matching code in CSGen for unresolved
specializations was incorrect because it didn't account for parameter
packs. Fortunately, a constraint to delay explicit generic argument
matching already exists for macros. Use it here.
2023-06-14 18:24:58 -07:00
Pavel Yaskevich
2b8a39724c Merge pull request #66513 from xedin/init-accessor-diagnostics
[Sema/SIL] Improve diagnostics related to init accessors
2023-06-14 09:57:08 -07:00
Pavel Yaskevich
3c924be2a0 [CSFix] InitAccessors: Add a fix that tracks invalid member references within init accessors 2023-06-13 10:58:50 -07:00