Repository: expo/expo
File: packages/expo-modules-core/android/src/main/java/expo/modules/kotlin/modules/Module.kt (Kotlin)

Code before:
package expo.modules.kotlin.modules

import android.os.Bundle
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.runtime.Runtime
import expo.modules.kotlin.convertToString
import expo.modules.kotlin.providers.AppContextProvider
import expo.modules.kotlin.tracing.trace
import expo.modules.kotlin.types.Enumerable
import expo.modules.kotlin.types.TypeConverterProvider
import kotlinx.coroutines.CoroutineScope
import java.lang.ref.WeakReference

abstract class Module : AppContextProvider {
  @Suppress("PropertyName")
  internal var _appContextHolder: WeakReference<AppContext> = WeakReference(null)

  val runtime: Runtime
    get() = requireNotNull(_appContextHolder.get()?.hostingRuntimeContext) { "The module wasn't created! You can't access the hosting runtime context." }

  @Deprecated(
    message = "Use 'runtime' property instead.",
    replaceWith = ReplaceWith("runtime")
  )
  val runtimeContext: Runtime
    get() = runtime

  // region AppContextProvider

  override val appContext: AppContext
    get() = requireNotNull(_appContextHolder.get()) {
      "You attempted to access the app context before the module was created. " +
        "Defer accessing the context until after the module initializes."
    }

  // endregion

  private val moduleEventEmitter by lazy { appContext.eventEmitter(this) }

  val registry
    get() = appContext.registry

  @PublishedApi
  internal lateinit var coroutineScopeDelegate: Lazy<CoroutineScope>

Review comment (suggestion):
```suggestion
    get() = requireNotNull(_appContextHolder.get()?.hostingRuntimeContext) { "The module wasn't created! You can't access the hosting runtime." }
```

Code after:
package expo.modules.kotlin.modules

import android.os.Bundle
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.runtime.Runtime
import expo.modules.kotlin.convertToString
import expo.modules.kotlin.providers.AppContextProvider
import expo.modules.kotlin.tracing.trace
import expo.modules.kotlin.types.Enumerable
import expo.modules.kotlin.types.TypeConverterProvider
import kotlinx.coroutines.CoroutineScope
import java.lang.ref.WeakReference

abstract class Module : AppContextProvider {
  @Suppress("PropertyName")
  internal var _appContextHolder: WeakReference<AppContext> = WeakReference(null)

  val runtime: Runtime
    get() = requireNotNull(_appContextHolder.get()?.hostingRuntimeContext) { "The module wasn't created! You can't access the hosting runtime." }

  @Deprecated(
    message = "Use 'runtime' property instead.",
    replaceWith = ReplaceWith("runtime")
  )
  val runtimeContext: Runtime
    get() = runtime

  // region AppContextProvider

  override val appContext: AppContext
    get() = requireNotNull(_appContextHolder.get()) {
      "You attempted to access the app context before the module was created. " +
        "Defer accessing the context until after the module initializes."
    }

  // endregion

  private val moduleEventEmitter by lazy { appContext.eventEmitter(this) }

  val registry
    get() = appContext.registry

  @PublishedApi
  internal lateinit var coroutineScopeDelegate: Lazy<CoroutineScope>