<div dir="ltr">Hi,<div><br></div><div>Maybe this has been asked before but I couldn't find it.</div><div><br></div><div>I would like to be able to give visibility of non-generic subclass of a generic class to obj-c. Is there any limitation of the compiler knowing that the type of the non-generic type is closed, to generate a compatible version for obj-c?</div><div><br></div><div>
<p class="gmail-p1"><span class="gmail-s1"></span>Code Example:</p>
<p class="gmail-p2"><span class="gmail-s1">class</span><span class="gmail-s2"> SwiftSuperType<T: NSObjectProtocol> : </span><span class="gmail-s3">NSObject</span><span class="gmail-s2"> {</span><br></p></div><div><p class="gmail-p1"><span class="gmail-s2">}</span></p><p class="gmail-p2"><span class="gmail-s1">class</span><span class="gmail-s2"> NonGenericClass2: </span><span class="gmail-s4">SwiftSuperType</span><span class="gmail-s2"><</span><span class="gmail-s3">NSObject</span><span class="gmail-s2">> {</span><br><span class="gmail-s2"></span></p><p class="gmail-p1">
</p><p class="gmail-p1"><span class="gmail-s2">}</span></p><p class="gmail-p1"><span class="gmail-s2">Or with a obj-c super class:</span></p><div><p class="gmail-p2"><span class="gmail-s2">@interface</span><span class="gmail-s1"> ObjcSuperType<T: </span><span class="gmail-s2">id</span><span class="gmail-s1"><NSObject>> : </span><span class="gmail-s3">NSObject</span></p><p class="gmail-p3"><span class="gmail-s1">@end</span></p></div><p class="gmail-p1"><span class="gmail-s2"></span></p><div><p class="gmail-p1"><span class="gmail-s1">class</span><span class="gmail-s2"> NonGenericClass: </span><span class="gmail-s3">ObjcSuperType</span><span class="gmail-s2"><</span><span class="gmail-s4">NSObject</span><span class="gmail-s2">> {</span></p><p class="gmail-p1"><span class="gmail-s2">}</span></p></div><div><span class="gmail-s2"><br></span></div><p class="gmail-p1"><span class="gmail-s2"><br></span></p><p class="gmail-p1"><span class="gmail-s2">Actual Behaviour:</span></p><p class="gmail-p1">Non-generic classes are not visible in obj-c. If adding the @objc notation we get the following error.</p><p class="gmail-p1">Actual error message:<br></p></div><div>Generic subclasses of '@objc' classes cannot have an explicit '@objc' attribute because they are not directly visible from Objective-C<br></div><div><br></div><div>regards,</div><div><br></div><div>--</div><div>Davide Mendolia</div></div>