mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* [WIP] Initial draft at v2 Clock/Instant/Duration * Ensure the literal types for _DoubleWide are able to be at least 64 bits on 32 bit platforms * static cast timespec members to long * Remove runtime exports from clock functions * Export clock functions in implementations as they are in headers * Clean up internal properties by adding leading underscores, refine availability to a TBD marker macro, and break at 80 lines to match style * Shift operators to concrete Instant types to avoid complexity in solver resolution * Adjust diagnostic note and error expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions * Update stdlib/public/Concurrency/TaskSleep.swift Co-authored-by: Karoy Lorentey <klorentey@apple.com> * [stdlib][NFC] Remove trailing whitespace * [stdlib] Remove _DoubleWidth from stdlib's ABI * [stdlib] Strip downd _DoubleWidth to _[U]Int128 * Additional adjustments to diagnostic notes and errors expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions * Disable type checker performance validation for operator overload inferences (rdar://33958047) * Decorate Duration, DurationProtocol, Instant and clocks with @available(SwiftStdlib 9999, *) * Restore diagnostic ambiguity test assertion (due to availability) * Add a rough attempt at implementing time accessors on win32 * Remove unused clock id, rename SPI for swift clock ids and correct a few more missing availabilities * remove obsolete case of realtime clock for dispatch after callout * Use the default implementation of ~ for Int128 and UInt128 * Ensure diagnostic ambiguitiy applies evenly to all platforms and their resolved types * Restore the simd vector build modifications (merge damage) * Update to latest naming results for Instant.Duration * Updates to latest proposal initializers and accessors and adjust encoding/decoding to string based serialization * Update availability for Clock/Instant/Duration methods and types to be 5.7 * Correct *Clock.now to report via the correct runtime API * Ensure the hashing of Duration is based upon the attoseconds hashing * Avoid string based encoding and resort back to high and low bit encoding/decoding but as unkeyed * Adjust naming of component initializer to use suffixes on parameters * Duration decoding should use a mutable container for decoding * fix up components initializer and decode access * Add platform base initializers for timespec and tiemval to and from Duration * Add some first draft documentation for standard library types Duration, DurationProtocol and InstantProtocol * Another round of documentation prose and some drive-by availability fixes * InstantProtocol availability should be 5.7 * Correct linux timeval creation to be Int and not Int32 Co-authored-by: Karoy Lorentey <klorentey@apple.com>
38 lines
2.9 KiB
Swift
38 lines
2.9 KiB
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// FIXME: The clarity of these diagnostics could be improved.
|
|
// <rdar://problem/29912193>
|
|
|
|
func isString(_ s: inout String) {}
|
|
|
|
func test_UnicodeScalarDoesNotImplementArithmetic(_ us: UnicodeScalar, i: Int) {
|
|
var a1 = "a" + "b" // OK
|
|
isString(&a1)
|
|
// We don't check for the overload choices list on the overload note match because they may change on different platforms.
|
|
let a2 = "a" - "b" // expected-error {{binary operator '-' cannot be applied to two 'String' operands}}
|
|
// expected-note@-1 {{overloads for '-' exist with these partially matching parameter lists:}}
|
|
let a3 = "a" * "b" // expected-error {{binary operator '*' cannot be applied to two 'String' operands}}
|
|
// expected-note@-1 {{overloads for '*' exist with these partially matching parameter lists:}}
|
|
let a4 = "a" / "b" // expected-error {{binary operator '/' cannot be applied to two 'String' operands}}
|
|
// expected-note@-1 {{overloads for '/' exist with these partially matching parameter lists:}}
|
|
|
|
let b1 = us + us // expected-error {{binary operator '+' cannot be applied to two 'UnicodeScalar' (aka 'Unicode.Scalar') operands}}
|
|
let b2 = us - us // expected-error {{binary operator '-' cannot be applied to two 'UnicodeScalar' (aka 'Unicode.Scalar') operands}}
|
|
let b3 = us * us // expected-error {{binary operator '*' cannot be applied to two 'UnicodeScalar' (aka 'Unicode.Scalar') operands}}
|
|
// DurationProtocol is a near miss here
|
|
let b4 = us / us // expected-error {{referencing operator function '/' on 'DurationProtocol' requires that 'UnicodeScalar' (aka 'Unicode.Scalar') conform to 'DurationProtocol'}}
|
|
|
|
let c1 = us + i // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}}
|
|
let c2 = us - i // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}}
|
|
let c3 = us * i // expected-note {{overloads for '*' exist with these partially matching parameter lists: (Int, Int)}}
|
|
// expected-error@-1 {{binary operator '*' cannot be applied to operands of type 'UnicodeScalar' (aka 'Unicode.Scalar') and 'Int'}}
|
|
let c4 = us / i // expected-note {{overloads for '/' exist with these partially matching parameter lists: (Int, Int)}}
|
|
// expected-error@-1 {{binary operator '/' cannot be applied to operands of type 'UnicodeScalar' (aka 'Unicode.Scalar') and 'Int'}}
|
|
|
|
let d1 = i + us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}}
|
|
let d2 = i - us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}}
|
|
let d3 = i * us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}}
|
|
let d4 = i / us // expected-error {{cannot convert value of type 'UnicodeScalar' (aka 'Unicode.Scalar') to expected argument type 'Int'}}
|
|
}
|
|
|