In last week's parsha (ויצא) we have the story of the birth of Dina. Rashi there comments (based on the Medrash) that Leah understood that she was pregnant with a boy and if she had another boy then Rachel would only have 1 of the shevatim, therefore she davened and Hashem made a miracle and turned the baby into a girl, Dina.
There are a number of problems with this Rashi as well as with the whole story of Dina.
In Parshas ויגש, the Torah writes when it lists the descendents of Yaakov, ואת דינה בתו. Rashi comments (based on the Gemara in Nidda) that we see that the Torah calls Dina the daughter of Yaakov to show us that the father is responsible for having a daughter. The Maharsha there asks, what is the proof from Dina, after all Dina started off as a boy (per the medrash in ויצא) and therefore how can any proof be brought from Dina?
Another problem that comes up in Parshas Vayigash is that Rashi comments (based on the medrash) on the pasuk ושאול בן הכנענית, that after what happened with Shechem, Dina made Shimon promise to marry her. The obvious question is how could Shimon marry Dina, his full sister? Even though there is a machlokes whether the shevatim had the status of klal yisrael and had to keep all the mitzvos, they certaionly had to keep the 7 mitzvos of בני נח, and one of those is arayos which prohibits them to marry their sister from their mother.
Both the Tur and the Maharsha answer based on the תרגום יונתן in ויצא. The תרגום יונתן explains the birth of Dina as follows. Both Leah and Rachel were pregnant, Leah was pregnant with Yosef and Rachel with Dina and miraculously the fetuses were switched. Therefore, Dina was always a girl and the proof from the pasuk (that the man is responsible for girls) is fine because Yaakov caused Dina to be a girl. Also, since Yosef and Dina were switched, על פי הלכה Leah was not Dina's mother, rather Rachel was and a בן נח is allowed to marry his sister from his father.
This Tur however, raises another question, what about Yosef? Who על פי הלכה is considered to be his mother? If it is Leah, then what good was the נס? Rachel still ended up with only 1 of the shevatim. Therefore we need to differentiate and say that both Dina and Yosef were Rachel's children.
When we consider how the halacha determines who the the mother of a baby is there are 3 possible alternatives:
1. Whoever conceives the child
2. Wherever the fetus is 40 days after conception (as until then it is considered מיא בעלמא and for example you are allowed to daven for the sex of the child)
3. Whoever gives birth
We see that the Tur cannot hold from 1 because even though Yosef was conceived by Leah he is considered Rachel's son. The Tur cannot hold from 3 either as the Tur holds that Dina was considered Rachel's daughter even though Leah gave birth to her. It would seem that the Tur holds like option 2.
With this we can say the following about Yosef. Leah was pregnant with Yosef but it was before 40 days while Rachel was pregnant with Dina and it was after 40 days. Therefore when they switched Yosef was less then 40 days so he was considered Rachel's son as on day 40 he was in Rachel's womb, while Dina had already passed day 40 in Rachel's womb so she was considered Rachel's daughter even though Leah gave birth to her.
It turns out according to the Tur that Rachel was the mother of both Dina and Yosef.
This Tur clearly has ramifications l'halacha with regards to surrogate mothers etc.