Commit Graph

7754 Commits

Author SHA1 Message Date
Slava Pestov
ab6584cf05 Merge pull request #41545 from slavapestov/non-final-class-self-same-type-requirement-conformance
Sema: Warn about non-final classes conforming to protocols with a same-type requirement on 'Self'
2022-02-25 10:46:14 -05:00
Slava Pestov
561e63552f Pass -requirement-machine-protocol-signatures=off in three tests 2022-02-24 15:09:53 -05:00
Slava Pestov
c98ddb99e2 Sema: Warn about non-final classes conforming to protocols with a same-type requirement on 'Self'
This is unsound because it breaks covariance of protocol conformances
on classes. See the test case and changelog entry for details.
2022-02-24 14:23:00 -05:00
Slava Pestov
d4b303e812 Merge pull request #41533 from slavapestov/unqualified-lookup-protocol-typealias-cycle-fix
Revert "Sema: Don't resolve protocol typealiases to DependentMemberTypes"
2022-02-24 11:24:29 -05:00
Slava Pestov
54bf6adb58 Revert "Sema: Don't resolve protocol typealiases to DependentMemberTypes"
This reverts commit 1dd79ae3db.

Fixes rdar://problem/88230388.
2022-02-23 23:11:05 -05:00
Mike Ash
61cc49ed06 Merge pull request #41528 from mikeash/fix-Assert-debugPrecondition-off.swift
Mark stdlib/Assert-debugPrecondition-off.swift as REQUIRES: executable_test.
2022-02-23 16:04:57 -05:00
Pavel Yaskevich
c22649e050 Merge pull request #41504 from xedin/rdar-84580119
[CSDiagnostics] Look through l-value conversions when mismatch is in …
2022-02-23 09:16:38 -08:00
Mike Ash
039eb10dab Mark stdlib/Assert-debugPrecondition-off.swift as REQUIRES: executable_test. 2022-02-23 12:16:35 -05:00
Pavel Yaskevich
d7254b9100 Merge pull request #41505 from xedin/rdar88256059-test
[TypeChecker] NFC: Add a test-case for rdar://88256059
2022-02-22 09:29:35 -08:00
Guillaume Lessard
544cd889c8 Merge pull request #41503 from glessard/sr15433
[test] return early when test cannot succeed
2022-02-22 10:03:59 -07:00
Karoy Lorentey
0704746bfa Merge pull request #41445 from lorentey/unconditional-debugPrecondition
[stdlib] Add build option to enable _debugPrecondition in Release mode
2022-02-21 20:59:22 -08:00
Tim Kientzle
4d91b45988 [RemoteMirror] Get spare bit info from reflection records (#40906)
This adds a new reflection record type carrying spare bit information for multi-payload enums.

The compiler includes this for any type that might need it in order to accurately reflect the contents of the enum. The RemoteMirror library will use this if present to determine how to project the contents of the enum. If not present (for example, in older binaries), the RemoteMirror library falls back on an internal calculation of the spare bitmask.

A few notes:
 * The internal calculation is not perfect.  In particular, it does not support MPEs that contain other enums (e.g., optionals).  It should accurately refuse to project any MPE that it does not correctly support.
 * The new reflection field is designed to be expandable; this might someday avoid the need for a new section.

Resolves rdar://61158214
2022-02-21 17:06:14 -08:00
Pavel Yaskevich
874d0fbe8f [TypeChecker] NFC: Add a test-case for rdar://88256059 2022-02-21 16:34:53 -08:00
Pavel Yaskevich
bf820c5dab [CSDiagnostics] Look through l-value conversions when mismatch is in subscript setter
`repairFailures` needs a special case when l-value conversion is
associated with a result type of subscript setter because otherwise
it falls through and treats result type as if it's an argument type,
which leads to crashes.

Resolves: rdar://84580119
2022-02-21 16:32:25 -08:00
Guillaume Lessard
4e3c1ea3ee [test] return early when test cannot succeed
- test requires Swift 5.7
- resolves rdar://89052037
2022-02-21 17:01:49 -07:00
Nate Chandler
f79f26f6ea [Test] Reenabled test.
Added flag to disable destroy hoisting to run line.  Destroy hoisting
will be disabled separately.

rdar://86271875
2022-02-21 08:05:48 -08:00
Anthony Latsis
b0043966cd Merge pull request #40269 from AnthonyLatsis/assoc-inference-system
AssociatedTypeInference: Initial refactoring of abstract type witness inference
2022-02-20 15:51:58 +03:00
Karoy Lorentey
5274295e3f [test] Update tests for new (conditional) _debugPrecondition behavior 2022-02-18 21:54:02 -08:00
Slava Pestov
1784aee148 Add '-requirement-machine-protocol-signatures=verify -requirement-machine-inferred-signatures=verify' to a few validation tests 2022-02-17 19:40:58 -05: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
Karoy Lorentey
7ce8544610 [StdlibUnittest] expectEqual: Use less opinionated argument names
Based on its argument names and messages, `expectEqual` and friends expects the expected value of the calculation being tested to be provided as its first argument, and the actual value as the second:

```
expectEqual(4, 2 + 2)
```

This does not always match actual use -- folks like myself find the opposite ordering far more natural:

```
expectEqual(2 + 2, 4)
```

`expectEqual` currently uses the `expected`/`actual` terminology in its failure messages, causing confusion and needless suffering.

Change `expectEqual`'s declaration and error messages to use a naming scheme that does not assume specific roles for the two arguments. (Namely, use `first`/`second` instead of `expected`/`actual`.)

An alternative way to solve this would be to use argument labels, as in `expectEqual(expected: 4, actual: 2 + 2)`, or to introduce some sort of expression builder scheme such as `expect(2 + 2).toEqual(2)`. These seem needlessly fussy and overly clever, respectively.
2022-02-16 14:00:54 -08:00
Slava Pestov
1665c57d52 Merge pull request #41381 from slavapestov/rqm-simplify-substitutions-records-projections
[RequirementMachine] Substitution simplification records projections
2022-02-16 16:08:13 -05:00
Slava Pestov
77d1063f2e Disable ArrayBridging test due to rdar://88637598 2022-02-16 14:21:43 -05:00
Alejandro Alonso
657c17fa39 Setup grapheme breaking tests 2022-02-15 17:16:36 -08:00
Alejandro Alonso
c0e1ef01f9 Fix backwards count of Indic graphemes 2022-02-15 15:28:37 -08:00
Anthony Latsis
4c68ecfdf5 TypeWitnessSystem: Add tests 2022-02-16 00:56:08 +03:00
Slava Pestov
4655fc359b Sema: Make a couple of TypeResolver methods idempotent
When emitting a diagnostic, mark the TypeRepr as invalid and
return an ErrorType to ensure that the diagnostic is not
emitted again, and to muffle downstream diagnostics.
2022-02-15 04:02:46 -05:00
Guillaume Lessard
d870a9f164 Merge pull request #41288 from glessard/sr15433
[stdlib] Implement `withContiguousStorageIfAvailable` for raw buffer types
2022-02-14 15:37:27 -07:00
Slava Pestov
5fa5ff7ce1 RequirementMachine: Update tests for protocol typealiases 2022-02-13 09:50:16 -05:00
Slava Pestov
f13f3bd898 Merge pull request #41332 from slavapestov/rqm-typealias-cycle-fix
Sema: Fix request cycle involving protocol typealiases in preparation for RequirementMachine support
2022-02-11 16:44:40 -05:00
Slava Pestov
6c714f4087 Sema: Try to avoid calling getGenericSignature() when performing structural resolution 2022-02-11 08:15:50 -05:00
Slava Pestov
7e733c424e RequirementMachine: compiler_crashers_2_fixed/0074-rdar28544316.swift now type checks; move it to test/Generics/ 2022-02-10 20:00:15 -05:00
Rintaro Ishizaki
6f1bca2296 [Test] Disable failing test while investigating
rdar://88581116
2022-02-09 10:10:21 -08:00
Guillaume Lessard
85250c7d26 [test] withContiguousStorage methods on raw buffer types 2022-02-08 18:05:02 -07:00
Guillaume Lessard
eb56bf3a79 [gardening] deallocate buffer after use 2022-02-08 18:05:02 -07:00
Guillaume Lessard
cec7b4b44b [gardening] silence unused variable warning 2022-02-08 18:05:02 -07:00
Guillaume Lessard
8552044dc5 Merge pull request #40828 from glessard/sort-optimization
[nfc] document legacy ABI in the implementation of sort
2022-02-08 16:17:05 -07:00
Guillaume Lessard
b9eed4fa55 [test] add ABI validation for the internals of sort() 2022-02-07 02:52:36 -07:00
Guillaume Lessard
1161f92bd7 Merge pull request #39529 from glessard/se-withMemoryRebound 2022-02-05 09:01:05 -07:00
Kavon Farvardin
13dd3d9ecf have the inferred isolation for properties change only in Swift 6
This patch delays the removal of redundant isolation for inferred
global-actor isolation to Swift 6 too, since we only warn about it
changing in Swift 5. Otherwise, only isolation that is a byproduct
of inference no longer needs an await, which will probably confuse
people.

This change is with respect to SE-327, which argues that the
non-static stored properties of ordinary structs do not need
global-actor isolation.
2022-02-04 14:43:12 -07:00
Kavon Farvardin
19bdfb1172 In a property-wrapper, global-actor isolation remains on wrappedValue
If a struct is a property-wrapper, then global-actor isolation
still applies to the `wrappedValue`, even if it's a stored property.
This is needed in order to support the propagation of global-actor
isolation through the wrapper, even when the programmer has opted
to use a stored property instead of a computed one for the
`wrappedValue`. Since this propagation is a useful pattern, I think
this exception is reasonable.
2022-02-04 14:41:49 -07:00
Guillaume Lessard
72f4e65eba [test] assumingMemoryBound on raw memory buffers 2022-02-03 20:02:33 -07:00
Guillaume Lessard
9f2c4b5959 [test] rebinding raw memory 2022-02-03 20:02:33 -07:00
Guillaume Lessard
69aa3c36bc [test] rebinding typed memory to wider and narrower types 2022-02-03 20:02:33 -07:00
Holly Borla
cd84df54bf [Sema] Don't wrap class types in existential types.
This could happen previously when computing the existential type
for a given archetype. In cases where an archetype is only constrained
to a class, return the class type directly rather than wrapping it
in an existential type.
2022-02-02 13:17:50 -08:00
Pavel Yaskevich
48ffeddbc7 [CSApply] Result coercion check should always use resolved type
`shouldCoerceToContextualType` used `solution.getType(ASTNode)`
which returns a type that has type variables in it. To properly
check whether result type needs a coercion it has to be resolved
first which is done via `solution.getResultType(ASTNode)`.

Resolves: rdar://88285682
2022-01-31 14:42:27 -08:00
Slava Pestov
f33eb17b75 GSB: Remove unsound cycle-breaking hack 2022-01-25 21:28:52 -05:00
Robert Widmann
3165ea5c9c Merge pull request #40971 from CodaFi/hitting-the-stacks
Add a Recursion Breaker to Opaque Type Substitution
2022-01-25 18:18:12 -08:00
Robert Widmann
ad94cbd415 Add a Recursion Breaker to Opaque Type Substitution
The current check in MiscDiagnostics can only handle local 2-cycles as in:

func foo() -> some P { return bar() }
func bar() -> some P { return foo() }

Larger cycles, such as the 3-cycle present in the validation test in this patch cannot be detected without resolving all substitutions up front. Therefore, we take the tact that we can at least prevent the compiler from crashing. At runtime, instead, type resolution will blow out the stack.

The check here is simple: Plumb through a set of opaque type decls that the resolution machinery has already seen, and if we encounter a recursive opaque type substitution bail with the original opaque type.

rdar://87121502
2022-01-25 13:01:39 -08:00
Alejandro Alonso
81ba0cee34 Disable unsupported_opened_existential.swift
disable only for asserts

one more time
2022-01-24 17:22:25 -08:00