Repository navigation
DynConstructors cleanup - #10542
DynConstructors cleanup#10542
Conversation
The `DynConstructors.Builder.hiddenImpl(Class<?>...)` is a varargs method, but cannot be used as such, because `hiddenImpl(Class<T>, Class<?>...)` exists and would be used instead. Since there are no usages, deprecate it instead of fixing.
| public void testInterfaceWrongImplString() throws Exception { | ||
| DynConstructors.Ctor<MyInterface> ctor = | ||
| DynConstructors.builder(MyInterface.class) | ||
| // TODO this should throw, since the MyUnrelatedClass does not implement MyInterface |
There was a problem hiding this comment.
This is reflection on current state of the API, pre-existing problem.
I can remove this TODO if this helps. I did not plan to address this as part of this cleanup PR.
There was a problem hiding this comment.
BTW my thinking about TODO in the test is this -- a test should prevent undesired behavioral changes of the implementation. If i write a test exercising specific behavior and I don't think the behavior change should be prevented I put a comment like this one. If I don't put the comment in, someone may treat this test as asserting something important and thus give up an otherwise good change.
I understand this is a bit convoluted, but that's a lesson learned from Trino on how contributors sometimes react to test failures. I've seen test failures causing otherwise good code to become less good, because the contributor considered modifying the test is not an option.
Alternatively, I could not have the test, but I am not convinced this is a better option.
There was a problem hiding this comment.
@nastra does this explanation address your concerns? or what should i change here?
There was a problem hiding this comment.
I think leaving the TODO here is fine and we should probably address this in a follow up so that it throws when buildChecked is called
| public void testInterfaceWrongImplClass() throws Exception { | ||
| DynConstructors.Ctor<MyInterface> ctor = | ||
| DynConstructors.builder(MyInterface.class) | ||
| // TODO this should throw or not compile at all, since the MyUnrelatedClass does not |
There was a problem hiding this comment.
TODO left here. Are you planning to address this?
There was a problem hiding this comment.
@findepi is this a case where we can make it a compile-time check? I think it is currently very permissive because the interface uses Class<?> but maybe we could keep track of MyInterface and make this Class<? extends MyInterface>?
There was a problem hiding this comment.
The `DynConstructors.Builder.hiddenImpl(Class<?>...)` is a varargs method, but cannot be used as such, because `hiddenImpl(Class<T>, Class<?>...)` exists and would be used instead. Since there are no usages, deprecate it instead of fixing.
The `DynConstructors.Builder.hiddenImpl(Class<?>...)` is a varargs method, but cannot be used as such, because `hiddenImpl(Class<T>, Class<?>...)` exists and would be used instead. Since there are no usages, deprecate it instead of fixing.
No description provided.