* Revert "[CSOptimizer] Look through `OptionalEvaluationExpr`s when dealing with unapplied disjunctions"
This reverts commit 72340f39b8.
* Revert "[CSOptimizer] Don't consider disabled overloads when checking whether disjunction is supported"
This reverts commit 6bc23b5057.
* Revert "[CSOptimizer] Disjunctions with IUO overload choices are unsupported"
This reverts commit 471ee21535.
* Revert "[CSOptimizer] MemberImportVisibility: Don't consider overloads that come from implicit imports"
This reverts commit aa4a2b9071.
* Revert "[CSOptimizer] Don't consider CGFloat widening when explicit initializer is used"
This reverts commit 3cc76eacdd.
* Revert "[CSOptimizer] Literal arguments should cause score reset only for operators"
This reverts commit e3987beffb.
* Revert "[CSOptimizer] NFC: check whether a choice is of operator instead of whole disjunction"
This reverts commit 6c82892c3c.
* Revert "[CSOptimizer/Tests] NFC: Add a perf test-case fixed by improved literal array handling"
This reverts commit cfd34e54c4.
* Revert "[CSOptimizer] Extend candidate/parameter matching to support array literals"
This reverts commit 8a304f88c6.
* Revert "[CSOptimizer] Favor choices that don't require application"
This reverts commit 0737542da8.
* Revert "[CSOptimizer] Disable CGFloat -> Double conversion for unary operators"
This reverts commit bc3a15fbe6.
* Revert "[CSOptimizer] Mark bitwise operators as supported"
This reverts commit 860ae08d1b.
* Revert "[CSOptimizer] Simplify handling of non-applied disjunctions"
This reverts commit 43ca7dfff9.
* Revert "[ConstraintSystem] Fix `getEffectiveOverloadType` handling of `mutating` methods"
This reverts commit c767f7aff7.
* Revert "[CSOptimizer] Reduce overload types before ranking"
This reverts commit 95b47aead6.
* Revert "[CSOptimizer] Implement special prioritization rules for result builder contexts"
This reverts commit 56d6635e46.
* Revert "[CSOptimizer] Allow only widening CGFloat->Double conversions while matching candidate arguments"
This reverts commit bf8ae3bc1b.
* Revert "[CSSimplify] CGFloat-Double: Rank narrowing correctly when result is injected into an optional"
This reverts commit cb876cbd9e.
* Revert "[CSBindings] Prevent `BindingSet::isViable` from dropping viable bindings (v2)"
This reverts commit b7e7493076.
* Revert "[CSOptimizer] Add support for chained members without arguments"
This reverts commit 87cd5f8733.
* Revert "[CSOptimizer] Mark compiler synthesized disjunctions as optimized"
This reverts commit 867e64182f.
* Revert "[CSOptimizer] Make a light-weight generic overload check if some requirements are unsatisfiable"
This reverts commit 15c773b9d7.
* Revert "[CSOptimizer] Fix `selectDisjunction` to use favored choices even if disjunction was not optimized"
This reverts commit c2a55886f0.
* Revert "[CSOptimizer] Limit "old" behavior compatibility to unlabeled unary arguments"
This reverts commit 9fb73143f6.
* Revert "[Tests] NFC: Update a couple of type-checker tests"
This reverts commit ff8663ff16.
* Revert "[Tests] NFC: Move simd related test-case from `slow` to `fast`"
This reverts commit 28396a6dce.
* Revert "[CSGen] NFC: Remove obsolete `ConstraintSystem::{get, set}FavoredType`"
This reverts commit 8bd288447f.
* Revert "[CSOptimizer] Allow literal arguments to match parameters that conform to `ExpressibleBy{Integer, Float}Literal`"
This reverts commit 2fdd4b6c35.
* Revert "[CSOptimizer] Adjust `scoreCandidateMatch` to indicate when match cannot be decided"
This reverts commit 9b62c84a4f.
* Revert "[CSOptimizer] Fix Double<->CGFloat implicit conversion support when arguments are literals"
This reverts commit 6caf1ccbb2.
* Revert "[CSOptimizer] A more comprehensive generic overload checking when candidates are fully resolved"
This reverts commit e30587bda4.
* Revert "[CSOptimizer] Restore old hack behavior which used to favor overloads based on arity matches"
This reverts commit a3a3ec4fe0.
* Revert "[CSOptimizer] Desugar types before checking for equality"
This reverts commit 802f5cd105.
* Revert "[ConstraintSystem] Narrowly disable `tryOptimizeGenericDisjunction` when some of the arguments are number literals"
This reverts commit 8d5cb112ef.
* Revert "[CSOptimizer] Infer argument candidates from calls to `Double` and CGFloat constructors"
This reverts commit f2a6677a6d.
* Revert "[CSOptimizer] Score all of the overload choices matching on literals uniformly"
This reverts commit 59109c2d60.
* Revert "[CSOptimizer] Enable ranking of `Int*`, `Float{80}` and `Double` initializers"
This reverts commit 6fb6d1cf90.
* Revert "[CSOptimizer] Rank disjunctions based on score only if both sides are supported"
This reverts commit 8818d399f9.
* Revert "[CSOptimizer] Rank results of operators regardless of whether anything is known about parameters"
This reverts commit 3996b25fbd.
* Revert "[Tests] NFC: Add more test-cases that were previously solved due to old hacks behavior"
This reverts commit d0ff6c81b8.
* Revert "[CSOptimizer] Average score should reflect number of defaulted parameters"
This reverts commit 23589add74.
* Revert "[Tests] NFC: Adjust a couple of improved tests"
This reverts commit 66981364fe.
* Revert "[CSOptimizer] Don't optimize (implicit) calls with code completion arguments"
This reverts commit 8a918e2369.
* Revert "[CSOptimizer] attempt to rank only standard/simd operators and fully concrete overload sets"
This reverts commit deca9b61c5.
* Revert "[CSOptimizer] Record best scores for each disjunction and use them in `selectDisjunction`"
This reverts commit 3819ddfb40.
* Revert "[CSOptimizer] Let `determineBestChoicesInContext` return the best disjunction if one is available"
This reverts commit cf05405eae.
* Revert "[CSOptimizer] Emulate old behavior related to favoring of unary calls to members"
This reverts commit 527de22bec.
* Revert "[Tests] NFC: Add a test-case for rdar://133340307 which is now fast"
This reverts commit 670127abd6.
* Revert "[CSOptimizer] Prefer homogeneous arithmetic operator overloads when argument(s) or result match"
This reverts commit d69b6a0594.
* Revert "[CSOptimizer] Remove an outdated optimization to compare resolved argument types with all else equal"
This reverts commit 1760bd1f1e.
* Revert "[CSOptimizer] NFC: Switch from llvm::Optional to std::optional post-rebase"
This reverts commit c429f5b9ec.
* Revert "[CSOptimizer] Increase score when type matches opaque type"
This reverts commit 2869dff995.
* Revert "[CSOptimizer] NFC: Switch to llvm::Optional"
This reverts commit 0fc6806922.
* Revert "[CSOptimizer] NFC: Adjust conformance check to use `ConstraintSystem::lookupConformance`"
This reverts commit da65333d41.
* Revert "[CSOptimizer] Treat all type parameters equally"
This reverts commit 957a5f4270.
* Revert "[CSStep] Remove disjunction pruning logic from DisjunctionStep"
This reverts commit 2c44e37948.
* Revert "[CSOptimizer] Relax candidate type requirements from equality to set of no-impact conversions"
This reverts commit 11b897b32f.
* Revert "[CSOptimizer] Use `matchCallArguments` to establish argument-to-parameter relationships"
This reverts commit cb1cb2018d.
* Revert "[CSOptimizer] Don't attempt to optimize calls with code completion token(s) in argument position"
This reverts commit 14e2a16fce.
* Revert "[CSOptimizer] Allow generic operator overloads without associated type parameters"
This reverts commit bc5f70a9a3.
* Revert "[CSOptimizer] Make sure that all parameters without arguments are defaulted"
This reverts commit 7c1c46d4e4.
* Revert "[CSStep] Don't favor choices until the disjunction is picked"
This reverts commit e404ed722a.
* Revert "[CSOptimizer] Keep track of mismatches while evaluating candidates"
This reverts commit a094c3ebb0.
* Revert "[CSOptimizer] Favor SIMD related arithmetic operator choices if argument is SIMD<N> type"
This reverts commit c2f7451c7b.
* Revert "[CSOptimizer] Initial implementation of disjunction choice favoring algorithm"
This reverts commit 672ae3d252.
* Revert "[ConstraintSystem] Add skeleton of constraint optimizer"
This reverts commit b5f08a4009.
* Revert "[CSGen] Remove ConstraintOptimizer and all favoring logic"
This reverts commit 4432c51f57.
* Revert "[ConstraintSystem] Remove `shrink`"
This reverts commit 757ca24e8a.
* [TypeChecker] NFC: Remove resurrected use of `SolverShrinkUnsolvedThreshold`
* [TypeChecker] Bring back `SolverDisableShrink`
* [Tests] NFC: Mark tests affected by solver-perf revert as slow
* [Tests] NFC: Adjust async tests that are affected by performance hacks
Warnings about unsafe uses due to an @unsafe IteratorProtocol conformance
(for the implicit call to next()) could not be silenced. Follow the same
path we did for the Sequence conformance (and makeIterator() call) by
associating it with the `unsafe` on the sequence argument.
This isn't the only solution here, but it's a reasonable one.
`TVO_PrefersSubtypeBinding` in this case is intended to support
references to Objective-C imported members that can be force
unwrapped before being used i.e. accessing an overloaded method
on `AnyObject` should always prefer an overload that returns
a subtype:
```
@objc class A: NSObject {
@objc func test() -> A { }
@objc func test() -> B { }
}
func test(obj: AnyObject) {
obj.test!()
}
```
where `B` is a subtype of `A` should result in selection of
`() -> B`.
Instead of using `one-way` constraints, just like in closure contexts
for-in statements should type-check their `where` clauses separately.
This also unifies and simplifies for-in preamble handling in the
solver.
Since the introduction of custom attributes (as part of property
wrappers), we've modeled the context of expressions within these
attributes as PatternBindingInitializers. These
PatternBindingInitializers would get wired in to the variable
declarations they apply to, establishing the appropriate declaration
context hierarchy. This worked because property wrappers only every
applied to---you guessed it!---properties, so the
PatternBindingInitializer would always get filled in.
When custom attributes were extended to apply to anything for the
purposes of macros, the use of PatternBindingInitializer became less
appropriate. Specifically, the binding declaration would never get
filled in (it's always NULL), so any place in the compiler that
accesses the binding might have to deal with it being NULL, which is a
new requirement. Few did, crashes ensued.
Rather than continue to play whack-a-mole with the abused
PatternBindingInitializer, introduce a new CustomAttributeInitializer
to model the context of custom attribute arguments. When the
attributes are assigned to a declaration that has a
PatternBindingInitializer, we reparent this new initializer to the
PatternBindingInitializer. This helps separate out the logic for
custom attributes vs. actual initializers.
Fixes https://github.com/swiftlang/swift/issues/76409 / rdar://136997841
Just because the type of the initializer expression is an opaque return type,
does not mean it is the opaque return type *for the variable being initialized*.
It looks like there is a bit of duplicated logic and layering violations going
on so I only fixed one caller of openOpaqueType(). This addresses the test case
in the issue. For the remaining calls I added FIXMEs to investigate what is
going on.
Fixes https://github.com/swiftlang/swift/issues/73245.
Fixes rdar://127180656.
FunctionRefKind was originally designed to represent
the handling needed for argument labels on function
references, in which the unapplied and compound cases
are effectively the same. However it has since been
adopted in a bunch of other places where the
spelling of the function reference is entirely
orthogonal to the application level.
Split out the application level from the
"is compound" bit. Should be NFC. I've left some
FIXMEs for non-NFC changes that I'll address in a
follow-up.
All but two remaining call sites can be changed to just check for a
non-null solverState, because we want to assert if we're inside
of an active undo.
The two places inside binding inference can check isUndoActive()
directly.
When we replay a solution, we must record changes in the trail, so fix the
logic to do that. This fixes the first assertion failure with this test case.
The test case also exposed a second issue. We synthesize a CustomAttr in
applySolutionToClosurePropertyWrappers() with a type returned by simplifyType().
Eventually, CustomAttrNominalRequest::evaluate() looks at this type, and passes
it to directReferencesForType(). Unfortunately, this entry point does not
understand type aliases whose underlying type is a type parameter.
However, directReferencesForType() is the wrong thing to use here, and we
can just call getAnyNominal() instead.
Fixes rdar://139237781.
The logic here for completion wasn't actually
helping things since it would result in adding the
var overload to the system, which would result
in an ErrorType binding. We could turn the ErrorType
into a placeholder when resolving the overload,
but the simpler solution is to just allow CSGen
to turn the reference into a PlaceholderType. This
matches what we do for regular solving, and fixes
a crash with an IUO completion.
rdar://89369091
Today ParenType is used:
1. As the type of ParenExpr
2. As the payload type of an unlabeled single
associated value enum case (and the type of
ParenPattern).
3. As the type for an `(X)` TypeRepr
For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.
3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
Instead of doing the pattern parsing in both the
C++ parser and ASTGen, factor out the parsing into
a request that returns the pattern to emit, regex
type, and version. This can then be lazily run
during type-checking.
`participatesInInference` is now always true for
a non-empty body, remove it along with the separate
type-checking logic such that empty bodies are
type-checked together with the context.
Some requirement machine work
Rename requirement to Value
Rename more things to Value
Fix integer checking for requirement
some docs and parser changes
Minor fixes