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 {
1059
1059
// If the objc type has any generic args, convert them and bind them to
1060
1060
// the imported class type.
1061
1061
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
+
1062
1072
unsigned typeParamCount = imported->getGenericParams ()->size ();
1063
1073
auto typeArgs = type->getObjectType ()->getTypeArgs ();
1064
1074
assert (typeArgs.empty () || typeArgs.size () == typeParamCount);
@@ -1084,7 +1094,7 @@ namespace {
1084
1094
}
1085
1095
assert (importedTypeArgs.size () == typeParamCount);
1086
1096
importedType = BoundGenericClassType::get (
1087
- imported, nullptr , importedTypeArgs);
1097
+ imported, parentTy , importedTypeArgs);
1088
1098
} else {
1089
1099
importedType = imported->getDeclaredInterfaceType ();
1090
1100
}
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