File tree 4 files changed +10
-19
lines changed
reactive/kotlinx-coroutines-reactive/src
ui/kotlinx-coroutines-android
4 files changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -82,16 +82,6 @@ public suspend fun <T> Publisher<T>.awaitSingle(): T = awaitOne(Mode.SINGLE)
82
82
83
83
// ------------------------ private ------------------------
84
84
85
- // ContextInjector service is implemented in `kotlinx-coroutines-reactor` module only.
86
- // If `kotlinx-coroutines-reactor` module is not included, the list is empty.
87
- private val contextInjectors: Array <ContextInjector > =
88
- ServiceLoader .load(ContextInjector ::class .java, ContextInjector ::class .java.classLoader).iterator().asSequence().toList().toTypedArray() // R8 opto
89
-
90
- private fun <T > Publisher<T>.injectCoroutineContext (coroutineContext : CoroutineContext ) =
91
- contextInjectors.fold(this ) { pub, contextInjector ->
92
- contextInjector.injectCoroutineContext(pub, coroutineContext)
93
- }
94
-
95
85
private enum class Mode (val s : String ) {
96
86
FIRST (" awaitFirst" ),
97
87
FIRST_OR_DEFAULT (" awaitFirstOrDefault" ),
Original file line number Diff line number Diff line change @@ -140,13 +140,14 @@ private class ReactiveSubscriber<T : Any>(
140
140
141
141
// ContextInjector service is implemented in `kotlinx-coroutines-reactor` module only.
142
142
// If `kotlinx-coroutines-reactor` module is not included, the list is empty.
143
- private val contextInjectors: List <ContextInjector > =
144
- ServiceLoader .load(ContextInjector ::class .java, ContextInjector ::class .java.classLoader).toList()
143
+ private val contextInjectors: Array <ContextInjector > =
144
+ ServiceLoader .load(ContextInjector ::class .java, ContextInjector ::class .java.classLoader)
145
+ .iterator().asSequence()
146
+ .toList().toTypedArray() // R8 opto
145
147
146
- private fun <T > Publisher<T>.injectCoroutineContext (coroutineContext : CoroutineContext ) =
148
+ internal fun <T > Publisher<T>.injectCoroutineContext (coroutineContext : CoroutineContext ) =
147
149
contextInjectors.fold(this ) { pub, contextInjector -> contextInjector.injectCoroutineContext(pub, coroutineContext) }
148
150
149
-
150
151
/* *
151
152
* Adapter that transforms [Flow] into TCK-complaint [Publisher].
152
153
* [cancel] invocation cancels the original flow.
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ task runR8(type: RunR8Task, dependsOn: 'jar'){
77
77
inputConfig = file(' testdata/r8-test-rules.pro' )
78
78
}
79
79
80
- task runR8NoOptim (type : RunR8Task , dependsOn : ' jar' ){
80
+ task runR8NoOptim (type : RunR8Task , dependsOn : ' jar' ) {
81
81
outputDex = unOptimizedDexDir
82
82
inputConfig = file(' testdata/r8-test-rules-no-optim.pro' )
83
83
}
@@ -103,4 +103,4 @@ tasks.withType(dokka.getClass()) {
103
103
url = new URL (" https://developer.android.com/reference/" )
104
104
packageListUrl = projectDir. toPath(). resolve(" package.list" ). toUri(). toURL()
105
105
}
106
- }
106
+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class R8ServiceLoaderOptimizationTest : TestBase() {
16
16
private val r8DexNoOptim = File (System .getProperty(" noOptimDexPath" )!! ).asDexFile()
17
17
18
18
@Test
19
- fun noServiceLoaderCalls () {
19
+ fun testNoServiceLoaderCalls () {
20
20
val serviceLoaderInvocations = r8Dex.types.any {
21
21
it.type == " Ljava/util/ServiceLoader;"
22
22
}
@@ -28,7 +28,7 @@ class R8ServiceLoaderOptimizationTest : TestBase() {
28
28
}
29
29
30
30
@Test
31
- fun androidDispatcherIsKept () {
31
+ fun testAndroidDispatcherIsKept () {
32
32
val hasAndroidDispatcher = r8DexNoOptim.classes.any {
33
33
it.type == " Lkotlinx/coroutines/android/AndroidDispatcherFactory;"
34
34
}
@@ -38,7 +38,7 @@ class R8ServiceLoaderOptimizationTest : TestBase() {
38
38
39
39
@Test
40
40
@Ignore
41
- fun noOptimRulesMatch () {
41
+ fun testNoOptimRulesMatch () {
42
42
val paths = listOf (
43
43
" META-INF/com.android.tools/proguard/coroutines.pro" ,
44
44
" META-INF/proguard/coroutines.pro" ,
You can’t perform that action at this time.
0 commit comments