[ConstraintSystem] Narrowly disable tryOptimizeGenericDisjunction when some of the arguments are number literals

Don't attempt this optimization if call has number literals.
This is intended to narrowly fix situations like:

```swift
func test<T: FloatingPoint>(_: T) { ... }
func test<T: Numeric>(_: T) { ... }

test(42)
```

The call should use `<T: Numeric>` overload even though the
`<T: FloatingPoint>` is a more specialized version because
selecting `<T: Numeric>` doesn't introduce non-default literal
types.
This commit is contained in:
Pavel Yaskevich
2024-09-21 20:50:27 -07:00
parent f2a6677a6d
commit 8d5cb112ef
4 changed files with 38 additions and 0 deletions

View File

@@ -497,6 +497,10 @@ public:
/// literal (represented by `ArrayExpr` and `DictionaryExpr` in AST).
bool isCollectionLiteralType() const;
/// Determine whether this type variable represents a literal such
/// as an integer value, a floating-point value with and without a sign.
bool isNumberLiteralType() const;
/// Determine whether this type variable represents a result type of a
/// function call.
bool isFunctionResult() const;