Ok, I think I finally know how to explain what I've been trying to say all along now, let's see how it goes : ) But first let's look at these from your previous post:
let doublePrinter = Printer<Double>(123.456)
let stringPrinter = Printer<String>("Hello")
Just so that we are on the same page. Here, doublePrinter and stringPrinter are of two separate types. There is no type Printer, Printer is not a type (on its own). It's only by giving it a T (by entering some text in your code, statically, at compile time) that you can get a type from whatever that Printer thing is, and the type you get by giving it a certain T is not a "subclass" or anything of Printer.
And as for the following, also from you previous post:
Is there really no better way of unarchiving generic Swift structs without falling back to using bunch of Any values?
I *know* that the unarchived structs are Printers. I want to let the compiler and typechecker know, too.
Well, You know that because you happen to know about some runtime-specific string or JSON file or something like that, how should the compiler be able to know about something which can change at runtime? You can of course make a bunch of Printer<Any>'s if the compiler can know they will always be some kind of Printer<?> types. But you can never get back a Printer<Int> or Printer<Double> if you can't know the T-part of Printer at compile time. (well, you can use an enum as I said previously, but the uncertainty as to which of that set of possible Printer<Hmm> types a certain value is will propagate throughout your code, and you'll have to switch case on/in your enum because of that).
The only way to "let the compiler and the typechecker know, too" is by doing something really crazy like:
Including some specific archive of choice within your source code, and make sure it is done in such a way that type checker / compiler can interpret it (ie you must turn it into code, ie do the unarchiving yourself(!)). So your "unarchiver" would now only be able to handle exactly this included archive. But you could of course add as many such (unarchived) archives as you want, letting the compiler know about those too ... This makes no sense, I know (and that is the point). But:
I think you will understand what I mean if you think a bit about the chronological and causal order of these steps:
#1. You write your code, here's where type checking and compilation happens, and you hit "Build".
#2. You get your executable.
#3. You change something in a JSON archive that the executable has been setup to unarchive from.
#4. You run your executable.
#5. You get frustrated about the fact that what happened in #3 can't be known by the compiler at #1.
IMHO You are actually asking if Swift will allow you to travel back in time (in an elegant and maintainable way)!
: )
I think this might also be (part of) the reason for why "the NSCoding approach cannot be used for complex struct-based models".