Skip to content

Commit

Permalink
Fix Kotlin compiler warnings and remove some obsolete annotations (Po…
Browse files Browse the repository at this point in the history
…lymerLabs#5752)

* Fix Kotlin compiler warnings and remove some obsolete annotations

* Review comments
  • Loading branch information
mykmartin authored Jul 22, 2020
1 parent 7024eee commit a7bde43
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 23 deletions.
2 changes: 0 additions & 2 deletions java/arcs/core/entity/EntityDereferencerFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import arcs.core.storage.ActivationFactory
import arcs.core.storage.Dereferencer
import arcs.core.storage.RawEntityDereferencer
import arcs.core.storage.Reference
import kotlinx.coroutines.ExperimentalCoroutinesApi

/** A [Dereferencer.Factory] for [Reference] and [RawEntity] classes. */
@ExperimentalCoroutinesApi
class EntityDereferencerFactory(
private val activationFactory: ActivationFactory
) : Dereferencer.Factory<RawEntity> {
Expand Down
9 changes: 8 additions & 1 deletion java/arcs/core/entity/VariableEntityBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ open class VariableEntityBase(
creationTimestamp: Long = UNINITIALIZED_TIMESTAMP,
expirationTimestamp: Long = UNINITIALIZED_TIMESTAMP,
isInlineEntity: Boolean = false
) : EntityBase(entityClassName, schema, entityId, creationTimestamp, expirationTimestamp) {
) : EntityBase(
entityClassName,
schema,
entityId,
creationTimestamp,
expirationTimestamp,
isInlineEntity
) {
private val rawSingletons = mutableMapOf<FieldName, Referencable?>()
private val rawCollections = mutableMapOf<FieldName, Set<Referencable>>()

Expand Down
1 change: 0 additions & 1 deletion java/arcs/core/host/EntityHandleManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class EntityHandleManager(
private val analytics: Analytics? = null
) {

@ExperimentalCoroutinesApi
@Deprecated(
message = "prefer primary constructor",
/* ktlint-disable max-line-length */
Expand Down
5 changes: 1 addition & 4 deletions java/arcs/core/storage/RawEntityDereferencer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ typealias EntityStore = ActiveStore<CrdtEntity.Data, CrdtEntity.Operation, CrdtE
*
* TODO(jasonwyatt): Use the [Scheduler] here when dereferencing.
*/
@ExperimentalCoroutinesApi
class RawEntityDereferencer(
private val schema: Schema,
private val entityActivationFactory: ActivationFactory = DefaultActivationFactory,
Expand All @@ -39,9 +38,7 @@ class RawEntityDereferencer(
private val log = TaggedLog { "RawEntityDereferencer" }

@ExperimentalCoroutinesApi
override suspend fun dereference(
reference: Reference
): RawEntity? {
override suspend fun dereference(reference: Reference): RawEntity? {
log.verbose { "De-referencing $reference" }

val storageKey = reference.referencedStorageKey()
Expand Down
2 changes: 1 addition & 1 deletion java/arcs/core/storage/Store.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
* when invoked with [StoreOptions] where [options.storageKey] is of type [ReferenceModeStorageKey],
* otherwise a [DirectStore] will be created.
*/
@ExperimentalCoroutinesApi
@Suppress("UNCHECKED_CAST")
object DefaultActivationFactory : ActivationFactory {
@ExperimentalCoroutinesApi
override suspend fun <Data : CrdtData, Op : CrdtOperation, T> invoke(
options: StoreOptions
): ActiveStore<Data, Op, T> = when (options.storageKey) {
Expand Down
2 changes: 0 additions & 2 deletions java/arcs/core/storage/StoreManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ package arcs.core.storage
import arcs.core.crdt.CrdtData
import arcs.core.crdt.CrdtOperationAtTime
import arcs.core.util.guardedBy
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock

/**
* Store manager provides a central holding places for the [Store] instances that a runtime will
* use, so that only one instance of a [Store] can be created per [StorageKey].
*/
@ExperimentalCoroutinesApi
class StoreManager(
/**
* If a store doesn't yet exist in this [StoreManager] for a provided [StorageKey],
Expand Down
10 changes: 5 additions & 5 deletions javatests/arcs/android/storage/database/DatabaseImplTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class DatabaseImplTest {
fun insertAndGet_entity_newEntityWithPrimitiveFields() = runBlockingTest {
val key = DummyStorageKey("key")

val inlineSchema = newSchema(
newSchema(
"inlineHash",
SchemaFields(
singletons = mapOf(
Expand Down Expand Up @@ -669,7 +669,7 @@ class DatabaseImplTest {
val key = DummyStorageKey("key")
val childSchema = newSchema("child")
database.getSchemaTypeId(childSchema, db)
val inlineSchema = newSchema(
newSchema(
"inlineHash",
SchemaFields(
singletons = mapOf(
Expand Down Expand Up @@ -1946,7 +1946,7 @@ class DatabaseImplTest {
assertTableIsSize("field_values", 16)

// Check collection entries have been cleared. For each remaining entity there should only
// be twelve values (two for the nums collection, five for the chars collection,
// be twelve values (two for the nums collection, five for the chars collection,
// two for the text list, two for the bigint list, one for the membership of the entity).
assertTableIsSize("collection_entries", 24)

Expand Down Expand Up @@ -1986,7 +1986,7 @@ class DatabaseImplTest {

@Test
fun removeExpiredEntities_inlineDataIsRemoved() = runBlockingTest {
val inlineInlineSchema = newSchema(
newSchema(
"inlineInlineHash",
SchemaFields(
singletons = mapOf(
Expand All @@ -1995,7 +1995,7 @@ class DatabaseImplTest {
collections = emptyMap()
)
)
val inlineSchema = newSchema(
newSchema(
"inlineHash",
SchemaFields(
singletons = mapOf(
Expand Down
1 change: 1 addition & 0 deletions javatests/arcs/core/data/expression/ExpressionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class ExpressionTest {
}

@Test
@Suppress("UNCHECKED_CAST")
fun testJsonSerialization() {
val q = query<Expression.Scope>("arg")
val field = Expression.FieldExpression<Expression.Scope, Number>(q, "bar")
Expand Down
1 change: 0 additions & 1 deletion javatests/arcs/core/entity/HandleManagerTestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ open class HandleManagerTestBase {

val updateDeferred = readHandle.onUpdateDeferred { it.size == 1 }
writeHandle.dispatchStore(entity)
val entityOut = updateDeferred.await()
assertThat(updateDeferred.await()).containsExactly(entity)
}

Expand Down
2 changes: 0 additions & 2 deletions javatests/arcs/core/entity/StorageAdapterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ import arcs.core.storage.testutil.DummyStorageKey
import arcs.jvm.util.testutil.FakeTime
import com.google.common.truth.Truth.assertThat
import kotlin.test.assertFailsWith
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@ExperimentalCoroutinesApi
@RunWith(JUnit4::class)
class StorageAdapterTest {
private val time = FakeTime()
Expand Down
2 changes: 0 additions & 2 deletions javatests/arcs/core/host/ParticleContextTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import com.nhaarman.mockitokotlin2.whenever
import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
Expand All @@ -38,7 +37,6 @@ import org.mockito.Mock
import org.mockito.MockitoAnnotations

@RunWith(JUnit4::class)
@OptIn(ExperimentalCoroutinesApi::class)
class ParticleContextTest {

@Mock
Expand Down
2 changes: 2 additions & 0 deletions javatests/arcs/core/storage/ReferenceModeStoreTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import arcs.core.util.testutil.LogRule
import com.google.common.truth.Truth.assertThat
import kotlin.reflect.KClass
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -671,6 +672,7 @@ class ReferenceModeStoreTest {
}

@Test
@FlowPreview
fun backingStoresCleanedUpWhenLastCallbackRemoved() = runBlocking {
DriverFactory.register(MockDriverProvider())
val store = createReferenceModeStore()
Expand Down
1 change: 0 additions & 1 deletion javatests/arcs/core/storage/driver/VolatileDriverTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.junit.runner.RunWith
import org.junit.runners.JUnit4

/** Tests for [VolatileDriver]. */
@Suppress("RedundantSuspendModifier")
@ExperimentalCoroutinesApi
@RunWith(JUnit4::class)
class VolatileDriverTest {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/schema2kotlin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ abstract class Abstract${particle.name} : ${this.opts.wasm ? 'WasmParticleImpl'

private getHandlesClassDecl(particleName: string, entitySpecs: string[], handleDecls: string[]): string {
const header = this.opts.wasm
? `class Handles(
? `${handleDecls.length ? '' : '@Suppress("UNUSED_PARAMETER")\n '}class Handles(
particle: WasmParticleImpl
)`
: `class Handles : HandleHolderBase(
Expand Down

0 comments on commit a7bde43

Please sign in to comment.