You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is not possible for a class in a library L to declare an implementation of a method whose member signature is introduced by a declaration D in a different library L2 when D has a private name.
In that situation, a 'noSuchMethod' forwarder is generated. This means that the method exists (for instance, we can tear it off), but it will not do anything other than calling noSuchMethod with various data describing the invocation.
However, you basically won't be able to interpret that data because, in particular, the memberName will be a symbol that you can't create outside L2, so you can't actually write your own noSuchMethod where you recognize that symbol by an equality test and run some code that you wish to execute when that private method is invoked.
All in all, this means that soundness is preserved (the object will have the required method), but it is kept private (in the sense that you can't just go ahead and implement it).
We discussed various options for making this scenario "more statically typed" (technically it is sound, but it looks a lot like a dynamic type error). Obviously, we could just make it a compile-time error to implement or extend a class (or mix in a mixin) in such a way that this mechanism kicks in. However, that would be a breaking change, which makes it a lot harder to do (for everyone!).
The P class declaration cannot see the _test declaration because it's private to a different library.
The rule in that case is that since P is not abstract, so it must implement its interface, but it cannot possibly implement _test (or know that it should), you get a free "no such method" forwarding stub added to implement _test.
Basically, you get a _test() => noSuchMethod(Invocation.method(#test, null)); method added automatically. That's what you're calling.
main.dart
lib.dart
The analyzer show no errors, but it crashed in running:
The text was updated successfully, but these errors were encountered: