Only reason I'm asking this question is that I want to fly home to the US to visit family in early February, but my current D visa (Spain) expires mid-March. I am approved for a residence permit in Sweden since I will be studying there from January to June, however I was instructed by the Swedish Migration Agency to pick up my permit in Sweden since I am a visa-free passport holder.
If I were to get a direct flight from US to Sweden I wouldn't worry about it since I know it's normal for students to travel to Sweden before getting their visa, and the border control there knows how the migration system works. However the only affordable flight I've found goes through Portugal (TAPAir) and I'm worried the Portuguese border control will question my motives (why flying back and forth, why is my flight connecting to Sweden and not Spain, etc) and will not let me in if I say I'm going to Sweden to pick up my residence permit.
Therefore my question is, will they even care or question me if I have a D visa for Spain that is valid until mid-March? Are they even able to deny entry to someone who has a valid D visa? I don't mind answering questions and being interviewed more than usual, I'm just worried about the possibility of being denied entry. I've already left and re-entered once throughout my D visa period with no questions asked (France as port of entry) but it was around Christmas when it's quite normal to travel.