Skip to content

Commit e24f447

Browse files
committed
AST: Resolve types when printing inheritance clauses.
Previously, a `.swiftinterface` emitted in lazy typechecking mode would fall back on printing the `TypeRepr` of entries in the inheritance clause of a declaration since inherited types could be unresolved.
1 parent 7c72e7d commit e24f447

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7688,8 +7688,8 @@ swift::getInheritedForPrinting(
76887688
InheritedTypes inherited = InheritedTypes(decl);
76897689

76907690
// Collect explicit inherited types.
7691-
for (auto entry : inherited.getEntries()) {
7692-
if (auto ty = entry.getType()) {
7691+
for (auto i : inherited.getIndices()) {
7692+
if (auto ty = inherited.getResolvedType(i)) {
76937693
bool foundUnprintable = ty.findIf([&](Type subTy) {
76947694
if (auto aliasTy = dyn_cast<TypeAliasType>(subTy.getPointer()))
76957695
return !options.shouldPrint(aliasTy->getDecl());
@@ -7703,7 +7703,7 @@ swift::getInheritedForPrinting(
77037703
continue;
77047704
}
77057705

7706-
Results.push_back(entry);
7706+
Results.push_back(inherited.getEntry(i));
77077707
}
77087708

77097709
// Collect synthesized conformances.

test/Inputs/lazy_typecheck.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public protocol PublicProto {
5454
}
5555

5656
protocol InternalProto {
57-
func goodReq() -> Int // expected-note {{protocol requires function 'goodReq()' with type '() -> Int'; add a stub for conformance}}
57+
func goodReq() -> Int // expected-note 2 {{protocol requires function 'goodReq()' with type '() -> Int'; add a stub for conformance}}
5858
func badReq() -> DoesNotExist // expected-error {{cannot find type 'DoesNotExist' in scope}}
5959
}
6060

@@ -137,6 +137,8 @@ extension String: PublicProto {
137137
}
138138
}
139139

140+
extension String: InternalProto {} // expected-error {{type 'String' does not conform to protocol 'InternalProto'}}
141+
140142
struct InternalStructConformingToPublicProto: PublicProto { // expected-error {{type 'InternalStructConformingToPublicProto' does not conform to protocol 'PublicProto'}}
141143
}
142144

test/ModuleInterface/lazy-typecheck.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
// CHECK: public class func publicClassMethod()
4141
// CHECK: deinit
4242
// CHECK: }
43-
// CHECK: public struct PublicStructConformingToPublicProto : PublicProto {
43+
// CHECK: public struct PublicStructConformingToPublicProto : lazy_typecheck.PublicProto {
4444
// CHECK: public init()
4545
// CHECK: public func req() -> Swift.Int
4646
// CHECK: }
47-
// CHECK: public class PublicClassConformingToPublicProto : PublicProto {
47+
// CHECK: public class PublicClassConformingToPublicProto : lazy_typecheck.PublicProto {
4848
// CHECK: public init()
4949
// CHECK: public func req() -> Swift.Int
5050
// CHECK: deinit
5151
// CHECK: }
52-
// CHECK: extension Swift.String : PublicProto {
52+
// CHECK: extension Swift.String : lazy_typecheck.PublicProto {
5353
// CHECK: public func req() -> Swift.Int
5454
// CHECK: }

0 commit comments

Comments
 (0)