Description
The macro proposal says:
Only the core libraries which don't violate the above rules are allowed... All other SDK libraries are not available.
What does this mean precisely? Some options:
-
It is a compile-time error for the macro class created by a macro application to be declared in a library that contains an import of any prohibited library, imports any other library (transitively) that contains a prohibited import.
-
It is a compile-time error for a macro class to refer to anything imported from a prohibited library. In other words, it's like the libraries exist but are completely empty.
-
It is a macro execution-time error to call any function or method in a prohibited library. In other words, it's like the libraries exist but all function and method bodies are
throw UnsupportedError()
.
I think we will also want to restrict some functionality in libraries that are otherwise allowed. For example, dart:core
is allowed, but DateTime.now()
should not be (#1915). Given that, option 3 might be the most consistent choice. In other words, all libraries are available but some functionality throws a runtime error. And it just happens to be that in some libraries like dart:isolate
that all functions throw runtime errors.
I think there is prior art here for how things like dart:io
are handled on Flutter that we can consult.