Commit Graph

16 Commits

Author SHA1 Message Date
Pavel Yaskevich
58ffca8f74 [ConstraintSystem] Don't produce partially matching note if none of the overloads matched 2023-05-09 14:11:38 -07:00
Philippe Hausler
e675b310f8 [SE-0329] Clock/Instant/Duration (#40609)
* [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>
2022-02-17 09:32:46 -08:00
Luciano Almeida
33d23719eb [tests] Fixing pattern match of note avalable overload lists diagnostic 2020-07-24 15:01:52 -03:00
Luciano Almeida
c09af513a0 [tests] Adjusting regression tests argument mismatch diagnostics on suit 2020-07-23 20:05:27 -03:00
Holly Borla
c8e9018c4d [CSGen] Don't merge type variables for literals in computeFavoredTypeForExpr 2020-07-22 14:43:05 -07:00
Pavel Yaskevich
0ea0b8e27b [ConstraintSystem] Adjust recording of "fixed" requirements to avoid conflicts
Currently it's possible to have a type conflict between different
requirements deduced as the same type which leads to incorrect
diagnostics. To mitigate that let's adjust how "fixed" requirements
are stored - instead of using resolved type for the left-hand side,
let's use originating generic parameter type.
2020-06-25 13:40:15 -07:00
Pavel Yaskevich
82fcee7bc7 [Diagnostics] NFC: Adjust diagnostic test-cases improved by new ambiguity diagnosis 2020-06-12 13:13:27 -07:00
Dmitri Gribenko
3f5c53a6b8 Reenable a test for UnicodeScalar
This test was disabled back in 2017 when the new integer protocols were
landing due to regressions in error messages. It is better to have a
working test that verifies the desired behavior (UnicodeScalar not
supporting arithmetic and the type checker producing somewhat readable
messages), rather than a disabled test because the error messages are
not perfect.
2020-05-19 11:53:11 +02:00
Max Moiseev
6a06b667da Fixing some and XFAILing other failing tests 2017-01-06 17:56:20 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00
Jordan Rose
e83c117c30 [test] Hack: run stdlib tests first to start long-running tests earlier.
This decreases total testing time by over a minute on my old Mac Pro.
It probably has much less effect on systems with fewer cores, but shouldn't
be any worse there.

Swift SVN r22745
2014-10-15 01:30:51 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Joe Pamer
0896a12197 Further improve type checker diagnostics through a variety of means.
Start capitalizing on some of the new diagnostic machinery in a few different ways:
- When mining constraints for type information, utilize constraints "favored" by the overload resolution process.
- When printing type variables, if the variable was created by opening a literal expression, utilize the literal
  default type or conformance if possible.
- Utilize syntactic information when crafting diagnostics:
	- If the constraint miner can produce a better diagnostic than the recorded failure, diagnose via constraints.
	- Factor in the expression kind when choosing which types to include in a diagnostic message.
- Start customizing diagnostics based on the amount of type data available.

What does all this mean?
- Fewer type variables leaking into diagnostic messages.
- Far better diagnostics for overload resolution failures. Specifically, we now print proper argument type data
  for failed function calls.
- No more "'Foo' is not convertible to 'Foo'" error messages
- A greater emphasis on type data means less dependence on the ordering of failed constraints. This means fewer
  inscrutable diagnostics complaining about 'UInt8' when all the constituent expressions are of type Float.

So we still have a ways to go, but these changes should greatly improve the number of head-scratchers served up
by the type checker.

These changes address the following radars:
rdar://problem/17618403
rdar://problem/17559042
rdar://problem/17007456
rdar://problem/17559042
rdar://problem/17590992
rdar://problem/17646988
rdar://problem/16979859
rdar://problem/16922560
rdar://problem/17144902
rdar://problem/16616948
rdar://problem/16756363
rdar://problem/16338509

Swift SVN r20927
2014-08-01 23:32:19 +00:00
Joe Pamer
cae36c9c9d Broaden the "favored constraint" binop optimization to work with simplified expression types, and not just default literal tyvars.
This addresses or improves several existing TC perf bugs (rdar://problem/15933674, rdar://problem/17110608, rdar://problem/17240816, rdar://problem/17244974), and seems to speed up our unit test runs by ~5%. (On my MacBook Pro, total average execution time is reduced from 557.28s to 531.89s.)

Swift SVN r19939
2014-07-14 19:20:49 +00:00
Dmitri Hrybenko
6e5060d471 stdlib/UnicodeScalar: remove arithmetic operations, they interact in
non-obvious ways with double-quoted literal sytax; "1" - "1" used to compile

rdar://17225816


Swift SVN r19563
2014-07-04 13:11:52 +00:00