When a lien provided for in this chapter shall have attached to a leasehold estate, forfeiture of such estate shall not impair any lien as to material, appurtenances and fixtures located thereon and to which such lien has attached prior to forfeiture. If a lien provided for in this chapter attaches to an equitable interest or to a legal interest contingent upon the happening of a condition subsequent, failure of such interest to ripen into legal title or such condition subsequent to be fulfilled, shall not impair any such lien as to material, appurtenances and fixtures located thereon and to which said lien had attached prior to such failure.