User: joe Date: 08 Apr 26 13:00 Revision: 0a7af7c42d14e0b0d02197344286f6e65f7c778e Summary: Add error for when an enum mixin targets a non-enum class TeamCity URL: http://ci.mcdev.io:80/viewModification.html?tab=vcsModificationFiles&modId=10498&personal=false Index: src/main/kotlin/platform/mixin/inspection/MixinClassTypeInspection.kt =================================================================== --- src/main/kotlin/platform/mixin/inspection/MixinClassTypeInspection.kt (revision c54831ec8b84efe5959556627ed6ccd7a1c4a506) +++ src/main/kotlin/platform/mixin/inspection/MixinClassTypeInspection.kt (revision 0a7af7c42d14e0b0d02197344286f6e65f7c778e) @@ -59,6 +59,7 @@ val needsToBeClass = mixinClass.mixinTargets.any { !it.hasAccess(Opcodes.ACC_INTERFACE) } val needsToBeInterface = mixinClass.mixinTargets.any { it.hasAccess(Opcodes.ACC_INTERFACE) } + val canBeEnum = mixinClass.mixinTargets.all { it.hasAccess(Opcodes.ACC_ENUM) } val fixes = mutableListOf() if (classKeywordElement != null) { @@ -67,12 +68,21 @@ } else if (needsToBeInterface && !needsToBeClass) { fixes += ChangeClassTypeFix(classKeywordElement, JavaKeywords.INTERFACE) } + if (canBeEnum) { + fixes += ChangeClassTypeFix(classKeywordElement, JavaKeywords.ENUM) - } + } + } - if (mixinClass.isEnum && !mixinClass.isFabricMixin) { - holder.registerProblem(problemElement, "Mixins cannot be enums", *fixes.toTypedArray()) + if (mixinClass.isEnum) { + if (!mixinClass.isFabricMixin) { + holder.registerProblem(problemElement, "Enum Mixins are not supported on this platform", *fixes.toTypedArray()) - return - } + return + } + if (!canBeEnum) { + holder.registerProblem(problemElement, "Enum Mixin targets a non-enum class", *fixes.toTypedArray()) + return + } + } if (mixinClass.isAnnotationType) { holder.registerProblem(problemElement, "Mixins cannot be annotation types", *fixes.toTypedArray())