diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
index ab359d9c05784b8cc415d205114483252eff7faf..65d66be020710fac31659c81f73dce7a6e2787cc 100644
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ b/src/shared/cplusplus/CheckDeclaration.cpp
@@ -594,16 +594,16 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
         return false;
 
     Symbol *symbol;
-    if (!ast->function_body) {
-        Declaration *decl = control()->newDeclaration(ast->firstToken(), methodType->name());
-        decl->setType(methodType);
-        symbol = decl;
-    } else {
+    if (ast->function_body) {
         if (!semantic()->skipFunctionBodies()) {
             semantic()->check(ast->function_body, methodType->members());
         }
 
         symbol = methodType;
+    } else {
+        Declaration *decl = control()->newDeclaration(ast->firstToken(), methodType->name());
+        decl->setType(methodType);
+        symbol = decl;
     }
 
     symbol->setStartOffset(tokenAt(ast->firstToken()).offset);