Skip to content

Commit 572315e

Browse files
committed
use resolveType
1 parent 20c90fa commit 572315e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/com/goide/inspections/GoStructInitializationInspection.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.goide.inspections;
1818

1919
import com.goide.psi.*;
20-
import com.goide.psi.impl.GoPsiImplUtil;
2120
import com.intellij.codeInspection.LocalInspectionToolSession;
2221
import com.intellij.codeInspection.ProblemHighlightType;
2322
import com.intellij.codeInspection.ProblemsHolder;
@@ -35,15 +34,12 @@ public void visitCompositeLit(@NotNull GoCompositeLit o) {
3534

3635
if (PsiTreeUtil.getParentOfType(o, GoReturnStatement.class, GoShortVarDeclaration.class, GoAssignmentStatement.class) == null) return;
3736

38-
GoType type = o.getType();
39-
if (!(type instanceof GoStructType) &&
40-
!(GoPsiImplUtil.findBaseTypeFromRef(o.getTypeReferenceExpression()) instanceof GoSpecType)) {
41-
return;
42-
}
43-
44-
for (GoElement element : o.getLiteralValue().getElementList()) {
45-
if (element.getKey() == null) {
46-
holder.registerProblem(element, "Unnamed field initialization", ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
37+
GoTypeReferenceExpression ref = o.getTypeReferenceExpression();
38+
if (o.getType() instanceof GoStructType || ref != null && ref.resolveType() instanceof GoSpecType) {
39+
for (GoElement element : o.getLiteralValue().getElementList()) {
40+
if (element.getKey() == null) {
41+
holder.registerProblem(element, "Unnamed field initialization", ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
42+
}
4743
}
4844
}
4945
}

0 commit comments

Comments
 (0)