Disclosed is a compound represented by general formula (I) (wherein all the symbols are as defined in the description). Since the compound has excellent metabolic stability and is capable of avoiding hepatotoxicity or the like, while having Btk-selective inhibitory activity, the compound can form a safe therapeutic agent for diseases associated with B cells or mast cells.一種通式(I)所示之化合物,(式中,全部符號如說明書所記載)為除具有Btk之選擇性抑制活性外,代謝穩定性亦優異,可避免肝毒性等之化合物,因此可製成安全之B細胞或肥胖細胞參與之疾病之治療劑。