kotlinx.coroutines 라이브러리에 종속성이 있는 코드에서 kotlin.coroutine.coroutineContext 프로퍼티가 사용된 경우를 보고합니다.

코드에 kotlin.coroutine.coroutineContextkotlinx.coroutines.CoroutineScope.coroutineContext가 동시에 있으면 혼동되고 잠재적인 버그가 발생할 수 있습니다.

kotlinx.coroutines 라이브러리는 명시적 충돌이 없더라도 선호되어야 할 더 명확한 대안으로 currentCoroutineContext() 함수를 제공합니다.

자세한 내용은 kotlin.coroutine.coroutineContextkotlinx.coroutines.currentCoroutineContext에 대한 문서를 참조하세요.

예:


  suspend fun getCurrentJob(): Job? {
    return coroutineContext[Job]
  }

빠른 수정을 적용한 후:


  suspend fun getCurrentJob(): Job? {
    return currentCoroutineContext()[Job]
  }