@@ -75,6 +75,14 @@ defmodule TypespecTest do
75
75
@ type my_type :: % URI . t ( ) { }
76
76
end
77
77
end
78
+
79
+ assert_raise Kernel.TypespecError ,
80
+ ~r" unexpected expression in typespec: t\. Foo" ,
81
+ fn ->
82
+ test_module do
83
+ @ type my_type :: t . Foo
84
+ end
85
+ end
78
86
end
79
87
80
88
test "invalid function specification" do
@@ -120,7 +128,7 @@ defmodule TypespecTest do
120
128
121
129
test "redefined type" do
122
130
assert_raise Kernel.TypespecError ,
123
- ~r" type foo/0 is already defined in .*test/elixir/typespec_test.exs:126 " ,
131
+ ~r" type foo/0 is already defined in .*test/elixir/typespec_test.exs:134 " ,
124
132
fn ->
125
133
test_module do
126
134
@ type foo :: atom
@@ -129,7 +137,7 @@ defmodule TypespecTest do
129
137
end
130
138
131
139
assert_raise Kernel.TypespecError ,
132
- ~r" type foo/2 is already defined in .*test/elixir/typespec_test.exs:136 " ,
140
+ ~r" type foo/2 is already defined in .*test/elixir/typespec_test.exs:144 " ,
133
141
fn ->
134
142
test_module do
135
143
@ type foo :: atom
@@ -139,7 +147,7 @@ defmodule TypespecTest do
139
147
end
140
148
141
149
assert_raise Kernel.TypespecError ,
142
- ~r" type foo/0 is already defined in .*test/elixir/typespec_test.exs:145 " ,
150
+ ~r" type foo/0 is already defined in .*test/elixir/typespec_test.exs:153 " ,
143
151
fn ->
144
152
test_module do
145
153
@ type foo :: atom
@@ -841,6 +849,19 @@ defmodule TypespecTest do
841
849
assert [ { :atom , _ , Keyword } , { :atom , _ , :t } , [ { :var , _ , :value } ] ] = kw_with_value_args
842
850
end
843
851
852
+ test "@type with macro in alias" do
853
+ bytecode =
854
+ test_module do
855
+ defmacro module ( ) do
856
+ quote do: __MODULE__
857
+ end
858
+
859
+ @ type my_type :: module ( ) . Foo
860
+ end
861
+
862
+ assert [ type: { :my_type , { :atom , _ , TypespecTest.TypespecSample.Foo } , [ ] } ] = types ( bytecode )
863
+ end
864
+
844
865
test "@type with a reserved signature" do
845
866
assert_raise Kernel.TypespecError ,
846
867
~r" type required\/ 1 is a reserved type and it cannot be defined" ,
0 commit comments