private boolean isSimpleDataTypeCompatibleWithExistingData(DataType simpleDT,
			Data existingData) {
		// simpleDT will be int, char, float, or string data types
		
		boolean isSameLen = isSameLen(simpleDT, existingData);
		DataType existingDT = existingData.getBaseDataType();

		if (simpleDT instanceof CharDataType && existingDT instanceof StringDataType) {
			// char overwriting a string
			return isSameLen || allowTruncating;
		}

		if (Undefined.isUndefined(existingDT) && isSameLen) {
			// some type overwriting an undefined
			return true;
		}

		return simpleDT.getClass().isInstance(existingDT) && isSameLen;
	}
Logic to test if a Data instance is replaceable with a data type.
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFDataInstanceHelper.java