Skip to content

Commit d335b0f

Browse files
committed
Review
1 parent e3858e4 commit d335b0f

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
227227
val Yinstrument: Setting[Boolean] = BooleanSetting("-Yinstrument", "Add instrumentation code that counts allocations and closure creations.")
228228
val YinstrumentDefs: Setting[Boolean] = BooleanSetting("-Yinstrument-defs", "Add instrumentation code that counts method calls; needs -Yinstrument to be set, too.")
229229

230-
val YforceInlineWhileTyping: Setting[Boolean] = BooleanSetting("-Yforce-inline-while-typing", "")
230+
val YforceInlineWhileTyping: Setting[Boolean] = BooleanSetting("-Yforce-inline-while-typing", "Make non-transparent inline methods inline when typing. Emulates the old inlining behavior of 3.0.0-M3.")
231231

232232
/** Dottydoc specific settings that are not used in scaladoc */
233233
val docSnapshot: Setting[Boolean] = BooleanSetting("-doc-snapshot", "Generate a documentation snapshot for the current Dotty version")

compiler/src/dotty/tools/dotc/transform/Inlining.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Inlining extends MacroTransform {
106106
object Inlining {
107107
val name: String = "inlining"
108108

109-
/** Check that `vdef.rhs` can be right hand-side or argument to `inline` value or parameter. */
109+
/** Check that `vdef.rhs` can be right hand-side of an `inline` value definition. */
110110
def checkInlineConformant(vdef: tpd.ValDef)(using Context): Unit = {
111111
val ValDef(_, tpt, rhs) = vdef
112112
if vdef.symbol.is(Inline, butNot = DeferredOrTermParamOrAccessor) && !ctx.erasedTypes && !Inliner.inInlineMethod then

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
258258
override def transform(tree: Tree)(using Context): Tree =
259259
try tree match {
260260
case tree: Ident if !tree.isType =>
261-
if tree.symbol.is(Inline) then
261+
if tree.symbol.is(Inline) && !Inliner.inInlineMethod then
262262
ctx.compilationUnit.needsInlining = true
263263
checkNoConstructorProxy(tree)
264264
tree.tpe match {
@@ -276,7 +276,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
276276
checkNoConstructorProxy(tree)
277277
transformSelect(tree, Nil)
278278
case tree: Apply =>
279-
if tree.symbol.is(Inline) then
279+
if tree.symbol.is(Inline) && !Inliner.inInlineMethod then
280280
ctx.compilationUnit.needsInlining = true
281281
val methType = tree.fun.tpe.widen
282282
val app =

docs/docs/reference/metaprogramming/inline.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,11 @@ val one: 1 = zero + 1
285285
```
286286

287287
### Transparent vs. non-transparent inline
288-
As we already discussed, transparent inline methods will provide a more precise.
289-
Technically this implies that transparent inline methods must be expanded while typing the program. Other inline methods are inlined later after the program is fully typed.
288+
As we already discussed, transparent inline methods may influence type checking at call site.
289+
Technically this implies that transparent inline methods must be expanded during type checking of the program.
290+
Other inline methods are inlined later after the program is fully typed.
290291

291-
For example the following two functions will be typed the same way but will be inlined at different times.
292+
For example, the following two functions will be typed the same way but will be inlined at different times.
292293
```scala
293294
inline def f1: T = ...
294295
transparent inline def f2: T = (...): T
@@ -297,7 +298,8 @@ transparent inline def f2: T = (...): T
297298
A noteworthy difference is the behavior of `transparent inline given`.
298299
If there is an error reported when inlining that definition, it will be considered as an implicit search mismatch and the search will continue.
299300
A `transparent inline given` can add a type ascription in its RHS (as in `f2` from the previous example) to avoid the precise type but keep the search behavior.
300-
On the other hand `inline given` be taken as the implicit and then after typing is done the code is inlined and any error will be emitted as usual.
301+
On the other hand, `inline given` be taken as the implicit and then inlined after typing.
302+
Any error will be emitted as usual.
301303

302304
## Inline Conditionals
303305

@@ -328,7 +330,7 @@ below:
328330
| This location is in code that was inlined at ...
329331
```
330332

331-
In a transparent inline, an `inline if` will force the inlining of any inline definition in its condition.
333+
In a transparent inline, an `inline if` will force the inlining of any inline definition in its condition during type checking.
332334

333335
## Inline Matches
334336

0 commit comments

Comments
 (0)