Profile Dependency Issue when Reinstalling

Hi peeps, I have a strange issue with registering a profile as a dependency in my package.

I have the following profiles registered in my package:
snap_2018_12_07_1

The two profiles which are causing the issue are the following:
snap_2018_12_07

In the metadata.xml file of my default profile I have the following entered:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <version>1000</version>
  <dependencies>
    <dependency>profile-my.webapp:contenttypes</dependency>
    <dependency>profile-plone.app.theming:default</dependency>
    <dependency>profile-plonetheme.barceloneta:registerless</dependency>
  </dependencies>
</metadata>

The thing to note here is the <dependency>profile-my.webapp:contenttypes</dependency> line. I set the contenttypes profile as a dependency of my default profile.

Here is the registration for these two profiles in my configure.zcml:

<genericsetup:registerProfile
      name="contenttypes"
      title="My Webapp (contenttypes)"
      directory="profiles/contenttypes"
      description="Installs the my.webapp Content-Types."
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />

<genericsetup:registerProfile
      name="default"
      title="My Webapp"
      directory="profiles/default"
      description="Installs the my.webapp add-on."
      provides="Products.GenericSetup.interfaces.EXTENSION"
      post_handler=".setuphandlers.post_install"
      />

The Issue

When I install the default profile (that has the contenttypes profile as a dependency), then the quickinstaller shows that I have the "My Webapp (contenttypes)" package installed. When I try to reinstall the package, it reinstalls from the contenttypes package and not the default package. Why is this, and do you guys have any idea how to fix this..?

Expected Result

I create a custom profile
it is called contenttypes
I set it as a dependency in my default profile
I install the default profile
and then I navigate to the quickinstaller
I should see the title of my default profile
and if I reinstall the package, it should reinstall the default profile

Current Result

I create a custom profile
it is called contenttypes
I set it as a dependency in my default profile
I install the default profile
and then I navigate to the quickinstaller
I see the title of the contenttypes profile
and if I reinstall the package, it imports the contenttypes profile

Any help would be greatly appreciated! I've taken a look at the documentation for registering multiple profiles, but it does not explain this behaviour...

I think the error happens during the initial installation and the error may be that you do not see that your "My Webapp" package has been installed, too. It is completely natural that when you reinstall a package, then that package's profile is reimported.

I have not yet analysed the behaviour of portal_quickinstaller in detail. However, I already have intensively debugged the dependency handling of GenericSetup (the component responsible for profile management): when GenericSetup is about to import a profile, it checks for dependencies and imports each of those dependencies before it imports the profile itself. One would hope that portal_quickinstaller sees installed all packages corresponding to the imported profiles. My current guess is that portal_quickinstaller gets confused in its logic to associate an installed package with an imported profile. I would use debugging to find out why.