Ahmed Mourad

    Ahmed Mourad

    2 years ago
    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.
    raulraja

    raulraja

    2 years ago
    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
    If you figure it out then we want it in meta too 🙏
    Ahmed Mourad

    Ahmed Mourad

    2 years ago
    How unfortunate. I'll see what I can do, if I find something, I'll let you know.
    raulraja

    raulraja

    2 years ago
    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
    Then use the lightweight declaration in the compile time validation.
    Ahmed Mourad

    Ahmed Mourad

    2 years ago
    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.