Skip to content

Commit eeb7b05

Browse files
authored
Merge pull request #26616 from varungandhi-apple/vg-add-isGeneric-doc-example
Add a couple of examples to the isGeneric() documentation.
2 parents 278725f + bc09a4a commit eeb7b05

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/swift/AST/Decl.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,17 @@ class GenericContext : private _GenericContext, public DeclContext {
15231523

15241524
/// Determine whether this context has generic parameters
15251525
/// of its own.
1526+
///
1527+
/// \code
1528+
/// class C<T> {
1529+
/// func f1() {} // isGeneric == false
1530+
/// func f2<T>() {} // isGeneric == true
1531+
/// }
1532+
///
1533+
/// protocol P { // isGeneric == true due to implicit Self param
1534+
/// func p() // isGeneric == false
1535+
/// }
1536+
/// \endcode
15261537
bool isGeneric() const { return GenericParams != nullptr; }
15271538

15281539
/// Retrieve the trailing where clause for this extension, if any.

0 commit comments

Comments
 (0)