The present invention relates to heterocyclic compounds of the general formula (I) their pharmaceutically acceptable salts, pharmaceutically acceptable solvates, enantiomers, diastereomers, and polymorphs. The invention also relates to processes for the preparation of the compounds of invention, pharmaceutical compositions containing the compounds and their use as selective Bruton’s Tyrosine Kinase (BTK) inhibitors.(I)