Skip to content

Commit cd3d98c

Browse files
committed
[Serialization] Don't look at extension members when resolving XREFs.
This is mostly a "don't crash" commit, but since member XREFs don't specify which module they're looking in, they can actually pick up members from the module currently being compiled...which may not have a type yet. rdar://problem/21071045 Swift SVN r30895
1 parent 91d1821 commit cd3d98c

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,8 @@ static void filterValues(Type expectedTy, Module *expectedModule,
982982
[=](ValueDecl *value) {
983983
if (isType != isa<TypeDecl>(value))
984984
return true;
985+
if (!value->hasType())
986+
return true;
985987
if (canTy && value->getInterfaceType()->getCanonicalType() != canTy)
986988
return true;
987989
// FIXME: Should be able to move a value from an extension in a derived

test/Serialization/Inputs/has_xref.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ public protocol ExtraIncrementable {
1313
}
1414

1515
extension SpecialInt : ExtraIncrementable {}
16+
17+
public protocol DefaultInitializable {
18+
init()
19+
}
20+
21+
extension SpecialInt : DefaultInitializable {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import has_xref
2+
3+
extension SpecialInt {
4+
init(conflict: ()) {}
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: rm -rf %t && mkdir %t
2+
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/struct_with_operators.swift
3+
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/alias.swift -module-name has_alias
4+
// RUN: %target-swift-frontend -emit-module -o %t -I %t %S/Inputs/has_xref.swift
5+
// RUN: llvm-bcanalyzer %t/has_xref.swiftmodule | FileCheck %s
6+
// RUN: %target-swift-frontend -emit-silgen -I %t -primary-file %s %S/Inputs/xref-multi-file-other.swift -module-name main > /dev/null
7+
8+
// CHECK-NOT: UnknownCode
9+
10+
import has_xref
11+
12+
func use<T: DefaultInitializable>(_: T) {}
13+
func test(x: SpecialInt) {
14+
use(x)
15+
}

0 commit comments

Comments
 (0)