Ben Woodworth
07/15/2020, 6:56 PMopen class A {
open fun String.x() {
// implementation
}
}
open class B : A() {
override fun String.x() {
// implementation
// 'super' is not an expression, it can not be used as a receiver for extension functions
super.run { this@x.x() }
}
}
Interestingly, when I click on the last x
, IntelliJ highlights the x
function name in A
, and if I remove super.
it'll highlight the x
function name in B
Shawn
07/15/2020, 7:06 PMsuper
in the first place? There is no instance of super
to pass to the statically resolved extension functionBen Woodworth
07/15/2020, 7:21 PMobject BukkitFcItem_1_9 {
@Singleton
class TypeClass @Inject constructor(
private val items: FcItem.Factory,
legacyMaterialInfo: LegacyMaterialInfo,
) : BukkitFcItem_1_7.TypeClass(
items = items,
legacyMaterialInfo = legacyMaterialInfo,
) {
override val FcItem.craftingRemainingItem: FcItem?
get() = when (material) {
Material.DRAGONS_BREATH -> items.fromMaterial(Material.GLASS_BOTTLE)
else -> super.run { craftingRemainingItem }
}
}
}
diesieben07
07/15/2020, 7:24 PM