Commit Graph

844 Commits

Author SHA1 Message Date
Robert Widmann
afe8f2b63f Drop TypeCheckerDebugConsumer 2020-05-18 22:49:55 -07:00
swift_jenkins
10e1981971 Merge remote-tracking branch 'origin/master' into master-next 2020-05-13 13:37:47 -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
swift_jenkins
2cb8077b5d Merge remote-tracking branch 'origin/master' into master-next 2020-04-30 15:38:43 -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
swift_jenkins
d8595f7cda Merge remote-tracking branch 'origin/master' into master-next 2020-04-30 00:54:04 -07:00
Pavel Yaskevich
326b371e10 [ConstraintSystem] Switch auxiliary functions to use ASTNode instead of TypedNode 2020-04-29 17:03:45 -07:00
swift_jenkins
6f288fc6ac Merge remote-tracking branch 'origin/master' into master-next 2020-04-25 09:18:25 -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
swift_jenkins
32dbe2ef15 Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 12:19:34 -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
swift_jenkins
1b8e500e16 Merge remote-tracking branch 'origin/master' into master-next 2020-04-22 15:57:30 -07: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
swift_jenkins
be1f3a551b Merge remote-tracking branch 'origin/master' into master-next 2020-04-21 13:37:18 -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
Hamish Knight
f9c0d25c39 [CS] Deindent a few debug messages
The additional indentation implies that they're
taking place in a new solver scope, but this isn't
the case.
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
swift_jenkins
8a10ab45eb Merge remote-tracking branch 'origin/master' into master-next 2020-04-10 07:40: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
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
swift_jenkins
c1468d9eb2 Merge remote-tracking branch 'origin/master' into master-next 2020-04-07 19:21:15 -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
swift_jenkins
d21857a5fb Merge remote-tracking branch 'origin/master' into master-next 2020-03-25 12:00:00 -07:00
Pavel Yaskevich
4b3d075fb7 [ConstraintSystem] Produce fallback diagnostic on mismatch between fixes/holes
If score indicates that a solution should have at least one fix
but it doesn't let's attempt to produce a fallback diagnostic inline.
2020-03-24 16:51:44 -07:00
Rintaro Ishizaki
a7cb72fe55 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	stdlib/public/Reflection/TypeRefBuilder.cpp
2020-03-10 12:46:49 -07:00
Pavel Yaskevich
7c19d1ccd1 [ConstraintSystem] Remove baseCS since CSDiag has been removed
There is no more sub-expression re-typechecking so no need to keep
parent constraint systems around.
2020-03-06 09:35:52 -08:00
swift_jenkins
29835814b6 Merge remote-tracking branch 'origin/master' into master-next 2020-03-05 09:38:08 -08:00
Pavel Yaskevich
4c600843d6 [ConstraintSystem] Check availability as part of resolving overload choice
This is a follow up to changes related to contextual availability
(https://github.com/apple/swift/pull/29921) which increased score
for unavailable declarations only if they were overloaded but
overlooked a case of a single unavailable choice.

Resolve: rdar://problem/60047439
2020-03-05 00:35:47 -08:00
swift_jenkins
a43b234c36 Merge remote-tracking branch 'origin/master' into master-next 2020-03-03 13:50:33 -08:00
Doug Gregor
8191aa4924 Merge pull request #30174 from DougGregor/function-builder-switch
[Constraint system] Implement switch support for function builders.
2020-03-03 12:34:08 -08:00
Nathan Hawes
a03dc92385 Merge remote-tracking branch 'upstream/master' into master-to-master-next 2020-03-02 19:06:34 -08:00
Doug Gregor
4b43573693 [Constraint system] Implement switch support for function builders.
Implement support for switch statements within function builders. Cases can
perform arbitrary pattern matches, e.g.,

    tuplify(true) { c in
      "testSwitchCombined"
      switch e {
      case .a:
        "a"
      case .b(let i, _?), .b(let i, nil):
        i + 17
      }
    }

subject to the normal rules of switch statements. Cases within function
builders cannot, however, include “fallthrough” statements, because those
(like “break” and “continue”) are control flow.

The translation of performed for `switch` statements is similar to that of
`if` statements, using `buildEither(first:)` and `buildEither(second:)` on
the function builder type.

This is the bulk of switch support, tracked by rdar://problem/50426203.
2020-03-02 17:25:25 -08:00
Hamish Knight
39d988da9c [CS] Remove ReturnAllDiscoveredSolutions flag
This is now no longer used.
2020-03-02 14:50:16 -08:00
Doug Gregor
13b200ddd5 [Constraint system] Generalize saved ASTNode -> solution target mapping.
We are currently only using the “solution targets” map for statement
conditions, but we will need it for more entities soon. Start generalizing
now.
2020-03-02 08:43:55 -08:00
swift_jenkins
dce5ca6447 Merge remote-tracking branch 'origin/master' into master-next 2020-02-24 21:00:10 -08:00
Doug Gregor
d2b2a50772 [Constraint system] Record application targets for statement conditions.
We’ll need this to generate constraints for statement conditions within the
constraint system. This is unused boilerplate at the moment.
2020-02-24 00:48:14 -08:00
swift_jenkins
567dba0f85 Merge remote-tracking branch 'origin/master' into master-next 2020-02-19 10:19:28 -08:00
Pavel Yaskevich
71753f3ca6 [ConstraintSystem] Rank contextually unavailable overloads lower than other choices (#29921)
Currently constraint solver is only capable of detecting universally unavailable
overloads but that's insufficient because it's still possible to pick a contextually
unavailable overload choice which could be better than e.g. generic overload, or
one with defaulted arguments, marked as disfavored etc.

Let's introduce `ConstraintSystem::isDeclUnavailable` which supports both universal
and contextual unavailability and allow constraint solver to rank all unavailable
overload choices lower than any other possible choice(s).

Resolves: rdar://problem/59056638
2020-02-19 13:13:53 -05:00
Hamish Knight
1a9764e6d7 [CS] Remove SubExpressionDiagnostics option 2020-02-19 07:43:59 -08:00
swift_jenkins
9fb3b6ac0e Merge remote-tracking branch 'origin/master' into master-next 2020-02-12 08:37:17 -08:00
Robert Widmann
86ea1912c4 Merge remote-tracking branch 'upstream/master' into HEAD 2020-02-11 23:03:59 -08:00
Doug Gregor
a308a7e53c [Constraint system] Sink down debug logging.
This way we’ll see constraints whenever they’re generated, and remove some
of the expression-centric nature of the top-level solve() and solveImpl().
2020-02-11 17:33:08 -08:00
Doug Gregor
f5b9517552 [Constraint system] Simplify and improve handling of node tyoes.
Rather than having separate dense maps for the type mappings of each
node type (expression, type location, variable declaration, pattern) that
a TypedNode can be, have a single such map. Sometimes we end up
setting a particular node's type more than once, so cope with that
by restoring the prior type.
2020-02-11 15:14:44 -08:00
swift-ci
91269532cd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-08 20:43:24 -08:00
Doug Gregor
efd4152061 [Constraint solver] Factor constraint generation logic for solution targets
Move more constraint generation logic for an expression target into a
new generateConstraints() on a solution target, so we can further
generalize the main “solve” logic.
2020-02-07 20:56:32 -08:00
swift-ci
48c4eebbf1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-04 02:42:48 -08:00
swift_jenkins
694b747b23 Merge remote-tracking branch 'origin/master' into master-next 2020-02-04 02:38:56 -08:00
Doug Gregor
bbc0a95723 [Constraint system] Simplify creation of contextual conversion constraint.
We were storing more state than necessary in the constraint system.
2020-02-03 22:38:24 -08:00