[ffigen] Fix function deduplication (#450)

diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md
index 0fe4436..38be297 100644
--- a/pkgs/ffigen/CHANGELOG.md
+++ b/pkgs/ffigen/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 6.1.2
+
+- Fix bug where function bindings were not deduped correctly.
+
 # 6.1.1
 
 - _EXPERIMENTAL_ support for `FfiNative`. The API and output
diff --git a/pkgs/ffigen/lib/src/header_parser/includer.dart b/pkgs/ffigen/lib/src/header_parser/includer.dart
index 6bc0d12..05bfa54 100644
--- a/pkgs/ffigen/lib/src/header_parser/includer.dart
+++ b/pkgs/ffigen/lib/src/header_parser/includer.dart
@@ -35,7 +35,7 @@
 
 bool shouldIncludeFunc(String usr, String name) {
   return _shouldIncludeDecl(
-      usr, name, bindingsIndex.isSeenType, config.functionDecl.shouldInclude);
+      usr, name, bindingsIndex.isSeenFunc, config.functionDecl.shouldInclude);
 }
 
 bool shouldIncludeEnumClass(String usr, String name) {
diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml
index 3de14a4..1bdec3a 100644
--- a/pkgs/ffigen/pubspec.yaml
+++ b/pkgs/ffigen/pubspec.yaml
@@ -3,7 +3,7 @@
 # BSD-style license that can be found in the LICENSE file.
 
 name: ffigen
-version: 6.1.1
+version: 6.1.2
 description: Generator for FFI bindings, using LibClang to parse C header files.
 repository: https://github.com/dart-lang/ffigen
 
diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_regress_384_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_regress_384_bindings.dart
new file mode 100644
index 0000000..745cd34
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_regress_384_bindings.dart
@@ -0,0 +1,28 @@
+// AUTO GENERATED FILE, DO NOT EDIT.
+//
+// Generated by `package:ffigen`.
+import 'dart:ffi' as ffi;
+
+/// Regression test for #384
+class NativeLibrary {
+  /// Holds the symbol lookup function.
+  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
+      _lookup;
+
+  /// The symbols are looked up in [dynamicLibrary].
+  NativeLibrary(ffi.DynamicLibrary dynamicLibrary)
+      : _lookup = dynamicLibrary.lookup;
+
+  /// The symbols are looked up with [lookup].
+  NativeLibrary.fromLookup(
+      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
+          lookup)
+      : _lookup = lookup;
+
+  void foo() {
+    return _foo();
+  }
+
+  late final _fooPtr = _lookup<ffi.NativeFunction<ffi.Void Function()>>('foo');
+  late final _foo = _fooPtr.asFunction<void Function()>();
+}
diff --git a/pkgs/ffigen/test/header_parser_tests/regress_384_header_1.h b/pkgs/ffigen/test/header_parser_tests/regress_384_header_1.h
new file mode 100644
index 0000000..3129b2d
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/regress_384_header_1.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "regress_384_shared.h"
diff --git a/pkgs/ffigen/test/header_parser_tests/regress_384_header_2.h b/pkgs/ffigen/test/header_parser_tests/regress_384_header_2.h
new file mode 100644
index 0000000..3129b2d
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/regress_384_header_2.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "regress_384_shared.h"
diff --git a/pkgs/ffigen/test/header_parser_tests/regress_384_shared.h b/pkgs/ffigen/test/header_parser_tests/regress_384_shared.h
new file mode 100644
index 0000000..265a786
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/regress_384_shared.h
@@ -0,0 +1,10 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef __REGRESS_384_SHARED__
+#define __REGRESS_384_SHARED__
+
+void foo();
+
+#endif
diff --git a/pkgs/ffigen/test/header_parser_tests/regress_384_test.dart b/pkgs/ffigen/test/header_parser_tests/regress_384_test.dart
new file mode 100644
index 0000000..950d985
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/regress_384_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:ffigen/src/code_generator.dart';
+import 'package:ffigen/src/config_provider.dart';
+import 'package:ffigen/src/header_parser.dart' as parser;
+import 'package:ffigen/src/strings.dart' as strings;
+import 'package:logging/logging.dart';
+import 'package:test/test.dart';
+import 'package:yaml/yaml.dart' as yaml;
+
+import '../test_utils.dart';
+
+late Library actual;
+void main() {
+  group('regress_384_test', () {
+    setUpAll(() {
+      logWarnings(Level.SEVERE);
+      actual = parser.parse(
+        Config.fromYaml(yaml.loadYaml('''
+${strings.name}: 'NativeLibrary'
+${strings.description}: 'Regression test for #384'
+${strings.output}: 'unused'
+${strings.headers}:
+  ${strings.entryPoints}:
+    - 'test/header_parser_tests/regress_384_header_1.h'
+    - 'test/header_parser_tests/regress_384_header_2.h'
+        ''') as yaml.YamlMap),
+      );
+    });
+
+    test('Expected bindings', () {
+      matchLibraryWithExpected(actual, [
+        'test',
+        'debug_generated',
+        'header_parser_regress_384_test_output.dart'
+      ], [
+        'test',
+        'header_parser_tests',
+        'expected_bindings',
+        '_expected_regress_384_bindings.dart'
+      ]);
+    });
+  });
+}
diff --git a/pkgs/ffigen/test/header_parser_tests/unions_test.dart b/pkgs/ffigen/test/header_parser_tests/unions_test.dart
index 5146d62..ce2b0ea 100644
--- a/pkgs/ffigen/test/header_parser_tests/unions_test.dart
+++ b/pkgs/ffigen/test/header_parser_tests/unions_test.dart
@@ -14,7 +14,7 @@
 
 late Library actual;
 void main() {
-  group('packed_structs_test', () {
+  group('unions_test', () {
     setUpAll(() {
       logWarnings(Level.SEVERE);
       actual = parser.parse(