Closed raould closed 9 years ago
The interface declaration should match the class definition, but the error will appear only when you try to create an instance for this class.
For instance, local o:A = A:new(0)
will not type check because the A
in the annotation is an alias to {x:number, const new:(self, number, value*) -> (number, nil*)}
which is not a subtype of {x:number, const new:(self, number, value*) -> (self, nil*)}
, the actual type that the variable A
holds.
Ok!
(Beggars can't be choosers, but... if TL can ever enforce the interface + the class even w/out invocations of the methods, that would be super bonus cool. ;-)
https://github.com/raould/typedlua/tree/master/QUESTIONS/7 It is unclear to me when TL will/not check things. I expected the interface's signature of new() to mismatch vs. the actual implementation and produce a compile time error. Is this on purpose, and if so then what are the rules / what is the overall gestalt for explaining why / how things are / not checked?
thanks :-)