lib&src/serialization: use deserialize_class_intern to avoid conflicts with custom...
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 29 Jun 2015 10:52:41 +0000 (06:52 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 29 Jun 2015 11:25:22 +0000 (07:25 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/serialization/serialization.nit
src/frontend/serialization_phase.nit

index 7cf291a..b0dc728 100644 (file)
@@ -107,6 +107,15 @@ abstract class Deserializer
        # All refinement should look for a precise `class_name` and call super
        # on unsupported classes.
        protected fun deserialize_class(class_name: String): Object do
+               return deserialize_class_intern(class_name)
+       end
+
+       # Generated service to deserialize the next available object as an instance of `class_name`
+       #
+       # Refinements to this method will be generated by the serialization phase.
+       # To avoid conflicts, there should not be any other refinements to this method.
+       # You can instead use `deserialize_class`.
+       protected fun deserialize_class_intern(class_name: String): Object do
                print "Error: doesn't know how to deserialize class \"{class_name}\""
                abort
        end
index 4e1ce6c..87b7433 100644 (file)
@@ -259,10 +259,10 @@ do
 
                if deserializer_npropdef == null then
                        # create the property
-                       code.add "      redef fun deserialize_class(name)"
+                       code.add "      redef fun deserialize_class_intern(name)"
                        code.add "      do"
                else
-                       toolcontext.error(deserializer_npropdef.location, "Error: you cannot define `Deserializer::deserialize_class` in a module where you use `auto_serializable`.")
+                       toolcontext.error(deserializer_npropdef.location, "Error: `Deserializer::deserialize_class_intern` is generated and must not be defined, use `deserialize_class` instead.")
                        return
                end
 
@@ -373,7 +373,7 @@ redef class AStdClassdef
        do
                for npropdef in n_propdefs do if npropdef isa AMethPropdef then
                        var id = npropdef.n_methid
-                       if id isa AIdMethid and id.n_id.text == "deserialize_class" then
+                       if id isa AIdMethid and id.n_id.text == "deserialize_class_intern" then
                                return npropdef
                        end
                end