PsiType (@NotNull GrReferenceExpression refExpr, @NotNull GroovyResolveResult result) { final PsiElement resolved = result.getElement(); if (resolved instanceof GrField) { ensureValid(resolved); if (CompileStaticUtil.isCompileStatic(refExpr)) { return TypesUtil.getJavaLangObject(refExpr); } else { return SpreadState.apply(((GrVariable)resolved).getTypeGroovy(), result.getSpreadState(), refExpr.getProject()); } } else if (resolved instanceof GrVariable) { ensureValid(resolved); PsiType typeGroovy = SpreadState.apply(((GrVariable)resolved).getTypeGroovy(), result.getSpreadState(), refExpr.getProject()); if (typeGroovy == null && CompileStaticUtil.isCompileStatic(refExpr)) { return TypesUtil.getJavaLangObject(refExpr); } else { return typeGroovy; } } else { return null; } }