When a disgruntled wife (Ari Graynor) loses interest in her millionaire husband (Zach Braff), he runs to a dominatrix. Photo:

There are some things you’d never expect to come out of Sutton Foster’s mouth. “Lick my boot” is one. “I’m a brain surgeon” is another.

It’s all the more jarring because, since her triumph eight years ago in “Thoroughly Modern Millie,” she’s been typecast as a sunny Pollyanna. If “Trust” achieves only one thing, it shows Foster can do more than belt out tunes.

The cast actually is the best thing in the show, which opened last night at Second Stage.

Foster, Zach Braff, Bobby Cannavale and Ari Graynor make this dark comedy by Paul Weitz (director of the “American Pie” and “About a Boy” movies) look a lot better than it is. They’re so good, in fact, that it takes you a little while to register that the characters make no sense.

Braff (from TV’s “Scrubs”) is quite credible as Harry, a dot.com multimillionaire with too much money and not enough lovin’. His disgruntled wife, Aleeza (Graynor), has lost interest in their sex life. In fact, she’s lost interest in pretty much anything that doesn’t involve putting Harry down.

Which is how he ends up hiring a professional dominatrix — who turns out to be an old high-school classmate named Prudence (Foster).

There’s leather and whips, but those scenes feel like cheap titillation and never summon any kind of dark-edged thrill. Especially since they’re accompanied by earnest, buzz-kill explanations about how S&M works.

And then there’s Weitz’s dopey life lessons. Turns out money can’t buy love, bored housewives need discipline, ostensibly macho guys really want to be told what to do and seemingly sensitive men can be manipulative. It’s all tied together by Etch A Sketch psychology. Child abuse? Really?

Director Peter DuBois handled the caustic “Becky Shaw” a couple of years ago, and here he does a great job sharpening some of Weitz’s more facile moments. In particular, he adds a couple of nifty sight gags to what’s already the play’s funniest scene (this is a great season for oral-sex humor). The second joke also gives us our first inkling of how imaginatively vengeful Harry can be.

Add an indie-rock soundtrack (Metric, Bjork, Fiona Apple) and a nicely ominous set by Alexander Dodge to the gifted director and likable cast, and you’ve got yourself a first-rate production of a second-rate play.