Skip to content

Commit 42a15b4

Browse files
committed
Make all orElse methods inline methods
Make all orElse methods that take a call-by-name argument inline methods.
1 parent c80d9a8 commit 42a15b4

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ object Trees {
174174
def toList: List[Tree[T]] = this :: Nil
175175

176176
/** if this tree is the empty tree, the alternative, else this tree */
177-
def orElse[U >: Untyped <: T](that: => Tree[U]): Tree[U] =
177+
inline def orElse[U >: Untyped <: T](inline that: Tree[U]): Tree[U] =
178178
if (this eq genericEmptyTree) that else this
179179

180180
/** The number of nodes in this tree */

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ object Denotations {
237237
def mapInfo(f: Type => Type)(using Context): Denotation
238238

239239
/** If this denotation does not exist, fallback to alternative */
240-
final def orElse(that: => Denotation): Denotation = if (this.exists) this else that
240+
inline def orElse(inline that: Denotation): Denotation = if (this.exists) this else that
241241

242242
/** The set of alternative single-denotations making up this denotation */
243243
final def alternatives: List[SingleDenotation] = altsWith(alwaysTrue)
@@ -596,7 +596,7 @@ object Denotations {
596596
def mapInfo(f: Type => Type)(using Context): SingleDenotation =
597597
derivedSingleDenotation(symbol, f(info))
598598

599-
def orElse(that: => SingleDenotation): SingleDenotation = if (this.exists) this else that
599+
inline def orElse(inline that: SingleDenotation): SingleDenotation = if (this.exists) this else that
600600

601601
def altsWith(p: Symbol => Boolean): List[SingleDenotation] =
602602
if (exists && p(symbol)) this :: Nil else Nil

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ object Symbols {
239239
}
240240

241241
/** This symbol, if it exists, otherwise the result of evaluating `that` */
242-
def orElse(that: => Symbol)(using Context): Symbol =
242+
inline def orElse(inline that: Symbol)(using Context): Symbol =
243243
if (this.exists) this else that
244244

245245
/** If this symbol satisfies predicate `p` this symbol, otherwise `NoSymbol` */

0 commit comments

Comments
 (0)