File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -747,8 +747,20 @@ class DecodedMetadataBuilder {
747
747
// Figure out the various levels of generic parameters we have in
748
748
// this type.
749
749
std::vector<unsigned > genericParamCounts;
750
- bool innermostIsGeneric =
751
- _gatherGenericParameterCounts (typeDecl, genericParamCounts);
750
+ bool innermostIsGeneric;
751
+
752
+ // If we have no parent given, try to form the whole type in one go.
753
+ if (!parent) {
754
+ innermostIsGeneric = !genericArgs.empty ();
755
+ if (innermostIsGeneric) {
756
+ genericParamCounts.push_back (genericArgs.size ());
757
+ }
758
+ // Otherwise, we'll need to steal the generic arguments from the parent
759
+ // type to build a nested type.
760
+ } else {
761
+ innermostIsGeneric = _gatherGenericParameterCounts (typeDecl,
762
+ genericParamCounts);
763
+ }
752
764
bool isGeneric = !genericParamCounts.empty ();
753
765
754
766
// Gather the generic arguments.
Original file line number Diff line number Diff line change @@ -782,4 +782,20 @@ mirrors.test("String.init") {
782
782
expectEqual ( " 42 " , String ( reflecting: 42 ) )
783
783
expectEqual ( " \" 42 \" " , String ( reflecting: " 42 " ) )
784
784
}
785
+
786
+ struct a < b> {
787
+ enum c { }
788
+ }
789
+ class d { }
790
+ struct e < f> {
791
+ var constraints : [ Int : a < f > . c ] = [ : ]
792
+ }
793
+
794
+ mirrors. test ( " field with generic nested type " ) {
795
+ let x = e < d > ( )
796
+
797
+ expectTrue ( type ( of: Mirror ( reflecting: x) . children. first!. value)
798
+ == [ Int : a < d > . c ] . self)
799
+ }
800
+
785
801
runAllTests ( )
You can’t perform that action at this time.
0 commit comments