Skip to content

Commit 2e3f4ac

Browse files
committed
AST: Fix mangling of unvalidated declarations
This is again just a temporary workaround until getInterfaceType() can kick off a request.
1 parent a4bb310 commit 2e3f4ac

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/ExistentialLayout.h"
2121
#include "swift/AST/GenericSignature.h"
2222
#include "swift/AST/Initializer.h"
23+
#include "swift/AST/LazyResolver.h"
2324
#include "swift/AST/Module.h"
2425
#include "swift/AST/Ownership.h"
2526
#include "swift/AST/ParameterList.h"
@@ -2323,6 +2324,12 @@ CanType ASTMangler::getDeclTypeForMangling(
23232324
parentGenericSig = nullptr;
23242325

23252326
auto &C = decl->getASTContext();
2327+
if (!decl->hasInterfaceType() && !decl->getDeclContext()->isLocalContext()) {
2328+
if (auto *resolver = C.getLazyResolver()) {
2329+
resolver->resolveDeclSignature(const_cast<ValueDecl *>(decl));
2330+
}
2331+
}
2332+
23262333
if (!decl->hasInterfaceType() || decl->getInterfaceType()->is<ErrorType>()) {
23272334
if (isa<AbstractFunctionDecl>(decl))
23282335
return CanFunctionType::get({AnyFunctionType::Param(C.TheErrorType)},

test/IRGen/Inputs/vtable_multi_file_helper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SillySequence : Sequence, IteratorProtocol {
99
var storedProperty: Int = 0
1010

1111
func makeIterator() -> SillySequence {
12-
return sel
12+
return self
1313
}
1414

1515
func next() -> Int? {
@@ -21,4 +21,8 @@ class Holder {
2121
func getSillySequence() -> SillySequence {
2222
return SillySequence()
2323
}
24+
}
25+
26+
class Base {
27+
func method() {}
2428
}

test/IRGen/vtable_multi_file.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
// REQUIRES: CPU=x86_64
44

5+
// CHECK-LABEL: @"$s17vtable_multi_file7DerivedCMf" = internal global
6+
// CHECK-SAME: @"$s17vtable_multi_file4BaseC6methodyyF"
7+
class Derived : Base {
8+
func another() {}
9+
}
10+
511
func markUsed<T>(_ t: T) {}
612

713
// CHECK-LABEL: define hidden swiftcc void @"$s17vtable_multi_file36baseClassVtablesIncludeImplicitInitsyyF"() {{.*}} {

0 commit comments

Comments
 (0)