Commit Graph

21 Commits

Author SHA1 Message Date
Slava Pestov
41df661160 AST: Use a builtin conformance for unconditional Copyable/Escapable
This generalizes what we were already doing for classes.
2024-03-07 15:07:47 -05:00
Slava Pestov
aa4a1b2b6e AST: The generic conformance of a specialized conformance is always normal 2024-03-07 12:22:33 -05:00
Slava Pestov
08ba88f71b Sema: Remove deriveConformanceForInvertible() 2024-03-07 12:20:17 -05:00
Slava Pestov
dcea491dbe Sema: Remove inference of conditional Copyable conformance from generic parameters 2024-03-06 22:47:54 -05:00
Joe Groff
fe7049ed13 SIL: More accurate for type lowering whether a type is trivial based on conditional Copyable requirements.
We want a conditionally-copyable type to still be classified as trivial in cases
where it's bitwise-copyable, has a trivial deinit, and is Copyable. The previous
implementation here only checked at the declaration level whether a type was
Copyable or not; get a more accurate answer by consulting the combination
of information in the substituted type and abstraction pattern we have
available during type lowering so that we classify definitely-copyable substitutions
of a conditionally-copyable type as trivial. Should fix rdar://123654553 and
rdar://123658878.
2024-02-27 15:01:20 -08:00
Pavel Yaskevich
b643cd8fb6 [AST/Sema] NonCopyableGenerics: Remove all but one direct use of getMarking(...) 2024-02-16 17:55:52 -08:00
Kavon Farvardin
8a7fd33101 Merge pull request #71560 from kavon/ncgenerics-test-fixes-kavon-v10
Ncgenerics test fixes kavon v10
2024-02-13 11:59:54 -08:00
Kavon Farvardin
3a45393e17 NCGenerics: break cycle with SuperclassTypeRequest
With NoncopyableGenerics, we get a cycle involving
`SuperclassTypeRequest` with this program:

  public struct RawMarkupHeader {}
  final class RawMarkup: ManagedBuffer<RawMarkupHeader, RawMarkup> { }

Because we generally don't support the following kind of relationship:

  class Base<T: P>: P {}
  class Derived: Base<Derived> {}

This commit works around the root-cause, which is that Derived's
synthesized conformance to Copyable gets superceded by the inherited one
from Base. Instead of recording conformances in the ConformanceLookup
table at all, create builtin conformances on the fly, since classes
cannot be conditionally Copyable or Escapable.
2024-02-13 09:19:12 -08:00
Kavon Farvardin
98e6c7b935 ConformanceLookup: filter ReferenceStorageType
There's a few uses of ReferenceStorageTypes being substituted for
generic parameters, at least in the test suite, such as
`Optional<@sil_unmanaged ..>` and just plain `<@sil_unowned ..>`.

Before, conformance lookup could (and did) give bogus answers when asked
 if the type satisfies any conformance requirements. Now with
 NoncopyableGenerics, we will interpret such conformance lookups as
 being asked of the referent type, ignoring the SIL ownership wrapping
 it.
2024-02-13 09:19:12 -08:00
Pavel Yaskevich
0e75312450 [AST] Handle pack element types in LookupConformanceInModuleRequest 2024-02-12 16:43:18 -08:00
Kavon Farvardin
32a0ea8734 ConformanceLookup: catch ReferenceStorageType
While this doesn't provde defence agianst incorrect conformance
responses in the general case, it should flush out a lot of incorrect
ones.
2024-02-11 20:40:03 -08:00
Kavon Farvardin
e913712bf5 Sema: drop @lvalue when building tuple conformance 2024-02-11 20:40:03 -08:00
Kavon Farvardin
d5eb76e2fb NCGenerics: remove optimistic assertion
I thought it might be impossible to recursively lookupConformance of
Copyable, unlike for Sendable. Turns out there are still situations
where it can happen, that aren't invalid.

This alone fixes `ClangImporter/objc_bridging_generics.swift` and will
help reveal any invalid request cycles.
2024-02-11 20:40:03 -08:00
Kavon Farvardin
5b36a5f724 NCGenerics: back-out @noescape being ~Escapable
I thought this would be simple to add a check for this, but it turns out
that a more complete refactoring that eliminates `isNoEscape` in favor
of `isEscapable` is most likely needed.
2024-02-11 12:54:35 -08:00
Slava Pestov
6027bf46a6 AST: Simplify collectExistentialConformances() 2024-02-10 09:36:37 -05:00
Kavon Farvardin
70266b589a NCGenerics: avoid UGT's in queries
An unbound generic type is not something that should end up in
`isNoncopyable` or `isEscapable` queries because there are no
conformances for such a type; it's unbound!

fixes test/Constraints/closures.swift
2024-02-06 08:15:26 -08:00
Slava Pestov
d7372396cb AST: Move TypeBase::isSendableType() to ConformanceLookup.cpp 2024-02-05 11:25:57 -05:00
Slava Pestov
d981cf3b77 Sema: De-requestify TypeBase::isNoncopyable() and TypeBase::isEscapable()
And consolidate the logic in ConformanceLookup.cpp.
2024-02-05 11:25:57 -05:00
Kavon Farvardin
b4985f7fde [NFC] replace canBeNoncopyable
First, "can have an absence of Copyable" is a rather confusing notion,
so the query is flipped to "can be Copyable". Next, it's more robust to
ask if a conformance exists for the TypeDecl to answer that question,
rather than trying to replicate what happens within that conformance
lookup.

Also renames `TypeDecl::isEscapable` to match.
2024-01-23 22:42:38 -08:00
Slava Pestov
9835a6f0ba AST: Assert that checkConformance() receives a fully-substituted type 2024-01-18 16:15:02 -05:00
Slava Pestov
f9e7181d46 AST: Split off ConformanceLookup.cpp from Module.cpp 2024-01-18 12:32:04 -05:00