File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -1059,6 +1059,16 @@ namespace {
10591059 // If the objc type has any generic args, convert them and bind them to
10601060 // the imported class type.
10611061 if (imported->getGenericParams ()) {
1062+ auto *dc = imported->getDeclContext ();
1063+ Type parentTy;
1064+ // Check if this is a nested type and if so,
1065+ // fetch the parent type.
1066+ if (dc->isTypeContext ()) {
1067+ parentTy = dc->getDeclaredInterfaceType ();
1068+ if (parentTy->is <ErrorType>())
1069+ return Type ();
1070+ }
1071+
10621072 unsigned typeParamCount = imported->getGenericParams ()->size ();
10631073 auto typeArgs = type->getObjectType ()->getTypeArgs ();
10641074 assert (typeArgs.empty () || typeArgs.size () == typeParamCount);
@@ -1084,7 +1094,7 @@ namespace {
10841094 }
10851095 assert (importedTypeArgs.size () == typeParamCount);
10861096 importedType = BoundGenericClassType::get (
1087- imported, nullptr , importedTypeArgs);
1097+ imported, parentTy , importedTypeArgs);
10881098 } else {
10891099 importedType = imported->getDeclaredInterfaceType ();
10901100 }
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t/src)
2+ // RUN: split-file %s %t/src
3+
4+ // RUN: %target-swift-frontend -typecheck -disable-objc-attr-requires-foundation-module -import-objc-header %t/src/ObjC.h -O %t/src/main.swift
5+
6+ // REQUIRES: objc_interop
7+
8+ //--- ObjC.h
9+
10+ @interface MyUnit
11+ @end
12+
13+ __attribute__( ( swift_name ( " Metrics.SomeMetric " ) ) )
14+ @interface SomeMetric < T : MyUnit *>
15+ @end
16+
17+ @interface Metrics
18+ @property ( readonly, strong) SomeMetric< MyUnit *> * metric;
19+ @end
20+
21+ //--- main.swift
22+ func test( metrics: Metrics) -> Metrics . SomeMetric < MyUnit > {
23+ metrics. metric
24+ }
25+
You can’t perform that action at this time.
0 commit comments