To be perfectly clear, not all retail is doing fine. Far from it, actually. With several recent high-profile retail bankruptcies, and many major retailers closing stores at a breathtaking pace, this is clearly not true. However, it's important to understand that "all retail is in trouble," and "some types of retailers are struggling" are two very different things.

The latter is certainly true, but the market seems to be punishing any company that has anything to do with retail. Here are two stocks that may be good buying opportunities amid the sector's weakness, and why each company's management thinks there's a bright future ahead for the right kinds of brick-and-mortar retail.

Store closing sign on windows of a retail store.

Not all retailers are in danger -- some are doing just fine. Image source: Getty Images.

Some brick-and-mortar retailers are still growing, and fast

Speaking at the REITWeek 2017 conference in New York, Kimco Realty's (KIM -0.32%) management acknowledged that while there is indeed softness in some areas of retail, such as apparel, that's not the case across the board.

The company said they are seeing wide demand from retailers that are actively expanding, particularly service-based and discount retailers. In its latest earnings presentation, Kimco listed dozens of examples, including T.J. Maxx, Starbucks, Whole Foods, and AMC Theaters, just to name a few.

To illustrate the difference between the perception and reality in retail, management points out the company's impressive occupancy rate, which is above 97%. The company successfully released five former Sports Authority stores to different retailers during the first quarter, and it says that with new supply at a 38-year low, the demand is certainly there to maintain the strong activity.

Kimco's plan is to focus on expanding areas of retail, continue to concentrate in high-barrier markets, and pre-lease much of its development projects before construction begins.

The right kind of retail

Realty Income (O 0.24%) is perhaps the least vulnerable retail REIT in the market. The company specializes in single-tenant net-lease retail properties, which are leased to high-quality tenants for long initial terms.

The majority of the retail tenants operate in one or more of three favorable categories of retail. Service-based retail businesses such as movie theaters and quick-service restaurants are immune to e-commerce competition, and they also take advantage of millennials' preference to pay for experiences rather than ownership.

Non-discretionary businesses such as drug stores and gas stations sell things people need, no matter what the economy is doing, and are therefore recession-resistant. And finally, discount-based retailers not only survive the tough times, but actually do better under those circumstances. When people need to cut back, they search for bargains at dollar stores and discount clubs, two of Realty Income's major property types.

In addition, while Realty Income is predominantly a retail REIT, it does have an element of diversification most other retail REITs don't. Specifically, about 20% of Realty Income's properties are non-retail in nature. Realty Income's industrial, office, and agricultural properties help offset any retail-related risk.

The proof is in the performance. It's tough to find any stock in the market that has delivered the level of performance Realty Income has with as little volatility. Realty Income has paid 562 consecutive monthly dividends and increased its payout for 78 consecutive quarters. The company's FFO (the REIT version of earnings) have grown steadily over the years, and portfolio occupancy has never fallen below 96%, even during the Great Recession. This steady, predictable growth makes Realty Income's 16.9% average annual returns since its 1994 NYSE listing even more impressive.

To sum it up

In a nutshell, brick-and-mortar discretionary retail (businesses that sell things people don't really need), especially those businesses that sell luxury items or aren't otherwise discount-oriented, are in a tough environment. However, not all retailers are in trouble, and therefore not all REITs that invest in retail properties deserve the reduced valuations they've got –- as you can see, these two have both fallen significantly since last summer.

O Chart

O data by YCharts

The bottom line is that it may be smart to look at this as an opportunity to pick up these REITs at a discounted price, especially if you don't believe all kinds of brick-and-mortar retailers are doomed.