diff --git a/lib/gir_ffi/builder/type/union.rb b/lib/gir_ffi/builder/type/union.rb
index <HASH>..<HASH> 100644
--- a/lib/gir_ffi/builder/type/union.rb
+++ b/lib/gir_ffi/builder/type/union.rb
@@ -23,6 +23,7 @@ module GirFFI
           setup_constants
           stub_methods
           setup_gtype_getter
+          setup_field_accessors
           provide_constructor
         end
 
diff --git a/test/integration/generated_gimarshallingtests_test.rb b/test/integration/generated_gimarshallingtests_test.rb
index <HASH>..<HASH> 100644
--- a/test/integration/generated_gimarshallingtests_test.rb
+++ b/test/integration/generated_gimarshallingtests_test.rb
@@ -424,17 +424,17 @@ describe "GIMarshallingTests" do
       end
 
       it "has a field long_" do
-        assert_equal 0, @it[:long_]
+        assert_equal 0, @it.long_
       end
 
       it "has a working method #inv" do
-        @it[:long_] = 42
+        @it.long_ = 42
         @it.inv
         pass
       end
 
       it "has a working method #method" do
-        @it[:long_] = 42
+        @it.long_ = 42
         @it.method
         pass
       end
Add field accessors to union types.