mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* Revert "[CSOptimizer] Look through `OptionalEvaluationExpr`s when dealing with unapplied disjunctions" This reverts commit72340f39b8. * Revert "[CSOptimizer] Don't consider disabled overloads when checking whether disjunction is supported" This reverts commit6bc23b5057. * Revert "[CSOptimizer] Disjunctions with IUO overload choices are unsupported" This reverts commit471ee21535. * Revert "[CSOptimizer] MemberImportVisibility: Don't consider overloads that come from implicit imports" This reverts commitaa4a2b9071. * Revert "[CSOptimizer] Don't consider CGFloat widening when explicit initializer is used" This reverts commit3cc76eacdd. * Revert "[CSOptimizer] Literal arguments should cause score reset only for operators" This reverts commite3987beffb. * Revert "[CSOptimizer] NFC: check whether a choice is of operator instead of whole disjunction" This reverts commit6c82892c3c. * Revert "[CSOptimizer/Tests] NFC: Add a perf test-case fixed by improved literal array handling" This reverts commitcfd34e54c4. * Revert "[CSOptimizer] Extend candidate/parameter matching to support array literals" This reverts commit8a304f88c6. * Revert "[CSOptimizer] Favor choices that don't require application" This reverts commit0737542da8. * Revert "[CSOptimizer] Disable CGFloat -> Double conversion for unary operators" This reverts commitbc3a15fbe6. * Revert "[CSOptimizer] Mark bitwise operators as supported" This reverts commit860ae08d1b. * Revert "[CSOptimizer] Simplify handling of non-applied disjunctions" This reverts commit43ca7dfff9. * Revert "[ConstraintSystem] Fix `getEffectiveOverloadType` handling of `mutating` methods" This reverts commitc767f7aff7. * Revert "[CSOptimizer] Reduce overload types before ranking" This reverts commit95b47aead6. * Revert "[CSOptimizer] Implement special prioritization rules for result builder contexts" This reverts commit56d6635e46. * Revert "[CSOptimizer] Allow only widening CGFloat->Double conversions while matching candidate arguments" This reverts commitbf8ae3bc1b. * Revert "[CSSimplify] CGFloat-Double: Rank narrowing correctly when result is injected into an optional" This reverts commitcb876cbd9e. * Revert "[CSBindings] Prevent `BindingSet::isViable` from dropping viable bindings (v2)" This reverts commitb7e7493076. * Revert "[CSOptimizer] Add support for chained members without arguments" This reverts commit87cd5f8733. * Revert "[CSOptimizer] Mark compiler synthesized disjunctions as optimized" This reverts commit867e64182f. * Revert "[CSOptimizer] Make a light-weight generic overload check if some requirements are unsatisfiable" This reverts commit15c773b9d7. * Revert "[CSOptimizer] Fix `selectDisjunction` to use favored choices even if disjunction was not optimized" This reverts commitc2a55886f0. * Revert "[CSOptimizer] Limit "old" behavior compatibility to unlabeled unary arguments" This reverts commit9fb73143f6. * Revert "[Tests] NFC: Update a couple of type-checker tests" This reverts commitff8663ff16. * Revert "[Tests] NFC: Move simd related test-case from `slow` to `fast`" This reverts commit28396a6dce. * Revert "[CSGen] NFC: Remove obsolete `ConstraintSystem::{get, set}FavoredType`" This reverts commit8bd288447f. * Revert "[CSOptimizer] Allow literal arguments to match parameters that conform to `ExpressibleBy{Integer, Float}Literal`" This reverts commit2fdd4b6c35. * Revert "[CSOptimizer] Adjust `scoreCandidateMatch` to indicate when match cannot be decided" This reverts commit9b62c84a4f. * Revert "[CSOptimizer] Fix Double<->CGFloat implicit conversion support when arguments are literals" This reverts commit6caf1ccbb2. * Revert "[CSOptimizer] A more comprehensive generic overload checking when candidates are fully resolved" This reverts commite30587bda4. * Revert "[CSOptimizer] Restore old hack behavior which used to favor overloads based on arity matches" This reverts commita3a3ec4fe0. * Revert "[CSOptimizer] Desugar types before checking for equality" This reverts commit802f5cd105. * Revert "[ConstraintSystem] Narrowly disable `tryOptimizeGenericDisjunction` when some of the arguments are number literals" This reverts commit8d5cb112ef. * Revert "[CSOptimizer] Infer argument candidates from calls to `Double` and CGFloat constructors" This reverts commitf2a6677a6d. * Revert "[CSOptimizer] Score all of the overload choices matching on literals uniformly" This reverts commit59109c2d60. * Revert "[CSOptimizer] Enable ranking of `Int*`, `Float{80}` and `Double` initializers" This reverts commit6fb6d1cf90. * Revert "[CSOptimizer] Rank disjunctions based on score only if both sides are supported" This reverts commit8818d399f9. * Revert "[CSOptimizer] Rank results of operators regardless of whether anything is known about parameters" This reverts commit3996b25fbd. * Revert "[Tests] NFC: Add more test-cases that were previously solved due to old hacks behavior" This reverts commitd0ff6c81b8. * Revert "[CSOptimizer] Average score should reflect number of defaulted parameters" This reverts commit23589add74. * Revert "[Tests] NFC: Adjust a couple of improved tests" This reverts commit66981364fe. * Revert "[CSOptimizer] Don't optimize (implicit) calls with code completion arguments" This reverts commit8a918e2369. * Revert "[CSOptimizer] attempt to rank only standard/simd operators and fully concrete overload sets" This reverts commitdeca9b61c5. * Revert "[CSOptimizer] Record best scores for each disjunction and use them in `selectDisjunction`" This reverts commit3819ddfb40. * Revert "[CSOptimizer] Let `determineBestChoicesInContext` return the best disjunction if one is available" This reverts commitcf05405eae. * Revert "[CSOptimizer] Emulate old behavior related to favoring of unary calls to members" This reverts commit527de22bec. * Revert "[Tests] NFC: Add a test-case for rdar://133340307 which is now fast" This reverts commit670127abd6. * Revert "[CSOptimizer] Prefer homogeneous arithmetic operator overloads when argument(s) or result match" This reverts commitd69b6a0594. * Revert "[CSOptimizer] Remove an outdated optimization to compare resolved argument types with all else equal" This reverts commit1760bd1f1e. * Revert "[CSOptimizer] NFC: Switch from llvm::Optional to std::optional post-rebase" This reverts commitc429f5b9ec. * Revert "[CSOptimizer] Increase score when type matches opaque type" This reverts commit2869dff995. * Revert "[CSOptimizer] NFC: Switch to llvm::Optional" This reverts commit0fc6806922. * Revert "[CSOptimizer] NFC: Adjust conformance check to use `ConstraintSystem::lookupConformance`" This reverts commitda65333d41. * Revert "[CSOptimizer] Treat all type parameters equally" This reverts commit957a5f4270. * Revert "[CSStep] Remove disjunction pruning logic from DisjunctionStep" This reverts commit2c44e37948. * Revert "[CSOptimizer] Relax candidate type requirements from equality to set of no-impact conversions" This reverts commit11b897b32f. * Revert "[CSOptimizer] Use `matchCallArguments` to establish argument-to-parameter relationships" This reverts commitcb1cb2018d. * Revert "[CSOptimizer] Don't attempt to optimize calls with code completion token(s) in argument position" This reverts commit14e2a16fce. * Revert "[CSOptimizer] Allow generic operator overloads without associated type parameters" This reverts commitbc5f70a9a3. * Revert "[CSOptimizer] Make sure that all parameters without arguments are defaulted" This reverts commit7c1c46d4e4. * Revert "[CSStep] Don't favor choices until the disjunction is picked" This reverts commite404ed722a. * Revert "[CSOptimizer] Keep track of mismatches while evaluating candidates" This reverts commita094c3ebb0. * Revert "[CSOptimizer] Favor SIMD related arithmetic operator choices if argument is SIMD<N> type" This reverts commitc2f7451c7b. * Revert "[CSOptimizer] Initial implementation of disjunction choice favoring algorithm" This reverts commit672ae3d252. * Revert "[ConstraintSystem] Add skeleton of constraint optimizer" This reverts commitb5f08a4009. * Revert "[CSGen] Remove ConstraintOptimizer and all favoring logic" This reverts commit4432c51f57. * Revert "[ConstraintSystem] Remove `shrink`" This reverts commit757ca24e8a. * [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
82 lines
3.4 KiB
Swift
82 lines
3.4 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %gyb %s -o %t/main.swift
|
|
// RUN: %line-directive %t/main.swift -- %target-swift-frontend -typecheck -verify -swift-version 4.2 %t/main.swift
|
|
|
|
func testUnaryMinusInUnsigned() {
|
|
var a: UInt8 = -(1) // expected-error {{no '-' candidates produce the expected contextual result type 'UInt8'}} expected-note * {{}} expected-warning * {{}}
|
|
|
|
var b: UInt16 = -(1) // expected-error {{no '-' candidates produce the expected contextual result type 'UInt16'}} expected-note * {{}} expected-warning * {{}}
|
|
|
|
var c: UInt32 = -(1) // expected-error {{no '-' candidates produce the expected contextual result type 'UInt32'}} expected-note * {{}} expected-warning * {{}}
|
|
|
|
var d: UInt64 = -(1) // expected-error {{no '-' candidates produce the expected contextual result type 'UInt64'}} expected-note * {{}} expected-warning * {{}}
|
|
}
|
|
|
|
// Int and UInt are not identical to any fixed-size integer type
|
|
var i : Int = 0
|
|
var i64 : Int64 = i // expected-error {{}}
|
|
var i32 : Int32 = i // expected-error {{}}
|
|
var i16 : Int16 = i // expected-error {{}}
|
|
var i8 : Int8 = i // expected-error {{}}
|
|
|
|
var u : UInt = 0
|
|
var u64 : UInt64 = u // expected-error {{}}
|
|
var u32 : UInt32 = u // expected-error {{}}
|
|
var u16 : UInt16 = u // expected-error {{}}
|
|
var u8 : UInt8 = u // expected-error {{}}
|
|
|
|
func testMixedSignArithmetic() {
|
|
// Ensure that the generic arithmetic operators for Strideable don't
|
|
// allow mixed-sign arithmetic to compile. We create a deliberate
|
|
// ambiguity in these cases.
|
|
% for T in "UInt UInt64 UInt32 UInt16 UInt8".split():
|
|
do {
|
|
typealias Stride = ${T}.Stride
|
|
_ = ${T}(1) + 0 // OK
|
|
_ = 0 + ${T}(1) // OK
|
|
_ = ${T}(1) + Stride(0) // expected-error {{}} expected-note {{}}
|
|
_ = Stride(1) + ${T}(0) // expected-error {{}} expected-note {{}}
|
|
_ = ${T}(1) - Stride(0) // expected-error {{}} expected-note {{}}
|
|
var x: ${T} = 0
|
|
x += 1 // OK
|
|
x += Stride(1) // expected-error {{cannot convert value of type 'Stride' (aka 'Int') to expected argument type '${T}'}} {{10-10=${T}(}} {{19-19=)}}
|
|
x -= Stride(1) // expected-error {{cannot convert value of type 'Stride' (aka 'Int') to expected argument type '${T}'}} {{10-10=${T}(}} {{19-19=)}}
|
|
|
|
_ = (x - x) as Stride // expected-error {{}}
|
|
|
|
//===------------------------------------------------------------------===//
|
|
// The following errors are different because they're not being
|
|
// disabled by the ambiguity trick.
|
|
//===------------------------------------------------------------------===//
|
|
|
|
(x + x) as Stride // expected-error {{}}
|
|
Stride(1) - ${T}(0) // expected-error {{}} expected-note {{}}
|
|
|
|
var y: Stride = 0
|
|
y += ${T}(1) // expected-error {{cannot convert value of type '${T}' to expected argument type 'Int'}} {{10-10=Int(}}
|
|
y -= ${T}(1) // expected-error {{cannot convert value of type '${T}' to expected argument type 'Int'}} {{10-10=Int(}}
|
|
}
|
|
% end
|
|
}
|
|
|
|
func testOps<T : FixedWidthInteger>(_ x: T, _ y: T) -> T {
|
|
let a = x + y
|
|
let s = x - y
|
|
let m = x * y
|
|
let d = x / y
|
|
let r = x % y
|
|
return a + s + m + d + r
|
|
}
|
|
|
|
let s_ops: Int = testOps(5, 2)
|
|
let u_ops: UInt = testOps(5, 2)
|
|
let s8_ops: Int8 = testOps(5, 2)
|
|
let u8_ops: UInt8 = testOps(5, 2)
|
|
let s16_ops: Int16 = testOps(5, 2)
|
|
let u16_ops: UInt16 = testOps(5, 2)
|
|
let s32_ops: Int32 = testOps(5, 2)
|
|
let u32_ops: UInt32 = testOps(5, 2)
|
|
let s64_ops: Int64 = testOps(5, 2)
|
|
let u64_ops: UInt64 = testOps(5, 2)
|
|
|