Commit Graph

15871 Commits

Author SHA1 Message Date
Pavel Yaskevich
103630296d [Diagnostics] Add a getLoc method to FailureDiagnostic 2020-04-14 11:30:11 -07:00
Holly Borla
66e85721cb Merge pull request #30807 from hborla/property-wrapper-refactoring
[Property Wrappers] Refactor property wrappers so the synthesized backing init is only type checked once
2020-04-14 10:48:22 -07:00
Holly Borla
48b6bcd869 Merge pull request #31002 from hborla/property-wrapper-contextual-type
[Property Wrappers] Use the outermost wrapper attribute type as the contextual type for property wrapper initialization
2020-04-13 20:38:43 -07:00
Holly Borla
df7735e545 [Property Wrappers] Use the outermost wrapper attribute type as the
contextual type for property wrapper initialization
2020-04-13 18:17:40 -07:00
Nathan Hawes
b3b7aa8ecf Merge pull request #30964 from nathawes/syntactic-rename-for-callAsFunction
[IDE][Refactoring] Handle 'callAsFunction' specially in syntactic rename
2020-04-13 11:36:53 -07:00
Slava Pestov
ab45d517d5 Merge pull request #29931 from theblixguy/fix/SR-12178
[Typechecker] Fix _modify for wrapped properties with observers
2020-04-12 22:11:10 -04:00
Nathan Hawes
bce68fa4e5 [IDE][Refactoring] Handle 'callAsFunction' specially in syntactic rename.
This change makes us treat it exactly as we do 'init'. We don't allow renaming the base name,
and don't fail if the basename doesn't match for calls.

Also:
  - explicit init calls/references like `MyType.init(42)` are now reported with
    'init' as a keywordBase range, rather than nothing.
  - cursor info no longer reports rename as available on init/callAsFunction
    calls without arguments, as there's nothing to rename in that case.
  - Improved detection of when a referenced function is a call (rather than
    reference) across syntactic rename, cursor-info, and indexing.

Resolves rdar://problem/60340429
2020-04-12 17:14:15 -07:00
Slava Pestov
23cac673ca IRGen: Enable dynamic replacement with library evolution
It looks like the only thing that fails is the linkage computation
for the dynamic replacement key of class methods. Even though
methods have hidden linkage to prevent them from being directly
referenced from outside a resilient module, we need to ensure
the dynamic replacement key is visible.

