User: kyle wood Date: 01 Oct 22 05:11 Revision: eaa8c26d70c26c7aac850866b0ce97c3f7557710 Summary: Fix NPE in NewExpressionSideOnlyInspection Fixes #1879 TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=8135&personal=false Index: src/main/kotlin/platform/forge/inspections/sideonly/NewExpressionSideOnlyInspection.kt =================================================================== --- src/main/kotlin/platform/forge/inspections/sideonly/NewExpressionSideOnlyInspection.kt (revision 09ca47e4abd7f78f4a54eb590d1680187cefd020) +++ src/main/kotlin/platform/forge/inspections/sideonly/NewExpressionSideOnlyInspection.kt (revision eaa8c26d70c26c7aac850866b0ce97c3f7557710) @@ -27,7 +27,7 @@ override fun buildErrorString(vararg infos: Any) = "A class annotated with @SideOnly can only be used in other matching annotated classes and methods" - override fun getStaticDescription(): String? { + override fun getStaticDescription(): String { return "A class that is annotated as @SideOnly(Side.CLIENT) or @SideOnly(Side.SERVER) cannot be " + "used in classes or methods which are annotated differently, or not at all. Since the " + "irrelevant code is removed when operating as a server or a client, common code cannot " + @@ -35,7 +35,7 @@ } override fun buildFix(vararg infos: Any): InspectionGadgetsFix? { - val annotation = infos[0] as PsiAnnotation + val annotation = infos[0] as? PsiAnnotation ?: return null return if (annotation.isWritable) { RemoveAnnotationInspectionGadgetsFix(annotation, "Remove @SideOnly annotation from class declaration") Index: src/main/kotlin/platform/forge/inspections/sideonly/SideOnlyUtil.kt =================================================================== --- src/main/kotlin/platform/forge/inspections/sideonly/SideOnlyUtil.kt (revision 09ca47e4abd7f78f4a54eb590d1680187cefd020) +++ src/main/kotlin/platform/forge/inspections/sideonly/SideOnlyUtil.kt (revision eaa8c26d70c26c7aac850866b0ce97c3f7557710) @@ -127,7 +127,7 @@ * @return a pair of the first sided annotation found on the given element with its side value. * `null` is returned if no known side annotation was found. Side might be [Side.INVALID] but never [Side.NONE]. */ - fun findSide(element: PsiModifierListOwner): Pair? { + private fun findSide(element: PsiModifierListOwner): Pair? { for (sideAnnotation in SideAnnotation.KNOWN_ANNOTATIONS) { val annotation = element.findAnnotation(sideAnnotation.annotationName) ?: continue