@@ -1438,6 +1438,23 @@ defmodule TypespecTest do
14381438 assert Code.Typespec . fetch_specs ( Unknown ) == :error
14391439 end
14401440
1441+ if System . otp_release ( ) >= "28" do
1442+ test "retrieval of Erlang nominal types" do
1443+ forms = [
1444+ { :attribute , 1 , :module , :typespec_nominal_sample } ,
1445+ { :attribute , 2 , :export_type , [ meters: 0 ] } ,
1446+ { :attribute , 3 , :nominal , { :meters , { :type , 3 , :integer , [ ] } , [ ] } } ,
1447+ { :attribute , 4 , :type , { :plain , { :type , 4 , :atom , [ ] } , [ ] } }
1448+ ]
1449+
1450+ { :ok , :typespec_nominal_sample , beam } = :compile . forms ( forms , [ :debug_info ] )
1451+
1452+ assert { :ok , types } = Code.Typespec . fetch_types ( beam )
1453+ assert { :nominal , { :meters , { :type , 3 , :integer , [ ] } , [ ] } } in types
1454+ assert { :typep , { :plain , { :type , 4 , :atom , [ ] } , [ ] } } in types
1455+ end
1456+ end
1457+
14411458 # This is a test that implements all types specified in lib/elixir/pages/typespecs.md
14421459 test "documented types and their AST" do
14431460 defmodule SomeStruct do
0 commit comments