@@ -190,19 +190,16 @@ public boolean hasCompatibleTypesForCall(AccessPath apBase, SootClass dest) {
190190
191191 /**
192192 * Gets the more precise one of the two given types. If there is no ordering
193- * (i.e., the two types are not cast-compatible) null is returned.
194- * IMPORTANT: this method is not commutative on array types. The second type must
195- * always be the declared type, which is used to infer the array depth.
196- * Consider, for example, the case
197- * objArr[i] = str;
198- * where we can narrow the type of objArr to String[]. Vice versa,
199- * obj = strArr[i];
200- * allows us to narrow the type of obj to String. Therefore,
201- * getMorePreciseType(String, Object[]) should return String[] and
202- * getMorePreciseType(Object[], String) should return String.
193+ * (i.e., the two types are not cast-compatible) null is returned. IMPORTANT:
194+ * this method is not commutative on array types. The second type must always be
195+ * the declared type, which is used to infer the array depth. Consider, for
196+ * example, the case objArr[i] = str; where we can narrow the type of objArr to
197+ * String[]. Vice versa, obj = strArr[i]; allows us to narrow the type of obj to
198+ * String. Therefore, getMorePreciseType(String, Object[]) should return
199+ * String[] and getMorePreciseType(Object[], String) should return String.
203200 *
204201 * @param possibleRefinement The first type
205- * @param declType The second type
202+ * @param declType The second type
206203 * @return The more precise one of the two given types
207204 */
208205 public Type getMorePreciseType (Type possibleRefinement , Type declType ) {
@@ -217,6 +214,8 @@ public Type getMorePreciseType(Type possibleRefinement, Type declType) {
217214 if (morePreciseType != null )
218215 return ArrayType .v (morePreciseType , at .numDimensions );
219216 } else if (possibleRefinement instanceof ArrayType ) {
217+ if (TypeUtils .isObjectLikeType (declType ))
218+ return possibleRefinement ;
220219 return getMorePreciseType (((ArrayType ) possibleRefinement ).baseType , declType );
221220 } else {
222221 final FastHierarchy fastHierarchy = scene .getOrMakeFastHierarchy ();
0 commit comments