Skip to content

Commit 1c3483c

Browse files
akyrtzitkremenek
authored andcommitted
Make sure to hide constructors with underscored API names as private stdlib symbols. (#2839)
This completely removes 'Builtin.<type>' from the interface. The changes in stdlib interface were reviewed by Dmitri.
1 parent dd2820f commit 1c3483c

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/AST/Decl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ bool Decl::isPrivateStdlibDecl(bool whitelistProtocols) const {
425425
for (auto param : *params) {
426426
if (param->hasName() && param->getNameStr().startswith("_"))
427427
return true;
428+
auto argName = param->getArgumentName();
429+
if (!argName.empty() && argName.str().startswith("_"))
430+
return true;
428431
}
429432
return false;
430433
};

stdlib/public/core/FixedPoint.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ public struct ${Self}
243243
% if self_ty.is_word:
244244
@_transparent
245245
public // @testable
246-
init(_ v: Builtin.Word) {
246+
init(_ _v: Builtin.Word) {
247247
% if BuiltinName == 'Int32':
248-
self._value = Builtin.truncOrBitCast_Word_Int32(v)
248+
self._value = Builtin.truncOrBitCast_Word_Int32(_v)
249249
% elif BuiltinName == 'Int64':
250-
self._value = Builtin.zextOrBitCast_Word_Int64(v)
250+
self._value = Builtin.zextOrBitCast_Word_Int64(_v)
251251
% end
252252
}
253253

test/IDE/print_stdlib.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// DONT_CHECK-NOT: {{([^I]|$)([^n]|$)([^d]|$)([^e]|$)([^x]|$)([^a]|$)([^b]|$)([^l]|$)([^e]|$)}}
3434
// CHECK-NOT: buffer: _ArrayBuffer
3535
// CHECK-NOT: func ~>
36-
// FIXME: Builtin.
37-
// FIXME: RawPointer
36+
// CHECK-NOT: Builtin.
37+
// CHECK-NOT: RawPointer
3838
// CHECK-NOT: extension [
3939
// CHECK-NOT: extension {{.*}}?
4040
// CHECK-NOT: extension {{.*}}!

0 commit comments

Comments
 (0)