Skip to content

[5.0] [Mangle] Include generic arguments of extensions for the Objective-C runtime #20789

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
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: 5 additions & 0 deletions lib/Demangling/OldRemangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,11 @@ void Remangler::mangleGenericArgs(Node *node, EntityContext &ctx) {
break;
}

case Node::Kind::Extension: {
mangleGenericArgs(node->getChild(1), ctx);
break;
}

default:
break;
}
Expand Down
3 changes: 3 additions & 0 deletions test/Demangle/remangle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ RUN: diff %t.input %t.output
// CHECK: Swift.(Mystruct in _7B40D7ED6632C2BEA2CA3BFFD57E3435)
RUN: swift-demangle -remangle-objc-rt '$ss8Mystruct33_7B40D7ED6632C2BEA2CA3BFFD57E3435LLV' | %FileCheck %s

// CHECK-GENERICEXT: Swift._ContiguousArrayStorage<(extension in Swift):Swift.FlattenSequence<StdlibCollectionUnittest.MinimalBidirectionalCollection<StdlibCollectionUnittest.MinimalBidirectionalCollection<Swift.Int>>>.Index>
RUN: swift-demangle -remangle-objc-rt '$ss23_ContiguousArrayStorageCys15FlattenSequenceVsE5IndexVy24StdlibCollectionUnittest020MinimalBidirectionalH0VyAIySiGG_GGD' | %FileCheck -check-prefix CHECK-GENERICEXT %s

102 changes: 40 additions & 62 deletions validation-test/stdlib/Lazy.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1251,36 +1251,32 @@ do {
% for Traversal in 'Forward', 'Bidirectional':
% TraversalCollection = collectionForTraversal(Traversal)

// re-enable commented out test case below as well when this is fixed
// (find FIXME: rdar45956357)
if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) {
tests.test("FlattenCollection/${Traversal}/\(data)") {
let base = Minimal${TraversalCollection}(
elements: data.map { Minimal${TraversalCollection}(elements: $0) })

let flattened = base.joined()
check${Traversal}Collection(expected, flattened, resiliencyChecks: .none)

// Checking that flatten doesn't introduce laziness
var calls = 0
_ = flattened.map { _ in calls += 1 }
expectLE(
expected.count, calls,
"unexpected laziness in \(type(of: flattened))")
}

tests.test("FlattenCollection/${Traversal}/Lazy\(data)") {
// Checking that flatten doesn't remove laziness
let base = Minimal${TraversalCollection}(
elements: data.map { Minimal${TraversalCollection}(elements: $0) }
).lazy.map { $0 }

let flattened = base.joined()

var calls = 0
_ = flattened.map { _ in calls += 1 }
expectEqual(0, calls, "unexpected eagerness in \(type(of: flattened))")
}
tests.test("FlattenCollection/${Traversal}/\(data)") {
let base = Minimal${TraversalCollection}(
elements: data.map { Minimal${TraversalCollection}(elements: $0) })

let flattened = base.joined()
check${Traversal}Collection(expected, flattened, resiliencyChecks: .none)

// Checking that flatten doesn't introduce laziness
var calls = 0
_ = flattened.map { _ in calls += 1 }
expectLE(
expected.count, calls,
"unexpected laziness in \(type(of: flattened))")
}

tests.test("FlattenCollection/${Traversal}/Lazy\(data)") {
// Checking that flatten doesn't remove laziness
let base = Minimal${TraversalCollection}(
elements: data.map { Minimal${TraversalCollection}(elements: $0) }
).lazy.map { $0 }

let flattened = base.joined()

var calls = 0
_ = flattened.map { _ in calls += 1 }
expectEqual(0, calls, "unexpected eagerness in \(type(of: flattened))")
}
% end
}
Expand All @@ -1295,38 +1291,20 @@ struct TryFlattenIndex<C: Collection> where C.Element: Collection {

let prefixDropWhileTests: [(data: [Int], value: Int, pivot: Int)]

// FIXME: rdar45956357
if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) {
prefixDropWhileTests = [
([], 0, 0),
([0], 0, 0),
([0], 99, 1),
([0, 10], 0, 0),
([0, 10], 10, 1),
([0, 10], 99, 2),
([0, 10, 20, 30, 40], 0, 0),
([0, 10, 20, 30, 40], 10, 1),
([0, 10, 20, 30, 40], 20, 2),
([0, 10, 20, 30, 40], 30, 3),
([0, 10, 20, 30, 40], 40, 4),
([0, 10, 20, 30, 40], 99, 5)
]
} else {
prefixDropWhileTests = [
([], 0, 0),
([0], 0, 0),
// ([0], 99, 1),
([0, 10], 0, 0),
// ([0, 10], 10, 1),
// ([0, 10], 99, 2),
// ([0, 10, 20, 30, 40], 0, 0),
// ([0, 10, 20, 30, 40], 10, 1),
// ([0, 10, 20, 30, 40], 20, 2),
// ([0, 10, 20, 30, 40], 30, 3),
// ([0, 10, 20, 30, 40], 40, 4),
// ([0, 10, 20, 30, 40], 99, 5)
]
}
prefixDropWhileTests = [
([], 0, 0),
([0], 0, 0),
([0], 99, 1),
([0, 10], 0, 0),
([0, 10], 10, 1),
([0, 10], 99, 2),
([0, 10, 20, 30, 40], 0, 0),
([0, 10, 20, 30, 40], 10, 1),
([0, 10, 20, 30, 40], 20, 2),
([0, 10, 20, 30, 40], 30, 3),
([0, 10, 20, 30, 40], 40, 4),
([0, 10, 20, 30, 40], 99, 5)
]

% for Kind in 'Sequence', 'Forward', 'Bidirectional':
% Self = 'Sequence' if Kind == 'Sequence' else collectionForTraversal(Kind)
Expand Down