<div class="chatlog__message-group"> <div id="chatlog__message-container-390689798014238721" class="chatlog__message-container" data-message-id="390689798014238721"> <div class="chatlog__message"> <div class="chatlog__message-aside"><img class="chatlog__avatar" src="https://cdn.discordapp.com/avatars/293573633035730946/08ab0592c6064f92c3674e09cc81b5da.png?size=512" alt="Avatar" loading="lazy"></div> <div class="chatlog__message-primary"> <div class="chatlog__header"><span class="chatlog__author" title="hiragram" data-user-id="293573633035730946">hiragram</span> <a href="/channels/306995750418513920?category=main&channel=swift-2&message_id=390690331282112512"><span class="chatlog__timestamp" title="Thursday, December 14, 2017 2:21 AM"></span></a><a href="#chatlog__message-container-390689798014238721">12/14/2017 2:21 AM</a></div> <div class="chatlog__content chatlog__markdown"><span class="chatlog__markdown-preserve"><code class="chatlog__markdown-pre chatlog__markdown-pre--multiline language-swift">import UIKit protocol ProtocolA {} class CustomCell: UITableViewCell, ProtocolA {} func hoge<T>(cellType: T.Type) where T: UITableViewCell & ProtocolA {} let typeA: (UITableViewCell & ProtocolA).Type = CustomCell.self let typeB: CustomCell.Type = CustomCell.self hoge(cellType: typeA) // error: generic parameter 'T' could not be inferred hoge(cellType: typeB) // ok</code> こういうもんなのか</span></div> </div> </div> </div> <div id="chatlog__message-container-390690331282112512" class="chatlog__message-container" data-message-id="390690331282112512"> <div class="chatlog__message"> <div class="chatlog__message-aside"> <div class="chatlog__short-timestamp" title="Thursday, December 14, 2017 2:23 AM">2:23 AM</div> </div> <div class="chatlog__message-primary"> <div class="chatlog__content chatlog__markdown"><span class="chatlog__markdown-preserve"><code class="chatlog__markdown-pre chatlog__markdown-pre--multiline language-swift">func fuga(cellType: (UITableViewCell & ProtocolA).Type) {} fuga(cellType: typeA) // ok fuga(cellType: typeB) // ok</code> ジェネリクスじゃなくしたら行けた。</span></div> </div> </div> </div> </div>