Skip to content

Commit 7817062

Browse files
authored
Clarify inline match doc (scala#16088)
Fixes scala#13774
2 parents c28c16e + b1108eb commit 7817062

File tree

1 file changed

+7
-6
lines changed
  • docs/_docs/reference/metaprogramming

1 file changed

+7
-6
lines changed

docs/_docs/reference/metaprogramming/inline.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@ In a transparent inline, an `inline if` will force the inlining of any inline de
344344
## Inline Matches
345345

346346
A `match` expression in the body of an `inline` method definition may be
347-
prefixed by the `inline` modifier. If there is enough static information to
348-
unambiguously take a branch, the expression is reduced to that branch and the
349-
type of the result is taken. If not, a compile-time error is raised that
350-
reports that the match cannot be reduced.
347+
prefixed by the `inline` modifier. If there is enough type information
348+
at compile time to select a branch, the expression is reduced to that branch and the
349+
type of the expression is the type of the right-hand side of that result.
350+
If not, a compile-time error is raised that reports that the match cannot be reduced.
351351

352352
The example below defines an inline method with a
353353
single inline match expression that picks a case based on its static type:
@@ -363,8 +363,9 @@ g("test") // Has type (String, String)
363363
```
364364

365365
The scrutinee `x` is examined statically and the inline match is reduced
366-
accordingly returning the corresponding value (with the type specialized because `g` is declared `transparent`). This example performs a simple type test over the
367-
scrutinee. The type can have a richer structure like the simple ADT below.
366+
accordingly returning the corresponding value (with the type specialized because `g` is declared `transparent`).
367+
This example performs a simple type test over the scrutinee.
368+
The type can have a richer structure like the simple ADT below.
368369
`toInt` matches the structure of a number in [Church-encoding](https://en.wikipedia.org/wiki/Church_encoding)
369370
and _computes_ the corresponding integer.
370371

0 commit comments

Comments
 (0)