File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -1558,7 +1558,17 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc,
1558
1558
1559
1559
// If we are generic at this level, emit all of the replacements at
1560
1560
// this level.
1561
- if (genericContext->isGeneric ()) {
1561
+ bool treatAsGeneric;
1562
+ if (auto opaque = dyn_cast<OpaqueTypeDecl>(decl)) {
1563
+ // For opaque type declarations, the generic parameters of the opaque
1564
+ // type declaration are not part of the mangling, so check whether the
1565
+ // naming declaration has generic parameters.
1566
+ auto namedGenericContext = opaque->getNamingDecl ()->getAsGenericContext ();
1567
+ treatAsGeneric = namedGenericContext && namedGenericContext->isGeneric ();
1568
+ } else {
1569
+ treatAsGeneric = genericContext->isGeneric ();
1570
+ }
1571
+ if (treatAsGeneric) {
1562
1572
auto genericParams = subs.getGenericSignature ().getGenericParams ();
1563
1573
unsigned depth = genericParams[currentGenericParamIdx]->getDepth ();
1564
1574
auto replacements = subs.getReplacementTypes ();
Original file line number Diff line number Diff line change 1
1
// RUN: %empty-directory(%t)
2
2
// RUN: %{python} %utils/chex.py < %s > %t/opaque_result_type.swift
3
- // RUN: %target-swift-frontend -enable-implicit-dynamic -disable-availability-checking -emit-ir %t/opaque_result_type.swift | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-NODEBUG %t/opaque_result_type.swift
3
+ // RUN: %target-swift-frontend -enable-experimental-named-opaque-types -enable- implicit-dynamic -disable-availability-checking -emit-ir %t/opaque_result_type.swift | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-NODEBUG %t/opaque_result_type.swift
4
4
5
5
// rdar://76863553
6
6
// UNSUPPORTED: OS=watchos && CPU=x86_64
@@ -196,6 +196,18 @@ public func useFoo(x: String, y: C) {
196
196
// CHECK: [[TYPE:%.*]] = call {{.*}} @__swift_instantiateConcreteTypeFromMangledName{{.*}}({{.*}} @"$s18opaque_result_type3baz1zQrx_tAA1PRzAA1QRzlFQOyAA1CCQo_MD")
197
197
// CHECK: call swiftcc i8** @swift_getAssociatedConformanceWitness(i8** [[CONFORMANCE]], %swift.type* [[TYPE]]
198
198
199
+ // Make sure we can mangle named opaque result types
200
+ struct Boom < T: P > {
201
+ var prop1 : Int = 5
202
+ var prop2 : < U , V > ( U , V ) = ( " hello " , 5 )
203
+ }
204
+
205
+ // CHECK-LABEL: define {{.*}} @"$s18opaque_result_type9gimmeBoomypyF
206
+ // CHECK: call swiftcc void @"$s18opaque_result_type4BoomV5prop15prop2ACyxGSi_AcEQr_QrtvpQOyx_Qo__AcEQr_QrtvpQOyx_Qo0_ttcfcfA0_"
207
+ public func gimmeBoom( ) -> Any {
208
+ Boom < String > ( prop1: 5 )
209
+ }
210
+
199
211
// CHECK-LABEL: define {{.*}} @"$sSS18opaque_result_type1PAA1AAaBP_AA1OPWT"
200
212
// CHECK: [[OPAQUE:%.*]] = call {{.*}} @"$sSS18opaque_result_typeE3pooQryFQOMg"
201
213
// CHECK: call swiftcc i8** @swift_getOpaqueTypeConformance(i8* {{.*}}, %swift.type_descriptor* [[OPAQUE]], [[WORD]] 1)
You can’t perform that action at this time.
0 commit comments