From beb09107e336ab6aebe89ed005d3d979f6ff30e9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 25 Aug 2024 21:44:31 +0700 Subject: [PATCH] Workaround K2 compiler bugs related to generics --- .../mc/otm/capability/MatteryCapability.java | 5 ++++- .../mc/otm/client/screen/panels/EffectListPanel.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 10 +++++----- .../otm/client/screen/panels/slot/FoldableSlotPanel.kt | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index 8f266908b..6f30afc7e 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.capability.matter.IReplicationTaskProvider; import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage; import ru.dbotthepony.mc.otm.graph.matter.MatterNode; import ru.dbotthepony.mc.otm.graph.storage.StorageNode; +import ru.dbotthepony.mc.otm.storage.StorageStack; import javax.annotation.Nonnull; @@ -53,7 +54,9 @@ public class MatteryCapability { @Nonnull @NotNull - public static final ItemCapability CONDENSATION_DRIVE = ItemCapability.createVoid(ResourceLocation.fromNamespaceAndPath(OverdriveThatMatters.MOD_ID, "condensation_drive"), IMatteryDrive.class); + // this weird cast is required because otherwise IMatteryDrive gets incompatible lower-bound due to Java raw generic type + // and K2 compiler chokes and dies due to it + public static final ItemCapability, Void> CONDENSATION_DRIVE = (ItemCapability, Void>) (Object) ItemCapability.createVoid(ResourceLocation.fromNamespaceAndPath(OverdriveThatMatters.MOD_ID, "condensation_drive"), IMatteryDrive.class); @Nonnull @NotNull diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index f760e0148..3f964deb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -242,7 +242,7 @@ open class EffectListPanel @JvmOverloads constructor( return false } - fun onSortedEffectPanels(sorted: List) { + fun onSortedEffectPanels(sorted: List.EffectSquare>) { if (sorted.size > (gridHeight * gridWidth) && !scroll.visible) { scroll.visible = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index a1a2b7651..74ffc9ace 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -253,28 +253,28 @@ open class FramePanel( protected var dragging = false - var closeButton: CloseButton? = null + var closeButton: FramePanel<*>.CloseButton? = null protected set - var helpButton: HelpButton? = null + var helpButton: FramePanel<*>.HelpButton? = null protected set var closeOnEscape = false - fun makeCloseButton(): CloseButton { + fun makeCloseButton(): FramePanel<*>.CloseButton { if (closeButton == null) closeButton = CloseButton() return closeButton!! } - fun makeHelpButton(): HelpButton { + fun makeHelpButton(): FramePanel<*>.HelpButton { if (helpButton == null) helpButton = HelpButton() return helpButton!! } - fun makeHelpButton(tooltips: Collection): HelpButton { + fun makeHelpButton(tooltips: Collection): FramePanel<*>.HelpButton { if (helpButton == null) { helpButton = HelpButton() helpButton!!.tooltips.addAll(tooltips) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt index fc326f9e0..f5dda62e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt @@ -73,7 +73,7 @@ open class FoldableSlotPanel, out T : Slot>( var hoveringSince: SystemTime? = null protected set - var hoverPanel: HoverPanel? = null + var hoverPanel: FoldableSlotPanel<*, *>.HoverPanel? = null protected set override fun onHovered() {