Open zajrik opened 1 hour ago
Summary: The user is encountering a runtime error when trying to pass an instance of a class augmented to implement an interface to a function expecting that interface. The analyzer does not detect the error, leading to confusion. The user expects the augmented class to behave like a direct implementation, but the runtime error suggests a mismatch between the augmented class and the expected interface.
I'm working on a little library for fun in which I intend to provide macros for reducing boilerplate and implementing some behind-the-scenes details. For the time being I am prototyping by handwriting augmentations before hashing out the macro implementations to generate them. Unfortunately I'm encountering an error at runtime that is giving me trouble because the analyzer is reporting nothing, leading me to believe the code itself is valid.
I've prepared code samples here to reproduce the error:
I receive no analyzer error but receive the following at runtime:
Given that the reported types in the error are from the same library in actuality (and visibly so in the error, even), I'm perplexed why this error is occurring. Of course, removing the augment and directly implementing
Bar
viaclass Foo implements Bar {}
runs as expected and printsInstance of 'Foo'
.Here's my
dart info
for both the repro and the actual use-case: