Skip to content

[Serialization] Handle XREFs to generic subscripts #16554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1687,8 +1687,11 @@ ModuleFile::resolveCrossReference(ModuleDecl *baseModule, uint32_t pathLen) {
}
} else if (auto alias = dyn_cast<TypeAliasDecl>(base)) {
paramList = alias->getGenericParams();
} else if (auto fn = dyn_cast<AbstractFunctionDecl>(base))
} else if (auto fn = dyn_cast<AbstractFunctionDecl>(base)) {
paramList = fn->getGenericParams();
} else if (auto subscript = dyn_cast<SubscriptDecl>(base)) {
paramList = subscript->getGenericParams();
}

if (!paramList) {
return llvm::make_error<XRefError>(
Expand Down
1 change: 1 addition & 0 deletions test/Serialization/Inputs/has_generic_subscript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public struct GenericSubscript {
set { }
}
}
extension GenericSubscript: GenericSubscriptProto {}

public struct Outer<T> {
public struct Inner<U> {
Expand Down
3 changes: 3 additions & 0 deletions test/Serialization/Inputs/has_generic_subscript_proto.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol GenericSubscriptProto {
subscript<K, V>(k: K) -> V { get set }
}
3 changes: 2 additions & 1 deletion test/Serialization/generic_subscript.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/has_generic_subscript.swift
// RUN: %target-build-swift -emit-module -o %t %S/Inputs/has_generic_subscript.swift %S/Inputs/has_generic_subscript_proto.swift -module-name has_generic_subscript
// RUN: llvm-bcanalyzer %t/has_generic_subscript.swiftmodule | %FileCheck %s
// RUN: %target-swift-frontend -emit-ir -I %t %s -o /dev/null

Expand All @@ -8,4 +8,5 @@
import has_generic_subscript

var sillyDict = GenericSubscript()
_ = sillyDict as GenericSubscriptProto
var value: Int = sillyDict["beer"]