File tree Expand file tree Collapse file tree
src/main/kotlin/platform/mixin/inspection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ class MixinClassTypeInspection : MixinInspection() {
5959
6060 val needsToBeClass = mixinClass.mixinTargets.any { ! it.hasAccess(Opcodes .ACC_INTERFACE ) }
6161 val needsToBeInterface = mixinClass.mixinTargets.any { it.hasAccess(Opcodes .ACC_INTERFACE ) }
62+ val canBeEnum = mixinClass.mixinTargets.all { it.hasAccess(Opcodes .ACC_ENUM ) }
6263
6364 val fixes = mutableListOf<LocalQuickFix >()
6465 if (classKeywordElement != null ) {
@@ -67,11 +68,20 @@ class MixinClassTypeInspection : MixinInspection() {
6768 } else if (needsToBeInterface && ! needsToBeClass) {
6869 fixes + = ChangeClassTypeFix (classKeywordElement, JavaKeywords .INTERFACE )
6970 }
71+ if (canBeEnum) {
72+ fixes + = ChangeClassTypeFix (classKeywordElement, JavaKeywords .ENUM )
73+ }
7074 }
7175
72- if (mixinClass.isEnum && ! mixinClass.isFabricMixin) {
73- holder.registerProblem(problemElement, " Mixins cannot be enums" , * fixes.toTypedArray())
74- return
76+ if (mixinClass.isEnum) {
77+ if (! mixinClass.isFabricMixin) {
78+ holder.registerProblem(problemElement, " Enum Mixins are not supported on this platform" , * fixes.toTypedArray())
79+ return
80+ }
81+ if (! canBeEnum) {
82+ holder.registerProblem(problemElement, " Enum Mixin targets a non-enum class" , * fixes.toTypedArray())
83+ return
84+ }
7585 }
7686
7787 if (mixinClass.isAnnotationType) {
You can’t perform that action at this time.
0 commit comments