@@ -171,7 +171,7 @@ function save_typed_object(s::SerializerState, x::T) where T
171
171
save_object (s, encode_type (T), type_key)
172
172
else
173
173
type_encoding = encode_type (T)
174
- if ! (T == reverse_type_map[type_encoding] || T == reverse_type_map[type_encoding][ " default " ] )
174
+ if ! (T == reverse_type_map[type_encoding])
175
175
# here we get "$T" = "fpField"
176
176
# see comment in register_serialization_type
177
177
save_object (s, " $T " , :_instance )
@@ -222,7 +222,7 @@ function load_typed_object(s::DeserializerState, key::Symbol; override_params::A
222
222
end
223
223
224
224
function load_typed_object (s:: DeserializerState ; override_params:: Any = nothing )
225
- if haskey (s. obj, :_instance )
225
+ if ! (s . obj isa String) && haskey (s. obj, :_instance )
226
226
# to be safe we need this check but there are currently issues
227
227
# see register_serialization_type and construction of the reverse type map
228
228
# s.obj["_instance"] in keys(reverse_type_map[s.obj[type_key]])
@@ -314,18 +314,16 @@ end
314
314
315
315
# ###############################################################################
316
316
# Type Registration
317
- function register_serialization_type (@nospecialize (T:: Type ), str:: String , default = false )
318
- if haskey (reverse_type_map, str) || default
319
- init = get ( reverse_type_map, str, Dict {String, Type} ())
317
+ function register_serialization_type (@nospecialize (T:: Type ), str:: String )
318
+ if haskey (reverse_type_map, str)
319
+ init = reverse_type_map[ str]
320
320
# promote the value to a dictionary if necessary
321
321
if init isa Type
322
- init = Dict {String, Type} (" $ init" => init)
322
+ init = Dict {String, Type} (string ( init) => init)
323
323
end
324
324
# here we have "$T" = "Nemo.fpField" for example
325
325
# see comment in save_typed_object
326
- key = default ? " default" : " $T "
327
-
328
- reverse_type_map[str] = merge (Dict {String, Type} (key => T), init)
326
+ reverse_type_map[str] = merge (Dict {String, Type} (string (T) => T), init)
329
327
else
330
328
reverse_type_map[str] = T
331
329
end
@@ -349,12 +347,11 @@ serialize_with_id(::Type) = false
349
347
serialize_with_id (obj:: Any ) = false
350
348
serialize_with_params (:: Type ) = false
351
349
352
-
353
350
function register_serialization_type (ex:: Any , str:: String , uses_id:: Bool ,
354
- uses_params:: Bool , attrs:: Any , default :: Bool )
351
+ uses_params:: Bool , attrs:: Any )
355
352
return esc (
356
353
quote
357
- Oscar. register_serialization_type ($ ex, $ str, $ default )
354
+ Oscar. register_serialization_type ($ ex, $ str)
358
355
Oscar. encode_type (:: Type{<:$ex} ) = $ str
359
356
# There exist types where equality cannot be discerned from the serialization
360
357
# these types require an id so that equalities can be forced upon load.
@@ -414,7 +411,6 @@ indicates which attributes will be serialized when using save with `with_attrs=t
414
411
macro register_serialization_type (ex:: Any , args... )
415
412
uses_id = false
416
413
uses_params = false
417
- default = false
418
414
str = nothing
419
415
attrs = nothing
420
416
for el in args
@@ -424,8 +420,6 @@ macro register_serialization_type(ex::Any, args...)
424
420
uses_id = true
425
421
elseif el == :uses_params
426
422
uses_params = true
427
- elseif el == :default
428
- default = true
429
423
else
430
424
attrs = el
431
425
end
@@ -434,7 +428,7 @@ macro register_serialization_type(ex::Any, args...)
434
428
str = string (ex)
435
429
end
436
430
437
- return register_serialization_type (ex, str, uses_id, uses_params, attrs, default )
431
+ return register_serialization_type (ex, str, uses_id, uses_params, attrs)
438
432
end
439
433
440
434
0 commit comments