-
Notifications
You must be signed in to change notification settings - Fork 13k
optimize TypeParameterResolver #3512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hello @guanchengang ,
You will get class C extends B<Integer> {} [1] There should be a compiler warning: The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended |
I'm sorry I gave an inappropriate example @harawata. class L0 {}
class L1 extends L0 {}
class A<AT extends L0> {
public AT foo() {
return null;
}
}
class B0 extends A {
}
class B1<BT1 extends L0> extends A<BT1> {
}
class B2<BT2 extends L1> extends A<BT2> {
}
public static void main(String[] args) throws Exception {
Method foo = A.class.getMethod("foo");
System.out.println(TypeParameterResolver.resolveReturnType(foo, A.class)); // class com.example.Test$L0
System.out.println(TypeParameterResolver.resolveReturnType(foo, B0.class)); // class com.example.Test$L0
System.out.println(TypeParameterResolver.resolveReturnType(foo, B1.class)); // class java.lang.Object
System.out.println(TypeParameterResolver.resolveReturnType(foo, B2.class)); // class java.lang.Object
} Subclass loses more information after extending from A. |
Assuming you need this enhancement for some mappings in your MyBatis application (let me know if this is not the case), please create a small demo project that demonstrates the actual usage (including DB data, mapper, Java classes, etc.) and share it on your GitHub repo. Here are some project templates and examples. I couldn't think of a good example that benefit from this in the context of MyBatis mappings. |
@harawata , |
Thank you , @guanchengang ! I will look into it, but it might take a while as it's not an urgent matter. |
Mixing |
There may be some issues when comparing |
optimize TypeParameterResolver