@@ -215,30 +215,40 @@ else if ( typeDetails.getTypeKind() == TypeDetails.Kind.TYPE_VARIABLE ) {
215
215
216
216
/**
217
217
* Given a type, resolve the underlying ClassDetails
218
+ *
219
+ * @see TypeDetails#determineRawClass()
218
220
*/
219
- public static ClassDetails resolveRawClass (
220
- TypeDetails typeDetails ,
221
- @ SuppressWarnings ("unused" ) SourceModelBuildingContext buildingContext ) {
221
+ public static ClassDetails resolveRawClass (TypeDetails typeDetails ) {
222
222
switch ( typeDetails .getTypeKind () ) {
223
223
case CLASS , PRIMITIVE , VOID , ARRAY -> {
224
224
return ( (ClassBasedTypeDetails ) typeDetails ).getClassDetails ();
225
225
}
226
226
case TYPE_VARIABLE -> {
227
227
final TypeVariableDetails resolvedTypeVariable = typeDetails .asTypeVariable ();
228
228
if ( CollectionHelper .size ( resolvedTypeVariable .getBounds () ) == 1 ) {
229
- // and assume the bound is a class
230
- return resolvedTypeVariable .getBounds ().get ( 0 ).asClassType ().getClassDetails ();
229
+ return resolvedTypeVariable .getBounds ().get ( 0 ).determineRawClass ();
231
230
}
232
231
return ClassDetails .OBJECT_CLASS_DETAILS ;
233
232
}
234
233
case PARAMETERIZED_TYPE -> {
235
234
final ParameterizedTypeDetails parameterizedType = typeDetails .asParameterizedType ();
236
235
if ( CollectionHelper .size ( parameterizedType .getArguments () ) == 1 ) {
237
- // and assume the bound is a class
238
- return parameterizedType .getArguments ().get ( 0 ).asClassType ().getClassDetails ();
236
+ return parameterizedType .getArguments ().get ( 0 ).determineRawClass ();
239
237
}
240
238
return ClassDetails .OBJECT_CLASS_DETAILS ;
241
239
}
240
+ case WILDCARD_TYPE -> {
241
+ final WildcardTypeDetails wildcardType = typeDetails .asWildcardType ();
242
+ if ( wildcardType .getBound () != null ) {
243
+ return wildcardType .getBound ().determineRawClass ();
244
+ }
245
+ return ClassDetails .OBJECT_CLASS_DETAILS ;
246
+ }
247
+ case TYPE_VARIABLE_REFERENCE -> {
248
+ final String identifier = typeDetails .asTypeVariableReference ().getIdentifier ();
249
+ final TypeDetails identifiedTypeDetails = typeDetails .resolveTypeVariable ( identifier );
250
+ return identifiedTypeDetails .determineRawClass ();
251
+ }
242
252
}
243
253
return ClassDetails .OBJECT_CLASS_DETAILS ;
244
254
}
@@ -256,7 +266,7 @@ public static ArrayTypeDetails arrayOf(TypeDetails constituentType, SourceModelB
256
266
.resolveClassDetails ( "[" + primitiveKind .getJavaTypeChar () );
257
267
}
258
268
else {
259
- final ClassDetails rawComponentType = TypeDetailsHelper . resolveRawClass ( constituentType , buildingContext );
269
+ final ClassDetails rawComponentType = constituentType . determineRawClass ( );
260
270
final String arrayClassName = "[L" + rawComponentType .getName ().replace ( '.' , '/' ) + ";" ;
261
271
arrayClassDetails = buildingContext
262
272
.getClassDetailsRegistry ()
0 commit comments