Commit Graph

610 Commits

Author SHA1 Message Date
swift_jenkins
76e2ec15b7 Merge remote-tracking branch 'origin/master' into master-next 2020-06-16 11:39:58 -07:00
Pavel Yaskevich
ccd7167371 [TypeChecker] Add a entry point to be used for code completion
As part of the code completion redesign this new entry point is going
to replace use of:

- `typeCheckExpression`
- `getTypeOfExpressionWithoutApplying` (which could be removed)

and possibly other methods currently used to retrieve information
for code completion purposes.

Advantages of a new approach:

- Avoids mutating AST;
- Allows to avoid sub-expression type-checking;
- Allows code completion access to multiple solutions in ambiguous cases;
- Provides all possible solutions - valid and invalid (with holes);
- Allows code completion to easily access not only types but
  overload choices and other supplimentary information associated
  with each solution.
2020-06-15 13:55:00 -07:00
swift_jenkins
0b350f6562 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 11:38:51 -07: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
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07:00
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00
Karoy Lorentey
1c9b0908e6 Merge remote-tracking branch 'origin/master-next'
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:43:40 -07:00
Doug Gregor
64f903fe2a [Type checker] Experimental support for one-way parameter constraints.
Introduce an experimental mode (behind the flag
`experimental-one-way-closure-params`) that places one-way
constraints between closure parameter types and references to those
parameters within the body of the closure. The intent here is to
break up constraint systems further, potentially improving type
checking performance and making way for larger closure bodies to be
supported.

This is a source-breaking change when the body of a single-expression
closure is used to determine the parameter types. One obvious example
is when there is no contextual type, e.g.,

    let _ = { $0 + 1 }

this type-checks today because `1` becomes `Int`, which matches the
`+` overload with the type `(Int, Int) -> Int`, determining the
parameter type `Int` for the closure. Such code would not type-check
with one-way constraints.
2020-06-05 22:47:21 -07:00
Varun Gandhi
c14e934563 [NFC] Remove redundant includes for llvm/ADT/SmallSet.h. 2020-05-31 13:07:45 -07:00
swift_jenkins
7406c8a983 Merge remote-tracking branch 'origin/master' into master-next 2020-05-25 17:58:30 -07:00
Hamish Knight
1de3d0dbef Merge pull request #31943 from owenv/line-and-col 2020-05-25 17:57:09 -07:00
swift_jenkins
ea82b47215 Merge remote-tracking branch 'origin/master' into master-next 2020-05-23 17:38:43 -07:00
Slava Pestov
80919e9fe1 Sema: Don't clone TypeReprs in ConstraintSystem::shrink() 2020-05-23 02:23:43 -04:00
Owen Voorhees
45bc578ae5 [SourceManager] Rename line and column APIs for clarity 2020-05-21 12:54:07 -05:00
swift_jenkins
df9ba33d11 Merge remote-tracking branch 'origin/master' into master-next 2020-05-19 11:39:09 -07:00
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