plugins types REFACTOR split store callback into store and resolve cb (#1220)

Refs #1161

Co-authored-by: Radek Krejci <rkrejci@cesnet.cz>
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 2fcea59..b7d449e 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -3947,7 +3947,7 @@
         /* ignore default values of the key */
         if (key->dflt) {
             key->dflt->realtype->plugin->free(ctx->ctx, key->dflt);
-            lysc_type_free(ctx->ctx, key->dflt->realtype);
+            lysc_type_free(ctx->ctx, (struct lysc_type *)key->dflt->realtype);
             free(key->dflt);
             key->dflt = NULL;
         }
@@ -7806,21 +7806,29 @@
     LY_ERR ret;
     struct ly_err_item *err = NULL;
 
-    ret = type->plugin->store(ctx->ctx, type, dflt, strlen(dflt), LY_TYPE_OPTS_SCHEMA,
-                              LY_PREF_SCHEMA, (void *)dflt_mod, node, NULL, storage, &err);
-    if (err) {
-        ly_err_print(err);
+    ret = type->plugin->store(ctx->ctx, type, dflt, strlen(dflt), 0, LY_PREF_SCHEMA, (void *)dflt_mod, LYD_HINT_SCHEMA,
+                              node, storage, &err);
+    if (ret == LY_EINCOMPLETE) {
+        /* we have no data so we will not be resolving it */
+        ret = LY_SUCCESS;
+    }
+
+    if (ret) {
         ctx->path[0] = '\0';
         lysc_path(node, LYSC_PATH_LOG, ctx->path, LYSC_CTX_BUFSIZE);
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-               "Invalid default - value does not fit the type (%s).", err->msg);
-        ly_err_free(err);
+        if (err) {
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
+                "Invalid default - value does not fit the type (%s).", err->msg);
+            ly_err_free(err);
+        } else {
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
+                "Invalid default - value does not fit the type.");
+        }
+        return ret;
     }
-    if (!ret) {
-        ++storage->realtype->refcount;
-        return LY_SUCCESS;
-    }
-    return ret;
+
+    ++((struct lysc_type *)storage->realtype)->refcount;
+    return LY_SUCCESS;
 }
 
 /**