@@ -293,4 +293,50 @@ public <O extends Number> void testInferOToAny()
293293
294294 assertEquals (expected , typeAssigns );
295295 }
296+
297+ @ Test
298+ public <O extends Number > void testInferOToAnyWithInterface ()
299+ throws TypeInferenceException
300+ {
301+ final Type type = new Nil <ArrayList <O >>() {}.getType ();
302+ final Type inferFrom = Cloneable .class ;
303+
304+ Map <TypeVariable <?>, MatchingUtils .TypeMapping > typeAssigns =
305+ new HashMap <>();
306+ MatchingUtils .inferTypeVariables (type , inferFrom , typeAssigns );
307+
308+ // We expect O = Any
309+ TypeVariable <?> typeVarO = (TypeVariable <?>) new Nil <O >() {}.getType ();
310+ Map <TypeVariable <?>, MatchingUtils .TypeMapping > expected = new HashMap <>();
311+ expected .put (typeVarO , new TypeMapping (typeVarO , new Any (), true ));
312+
313+ assertEquals (expected , typeAssigns );
314+ }
315+
316+ @ Test
317+ public <O extends Number > void testInferOToAnyWithClass ()
318+ throws TypeInferenceException
319+ {
320+ final Type type = new Nil <TypedBar <O >>() {}.getType ();
321+ final Type inferFrom = Bar .class ;
322+
323+ Map <TypeVariable <?>, MatchingUtils .TypeMapping > typeAssigns =
324+ new HashMap <>();
325+ MatchingUtils .inferTypeVariables (type , inferFrom , typeAssigns );
326+
327+ // We expect O = Any
328+ TypeVariable <?> typeVarO = (TypeVariable <?>) new Nil <O >() {}.getType ();
329+ Map <TypeVariable <?>, MatchingUtils .TypeMapping > expected = new HashMap <>();
330+ expected .put (typeVarO , new TypeMapping (typeVarO , new Any (), true ));
331+
332+ assertEquals (expected , typeAssigns );
333+ }
334+
335+ class Bar {
336+
337+ }
338+
339+ class TypedBar <E > extends Bar {
340+ E type ;
341+ }
296342}
0 commit comments