File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,17 @@ class GenericTypeRegistrySpec < Minitest::Spec
77
77
refute_same ( result , RaisesInInheritedCallback )
78
78
assert_operator ( result , :< , RaisesInInheritedCallback )
79
79
end
80
+
81
+ it "works for classes that specify a 'loose' sig on .inherited" do
82
+ # By "loose", we mean `T::Class[T.anything]` instead of `T::Class[SampleGenericClass[T.anything]]`
83
+ _ = HasNonRecursiveInheritedSig [ Object ]
84
+ end
85
+
86
+ it "FIXME: breaks from infinite recursion if the sig on .inherited uses the generic type" do
87
+ assert_raises ( SystemStackError ) do
88
+ HasRecursiveInheritedSig [ Object ]
89
+ end
90
+ end
80
91
end
81
92
end
82
93
@@ -98,6 +109,37 @@ def inherited(subclass)
98
109
end
99
110
end
100
111
end
112
+
113
+ class HasNonRecursiveInheritedSig
114
+ extend T ::Generic
115
+
116
+ Element = type_member
117
+
118
+ class << self
119
+ extend T ::Sig
120
+
121
+ # The correct type would be `T::Class[SampleGenericClass[T.anything]]` not honey, that's recursion Pooh!
122
+ sig { params ( subclass : T ::Class [ T . anything ] ) . void }
123
+ def inherited ( subclass )
124
+ super
125
+ end
126
+ end
127
+ end
128
+
129
+ class HasRecursiveInheritedSig
130
+ extend T ::Generic
131
+
132
+ Element = type_member
133
+
134
+ class << self
135
+ extend T ::Sig
136
+
137
+ sig { params ( subclass : T ::Class [ HasRecursiveInheritedSig [ T . anything ] ] ) . void }
138
+ def inherited ( subclass )
139
+ super
140
+ end
141
+ end
142
+ end
101
143
end
102
144
end
103
145
end
You can’t perform that action at this time.
0 commit comments