private boolean isDataTypeCompatibleWithExistingData(DataType dataType, Data existingData) {
		if (existingData == null || !existingData.isDefined()) {
			return true;
		}

		if (dataType instanceof Array) {
			return isArrayDataTypeCompatibleWithExistingData((Array) dataType, existingData);
		}
		if (dataType instanceof Pointer) {
			return isPointerDataTypeCompatibleWithExistingData((Pointer) dataType, existingData);
		}
		if (dataType instanceof Structure) {
			return isStructDataTypeCompatibleWithExistingData((Structure) dataType, existingData);
		}
		if (dataType instanceof TypeDef) {
			return isDataTypeCompatibleWithExistingData(((TypeDef) dataType).getBaseDataType(),
				existingData);
		}
		if (dataType instanceof Enum) {
			return isEnumDataTypeCompatibleWithExistingData((Enum) dataType, existingData);
		}

		if (dataType instanceof AbstractIntegerDataType ||
			dataType instanceof AbstractFloatDataType || dataType instanceof StringDataType ||
			dataType instanceof WideCharDataType || dataType instanceof WideChar16DataType ||
			dataType instanceof WideChar32DataType) {
			return isSimpleDataTypeCompatibleWithExistingData(dataType, existingData);
		}

		return false;
	}
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