@@ -364,11 +364,12 @@ public JavaType constructSpecializedType(JavaType baseType, Class<?> subclass)
364
364
}
365
365
}
366
366
// (3) Sub-class does not take type parameters -- just resolve subtype
367
- if (subclass .getTypeParameters ().length == 0 ) {
367
+ int typeParamCount = subclass .getTypeParameters ().length ;
368
+ if (typeParamCount == 0 ) {
368
369
newType = _fromClass (null , subclass , TypeBindings .emptyBindings ());
369
370
break ;
370
371
}
371
-
372
+
372
373
// If not, we'll need to do more thorough forward+backwards resolution. Sigh.
373
374
// !!! TODO (as of 28-Jan-2016, at least)
374
375
@@ -390,7 +391,20 @@ public JavaType constructSpecializedType(JavaType baseType, Class<?> subclass)
390
391
if (newType == null ) {
391
392
// But otherwise gets bit tricky, as we need to partially resolve the type hierarchy
392
393
// (hopefully passing null Class for root is ok)
393
- newType = _fromClass (null , subclass , TypeBindings .emptyBindings ());
394
+ TypeBindings tb = null ;
395
+
396
+ // 14-Apr-2016, tatu: One possible short-cut; if type parameter counts
397
+ // match, chances are they ought to match. Let's take our chances...
398
+ if (baseType .containedTypeCount () == typeParamCount ) {
399
+ if (typeParamCount == 1 ) {
400
+ tb = TypeBindings .create (subclass , baseType .containedType (0 ));
401
+ } else if (typeParamCount == 2 ) {
402
+ tb = TypeBindings .create (subclass , baseType .containedType (0 ),
403
+ baseType .containedType (1 ));
404
+ }
405
+ }
406
+ newType = _fromClass (null , subclass ,
407
+ (tb == null ) ? TypeBindings .emptyBindings () : tb );
394
408
}
395
409
} while (false );
396
410
0 commit comments