There is no free lunch for a few other reasons.
1. While the lunch with free for you, it was not free for the other person. He or she had to pay. So, in the ultimate sense, there was nothing free.
2. You also have to consider what took place in the lunch. Did you help the person in any way or even simply keep the person company? If so, you paid for it through your services.
3. Finally, is there an unspoken assumption that you owe that person lunch or something else next time, some sort of quid pro quo arrangement? If so, again, lunch was not free!
According to economists, there is no such thing as a free lunch. So no matter what situation you cite, it can't be a free lunch.
Here's why it's not a free lunch, even for you:
Even though you are not paying for the lunch, you are giving something up. In your case, what you're giving up is the chance to do or eat something other than what you did/ate.
When you went with your friend, you didn't go with some other friend. Or you didn't study. Or you didn't do more work. In other words, there were other things you could have done.
When you had whatever your friend bought you, you gave up the chance to have some other kind of meal for your lunch.
So the whole point of the saying that there's no such thing as a free lunch is that everything has an opportunity cost. And your opportunity costs were the things you might have done if you hadn't gone with your friend.