Uploaded image for project: 'Swift'
  1. Swift
  2. SR-10721

Runtime fails to demangle superclass when a type used to satisfy the superclass's generic bound is used in a superficial way

    XMLWordPrintable

    Details

      Description

      We have a `class C<T, U, V> where U: Switch`. Another class `MyPlugin: C<Context, OneCaseEnum, PluginType>` inherits from `C`.

      Running the attached sample code causes it to fail with

      failed to demangle superclass of MyPlugin from mangled name '11ClassModule1CCy04EnumB07ContextCAD07OneCaseC0OAD10PluginTypeCG'
      2019-05-20 15:49:23.357211-0700 OneCaseEnum2[12132:17387604] failed to demangle superclass of MyPlugin from mangled name '11ClassModule1CCy04EnumB07ContextCAD07OneCaseC0OAD10PluginTypeCG' 

      `OneCaseEnum` is only used in the context of this generic and stored in the class. In our real project adding something like `print(OneCaseEnum.myCase)` is enough to fix the issue, but in this sample only adding a direct reference to the type metadata as `public let test: Any.Type = PluginFactory<Context, OneCaseEnum, PluginType>.self` will fix it (and continues to work in release builds).

      In our real app using `all_load` also doesn't work, but I haven't tried this in this code sample.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              benpious Ben Pious
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated: