Commit Graph

1087 Commits

Author SHA1 Message Date
Luciano Almeida
cc15c0b8dd [ConstraintSystem] Remove unnecessary check for decl and use getDeclOrNNull 2020-05-31 12:28:19 -03:00
Luciano Almeida
a331ba0780 [ConstraintSystem] Abstract common logic for various get property wrappers get information 2020-05-30 13:26:30 -03:00
Luciano Almeida
042939e77e [ConstraintSystem] Move some property wrappers implementation form header to cpp file 2020-05-30 12:27:54 -03:00
Pavel Yaskevich
9737ce040c [ConstraintSystem] Add missing handling of Stmt * to getLoc 2020-05-29 17:20:27 -07:00
Holly Borla
a97bbf9eee Merge pull request #31949 from hborla/property-wrapper-default-init
[Property Wrappers] Fix handling of properties that are default initialized via property wrapper
2020-05-21 18:01:42 -07:00
Pavel Yaskevich
28fa3ab9e9 Merge pull request #31848 from LucianoPAlmeida/SR-12827-keypath-hole
[SR-12827] [Diagnostics] Improve diagnostics keypath hole involving generic argument
2020-05-21 17:19:02 -07:00
Holly Borla
fcc4befb21 [Property Wrappers] For properties that are implicitly default initialized
via property wrapper, mark the init call as implicit.
2020-05-21 14:30:41 -07:00
Luciano Almeida
bbd6d53f3b [ConstraintSystem] Move implementation of isRepresentativeFor to cpp instead of inline in the header 2020-05-21 18:16:07 -03:00
Pavel Yaskevich
ca3aa67713 Merge pull request #31867 from xedin/pinpoint-arg-attr-mismatches
[ConstraintSystem] Add a new locator element - `argument attribute`
2020-05-19 12:28:50 -07:00
Robert Widmann
afe8f2b63f Drop TypeCheckerDebugConsumer 2020-05-18 22:49:55 -07:00
Pavel Yaskevich
9347a091e1 [ConstraintSystem] Adjust getCalleeLocator and simplifyLocator to handle ArgumentAttribute
- `getCalleeLocator`, if given locator ends at `ArgumentAttribute`
  strip the last element which makes sure that produced locator
  always refers directly to argument-to-parameter conversion.

- `simplifyLocator`, always leave `ArgumentAttribute` in the path
  because it's useful for diagnostics.
2020-05-18 13:10:26 -07:00
Robert Widmann
ea516bcbb3 Merge pull request #31760 from CodaFi/patternak
Remove The Parser Hack For If-Let
2020-05-13 18:10:35 -07:00
Robert Widmann
31242bc3da Remove The Parser Hack For If-Let
The parser used to rewrite

if let x: T

into

if let x: T?

This transformation is correct at face value, but relied on being able
to construct TypeReprs with bogus source locations. Instead of having
the parser kick semantic analysis into shape, let's perform this
reinterpretation when we resolve if-let patterns in statement
conditions.
2020-05-13 12:34:24 -07:00
Robert Widmann
2bca013457 Move "isDebugMode" into ConstraintSystem
This eliminates the final source of mutation of the TypeCheckerFlags on the ASTContext.
2020-05-13 09:13:44 -07:00
Hamish Knight
dad8f13f6e [Sema] Eliminate a subscript AnyObject lookup ambiguity
Previously we would always consider an AnyObject
subscript lookup to be ambiguous if there was a
candidate in both a class and protocol, even if
the selectors and types matched. This was due to
the protocol's generic signature preventing the
signatures from being coalesced.

Tweak the logic to strip generic signatures when
comparing for AnyObject lookup, matching what we
do for @objc methods.

Resolves SR-8611.
Resolves rdar://43645564 & rdar://62906344.
2020-05-12 21:23:34 -07:00
Pavel Yaskevich
f80726aff0 Merge pull request #31654 from xedin/rdar-62989214
[ConstraintSystem] Look through key path dynamic lookup nodes while s…
2020-05-08 09:40:34 -07:00
Pavel Yaskevich
b99ccd38ad [ConstraintSystem] Look through key path dynamic lookup nodes while simplifying locators
Key path dynamic member lookup should be completely transparent
for simplification purposes, it's just a means to get to the current
overload choice.

Resolves: rdar://problem/62989214
2020-05-08 00:43:23 -07:00
Saleem Abdulrasool
09975d1253 sprinkle llvm_unreachable for covered switches (NFC)
Annotate the covered switches with `llvm_unreachable` to avoid the MSVC
warning which does not recognise the covered switches.  This allows us
to avoid a spew of warnings.
2020-05-07 11:05:35 -07:00
Pavel Yaskevich
2788747b12 Merge pull request #31479 from xedin/audit-use-of-cs-in-diags
[Diagnostics] Audit use of constraint system in diagnostics
2020-05-01 20:28:46 -07:00
Pavel Yaskevich
b405f7c543 [Diagnostics] Avoid direct use of constraint system by MissingArgumentsFailure::isMisplacedMissingArgument 2020-05-01 12:45:48 -07:00
Robert Widmann
31d23303e1 [NFC] Strip all remaining TypeResolutionOptions parameters
Now that these are stored in the TypeResolution object itself, and all callers that mutate flags create a new resolution object, this data can be derived from the resolution itself.
2020-04-30 10:58:40 -07:00
Robert Widmann
4130170bf2 [NFC] Internalize TypeCheckerOptions in a TypeResolution Object
Add the appropriate assertions to ensure that the now-redundant options parameters are being kept in sync so they can be retracted.

