Skip to content

Commit 9f43fcd

Browse files
committed
Merge pull request #289 from gregheo/fix-optionals-docs-comment
Fix docs and comments around optional intrinsics
2 parents a35567d + 7bbf54b commit 9f43fcd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/archive/LangRef.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,13 @@ <h3 id="type-optional">Optional Types</h3>
12951295
<code>T?</code>.</li>
12961296
</ul>
12971297
To support these intrinsic use cases, the library is required to
1298-
provide four functions with these exact signatures:
1298+
provide functions with these exact signatures:
12991299
<ul>
1300-
<li><code>func _preconditionOptionalHasValue<T>(inout v : T?)</code>
1300+
<li><code>func _doesOptionalHaveValueAsBool<T>(v : T?) -> Bool</code></li>
1301+
<li><code>func _diagnoseUnexpectedNilOptional()</code></li>
13011302
<li><code>func _getOptionalValue<T>(v : T?) -> T</code></li>
1303+
<li><code>func _injectValueIntoOptional<T>(v : T) -> T?</code></li>
1304+
<li><code>func _injectNothingIntoOptional<T>() -> T?</code></li>
13021305
</ul>
13031306
</p>
13041307

@@ -1317,7 +1320,7 @@ <h3 id="type-optional">Optional Types</h3>
13171320
var b : Int? = .None
13181321

13191322
<i>// Declare an array of optionals:</i>
1320-
var c : Int?[] = new Int?[4]
1323+
var c : [Int?] = [10, nil, 42]
13211324
</pre>
13221325

13231326
<!-- _____________________________________________________________________ -->

lib/SILGen/SILGenFunction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,8 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
810810
/// The result is a Builtin.Int1.
811811
SILValue emitDoesOptionalHaveValue(SILLocation loc, SILValue addrOrValue);
812812

813-
/// \brief Emit a call to the library intrinsic _preconditionOptionalHasValue.
813+
/// \brief Emit a switch_enum to call the library intrinsic
814+
/// _diagnoseUnexpectedNilOptional if the optional has no value.
814815
void emitPreconditionOptionalHasValue(SILLocation loc, SILValue addr);
815816

816817
/// \brief Emit a call to the library intrinsic _getOptionalValue

0 commit comments

Comments
 (0)