Document handling of extensions in ObjCExport
Co-authored-by: Pavel Semyonov <42832629+p7nov@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
786f5e8657
commit
2c00af05b7
+15
-2
@@ -32,7 +32,7 @@ The table below shows how Kotlin concepts are mapped to Swift/Objective-C and vi
|
|||||||
| Method | Method | Method | [note](#top-level-functions-and-properties) [note](#method-names-translation) |
|
| Method | Method | Method | [note](#top-level-functions-and-properties) [note](#method-names-translation) |
|
||||||
| `suspend` -> | `completionHandler:` | | [note](#errors-and-exceptions) |
|
| `suspend` -> | `completionHandler:` | | [note](#errors-and-exceptions) |
|
||||||
| `@Throws fun` | `throws` | `error:(NSError**)error` | [note](#errors-and-exceptions) |
|
| `@Throws fun` | `throws` | `error:(NSError**)error` | [note](#errors-and-exceptions) |
|
||||||
| Extension | Extension | Category member | [note](#category-members) |
|
| Extension | Extension | Category member | [note](#extensions-and-category-members) |
|
||||||
| `companion` member <- | Class method or property | Class method or property | |
|
| `companion` member <- | Class method or property | Class method or property | |
|
||||||
| `null` | `nil` | `nil` | |
|
| `null` | `nil` | `nil` | |
|
||||||
| `Singleton` | `Singleton()` | `[Singleton singleton]` | [note](#kotlin-singletons) |
|
| `Singleton` | `Singleton()` | `[Singleton singleton]` | [note](#kotlin-singletons) |
|
||||||
@@ -151,12 +151,25 @@ Note that the opposite reversed translation is not implemented yet:
|
|||||||
Swift/Objective-C error-throwing methods aren't imported to Kotlin as
|
Swift/Objective-C error-throwing methods aren't imported to Kotlin as
|
||||||
exception-throwing.
|
exception-throwing.
|
||||||
|
|
||||||
### Category members
|
### Extensions and category members
|
||||||
|
|
||||||
Members of Objective-C categories and Swift extensions are imported to Kotlin
|
Members of Objective-C categories and Swift extensions are imported to Kotlin
|
||||||
as extensions. That's why these declarations can't be overridden in Kotlin.
|
as extensions. That's why these declarations can't be overridden in Kotlin.
|
||||||
And the extension initializers aren't available as Kotlin constructors.
|
And the extension initializers aren't available as Kotlin constructors.
|
||||||
|
|
||||||
|
Kotlin extensions to "regular" Kotlin classes are imported to Swift and Objective-C as extensions and category members respectively.
|
||||||
|
Kotlin extensions to other types are treated as [top-level declarations](#top-level-functions-and-properties)
|
||||||
|
with an additional receiver parameter. These types include:
|
||||||
|
|
||||||
|
* Kotlin `String` type
|
||||||
|
* Kotlin collection types and subtypes
|
||||||
|
* Kotlin `interface` types
|
||||||
|
* Kotlin primitive types
|
||||||
|
* Kotlin `inline` classes
|
||||||
|
* Kotlin `Any` type
|
||||||
|
* Kotlin function types and subtypes
|
||||||
|
* Objective-C classes and protocols
|
||||||
|
|
||||||
### Kotlin singletons
|
### Kotlin singletons
|
||||||
|
|
||||||
Kotlin singleton (made with an `object` declaration, including `companion object`)
|
Kotlin singleton (made with an `object` declaration, including `companion object`)
|
||||||
|
|||||||
Reference in New Issue
Block a user