Commit Graph

7859 Commits

Author SHA1 Message Date
Nate Cook
e2a394b435 Disable String breadcrumbs tests for freestanding stdlib (#42000) 2022-03-25 07:46:22 -05:00
Anthony Latsis
38e48ac15d TypeWitnessSystem: Disable by default 2022-03-25 08:45:54 +03:00
Slava Pestov
7d0215e6e0 RequirementMachine: Tweak rule limit non-termination heuristic
Add the length of the longest *initial* rule to the rule length limit
before comparing.

Fixes https://bugs.swift.org/browse/SR-16024.
2022-03-25 01:00:49 -04:00
Kuba (Brecka) Mracek
e48cd332ff Mark validation-test/stdlib/StringBreadcrumbs.swift as UNSUPPORTED: freestanding (#41991) 2022-03-24 06:57:23 -07:00
Pavel Yaskevich
9d413b3668 Merge pull request #41939 from xedin/rdar-87407899
[Diagnostics] Fix out-of-bounds index while fixing argument mismatch
2022-03-22 22:46:54 -07:00
Pavel Yaskevich
b6c2b3edff [Diagnostics] Fix out-of-bounds index while fixing argument mismatch
Although the overload choice has two parameters, it doesn't
mean that there are exactly two arguments passed to it.

Resolves: rdar://87407899
2022-03-21 14:57:50 -07:00
Alejandro Alonso
908161136d Renable StringMemoryTest 2022-03-21 13:33:42 -07:00
Alex Hoppen
458ce70245 Merge pull request #41633 from ahoppen/pr/solver-based-global-completions
[CodeCompletion] Migrate expression completions to solver-based
2022-03-21 20:02:47 +01:00
Alex Hoppen
e2a62f1a60 [CodeCompletion] Migrate expression completions to solver-based 2022-03-21 13:00:33 +01:00
Kavon Farvardin
9b1fcedf2f backtrack on part of SE-327 dealing with default-value exprs
This effectively reverts 6823744779

The blanket removal of isolation in default-value expressions had
unintented consequences for important workflows. It's still
a problem that needs to be addressed, but we need to be more precise
about the problematic situations.
2022-03-18 18:41:05 -07:00
Pavel Yaskevich
fc83c6fa68 [Diagnostics] Ignore type mismatches related to synthesized arguments
The main issue is the absence of the argument itself.

Resolves: rdar://90419017
2022-03-18 14:54:15 -07:00
David Smith
cb082e185c Merge pull request #41866 from Catfish-Man/what-a-crumb-y-optimization
Vectorize UTF16 offset calculations
2022-03-18 09:53:55 -07:00
Alex Hoppen
1680ec3f08 Merge pull request #41853 from ahoppen/pr/add-fixed-test-cases
[CodeCompletion] Add test cases
2022-03-18 17:09:11 +01:00
Slava Pestov
e6d1ef9f6d Merge pull request #41868 from slavapestov/rqm-opaque-archetypes
RequirementMachine: Opaque archetype support (sort of)
2022-03-17 23:06:24 -04:00
nate-chandler
b2588656d8 Merge pull request #41478 from nate-chandler/lexical_lifetimes/destroy-hoisting/disable
[SILOpt] Disabled DestroyHoisting.
2022-03-17 17:26:11 -07:00
Slava Pestov
2f727d6b47 RequirementMachine: Opaque archetype support (sort of)
Complete support is behind a flag, because it can result in a non-convergent
rewrite system if the opaque result type has a recursive conformance of its
own (eg, `some View` for SwiftUI's View protocol).

Without the flag, it's good enough for simple examples; you just can't have
a requirement that mentions a nested type of a type parameter equated to
the concrete type.

Fixes rdar://problem/88135291, https://bugs.swift.org/browse/SR-15983.
2022-03-17 17:45:59 -04:00
Alex Hoppen
17ac201b29 Merge pull request #39373 from ahoppen/pr/solver-based-arg-completion
[CodeCompletion] Migrate argument position completion to the solver-based implementation
2022-03-17 22:41:59 +01:00
David Smith
eaf3f316ec Vectorize UTF16 offset calculations 2022-03-17 14:18:21 -07:00
Slava Pestov
7390f7d8bc Merge pull request #41842 from slavapestov/gsb-relax-verify-check
GSB: Relax -requirement-machine-protocol-signatures=verify check a little
2022-03-17 17:07:00 -04:00
Pavel Yaskevich
10324641f9 [TypeChecker] NFC: Restrict multi-statement closure + simd test-case to macOS
Resolves: rdar://90445018
2022-03-17 12:10:31 -07:00
Nate Chandler
979196cb16 [Test] For disabling destroy hoisting. 2022-03-17 12:06:53 -07:00
Alex Hoppen
f538d33e5f [CodeCompletion][Sema] Migrate CallArgurment position completion to the solver-based implementation
This hooks up call argument position completion to the typeCheckForCodeCompletion API to generate completions from all the solutions the constraint solver produces (even those requiring fixes), rather than relying on a single solution being applied to the AST (if any).

Co-authored-by: Nathan Hawes <nathan.john.hawes@gmail.com>
2022-03-17 15:15:54 +01:00
Alex Hoppen
4af49e3479 [CodeCompletion] Add test cases
Add test cases for three issues that have been fixed on main
- SR-14693
- SR-14704
- SR-14739
2022-03-17 09:03:17 +01:00
Slava Pestov
f518c80f4b Move validation-test/compiler_crashers_2/sr8968.swift to test/Generics/ since it passes with the Requirement Machine 2022-03-16 23:23:10 -04:00
Guillaume Lessard
b17b1a9d04 Merge pull request #41836 from glessard/sr15994
[stdlib] tolerate empty source buffers in `UMRBP.copyMemory`
2022-03-16 16:24:44 -06:00
Pavel Yaskevich
839b483f1b Merge pull request #41824 from xedin/rdar-85516390
[CSDiagnostics] Contextual failure could result in optional chain hav…
2022-03-16 10:33:39 -07:00
Guillaume Lessard
cc60db78e1 [test] validate behaviour when copying from an empty buffer 2022-03-16 10:06:20 -06:00
Robert Widmann
1afdb47271 Un-XFAIL Stdlib Validation Test 2022-03-15 21:07:57 -07:00
Pavel Yaskevich
5331e276d5 Merge pull request #41730 from xedin/se-0326-solve-pattern-bindings-via-conjunctions
[SE-0326] Re-enable multi-statement closure inference by default
2022-03-15 13:21:03 -07:00
Pavel Yaskevich
6fb5c3042b [CSDiagnostics] Contextual failure could result in optional chain having non-optional type
Fixes a crash during diagnostics by not assuming that optional chain
would always produce an optional type, which is not true because in
error scenarios it could get assigned an invalid type from context.

Resolves: rdar://85516390
2022-03-15 13:14:48 -07:00
Alejandro Alonso
27e6241a41 Merge pull request #41389 from Azoy/fix-indic-sequences
[stdlib] Fix backwards count of Indic graphemes
2022-03-14 12:08:21 -07:00
Slava Pestov
305a1e42b6 RequirementMachine: Update some tests to pass with -requirement-machine-inferred-signatures=verify 2022-03-14 12:33:18 -04:00
Slava Pestov
6a74ad7065 RequirementMachine: Drop GSB compatibility hack involving ErrorTypes
Another hack we can remove now that 'verify' mode skips checking if
there was a conflict.
2022-03-14 12:33:18 -04:00
Slava Pestov
226d2c89a0 RequirementMachine: Disable verification in a few highly-invalid compiler_crashers where it's not useful 2022-03-14 12:33:18 -04:00
Slava Pestov
a61f67a0e8 RequirementMachine: Hack to allow protocol typealiases to appear in associated type inheritance clauses
If you have something like

    protocol P {
      typealias A = C

      associatedtype T : A
    }

    class C {}

Then ::Structural resolution of 'A' in the inheritance clause will
produce a DependentMemberType 'Self.A'. Check for this case and
attempt ::Interface resolution to get the correct underlying type.

Fixes rdar://problem/90219229.
2022-03-14 12:33:18 -04:00
nate-chandler
58b414d211 Merge pull request #41781 from nate-chandler/lexical_lifetimes/di-moves-end_borrow
[DI] Fixup alloc_box borrow scope ends.
2022-03-11 13:15:47 -08:00
Nate Chandler
05e643ba04 [DI] Fixup alloc_box borrow scope ends.
After https://github.com/apple/swift/pull/40793, alloc_boxes all have
their lifetimes protected by a lexical borrow scope.  In that PR, DI had
been updated to see through begin_borrow instructions from a project_box
to a mark_uninitialized.  It did not, however, correct the end_borrow
instructions when destroy_values of mark_uninitializeds were replaced
with destroy_addrs of project_boxes.  That is done here.

In a bit more detail, in the following context

    %box = alloc_box
    %mark_uninit = mark_uninitialized %box
    %lifetime = begin_borrow [lexical] %mark_uninit
    %proj_box = project_box %lifetime

When it is not statically known whether a field is initialized, we are
replacing the instruction

      // before
      destroy_value %mark_uninit
      // after

with the following diamond

      // before
      %initialized = load
      cond_br %initialized, yes, no

    yes:
      destroy_addr %proj_box
      br bottom

    no:
      br bottom

    bottom:
      dealloc_box %box
      br keep_going

    keep_going:
      // after

Doing so is problematic, though, because by SILGen construction the
destroy_value is always preceded by an end_borrow:

      end_borrow %lifetime
      destroy_value %mark_uninit

Previously, that end_borrow remained above the

      %initialized = load

instruction in the above.  That was invalid because the the newly
introduced

      destroy_addr %proj_box

was a use of the borrow scope (%proj_box is a projection of the
begin_borrow) and consequently must be within the borrow scope.

Note also that it would not be sufficient to simply emit the diamond
before the end_borrow.  The end_borrow must come before the destruction
of the value whose lifetime it is protecting (%box), and the diamond
contains the instruction to destroy that value (dealloc_box) in its
bottom block.

To resolve this issue, just move the end_borrow instruction from where
it was to before the dealloc box.  (This is actually done by moving it to
the top of the diamond's "continue" block prior to the emission of that
dealloc_box instruction.)

rdar://89984216
2022-03-11 08:29:34 -08:00
Slava Pestov
1ff3fda53f Merge pull request #41757 from slavapestov/protocol-self-reference-fixes
Sema: Fix a couple of issues related to variance of protocol 'Self'
2022-03-09 23:07:46 -05:00
Slava Pestov
599bb79933 Sema: Generalize the 'invariant Self requirement' check to handle a related case
There are three kinds of invariant 'Self' uses here:

- 'Self' appears as the left hand side of a same-type requirement between type parameters
- 'Self' appears as a structural component of the right hand side of a concrete type requirement
- 'Self' appears as a structural component of the right hand side of a superclass requirement

My previous fix only handled the first case. Generalize it to handle all three.

Fixes rdar://problem/74944514.
2022-03-09 18:50:14 -05:00
Robert Widmann
512ebc52a6 Merge pull request #41743 from CodaFi/existential-dread 2022-03-09 15:12:29 -08:00
Robert Widmann
0aead2818c Add a Compiler Crasher
The problem is that we currenly cannot represent the generic signature of
values of type `any P<some P>`. This is because we wind up producing

<Self where Self : P, Self.T == (some P)>

What we'd like to do in the future is erase the errant (some P) with
a fresh generic parameter and keep a substitution map on the side that
records the opaque type constraint. Something like

<Self, Opaque1 where Self : P, Opaque1 : P, Self.T == Opaque1> where Opaque1 == (some P)
2022-03-09 11:49:38 -08:00
eeckstein
44a9753eea Merge pull request #41703 from eeckstein/simplify-linkage
Stabilize and simplify SIL linkage and serialization
2022-03-09 18:48:14 +01:00
Hamish Knight
187e6f3472 [test] Disable ArrayTrapsObjC.swift for backdeployment
rdar://89821303
2022-03-09 16:13:00 +00:00
Erik Eckstein
6a020f8f15 Stabilize and simplify SIL linkage and serialization
The main point of this change is to make sure that a shared function always has a body: both, in the optimizer pipeline and in the swiftmodule file.
This is important because the compiler always needs to emit code for a shared function. Shared functions cannot be referenced from outside the module.
In several corner cases we missed to maintain this invariant which resulted in unresolved-symbol linker errors.

As side-effect of this change we can drop the shared_external SIL linkage and the IsSerializable flag, which simplifies the serialization and linkage concept.
2022-03-09 15:28:05 +01:00
Pavel Yaskevich
5c3fb222e1 [CSClosure] Explode pattern binding declarations into conjunctions
`one-way` constraints disable some optimizations related to component
selection because they imply strict ordering. This is a problem for
multi-statement closures because variable declarations could involve
complex operator expressions that rely on aforementioned optimizations.

In order to fix that, let's move away from solving whole pattern binding
declaration into scheme that explodes such declarations into indvidual
elements and inlines them into a conjunction.

For example:

```
let x = 42, y = x + 1, z = (x, test())
```

Would result in a conjunction of three elements:

```
x = 42
y = x + 1
z = (x, test())
```

Each element is solved indepedently, which eliminates the need for
`one-way` constraints and re-enables component selection optimizations.
2022-03-08 21:37:40 -08:00
Pavel Yaskevich
966f58f044 [Tests] NFC: Adjust all the test-cases improved by multi-statement inference 2022-03-08 01:13:44 -08:00
Holly Borla
70197c8557 Merge pull request #41693 from hborla/any-in-diagnositcs
[Diagnostics] Print `any` in diagnostics.
2022-03-06 10:09:12 -08:00
Holly Borla
12459cff80 [Diagnostics] Print 'any' in diagnostic arguments. 2022-03-05 14:26:45 -08:00
Jonathan Grynspan
5d729845ce Merge pull request #41669 from grynspan/jgrynspan/SR-15938-imagebase-linkage
[SR-15938] Error when referencing #dsohandle in a Swift test on Windows
2022-03-04 16:35:05 -05:00
Jonathan Grynspan
34a4d66481 [SR-15938] Error when referencing #dsohandle in a Swift test on Windows 2022-03-04 12:25:49 -05:00