Skip to content

Commit beb6240

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents 76ee81c + 330326a commit beb6240

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10149,6 +10149,15 @@ static void finishTypeWitnesses(
1014910149
break;
1015010150
}
1015110151

10152+
if (!satisfied && assocType->hasDefaultDefinitionType()) {
10153+
auto defaultType = assocType->getDefaultDefinitionType();
10154+
auto subMap =
10155+
selfType->getContextSubstitutionMap(assocType->getDeclContext());
10156+
defaultType = defaultType.subst(subMap);
10157+
conformance->setTypeWitness(assocType, defaultType, assocType);
10158+
satisfied = true;
10159+
}
10160+
1015210161
if (!satisfied) {
1015310162
ABORT([&](auto &out) {
1015410163
out << "Cannot look up associated type for imported conformance:\n";
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/include)
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %target-swift-frontend -typecheck -module-name a -cxx-interoperability-mode=default -I %t/include %t/a.swift
6+
7+
//--- include/module.modulemap
8+
module cxx {
9+
header "header.h"
10+
export *
11+
}
12+
13+
//--- include/header.h
14+
struct S {
15+
S() {}
16+
} __attribute__((swift_attr("conforms_to:a.P")));
17+
18+
struct S2 {
19+
S2() {}
20+
using A = S2;
21+
} __attribute__((swift_attr("conforms_to:a.P")));
22+
23+
//--- a.swift
24+
import cxx
25+
public protocol P {
26+
associatedtype A = Int
27+
func foo(_: A)
28+
}
29+
extension P {
30+
func foo(_: A) {}
31+
}
32+
func test(s: S) {
33+
let _ = s.foo(0)
34+
}
35+
func test2(s: S2) {
36+
let _ = s.foo(s)
37+
}

0 commit comments

Comments
 (0)