Commit Graph

126 Commits

Author SHA1 Message Date
Nate Chandler
4cb8453d6a [SILGen] Used formal type when bridging continuation arguments.
Address a FIXME where lowered types rather than formal types were used
when converting from objc to native types which resulted in a failure to
convert block types.
2021-07-24 14:25:26 -07:00
Robert Widmann
a0615e9848 [NFC] Use GenericSIgnature::getGanonicalSignature Where Possible 2021-07-22 23:27:06 -07:00
Hamish Knight
d4c25f55c2 [AST] Reject GenericFunctionType in TypeBase::getTypeOfMember
Remove the default argument for the `memberType`
parameter and enforce that GenericFunctionType is
not passed. Also add a defaulted overload for the
property case, as they should never have a
GenericFunctionType interface type.
2021-07-20 14:11:31 +01:00
Slava Pestov
76a5fd9bc6 SIL: Allow lowering Optional<T> against a nested type of an opaque result type
Only the root archetype is a OpaqueTypeArchetypeType; the nested types are
NestedArchetypeType. Use the correct predicate here.

Also remove a dead check in tuple lowering; the isa<OpaqueTypeArchetypeType>()
check is dominated by isTypeParameterOrOpaqueArchetype() which is always
true if isa<OpaqueTypeArchetypeType>() is true anyway.

Fixes rdar://problem/79597666.
2021-07-13 18:36:25 -04:00
Saleem Abdulrasool
25f437e17d mark some switches as covered (NFCI)
Unfortunately, MSVC does not detect covered switches as clang.  Mark
some of the switches as covered to avoid an unnecessary warning from
MSVC.
2021-06-05 15:30:25 -07:00
Slava Pestov
a0c215b7d2 SIL: A tuple type can be lowered with an opaque result type as the original type
AbstractionPattern::matchesTuple() is used by various assertions, and
the condition was too strict. Relax the condition to fix an assertion
failure in the case where an opaque result type has a tuple as its
underlying type.

Fixes https://bugs.swift.org/browse/SR-14426 / rdar://problem/76057095.
2021-04-13 14:46:58 -04:00
Egor Zhdan
7141ae24cf C++ Interop: import call operators
This change adds support for calling `operator()` from Swift code.

As the C++ interop manifesto describes, `operator()` is imported into Swift as `callAsFunction`.
2021-03-02 21:13:57 +03:00
Joe Groff
4bb49ba521 SILGen/ClangImporter: Handle async imports with a boolean error flag argument.
Import APIs with the `swift_async_error` attribute in `zero_argument` or `nonzero_argument`
modes by checking the corresponding boolean argument to indicate the error status, instead of
treating it as part of the result tuple. rdar://70594666
2021-02-19 17:31:09 -08:00
Joe Groff
eea3a6c27f SILGen: Handle pseudogeneric completion-handler-based async APIs.
Plumb generic signatures through the codegen for invoking foreign APIs as async, so that we
correctly handle APIs declared on ObjC lightweight generic classes. rdar://74361267
2021-02-16 16:05:04 -08:00
Joe Groff
6db85203db SIL: Abstraction pattern support for multiple foreign async returns.
An ObjC API maybe imported as async that had multiple non-error arguments to
its completion handler, which we treat in Swift as returning a tuple. Use a new
form of abstraction pattern to represent this return type, to maintain the
correct relation between individual tuple elements and the Clang block parameter
types they map to.
2020-11-12 16:53:21 -08:00
Doug Gregor
f30778ff8c [async type lowering] Handle Void return from @objc async methods. 2020-10-29 17:03:21 -07:00
Joe Groff
577f83a260 SIL: Type lowering for imported ObjC async decls.
When lowering the type for `@objc` entry points of async declarations, restore
the original ObjC signature with the completion handler argument in the lowered
SIL type.
2020-10-27 09:00:45 -07:00
Varun Gandhi
abce3de41c [NFC] Add some TODO comments for cleanup. 2020-09-24 00:38:45 -07:00
Slava Pestov
61104cf9c6 SIL: Clean up AbstractionPattern::getLayoutConstraint() 2020-08-15 03:09:12 -04:00
Michael Forster
26358c4588 Import member operator functions as static members (#32293)
This adds support to `ClangImporter` to import C++ member function operators as static methods into Swift, which is part of SR-12748.

The left-hand-side operand, which gets passed as the `this` pointer to the C++ function is represented as an additional first parameter in the Swift method. It gets mapped back in SILGen.

Two of the tests are disabled on Windows because we can't yet call member functions correctly on Windows (SR-13129).
2020-07-03 11:06:22 +02:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Marcel Hlopko
e293330563 [CxxInterop] Import C++ references. (#31784) 2020-05-15 10:42:37 +02:00
Saleem Abdulrasool
6bf7593fd5 Revert "[CxxInterop] Import C++ references." (#31777) 2020-05-14 10:43:22 +02:00
Marcel Hlopko
30b5fd52e8 [CxxInterop] Import C++ references. (#31702) 2020-05-13 13:34:28 +02:00
Robert Widmann
c70dce0226 Merge pull request #31515 from AnthonyLatsis/assert-type-param-requires-class
AST: Assert we were given a type parameter in GenericSignatureImpl::requiresClass
2020-05-09 09:13:41 -07:00
Dmitri Gribenko
68bc265190 Correctly print an AbstractionPattern with C++ method types
Printing an AbstractionPattern with a CXXMethodType would previously
fail because the code would try to get a Clang type instead. I could
add an if statement but instead, I split off the cases related to C++
method type into a new block, as that seems to follow the pattern in
AbstractionPattern::print().
2020-05-08 13:27:49 +02:00
Anthony Latsis
ab1ca1d6f7 AST: Assert we were given a type parameter in GenericSignatureImpl::requiresClass 2020-05-03 16:46:52 +03:00
Joe Groff
aa8a07aec9 Merge pull request #31347 from jckarter/opaque-structural-type-reabstraction
SILGen: Fix some issues with tuple/metatype/function reabstraction against opaque return types.
2020-04-29 08:17:28 -07:00
Joe Groff
65a2f92de5 SILGen: Fix some issues with tuple/metatype/function reabstraction against opaque return types.
- Getting a tuple element from an opaque return type `AbstractionPattern` should produce another
  opaque abstraction pattern.
- Relax an assertion failure when lowering metatypes against opaque return type abstraction
  patterns.

Fixes rdar://problem/58787252.
2020-04-27 14:49:34 -07:00
Saleem Abdulrasool
fa46f7131c sprinkle some llvm_unreachable for MSVC (NFC)
MSVC does not realize that the switch is exhaustive and requires that
the path is explicitly marked as unreachable.  This silences the C4715
warning ("not all control paths return a value").
2020-04-24 18:59:07 -07:00
Michael Gottesman
e1a19e4173 [sil] Split library into subfolders, while still building as a single library still.
Specifically, I split it into 3 initial categories: IR, Utils, Verifier. I just
did this quickly, we can always split it more later if we want.

I followed the model that we use in SILOptimizer: ./lib/SIL/CMakeLists.txt vends
 a macro (sil_register_sources) to the sub-folders that register the sources of
 the subdirectory with a global state variable that ./lib/SIL/CMakeLists.txt
 defines. Then after including those subdirs, the parent cmake declares the SIL
 library. So the output is the same, but we have the flexibility of having
 subdirectories to categorize source files.
2020-03-30 11:01:00 -07:00