File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -8,16 +8,19 @@ object implicitClasses {
8
8
9
9
implicit final class ImplicitStandard [A ](val oa : Option [A ]) { def bar = oa.isDefined }
10
10
implicit final class ImplicitAnyVal [A ](val oa : Option [A ]) extends AnyVal { def bar = oa.isDefined }
11
+ @ inline implicit final class ImplicitInlineAnyVal [A ](val oa : Option [A ]) extends AnyVal { def bar = oa.isDefined }
11
12
12
13
}
13
14
14
15
object implicitFunctions {
15
16
16
17
final class ImplicitStandard [A ](val oa : Option [A ]) { def bar = oa.isDefined }
17
18
final class ImplicitAnyVal [A ](val oa : Option [A ]) extends AnyVal { def bar = oa.isDefined }
19
+ @ inline final class ImplicitInlineAnyVal [A ](val oa : Option [A ]) extends AnyVal { def bar = oa.isDefined }
18
20
19
21
implicit def toStandard [A ](oa : Option [A ]) = new ImplicitStandard (oa)
20
22
implicit def toAnyVal [A ](oa : Option [A ]) = new ImplicitAnyVal (oa)
23
+ @ inline implicit def toInlineAnyVal [A ](oa : Option [A ]) = new ImplicitInlineAnyVal (oa)
21
24
}
22
25
23
26
@ State (Scope .Thread )
@@ -40,6 +43,12 @@ class ImplicitClassTest {
40
43
option.bar
41
44
}
42
45
46
+ @ Benchmark
47
+ def testClassInlineAnyVal = {
48
+ import implicitClasses .ImplicitAnyVal
49
+ option.bar
50
+ }
51
+
43
52
@ Benchmark
44
53
def testFunctionStandard = {
45
54
import implicitFunctions .toStandard
@@ -51,4 +60,10 @@ class ImplicitClassTest {
51
60
import implicitFunctions .toAnyVal
52
61
option.bar
53
62
}
63
+
64
+ @ Benchmark
65
+ def testFunctionInlineAnyVal = {
66
+ import implicitFunctions .toInlineAnyVal
67
+ option.bar
68
+ }
54
69
}
You can’t perform that action at this time.
0 commit comments