Skip to content

Conversation

@justice-adams-apple
Copy link
Contributor

Cherry picking #65424 in to 5.8

eeckstein and others added 30 commits January 4, 2023 15:51
[5.8] COWOpts: fix a crash in case a buffer "escapes" to a cond_br condition
…orm-by-default-with-old-impl-5.8

[5.8][TypeChecker] Enable result builder AST transform by default
…element (#62777)

* [CSSimplify] fix pattern matching logic which is as part of the enum element for closure

* add test

* Fixed logic to apply to N levels of nesting

* update tests that take into account N levels of nesting.

* fix indentation

* use dynamic variables and uppdate some logic

* Revert "use dynamic variables and uppdate some logic"

This reverts commit 279dc4f.

* fix logic to only see pattern matches

* clean up unnecessary logic

Co-authored-by: Luciano Almeida <[email protected]>

* Clean up unnecessary logic(2)

* remove dropping

* Fix documentation comments to match current context

* clean up unnecessary logic

* remove comments

Co-authored-by: Luciano Almeida <[email protected]>
(cherry picked from commit 29bf82e)
All of the type variables referenced by a type had to be
handled by `inferVariables` otherwise it would to possible
to bring non-representative variable into scope which in
turn later would get simplied into a variable that doesn't
exist in the active scope and solver would crash.

Resolves: rdar://83418797
(cherry picked from commit 4789369)
In some situations `getContextualType` for a contextual type
locator is going to return then empty type. This happens because
e.g. optional-some patterns and patterns with incorrect type don't
have a contextual type for initialization expression but use
a conversion with contextual locator nevertheless to indicate
the purpose. This doesn't affect non-ambiguity diagnostics
because mismatches carry both `from` and `to` types.

Resolves: rdar://problem/103739206
(cherry picked from commit eaf0532)
[5.8][stdlib] Speed up short UTF-16 distance calculations
When a declaration has a structural opaque return type like:

  func foo() -> Bar<some P>

then to mangle that return type `Bar<some P>`, we have to mangle the `some P`
part by referencing its defining declaration `foo()`, which in turn includes
its return type `Bar<some P>` again (this time using a special mangling for
`some P` that prevents infinite recursion). Since we mangle `Bar<some P>`
once as part of mangling the declaration, and we register substitutions for
bound generic types when they're complete, we end up registering the
substitution for `Bar<some P>` twice, once as the return type of the
declaration name, and again as the actual type. This would be fine, except
that the mangler doesn't check for key collisions, and it picks
substitution indexes based on the number of entries in its hash map, so
the duplicated substitution ends up corrupting the substitution sequence,
causing the mangler to produce an invalid mangled name.

Fixing that exposes us to another problem in the remangler: the AST
mangler keys substitutions by type identity, but the remangler
uses the value of the demangled nodes to recognize substitutions.
The mangling for `Bar<current declaration's opaque return type>` can
appear multiple times in a demangled tree, but referring to different
declarations' opaque return types, and the remangler would reconstruct
an incorrect mangled name when this happens. To avoid this, change the
way the demangler represents `OpaqueReturnType` nodes so that they
contain a backreference to the declaration they represent, so that
substitutions involving different declarations' opaque return types
don't get confused.
… views

These simply expose the preexisting internal
`_StringGuts.validate*Index` functions that indexing operations
use to implicitly round indices down to the nearest valid index. (Or, in the case of the encoding views, the nearest scalar boundary.)

Being able to do this as a standalone, explicit, efficient operation
is crucial when implementing some `String` algorithms that need to
work with arbitrary indices.
Instead of just checking the number of breaks in each test case,
expose and check the actual positions of those breaks, too.
This turns _GraphemeBreakingState into a more proper state
machine, although it is only able to recognize breaks in the
forward direction.

The backward direction requires arbitrarily long lookback,
and it currently remains in _StringGuts.
`Unicode._CharacterRecognizer` is a newly exported opaque type that
exposes the stdlib’s extended grapheme cluster breaking facility,
independent of `String`.

This essentially makes the underlying simple state machine public,
without exposing any of the (unstable) Unicode details.

The ability to perform grapheme breaking over, say, the scalars stored
in multiple `String` values can be extremely useful while building
custom text processing algorithms and data structures.

Ideally this would eventually become API, but before proposing this
to Swift Evolution, I’d like to prove the shape of the type in actual
use (and we’ll also need to find better names for its operations).
[5.8][CSClosure] A couple of closure related fixes
[interop][SwiftToCxx] disable the arm64e testing for swift-expected-execution.cpp
Need to use the lowered type instead of the original type.

rdar://103834325
[5.8][Diagnostics] Relax contextual type presence from assertion to a check
[5.8] EscapeUtils: fix a wrong handling of argument indices in walkUpApplyResult
[5.8][stdlib] Expose index rounding entry points
[5.8][stdlib] Export grapheme breaking facility
De/serialize package name in module binary
Resoles rdar://103531218, rdar://103531208
Resolves rdar://103531208
The test is now taking multiple hours to complete on some configurations. Let's disable this while I'm investigating offline.

rdar://103934958
…'Swift' module (#62834)

fix a crash in symbol graph generation caused by an empty SmallVector access while expanding protocol compositions during conformance expansion for extension block symbols

rdar://103322385
[5.8] SILCombine: fix a crash when optimizing keypath-offset-of
… gracefully

`OpaqueUnderlyingTypeChecker` should skip conditional availability
blocks if none of the conditions restrict the current target.

Resolves: rdar://103445432
(cherry picked from commit 3c03449)
@justice-adams-apple
Copy link
Contributor Author

Wrong target branch, my mistake. closing

@AnthonyLatsis
Copy link
Collaborator

@justice-adams-apple The target branch can be changed via the edit button next to the title.

@justice-adams-apple justice-adams-apple deleted the 5.8/cherry-pick-lsan-buildfix branch May 26, 2023 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.