Skip to content

Commit

Permalink
First attempt to build Kord with K2
Browse files Browse the repository at this point in the history
The @Suppress annotations were changed because of this issue:
https://youtrack.jetbrains.com/issue/KT-62146
  • Loading branch information
lukellmann committed Oct 25, 2023
1 parent 8a9a543 commit dcfea7c
Show file tree
Hide file tree
Showing 38 changed files with 1,646 additions and 1,624 deletions.
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/Compiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet

object OptIns {
Expand All @@ -28,6 +29,9 @@ fun KotlinCommonCompilerOptions.applyKordCompilerOptions() {
allWarningsAsErrors = true
progressiveMode = true
freeCompilerArgs.add("-Xexpect-actual-classes")
// enable K2
languageVersion = KOTLIN_2_0
freeCompilerArgs.add( "-Xsuppress-version-warnings")
}

fun KotlinSourceSet.applyKordOptIns() {
Expand Down
1,175 changes: 590 additions & 585 deletions common/api/common.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public sealed class ApplicationFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith")
@Deprecated(
level = DeprecationLevel.ERROR,
message =
Expand All @@ -317,7 +317,7 @@ public sealed class ApplicationFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
@Deprecated(
level = DeprecationLevel.ERROR,
message = "ApplicationFlag is no longer an enum class.",
Expand All @@ -330,7 +330,7 @@ public sealed class ApplicationFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "ApplicationFlag is no longer an enum class.",
Expand All @@ -340,8 +340,8 @@ public sealed class ApplicationFlag(
@JvmStatic
public open fun getEntries(): EnumEntries<ApplicationFlag> = EnumEntriesList

@Suppress(names = arrayOf("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED"))
@Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED")
private object EnumEntriesList : EnumEntries<ApplicationFlag>, List<ApplicationFlag> by
entries {
override fun equals(other: Any?): Boolean = entries == other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public sealed class ChannelFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith")
@Deprecated(
level = DeprecationLevel.ERROR,
message = "ChannelFlag is no longer an enum class. Deprecated without a replacement.",
Expand All @@ -185,7 +185,7 @@ public sealed class ChannelFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
@Deprecated(
level = DeprecationLevel.ERROR,
message = "ChannelFlag is no longer an enum class.",
Expand All @@ -198,7 +198,7 @@ public sealed class ChannelFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "ChannelFlag is no longer an enum class.",
Expand All @@ -208,8 +208,8 @@ public sealed class ChannelFlag(
@JvmStatic
public open fun getEntries(): EnumEntries<ChannelFlag> = EnumEntriesList

@Suppress(names = arrayOf("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED"))
@Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED")
private object EnumEntriesList : EnumEntries<ChannelFlag>, List<ChannelFlag> by entries {
override fun equals(other: Any?): Boolean = entries == other

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public sealed class MessageFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith")
@Deprecated(
level = DeprecationLevel.ERROR,
message = "MessageFlag is no longer an enum class. Deprecated without a replacement.",
Expand All @@ -317,7 +317,7 @@ public sealed class MessageFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
@Deprecated(
level = DeprecationLevel.ERROR,
message = "MessageFlag is no longer an enum class.",
Expand All @@ -330,7 +330,7 @@ public sealed class MessageFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "MessageFlag is no longer an enum class.",
Expand All @@ -340,8 +340,8 @@ public sealed class MessageFlag(
@JvmStatic
public open fun getEntries(): EnumEntries<MessageFlag> = EnumEntriesList

@Suppress(names = arrayOf("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED"))
@Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED")
private object EnumEntriesList : EnumEntries<MessageFlag>, List<MessageFlag> by entries {
override fun equals(other: Any?): Boolean = entries == other

Expand Down
10 changes: 5 additions & 5 deletions common/src/commonMain/kotlin/entity/ActivityFlag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public sealed class ActivityFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith")
@Deprecated(message =
"ActivityFlag is no longer an enum class. Deprecated without a replacement.", level = DeprecationLevel.ERROR)
@JvmStatic
Expand All @@ -231,7 +231,7 @@ public sealed class ActivityFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
@Deprecated(
message = "ActivityFlag is no longer an enum class.",
replaceWith = ReplaceWith(expression = "ActivityFlag.entries.toTypedArray()", imports =
Expand All @@ -244,7 +244,7 @@ public sealed class ActivityFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "ActivityFlag is no longer an enum class.",
Expand All @@ -254,8 +254,8 @@ public sealed class ActivityFlag(
@JvmStatic
public open fun getEntries(): EnumEntries<ActivityFlag> = EnumEntriesList

@Suppress(names = arrayOf("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED"))
@Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED")
private object EnumEntriesList : EnumEntries<ActivityFlag>, List<ActivityFlag> by entries {
override fun equals(other: Any?): Boolean = entries == other

Expand Down
10 changes: 5 additions & 5 deletions common/src/commonMain/kotlin/entity/GuildMemberFlag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public sealed class GuildMemberFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith")
@Deprecated(message =
"GuildMemberFlag is no longer an enum class. Deprecated without a replacement.", level = DeprecationLevel.ERROR)
@JvmStatic
Expand All @@ -217,7 +217,7 @@ public sealed class GuildMemberFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
@Deprecated(
message = "GuildMemberFlag is no longer an enum class.",
replaceWith = ReplaceWith(expression = "GuildMemberFlag.entries.toTypedArray()", imports
Expand All @@ -230,7 +230,7 @@ public sealed class GuildMemberFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "GuildMemberFlag is no longer an enum class.",
Expand All @@ -240,8 +240,8 @@ public sealed class GuildMemberFlag(
@JvmStatic
public open fun getEntries(): EnumEntries<GuildMemberFlag> = EnumEntriesList

@Suppress(names = arrayOf("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED"))
@Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED")
private object EnumEntriesList : EnumEntries<GuildMemberFlag>, List<GuildMemberFlag> by
entries {
override fun equals(other: Any?): Boolean = entries == other
Expand Down
4 changes: 2 additions & 2 deletions common/src/commonMain/kotlin/entity/Interactions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public sealed class Option {
ApplicationCommandOptionType.User -> CommandArgument.Serializer.deserialize(
json, jsonValue!!, name, type!!, focused
)
null, is ApplicationCommandOptionType.Unknown -> error("unknown ApplicationCommandOptionType $type")
is ApplicationCommandOptionType.Unknown -> error("unknown ApplicationCommandOptionType $type")
}
}

Expand Down Expand Up @@ -601,7 +601,7 @@ public sealed class CommandArgument<out T> : Option() {
is AutoCompleteArgument, is StringArgument -> encodeStringElement(
descriptor,
1,
value.value as String
value.value
)
}
}
Expand Down
10 changes: 5 additions & 5 deletions common/src/commonMain/kotlin/entity/SystemChannelFlag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public sealed class SystemChannelFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith")
@Deprecated(message =
"SystemChannelFlag is no longer an enum class. Deprecated without a replacement.", level = DeprecationLevel.ERROR)
@JvmStatic
Expand All @@ -236,7 +236,7 @@ public sealed class SystemChannelFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
@Deprecated(
message = "SystemChannelFlag is no longer an enum class.",
replaceWith = ReplaceWith(expression = "SystemChannelFlag.entries.toTypedArray()",
Expand All @@ -249,7 +249,7 @@ public sealed class SystemChannelFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "SystemChannelFlag is no longer an enum class.",
Expand All @@ -259,8 +259,8 @@ public sealed class SystemChannelFlag(
@JvmStatic
public open fun getEntries(): EnumEntries<SystemChannelFlag> = EnumEntriesList

@Suppress(names = arrayOf("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED"))
@Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED")
private object EnumEntriesList : EnumEntries<SystemChannelFlag>, List<SystemChannelFlag> by
entries {
override fun equals(other: Any?): Boolean = entries == other
Expand Down
14 changes: 7 additions & 7 deletions common/src/commonMain/kotlin/entity/UserFlag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public sealed class UserFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("DeprecatedCallableAddReplaceWith", "DEPRECATION_ERROR"))
@Suppress("DeprecatedCallableAddReplaceWith", "DEPRECATION_ERROR")
@Deprecated(message = "UserFlag is no longer an enum class. Deprecated without a replacement.", level = DeprecationLevel.ERROR)
public fun ordinal(): Int = when (this) {
DiscordEmployee -> 0
Expand Down Expand Up @@ -282,7 +282,7 @@ public sealed class UserFlag(
@JvmField
public val TeamUser: UserFlag = TeamUser

@Suppress(names = arrayOf("DEPRECATION_ERROR"))
@Suppress("DEPRECATION_ERROR")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility",
Expand Down Expand Up @@ -360,7 +360,7 @@ public sealed class UserFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "DeprecatedCallableAddReplaceWith")
@Deprecated(message =
"UserFlag is no longer an enum class. Deprecated without a replacement.", level = DeprecationLevel.ERROR)
@JvmStatic
Expand All @@ -387,7 +387,7 @@ public sealed class UserFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
@Deprecated(
message = "UserFlag is no longer an enum class.",
replaceWith = ReplaceWith(expression = "UserFlag.entries.toTypedArray()", imports =
Expand All @@ -400,7 +400,7 @@ public sealed class UserFlag(
/**
* @suppress
*/
@Suppress(names = arrayOf("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED"))
@Suppress("NON_FINAL_MEMBER_IN_OBJECT", "UPPER_BOUND_VIOLATED")
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "UserFlag is no longer an enum class.",
Expand All @@ -410,8 +410,8 @@ public sealed class UserFlag(
@JvmStatic
public open fun getEntries(): EnumEntries<UserFlag> = EnumEntriesList

@Suppress(names = arrayOf("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED"))
@Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE",
"SEALED_INHERITOR_IN_DIFFERENT_PACKAGE", "UPPER_BOUND_VIOLATED")
private object EnumEntriesList : EnumEntries<UserFlag>, List<UserFlag> by entries {
override fun equals(other: Any?): Boolean = entries == other

Expand Down
6 changes: 3 additions & 3 deletions common/src/nonJvmMain/kotlin/Class.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import dev.kord.common.annotation.KordInternal
import kotlin.reflect.KClass

/** @suppress */
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual typealias Class<T> = KClass<T>
public actual typealias Class<T> = ArrayDeque<T>

/** @suppress */
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.InlineOnly
@KordInternal
public actual inline val <T : Any> KClass<T>.java: Class<T> inline get() = this
public actual inline val <T : Any> KClass<T>.java: Class<T>
inline get() = throw UnsupportedOperationException("'getDeclaringClass()' was never present on Kotlin/JS")
Loading

0 comments on commit dcfea7c

Please sign in to comment.