mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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
This commit is contained in:
@@ -982,6 +982,8 @@ static void filterValues(Type expectedTy, Module *expectedModule,
|
||||
[=](ValueDecl *value) {
|
||||
if (isType != isa<TypeDecl>(value))
|
||||
return true;
|
||||
if (!value->hasType())
|
||||
return true;
|
||||
if (canTy && value->getInterfaceType()->getCanonicalType() != canTy)
|
||||
return true;
|
||||
// FIXME: Should be able to move a value from an extension in a derived
|
||||
|
||||
@@ -13,3 +13,9 @@ public protocol ExtraIncrementable {
|
||||
}
|
||||
|
||||
extension SpecialInt : ExtraIncrementable {}
|
||||
|
||||
public protocol DefaultInitializable {
|
||||
init()
|
||||
}
|
||||
|
||||
extension SpecialInt : DefaultInitializable {}
|
||||
|
||||
5
test/Serialization/Inputs/xref-multi-file-other.swift
Normal file
5
test/Serialization/Inputs/xref-multi-file-other.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
import has_xref
|
||||
|
||||
extension SpecialInt {
|
||||
init(conflict: ()) {}
|
||||
}
|
||||
15
test/Serialization/xref-multi-file.swift
Normal file
15
test/Serialization/xref-multi-file.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
// RUN: rm -rf %t && mkdir %t
|
||||
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/struct_with_operators.swift
|
||||
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/alias.swift -module-name has_alias
|
||||
// RUN: %target-swift-frontend -emit-module -o %t -I %t %S/Inputs/has_xref.swift
|
||||
// RUN: llvm-bcanalyzer %t/has_xref.swiftmodule | FileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-silgen -I %t -primary-file %s %S/Inputs/xref-multi-file-other.swift -module-name main > /dev/null
|
||||
|
||||
// CHECK-NOT: UnknownCode
|
||||
|
||||
import has_xref
|
||||
|
||||
func use<T: DefaultInitializable>(_: T) {}
|
||||
func test(x: SpecialInt) {
|
||||
use(x)
|
||||
}
|
||||
Reference in New Issue
Block a user