Skip to content

Commit

Permalink
[fix] Only map nodes of the exact same type #57
Browse files Browse the repository at this point in the history
  • Loading branch information
slarse committed Mar 20, 2020
1 parent 1092688 commit b562729
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/se/kth/spork/spoon/SpoonMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public static SpoonMapping fromGumTreeMapping(MappingStore gumtreeMapping) {
throw new IllegalStateException("non-root node " + m.first.toShortString()
+ " had no mapped Spoon object");
}
} else {
} else if (spoonSrc.getClass() == spoonDst.getClass()) {
// It is important to only map nodes of the exact same type, as 3DM has no notion of "correct"
// parent-child relationships. Mapping e.g. an array type reference to a non-array type reference
// may cause the resulting merge to try to treat either as the other, which does not work out.
mapping.put(spoonSrc, spoonDst);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Cls {
private Integer[] arr;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Cls {
private Object arr;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Cls {
private Object arr;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Cls {
private Integer[] arr;
}

0 comments on commit b562729

Please sign in to comment.