Fixes <rdar://problem/58457716>.
2020-04-10 22:53:36 -04:00
Artem Chikin
e3ce6f7b7e Merge pull request #30939 from artemcm/ImplOnlyPropertyWrappers
[Sema] Diagnose use of implementation-only property wrappers
2020-04-10 15:12:41 -07:00
Suyash Srijan
2fbd89dce5 [Typechecker] Simplify StorageImplInfo code in finishPropertyWrapperImplInfo and check for AccessorKind in synthesizeCoroutineAccessorBody 2020-04-10 21:31:23 +01:00
Hamish Knight
a61223a255 [CS] Visit all fixed bindings for constraint re-activation (#30886)
[CS] Visit all fixed bindings for constraint re-activation
2020-04-10 12:27:47 -07:00
Dan Zheng
486e667904 [AutoDiff] Support direct init reference differentiation. (#30946)
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 12:23:19 -07:00
Slava Pestov
cabb657caa Merge pull request #30937 from slavapestov/fix-property-wrapper-vtable-layout-with-subclass
Sema: Force property wrappers in EmittedMembersRequest::evaluate()
2020-04-10 15:15:23 -04:00
Artem Chikin
efdfceeb9b [Sema] Diagnose use of implementation-only property wrappers
We already ban all structs from declaring storage that comes from implementation-only imports. Until now we missed property wrappers, they were just dropped in deserialization.

Resolves rdar://problem/59403617
2020-04-10 11:19:42 -07:00
Hamish Knight
78072de623 [CS] Assert that we don't end up with unsolved constraints
Make sure we don't end up in a situation where we
have unsolved constraints left over and consider
the system fully solved.

This requires tweaking the type matching code for
dependent members such that a concrete base is
considered a failure rather than being left
unsolved. This should only happen when not in
diagnostic mode, as otherwise we use a hole.
2020-04-10 10:16:08 -07:00
Hamish Knight
d69a42d656 [CS] Preserve compatibility for collection coercions
Previously we could allow some invalid coercions to
sneak past Sema. In most cases these would either
cause crashes later down the pipeline or
miscompiles. However, for coercions between
collections, we emitted somewhat reasonable code
that performed a force cast.

This commit aims to preserve compatibility with
those collection coercions that previously
compiled, and emits a warning telling the user to
use either 'as?' or 'as!' instead.
2020-04-10 10:16:07 -07:00
Hamish Knight
6c7d695492 Revert "[Constraint graph] Reinstate the adjacencies of constraint graph nodes."
This reverts commit cf1732cce2.
With `gatherConstraints` no longer visiting
adjacencies, we no longer need to maintain the
adjacency info.
2020-04-10 10:16:07 -07:00
Hamish Knight
47541d86f7 [CS] Visit all fixed bindings for constraint re-activation
Start visiting transitive fixed bindings for type
variables, and stop visiting adjacencies for
`gatherConstraint`'s `AllMentions` mode.

This improves performance and fixes a correctness
issue with the old implementation where we could
fail to re-activate a coercion constraint, and
then let invalid code get past Sema, causing
either miscompiles or crashes later down the
pipeline.

Unfortunately this change requires us to
temporarily drop the non-ephemeral fix for a couple
of fairly obscure cases where the overload hasn't
yet been resolved. The logic was previously relying
on stale adjacency state in order to re-activate
the fix when the overload is bound, but it's not
connected on the constraint graph. We need to find
a way to connect constraints to unresolved
overloads they depend on.

Resolves SR-12369.
2020-04-10 10:16:07 -07:00
Hamish Knight
0df444920e [CS] NFC: Move depthFirstSearch up slightly 2020-04-10 10:16:06 -07:00
Hamish Knight
84a3db45db [CS] Account for type variables when matching metatypes
Previously we could prematurely attempt to perform
a bind of class metatypes without checking for
subtyping. Tweak the logic to not perform a bind
if we can't prove that we're dealing with non-class
types.
2020-04-10 10:16:06 -07:00
Holly Borla
815ecad5c9 [Property Wrappers] Don't continue on to synthesizing and type checking a
property wrapper backing init if the property type doesn't match the
wrapped value type.
2020-04-10 10:07:52 -07:00
Doug Gregor
6999c318b7 Merge pull request #30924 from DougGregor/for-each-solution-application-target
[Constraint solver] Migrate for-each statement checking into SolutionApplicationTarget
2020-04-10 07:28:21 -07:00
Dan Zheng
e9ed2d50cf [AutoDiff] Fix @derivative attribute type-checking crash. (#30936)
Fix `@derivative` attribute type-checking crash, so far reproducible only via
`-parse-stdlib`.

The crash occurs because it is not sufficient for type-checking to check for
`Differentiable` conformances. We must also check for invalid `TangentVector`
associated types.

Resolves SR-12559.
2020-04-10 02:14:02 -07:00
Dan Zheng
b4fa7e0027 [AutoDiff] Support direct init reference differentiation.
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 01:26:34 -07:00
Pavel Yaskevich
afaff4831c Merge pull request #30932 from xedin/failure-diagnostic-gardening
[Diagnostics] A couple of adjustments to `FailureDiagnostic`
2020-04-10 00:55:14 -07:00
Slava Pestov
8ee5d2931f Sema: Force property wrappers in EmittedMembersRequest::evaluate()
Fixes <rdar://problem/61229365>.
2020-04-09 19:57:12 -04:00
Suyash Srijan
84f8e41dee [Typechecker] Add an hasObservers() convenience method and simplify some code 2020-04-10 00:26:52 +01:00
Holly Borla
65105f3a26 [Property Wrappers] Introduce a new Expr node for the property wrapper
wrapped value placeholder in an init(wrappedValue:) call that was previously
injected as an OpaqueValueExpr. This commit also restores the old design of
OpaqueValueExpr.
2020-04-09 16:00:57 -07:00
Pavel Yaskevich
42bdfc9bc6 [Diagnostics] Remove unsafe getRestrictionFor method 2020-04-09 15:35:14 -07:00
Suyash Srijan
ba481f31a2 [Typechecker] Supress _modify synthesis if the wrapped property has observers 2020-04-09 23:21:18 +01:00
Suyash Srijan
216ae871eb [Typechecker] Wrapped properties with observers should not have ReadWriteImplKind::Modify 2020-04-09 23:21:18 +01:00
Pavel Yaskevich
6f2af1f433 [Diagnostics] Replace getChoiceFor with getCalleeOverloadChoiceIfAvailable
New name is more consistent with existing `getOverloadChoiceIfAvailable`
and allows us to clean up a couple of places where `getCalleeLocator` was
used directly before.
2020-04-09 12:44:16 -07:00
Doug Gregor
1f232f7f53 [Constraint solver] Remove ExprTypeCheckListener.
The last client of this listener-based interface has been refactored,
so remove it.
2020-04-09 11:18:53 -07:00
Doug Gregor
87d86f3545 [Constraint solver] Migrate for-each statement checking into SolutionApplicationTarget.
Pull the entirety of type checking for for-each statement headers (i.e., not the
body) into the constraint system, using the normal SolutionApplicationTarget-based
constraint generation and application facilities. Most of this was already handled
in the constraint solver (although the `where` filtering condition was not), so
this is a smaller change than it looks like.
2020-04-09 11:02:56 -07:00
Owen Voorhees
39465996b8 Merge pull request #30879 from owenv/cleanup-case-typechecking
[Sema] Eliminate duplication in CaseStmt typechecking for switch and do-catch
2020-04-09 09:23:26 -05:00
Suyash Srijan
724f8c23db [Typechecker] Implement SE-0268 Refine didSet Semantics (#26632) 2020-04-09 01:23:15 +01:00
Pavel Yaskevich
6f83c08aae [Diagnostics] Remove obsolete getResolvedMemberRef 2020-04-08 16:09:08 -07:00
Pavel Yaskevich
deb58e0b68 Merge pull request #30022 from LucianoPAlmeida/SR-9839-convention-function-conversions-fail
[SR-9839] Fixes ambiguity in convention function argument inference
2020-04-08 15:48:51 -07:00
Pavel Yaskevich
a84e0b70fc [Diagnostics] Obsolete and remove HasComplexLocator field from diagnostic
This was useful when CSDiag was still in play but since everything
has been ported this is no longer useful.
2020-04-08 15:03:42 -07:00
Holly Borla
008b33ecb3 Merge pull request #30896 from hborla/property-wrapper-invalid-redeclaration
[Property Wrappers] Improve error recovery in buildStorageReference.
2020-04-08 14:50:25 -07:00
Luciano Almeida
426a2f8694 [ConstraintSystem] Checking for SK_Fix when diagnose ambiguity for generic parameter bindings with no fixes 2020-04-08 17:51:45 -03:00
Luciano Almeida
2704b6d737 [ConstraintSystem] Diagnose ambiguity for generic parameter bindings with no fixes 2020-04-08 17:16:47 -03:00
Holly Borla
32c338f465 [Property Wrappers] Improve error recovery in buildStorageReference.
Bail out if the backing storage has an error type. This can happen
if there's an invalid redeclaration of the property wrapper, for
example.
2020-04-08 12:45:32 -07:00
Brent Royal-Gordon
4de19e1c3c Merge pull request #30819 from brentdax/a-less-ambitious-crossover-event
Ignore transitive ObjC imports when cross-importing
2020-04-08 11:40:35 -07:00
Pavel Yaskevich
51267754fc Merge pull request #30867 from xedin/rdar-59874355
[TypeChecker] Diagnose key paths with contextual type but no leading dot
2020-04-08 10:05:35 -07:00
Artem Chikin
0d1013245e Merge pull request #30782 from artemcm/Rcross-import
Add -Rcross-import option
2020-04-07 19:04:47 -07:00
Hamish Knight
76881a39a5 [CS] Adjust applied overload simplification (#30716)
[CS] Adjust applied overload simplification
2020-04-07 19:04:27 -07:00
Owen Voorhees
5213bec4d2 [Sema] Eliminate duplication in CaseStmt typechecking for switch and do-catch statements 2020-04-07 17:56:39 -07:00
Holly Borla
b2e6048f55 Merge pull request #30844 from hborla/diagnose-for-ambiguity
[Diagnostics] In DefineMemberBasedOnUse::diagnoseForAmbiguity, use the base type from each solution
2020-04-07 17:52:20 -07:00
marcrasi
eefe9a083c Merge pull request #30851 from apple/derivative-attr-serialization
[AutoDiff] SR-12526: cross-module @derivative deserialization
2020-04-07 17:23:47 -07:00