Commit Graph

1087 Commits

Author SHA1 Message Date
Rintaro Ishizaki
f97d68f3a7 Merge pull request #33290 from apple/revert-33245-index-key-paths
Revert "[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc."
2020-08-04 15:48:09 -07:00
Pavel Yaskevich
98007904b8 [Diagnostics] Detect and diagnose type mismatches related to function builder result
Generic requirement failures are already covered but general type
mismatches have to be handled separately.

Resolves: rdar://problem/65413640
2020-08-04 14:52:18 -07:00
Anthony Latsis
78f0259bfb Merge pull request #33283 from AnthonyLatsis/type-locura-2
ASTWalker: Offload TypeLoc
2020-08-05 00:17:33 +03:00
Rintaro Ishizaki
00e4a76ef0 Revert "[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc." 2020-08-04 12:51:52 -07:00
Anthony Latsis
17f12da381 [NFC] AST: Remove TypedPattern:getTypeLoc() 2020-08-04 18:46:21 +03:00
Varun Gandhi
3882beb85d [NFC] Use consistent naming scheme for predicate methods. (#33265)
bool throws() -> isThrowing(), bool async() -> isAsync()
2020-08-03 16:37:29 -07:00
Varun Gandhi
270b5dc7a6 Merge pull request #33118 from varungandhi-apple/vg-builder-pattern-ExtInfo
Refactor ExtInfo to use the builder pattern for construction.
2020-08-03 10:30:05 -07:00
Nathan Hawes
4c7cd16c3f Merge pull request #33245 from nathawes/index-key-paths
[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc.
2020-08-03 10:28:48 -07:00
Nathan Hawes
1d78fe1211 [Sema/Index] Resolve #keyPath components so they can be indexed
Unlike \keypath expressions, only the property components of #keypath
expressions were being resolved, so index wouldn't pick up references for their
qualifying types.

Also fixes a code completion bug where it was reporting members from the Swift
rather than ObjC side of bridged types.

Resolves rdar://problem/61573935
2020-07-31 17:11:23 -07:00
Varun Gandhi
f219e58ada [NFC] Refactor ExtInfo to use a builder-pattern based API.
Since the two ExtInfos share a common ClangTypeInfo, and C++ doesn't let us
forward declare nested classes, we need to hoist out AnyFunctionType::ExtInfo
and SILFunctionType::ExtInfo to the top-level.

We also add some convenience APIs on (AST|SIL)ExtInfo for frequently used
withXYZ methods. Note that all non-default construction still goes through the
builder's build() method.

We do not add any checks for invariants here; those will be added later.
2020-07-31 13:55:55 -07:00
Slava Pestov
45fc0bc4db Sema: Replace some calls to getDeclaredType() with getDeclaredInterfaceType() 2020-07-31 13:39:02 -04:00
Slava Pestov
769c4c1911 Sema: Fix some crashes with invalid nesting of extensions and protocols
Make sure we consistently use getParentForLookup() and not getParent()
when looking at generic DeclContexts. This is because an extension or
protocol that is nested inside of another generic context must never
inherit generic parameters from the parent context.

We already had this invariant enforced in some places, but now that we
do it more consistently we can fix more crashes of this kind.

Fixes <rdar://problem/58813746>, <https://bugs.swift.org/browse/SR-13004>.
2020-07-28 02:07:16 -04:00
Holly Borla
28a817b271 [Property Wrappers] Treat default wrapped values that are noescape
autoclosures the same way we treat default arguments that are
noescape autoclosures.
2020-07-15 10:02:35 -07:00
Holly Borla
a6c33a9611 [Property Wrappers] Use autoclosure information from CSApply to compute
`VarDecl::getPropertyWrapperInitValueInterfaceType`.
2020-07-13 17:22:29 -07:00
Anthony Latsis
2133fe27df Sema: Have TypeResolution accept an unbound generic type opener function 2020-07-08 13:39:34 +03:00
Holly Borla
063d420e50 Merge pull request #32672 from hborla/property-wrapper-diagnostics
[Property Wrappers] Improve diagnostics for property wrappers initialized out-of-line
2020-07-07 19:07:55 -07:00
Luciano Almeida
28fb66cbaf [SR-13088] Fix false positive downcast unrelated of types that cannot be statically known (#32592)
* [TypeCheckConstraints] Adjusting cases where checked casts that cannot be determined statically were producing misleading warnings

* [tests] Adding regression tests for SR-13088

* [TypeCheckConstraints] Adjusting comment and adding an extra test case for SR13035

* [TypeCheckConstraints] Fixing typos in comments

* [AST] Moving implementation of isCollection from ConstraintSystem to AST TypeBase

* [TypeCheckConstraints] Adjusting logic to verify specific conformance to stdlib collection type before emit an downcast warning

* [TypeCheckConstraints] Creating new CheckedCastContextKind::CollectionElement to be able to verify special cases within typeCheckCheckedCast for collection elements

* [TypeCheckConstraints] Adjusting logic around generic substitution to check both subtype and supertype

* [Sema] Adding isKnownStdlibCollectionType and replacing all usages contraint system method

* [TypeChecker] Reverting fixes around array element types

* [TypeChecker] Abstract logic of check for conditional requirements on TypeChecker::couldDynamicallyConformToProtocol

* [TypeChecker] Ajdustinc can conformDynamically conform and adjust review comments

* [TypeChecker] Ajusting comments and fixing typos

* [TypeChecker] Adjusting existential and archetype logic to check inside couldDynamicConform

* [TypeChecker] Adjusting minor and adding existential check into couldDynamically conform.

* [TypeChecker] Adjusting comments
2020-07-02 22:06:29 -03:00
Holly Borla
f555bfefc9 [Property Wrappers] Add new contextual type purposes for property wrappers
to produce better diagnostics when there's a 'wrappedValue' type mismatch.
2020-07-02 14:47:45 -07:00
Holly Borla
142e9f6289 [Diagnostics] Tweak some diagnostics code to allow diagnosing a fix
anchored at a TypeRepr rather than an Expr.
2020-07-02 14:47:45 -07:00
Holly Borla
2ac8d7ea17 [ConstraintSystem] Add support for type checking an out-of-line
initialized wrapped property via SolutionApplicationTarget.
2020-07-01 18:02:58 -07:00
Pavel Yaskevich
a8d44bc9ce Merge pull request #32558 from xedin/fix-req-conformace-assessment
[ConstraintSystem] Adjust recording of "fixed" requirements to avoid conflicts
2020-06-26 15:28:13 -07:00
Pavel Yaskevich
f7ef6d411c [Diagnostics] Augment conformance failure to with a note about enum with associated values
If the problem is related to an operator and argument is an enum
with associated values mention that conformances to `Equatable`
and `Comparable` are not synthesized in such cases.
2020-06-25 14:44:28 -07:00
Pavel Yaskevich
0ea0b8e27b [ConstraintSystem] Adjust recording of "fixed" requirements to avoid conflicts
Currently it's possible to have a type conflict between different
requirements deduced as the same type which leads to incorrect
diagnostics. To mitigate that let's adjust how "fixed" requirements
are stored - instead of using resolved type for the left-hand side,
let's use originating generic parameter type.
2020-06-25 13:40:15 -07:00
Pavel Yaskevich
c4f4ce1e5d [ConstraintSystem] Record substitutions from opened unbound generic types
Substitutions are already recorded for other situations like
member references, this was just slipped under the radar.
2020-06-24 16:00:12 -07:00
Pavel Yaskevich
92271e9ce5 [ConstraintSystem] Rework handling of object literal expressions
Instead of special casing argument-to-parameter matching for
object literal expressions, let's allow constraint system to
lookup a witness initializer and apply it to the given set
of arguments.

This also simplifies constraint application because
`coerceCallArguments` could be used to form type-checked
argument expression.
2020-06-22 10:15:08 -07:00
Pavel Yaskevich
16862e50a5 Merge pull request #31713 from xedin/no-ranking-with-ambiguous-with-fixes
[ConstraintSystem] Overhaul ambiguity diagnostics
2020-06-16 12:55:14 -07:00
Pavel Yaskevich
73667cdc7e [Diagnostics] Use Id_MatchOperator to check whether given operator is pattern match 2020-06-15 11:57:48 -07:00
Suyash Srijan
15643777df [CS] Update splice logic in simplifyLocator to handle situations where the index expression isn't a tuple or paren expression (#32356) 2020-06-13 03:28:57 +01:00
Pavel Yaskevich
f854cc666c [ConstraintSystem] Attach candidate notes either to decl (if it has valid loc) or AST node 2020-06-12 14:59:50 -07:00
Pavel Yaskevich
13b4fcc5e7 [Diagnostics] Diagnose ambiguity related to contextual type specifically 2020-06-12 11:47:04 -07:00
Pavel Yaskevich
7bbf9fe279 [Diagnostics] If aggregate fix consists of identical fixes diagnose it specially
If aggregate fix (based on callee locator) differs only in picked
overload choices, let's diagnose that via `diagnoseForAmbiguity`
associated with a particular fix kind all solutions share, that
would produce a tailored diagnostic instead of the most general one.
2020-06-12 11:47:04 -07:00
Pavel Yaskevich
b9aa70bc4f [ConstraintSystem] NFC/Debug: Log solutions before attempting to diagnose ambiguity with fixes 2020-06-12 11:47:04 -07:00
Pavel Yaskevich
9067ed23ca [ConstraintSystem] Specialize diagnostic for ~= to talk about expression pattern use 2020-06-12 11:47:04 -07:00
Pavel Yaskevich
cf3f52c94d [ConstraintSystem] NFC: Leave notes on the algorithm used by diagnoseAmbiguityWithFixes 2020-06-12 11:46:41 -07:00
Pavel Yaskevich
7d3f5e3775 [ConstraintSystem] Overhaul ambiguity diagnostics
Refactor `diagnoseAmbiguityWithFixes` as follows:

- Aggregate all of the available fixes based on callee locator;
- For each ambiguous overload match aggregated fixes and diagnose;
- Discard all of the fixes which have been already considered
  as part of overload diagnostics;
- Diagnose remaining (uniqued based on kind + locator) fixes
  iff they appear in all of the solutions.
2020-06-12 11:46:41 -07:00
Pavel Yaskevich
a8885189ac [ConstraintSystem] Encapsulate a way to diagnose ambiguity for aggregate fixes 2020-06-12 11:46:41 -07:00
Pavel Yaskevich
6b52016607 [ConstraintSystem] Rank solutions based on overload choices only after fix diagnostics have failed
If there are multiple solutions with fixes, let's not try to rank
them based on overload choices because doing so would filter out
viable candidates.
2020-06-12 11:46:41 -07:00
Anthony Latsis
f4f2101e9c [NFC] Sema: Internalize the use of UnboundGenericType in applyUnboundGenericArguments 2020-06-12 18:04:55 +03:00
Anthony Latsis
86b7e989e7 [NFC] CS: Give the type-transforming openUnboundGenericType method a more accurate name 2020-06-11 23:58:01 +03:00
Anthony Latsis
cdc38dab31 Merge pull request #32309 from AnthonyLatsis/cs-openunbound-dead-param
[NFC] CS: Inline a parameter in openUnboundGenericType
2020-06-11 13:45:50 +03:00
Robert Widmann
fb8fdd9644 Replace resolveCustomAttrType with a Request 2020-06-10 19:31:41 -07:00
Anthony Latsis
bd23534db6 [NFC] CS: Inline a parameter in openUnboundGenericType 2020-06-11 04:54:44 +03:00
Robert Widmann
ca728917e1 Merge pull request #32138 from AnthonyLatsis/eliminate-typeloc
Sema: Remove TypeLoc from ExplicitCastExpr (via TypeExpr)
2020-06-10 11:28:50 -07:00
Anthony Latsis
4b4634141f Sema: Remove TypeLoc from ExplicitCast 2020-06-09 15:20:25 +03:00
Luciano Almeida
3e280b8e83 Merge pull request #32107 from LucianoPAlmeida/nfc-move-to-cpp
[NFC][ConstraintSystem] Move some inlined header methods to implementation file
2020-06-06 16:37:19 -03:00
Doug Gregor
a4239370c8 [Constraint solver] Wire up "parents" of closure return statements. 2020-06-05 14:02:46 -07:00
Anthony Latsis
267e32dcd8 Merge pull request #32118 from AnthonyLatsis/post-increment-cleanup
[NFC] Pre- increment and decrement where possible
2020-06-02 20:10:29 +03:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Varun Gandhi
c14e934563 [NFC] Remove redundant includes for llvm/ADT/SmallSet.h. 2020-05-31 13:07:45 -07:00
Luciano Almeida
c91211c3ad [ConstraintSystem] Inline static method calls into the closures 2020-05-31 17:07:25 -03:00