Skip to content

Commit

Permalink
Fix runtime error about sealed interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Jun 18, 2023
1 parent 95e6a64 commit 16460e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WebSocketSession(
val delegate: DefaultWebSocketServerSession
) : DefaultWebSocketServerSession by delegate {
suspend inline fun <reified T : Event> sendEvent(event: T) {
val updatedEvent = if (event is SoundEvent && useUnicode) {
val updatedEvent = if (event is HasSound && useUnicode) {
event.withSound(event.sound.convertForNonJvmPlatforms())
} else {
event
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {

allprojects {
group = "dev.schlaubi.tonbrett"
version = "1.9.9"
version = "1.9.10"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import kotlinx.serialization.json.JsonClassDiscriminator
@Serializable
public sealed interface Event

public sealed interface SoundEvent : Event {
public sealed interface HasSound {
public val sound: Sound

public fun withSound(sound: Sound): SoundEvent
public fun withSound(sound: Sound): Event
}

@Serializable
Expand All @@ -26,8 +26,8 @@ public data class VoiceStateUpdateEvent(val voiceState: User.VoiceState?) : Even

@Serializable
@SerialName("sound_create")
public data class SoundCreatedEvent(override val sound: Sound) : SoundEvent {
override fun withSound(sound: Sound): SoundEvent = copy(sound = sound)
public data class SoundCreatedEvent(override val sound: Sound) : Event, HasSound {
override fun withSound(sound: Sound): Event = copy(sound = sound)
}

@Serializable
Expand All @@ -36,6 +36,6 @@ public data class SoundDeletedEvent(val id: Id<Sound>) : Event

@Serializable
@SerialName("sound_update")
public data class SoundUpdatedEvent(override val sound: Sound) : SoundEvent {
override fun withSound(sound: Sound): SoundEvent = copy(sound = sound)
public data class SoundUpdatedEvent(override val sound: Sound) : Event, HasSound {
override fun withSound(sound: Sound): Event = copy(sound = sound)
}

0 comments on commit 16460e5

Please sign in to comment.