Enable -Xobjc-generics by default
This commit is contained in:
committed by
SvyatoslavScherbina
parent
4787be95f5
commit
1f397abaaf
+14
-15
@@ -232,21 +232,6 @@ generics defined on classes to help provide additional type information to the c
|
||||
Generic feature support for Objc and Swift differ from Kotlin, so the translation will inevitably lose some information,
|
||||
but the features supported retain meaningful information.
|
||||
|
||||
### To Use
|
||||
|
||||
Generics are currently not enabled by default. To have the framework header written with generics, add an experimental
|
||||
flag to the compiler config:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" data-highlight-only>
|
||||
|
||||
```kotlin
|
||||
binaries.framework {
|
||||
freeCompilerArgs += "-Xobjc-generics"
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
#### Limitations
|
||||
|
||||
Objective-C generics do not support all features of either Kotlin or Swift, so there will be some information lost
|
||||
@@ -327,6 +312,20 @@ In Kotlin you can provide upper bounds for a generic type. Objective-C also supp
|
||||
in more complex cases, and is currently not supported in the Kotlin - Objective-C interop. The exception here being a non-null
|
||||
upper bound will make Objective-C methods/properties non-null.
|
||||
|
||||
### To disable
|
||||
|
||||
To have the framework header written without generics, add the flag to the compiler config:
|
||||
|
||||
<div class="sample" markdown="1" theme="idea" data-highlight-only>
|
||||
|
||||
```kotlin
|
||||
binaries.framework {
|
||||
freeCompilerArgs += "-Xno-objc-generics"
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
## Casting between mapped types
|
||||
|
||||
When writing Kotlin code, an object may need to be converted from a Kotlin type
|
||||
|
||||
@@ -218,7 +218,7 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
put(COVERAGE, arguments.coverage)
|
||||
put(LIBRARIES_TO_COVER, arguments.coveredLibraries.toNonNullList())
|
||||
arguments.coverageFile?.let { put(PROFRAW_PATH, it) }
|
||||
put(OBJC_GENERICS, arguments.objcGenerics)
|
||||
put(OBJC_GENERICS, !arguments.noObjcGenerics)
|
||||
|
||||
put(LIBRARIES_TO_CACHE, parseLibrariesToCache(arguments, configuration, outputKind))
|
||||
val libraryToAddToCache = parseLibraryToAddToCache(arguments, configuration, outputKind)
|
||||
|
||||
@@ -236,8 +236,8 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value = "-Xcoverage-file", valueDescription = "<path>", description = "Save coverage information to the given file")
|
||||
var coverageFile: String? = null
|
||||
|
||||
@Argument(value = "-Xobjc-generics", description = "Enable experimental generics support for framework header")
|
||||
var objcGenerics: Boolean = false
|
||||
@Argument(value = "-Xno-objc-generics", description = "Disable generics support for framework header")
|
||||
var noObjcGenerics: Boolean = false
|
||||
|
||||
@Argument(value="-Xoverride-clang-options", valueDescription = "<arg1,arg2,...>", description = "Explicit list of Clang options")
|
||||
var clangOptions: Array<String>? = null
|
||||
|
||||
@@ -3788,7 +3788,6 @@ if (isAppleTarget(project)) {
|
||||
}
|
||||
|
||||
extraOpts "-Xembed-bitcode-marker"
|
||||
extraOpts "-Xobjc-generics"
|
||||
extraOpts "-Xemit-lazy-objc-header=$lazyHeader"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
@@ -3810,7 +3809,7 @@ if (isAppleTarget(project)) {
|
||||
dependsOn ":${target}CrossDistRuntime", ':commonDistRuntime', ':distCompiler'
|
||||
}
|
||||
|
||||
extraOpts "-Xembed-bitcode-marker", "-Xobjc-generics"
|
||||
extraOpts "-Xembed-bitcode-marker"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
@@ -3832,7 +3831,6 @@ if (isAppleTarget(project)) {
|
||||
}
|
||||
|
||||
extraOpts "-Xembed-bitcode"
|
||||
extraOpts "-Xobjc-generics"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user