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,
15581558
15591559 // If we are generic at this level, emit all of the replacements at
15601560 // 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) {
15621572 auto genericParams = subs.getGenericSignature ().getGenericParams ();
15631573 unsigned depth = genericParams[currentGenericParamIdx]->getDepth ();
15641574 auto replacements = subs.getReplacementTypes ();
Original file line number Diff line number Diff line change 11// RUN: %empty-directory(%t)
22// 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
44
55// rdar://76863553
66// UNSUPPORTED: OS=watchos && CPU=x86_64
@@ -196,6 +196,18 @@ public func useFoo(x: String, y: C) {
196196// CHECK: [[TYPE:%.*]] = call {{.*}} @__swift_instantiateConcreteTypeFromMangledName{{.*}}({{.*}} @"$s18opaque_result_type3baz1zQrx_tAA1PRzAA1QRzlFQOyAA1CCQo_MD")
197197// CHECK: call swiftcc i8** @swift_getAssociatedConformanceWitness(i8** [[CONFORMANCE]], %swift.type* [[TYPE]]
198198
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+
199211// CHECK-LABEL: define {{.*}} @"$sSS18opaque_result_type1PAA1AAaBP_AA1OPWT"
200212// CHECK: [[OPAQUE:%.*]] = call {{.*}} @"$sSS18opaque_result_typeE3pooQryFQOMg"
201213// 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