Skip to content

Make an internal KeyPath helper final. #32088

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 3 commits into from
May 30, 2020
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
2 changes: 1 addition & 1 deletion include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ DECL_ATTR(available, Available,
CONTEXTUAL_SIMPLE_DECL_ATTR(final, Final,
OnClass | OnFunc | OnAccessor | OnVar | OnSubscript |
DeclModifier |
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIStableToRemove,
ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
2)
DECL_ATTR(objc, ObjC,
OnAbstractFunction | OnClass | OnProtocol | OnExtension | OnVar |
Expand Down
11 changes: 11 additions & 0 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
//
//===----------------------------------------------------------------------===//

#define DEBUG_TYPE "type-metadata-layout"

#include "swift/ABI/MetadataValues.h"
#include "swift/ABI/TypeIdentity.h"
#include "swift/AST/ASTContext.h"
Expand Down Expand Up @@ -1520,6 +1522,15 @@ namespace {
void addVTable() {
if (VTableEntries.empty())
return;

LLVM_DEBUG(
llvm::dbgs() << "VTable entries for " << getType()->getName() << ":\n";
for (auto entry : VTableEntries) {
llvm::dbgs() << " ";
entry.print(llvm::dbgs());
llvm::dbgs() << '\n';
}
);

// Only emit a method lookup function if the class is resilient
// and has a non-empty vtable.
Expand Down
11 changes: 2 additions & 9 deletions stdlib/public/core/KeyPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class AnyKeyPath: Hashable, _AppendKeyPath {

// Prevent normal initialization. We use tail allocation via
// allocWithTailElems().
@available(*, unavailable)
internal init() {
_internalInvariantFailure("use _create(...)")
}
Expand All @@ -158,7 +159,7 @@ public class AnyKeyPath: Hashable, _AppendKeyPath {
return result
}

internal func withBuffer<T>(_ f: (KeyPathBuffer) throws -> T) rethrows -> T {
final internal func withBuffer<T>(_ f: (KeyPathBuffer) throws -> T) rethrows -> T {
defer { _fixLifetime(self) }

let base = UnsafeRawPointer(Builtin.projectTailElems(self, Int32.self))
Expand Down Expand Up @@ -348,14 +349,6 @@ public class ReferenceWritableKeyPath<

internal final override class var kind: Kind { return .reference }

internal final override func _projectMutableAddress(
from base: UnsafePointer<Root>
) -> (pointer: UnsafeMutablePointer<Value>, owner: AnyObject?) {
// Since we're a ReferenceWritableKeyPath, we know we don't mutate the base
// in practice.
return _projectMutableAddress(from: base.pointee)
}

@usableFromInline
internal final func _projectMutableAddress(from origBase: Root)
-> (pointer: UnsafeMutablePointer<Value>, owner: AnyObject?) {
Expand Down
1 change: 0 additions & 1 deletion test/api-digester/Outputs/Cake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ cake: TypeAlias TChangesFromIntToString.T has underlying type change from Swift.
/* Decl Attribute changes */
cake: Enum IceKind is now without @frozen
cake: Func C1.foo1() is now not static
cake: Func FinalFuncContainer.NewFinalFunc() is now with final
cake: Func HasMutatingMethodClone.foo() has self access kind changing from Mutating to NonMutating
cake: Func S1.foo1() has self access kind changing from NonMutating to Mutating
cake: Func S1.foo3() is now static
Expand Down