Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/noinline

noinline

scala.noinline
finalclassnoinline extendsStaticAnnotation

An annotation for methods that the optimizer should not inline.

Note that by default, the Scala optimizer is disabled and no callsites are inlined. See-opt:help for information how to enable the optimizer and inliner.

When inlining is enabled, the inliner will never inline methods or callsites annotated@noinline.

Examples:

@inline   final def f1(x: Int) = x@noinline final def f2(x: Int) = x         final def f3(x: Int) = xdef t1 = f1(1)              // inlined if possibledef t2 = f2(1)              // not inlineddef t3 = f3(1)              // may be inlined (the inliner heuristics can select the callsite)def t4 = f1(1): @noinline   // not inlined (override at callsite)def t5 = f2(1): @inline     // inlined if possible (override at callsite)def t6 = f3(1): @inline     // inlined if possibledef t7 = f3(1): @noinline   // not inlined}

Note: parentheses are required when annotating a callsite within a larger expression.

def t1 = f1(1) + f1(1): @noinline   // equivalent to (f1(1) + f1(1)): @noinlinedef t2 = f1(1) + (f1(1): @noinline) // the second call to f1 is not inlined

Attributes

Source
noinline.scala
Graph
Supertypes
classObject
traitMatchable
classAny
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp