https://kotlinlang.org logo
#arrow-meta
Title
# arrow-meta
a

Ahmed Mourad

09/23/2020, 10:19 PM
Hi everyone! So I'm still playing with
eval
, is there a way to use the classpath of the plugin consumer during the evaluation?
As in, if the consumer writes something like this:
I'd like to be able to use
Password
during the evaluation.
r

raulraja

09/23/2020, 10:28 PM
Password is not resolved when that gets evaluated at compile time. This is why the validate function in the type refinements in meta is pure
And only refers to types that are available in the compiler classpath
In this case it would expect the receiver to be a String and that's all you can resolve at compile time because the compiler classpath includes the std lib.
You can workaround this limitations with your own types if they come from already compiled modules and you expose those in the kotlinCompilerClasspath but not with the same type you are refining in a local module.
TLDR you can use third party compiled libs inside eval but not local module types you are refining in place
😓 1
If you figure it out then we want it in meta too 🙏
arrow 1
a

Ahmed Mourad

09/24/2020, 12:12 AM
How unfortunate. I'll see what I can do, if I find something, I'll let you know.
r

raulraja

09/24/2020, 8:19 AM
You can potentially use your type on eval if you add a version of it to the eval session as a declaration. That is declare Password and eval it without the constrains once in the session
🤔 1
Then use the lightweight declaration in the compile time validation.
a

Ahmed Mourad

09/24/2020, 11:54 AM
Sounds interesting, the only problem would be if
Password
used other locally declared classes. But I guess I could through those recursively as well until only third party types are left.
2 Views