Skip to content
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

Enable type parameter traversal in exact type patterns #222

Merged
merged 7 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
UnresolvedType: fix JVM signature conversion
Fixes #211. Previously, '?' was not converted to '*' in
UnresolvedType.nameToSignature, but kept as-is. That is why - falsely -
it was necessary to handle the '?' case in UnresolvedType.forSignature
at all, reading this kind of bogus signature and creating a type for it
in TypeFactory.createTypeFromSignature. This, ironically, led to correct
JVM generic type signatures containing '*' not being handled at all.

The conversion should now work correctly both ways.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
  • Loading branch information
kriegaex committed Apr 11, 2024
commit e88b2cf780d02f011699b7413143b209fbfed984
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static UnresolvedType createTypeFromSignature(String signature) {
return new UnresolvedType(signature, signatureErasure, typeParams);
}
// can't replace above with convertSigToType - leads to stackoverflow
} else if ((firstChar == '?' || firstChar == '*') && signature.length()==1) {
} else if (firstChar == '*' && signature.length()==1) {
return WildcardedUnresolvedType.QUESTIONMARK;
} else if (firstChar == '+') {
// ? extends ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public static UnresolvedType forSignature(String signature) {
return TypeFactory.createTypeFromSignature(signature);
case '-':
return TypeFactory.createTypeFromSignature(signature);
case '?':
case '*':
return TypeFactory.createTypeFromSignature(signature);
case 'T':
return TypeFactory.createTypeFromSignature(signature);
Expand Down Expand Up @@ -746,7 +746,7 @@ private static String nameToSignature(String name) {
return "C";
}
if (name.equals("?")) {
return name;
return "*";
}
}
if (len == 0) {
Expand Down