The eventual goal is to have TypeResolution requestified.
2020-04-30 10:35:02 -07:00
Pavel Yaskevich
326b371e10 [ConstraintSystem] Switch auxiliary functions to use ASTNode instead of TypedNode 2020-04-29 17:03:45 -07:00
Slava Pestov
742bd98402 Sema: Remove ConformanceCheckOptions::SkipConditionalRequirements
All callers can trivially be refactored to use ModuleDecl::lookupConformance()
instead. Since this was the last flag in ConformanceCheckOptions, we can remove
that, too.
2020-04-25 00:14:24 -04:00
Pavel Yaskevich
9eb9b8d53b Merge pull request #31279 from xedin/rdar-62054241
[ConstraintSystem] Properly diagnose operator reference ambiguities
2020-04-24 14:20:19 -07:00
Joe Groff
b4c7a7e85d Merge pull request #31224 from AnthonyLatsis/rename-getfullname-2
AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl
2020-04-24 12:51:28 -07:00
Pavel Yaskevich
bb414927a0 [ConstraintSystem] Properly diagnose operator reference ambiguities
If operator is referenced instead of applied e.g. `arr.sort(by: <)`
ambiguities should be diagnosed as `no exact matches` with attached
notes describing a failure associated with each potential candidate.

Resolves: rdar://problem/62054241
2020-04-24 12:22:08 -07:00
Pavel Yaskevich
7bdf0164d4 [ConstraintSystem] Replace remaining uses of TypedNode::dyn_cast with getAsExpr 2020-04-23 01:13:13 -07:00
Pavel Yaskevich
4b1aa29149 [ConstraintSystem] NFC: Adjust all uses of locator anchors to work with TypedNode 2020-04-23 01:13:13 -07:00
Pavel Yaskevich
398f37842a [ConstraintSystem] Elevate TypedNode access helpers up to the namespace
Originally such accessors were only useful for `FailureDiagnostic` but
now since `ConstraintLocator` is anchored with `TypedNode` it makes sense
to make them universally accessible.
2020-04-23 01:13:13 -07:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Robert Widmann
78e07c1d41 Merge pull request #31159 from CodaFi/track-star
Remove Fallback Infrastructure For Evaluator-Based Dependencies
2020-04-22 15:37:48 -07:00
Hamish Knight
c39c4e8aad [CS] Unify failed constraint recording
Rename `addNewFailingConstraint` to
`recordFailedConstraint`, and call into it
whenever a constraint fails, instead of setting
`failedConstraint`. This ensures that
`-debug-constraints` will always log the constraint
that failed a given scope.

In addition, introduce `retireFailedConstraint`
to cover the common case of retiring a constraint
that just failed.
2020-04-20 19:08:24 -07:00
Robert Widmann
48a5432cb7 [NFC] Remove ConformanceCheckFlags::InExpression
The last read of this bit was removed when the legacy referenced name tracker was deleted in the last commit.
2020-04-20 10:22:58 -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
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
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
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
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
Hamish Knight
76881a39a5 [CS] Adjust applied overload simplification (#30716)
[CS] Adjust applied overload simplification
2020-04-07 19:04:27 -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
Holly Borla
ece84b176c [Diagnostics] Adjust ConstraintFix::diagnoseForAmbiguity to take an array
ref of pairs rather than two parallel arrays.
2020-04-07 13:38:26 -07:00
Holly Borla
6375481ea4 [Diagnostics] In DefineMemberBasedOnUse::diagnoseForAmbiguity, use
the base type from each solution instead of only the base type from
the first solution.
2020-04-06 17:35:31 -07:00
Holly Borla
bbfcb55e9e [Property Wrappers] Inject the opaque value placeholder for a property
wrapper original wrapped value expression inside of CSApply.

This prevents type checking the synthesized backing storage initializer
twice - once with the original expression and again with the placeholder.
2020-04-05 19:02:37 -07:00
Holly Borla
c301176ca6 [ConstraintSystem] Allow SolutionApplicationTarget to store the
innermost call to init(wrappedValue:) if the target is for initialization
of a property wrapper's backing storage.
2020-04-03 15:12:12 -07:00
Robert Widmann
27b211c1f9 Lazy-load the eraser of @_typeEraser where possible
Type erasure requires a circular construction by its very nature:

@_typeEraser(AnyProto)
protocol Proto { /**/ }
public struct AnyProto : Proto {}

If we eagerly resolve AnyProto, the chain of resolution steps that
deserialization must make goes a little something like this:

Lookup(Proto)
    -> Deserialize(@_typeEraser(AnyProto))
    -> Lookup(AnyProto)
    -> DeserializeInheritedStuff(AnyProto)
    -> Lookup(Proto)

This cycle could be broken if the order of incremental inputs was
such that we had already cached the lookup of Proto.

Resolve this cycle in any case by suspending the deserialization of the
type eraser until the point it's demanded by adding
ResolveTypeEraserTypeRequest.

rdar://61270195
2020-04-03 14:52:21 -07:00
Hamish Knight
71882996ca [CS] Adjust applied overload simplification
Currently `simplifyAppliedOverloads` depends on
the order in which constraints are simplified,
specifically that a lookup constraint for a
function gets simplified before the applicable
function constraint. This happens to work out
just fine today with the order in which we
re-activate constraints, but I'm planning on
changing that order.

This commit changes the logic such that it it's no
longer affected by the order in which constraints
are simplified. We'll now run it when either an
applicable function constraint is added, or a new
bind overload disjunction is added. This also
means we no longer need to run it potentially
multiple times when simplifying the applicable fn.
2020-03-29 18:33:59 -07:00