Gat Tag
04/29/2024, 1:29 PMdmitriy.novozhilov
04/29/2024, 1:32 PMGat Tag
04/29/2024, 1:33 PMGat Tag
04/29/2024, 1:34 PMGat Tag
04/29/2024, 1:37 PMGat Tag
04/29/2024, 1:38 PMdmitriy.novozhilov
04/29/2024, 1:44 PMGat Tag
04/29/2024, 1:59 PM==
for each captured val
(and var
, but that's iffy)). Since I am sharing logic between my core library and my compiler plugin, the plugin is dependent on these immutable collections and how they are useddmitriy.novozhilov
04/29/2024, 2:01 PMGat Tag
04/29/2024, 2:01 PMdmitriy.novozhilov
04/29/2024, 2:01 PMIs it given its own class loader or does it share one with idea?@Roman Golyshev could you help with it?
dmitriy.novozhilov
04/29/2024, 2:02 PMbut do you know if there is strong overlap in loaded classesWhat do you mean? Most of the code from the frontend is reused, but some service and core transfomers are replaced with IDE-specific implementations
Gat Tag
04/29/2024, 2:02 PMGat Tag
04/29/2024, 2:09 PMdmitriy.novozhilov
04/29/2024, 2:09 PMdmitriy.novozhilov
04/29/2024, 2:10 PMGat Tag
04/29/2024, 2:18 PMRoman Golyshev
04/29/2024, 3:00 PMRoman Golyshev
04/29/2024, 3:11 PMRoman Golyshev
04/29/2024, 4:23 PMKFunction0
?Gat Tag
04/29/2024, 4:25 PMnew AgentBuilder.Default()
.type(isSubTypeOf(Class.forName("kotlin.jvm.internal.Lambda")))
.transform((builder, type, classLoader, module, protectionDomain) ->
builder
.method(named("equals")).intercept(to(new Object(){
public static boolean impl(@This Object o1, @Argument(0) Object o2) throws IllegalAccessException {
if(o1 == o2) return true;
if(o2 == null) return false;
if(o1.getClass() != o2.getClass()) return false;
var fields = o1.getClass().getDeclaredFields();
if(fields.length == 0) return true;
AccessibleObject.setAccessible(fields, true);
for (var field: fields) if(!Objects.equals(field.get(o1), field.get(o2))) return false;
return true;
}
}.getClass()))
.method(named("hashCode")).intercept(to(new Object(){
public static int impl(@This Object o1) throws IllegalAccessException {
int result = 31 + o1.hashCode();
var fields = o1.getClass().getDeclaredFields();
if(fields.length == 0) return result;
AccessibleObject.setAccessible(fields, true);
for (var field : fields) {
var element = field.get(o1);
result = 31 * result + (element == null ? 0 : element.hashCode());
}
return result;
}
}.getClass()))
).installOn(instrumentation);
Gat Tag
04/29/2024, 4:25 PMGat Tag
04/29/2024, 4:26 PMGat Tag
04/29/2024, 4:27 PMGat Tag
04/29/2024, 4:29 PMassert({ "hi" } != { "hi"})
fun makeFunc(v: String) = { v }
assert(makeFunc("hi") == makeFunc("hi"))
assert(makeFunc("hi") != makeFunc("bye"))
Gat Tag
04/29/2024, 4:33 PMfun doSomething(a: String, b: String, c: Int){
return memoize{ (a + b).length + c } // Imagine that this is potentially some other expensive and pure operation
}
Where all memoize has to do is look up if the function in a map to see if it has already been computed, because it will result in the same value given it captured the same valuesRoman Golyshev
04/29/2024, 4:38 PMGat Tag
04/29/2024, 4:39 PMGat Tag
04/29/2024, 4:43 PMGat Tag
04/29/2024, 4:49 PM