@@ -67,7 +67,7 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
67
67
68
68
@ Test def noBoxingSpecFunction0 = {
69
69
implicit val source : String =
70
- """ |object Test {
70
+ """ |class Test {
71
71
| class Func0 extends Function0[Int] {
72
72
| def apply() = 1337
73
73
| }
@@ -76,13 +76,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
76
76
|}""" .stripMargin
77
77
78
78
checkBCode(source) { dir =>
79
- assertNoBoxing(" <init>" , findClass(" Test$ " , dir).methods)
79
+ assertNoBoxing(" <init>" , findClass(" Test" , dir).methods)
80
80
}
81
81
}
82
82
83
83
@ Test def boxingFunction1 = {
84
84
implicit val source : String =
85
- """ |object Test {
85
+ """ |class Test {
86
86
| class Func1 extends Function1[Char, Int] {
87
87
| def apply(c: Char) = c.toInt
88
88
| }
@@ -92,13 +92,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
92
92
93
93
checkBCode(source) { dir =>
94
94
// No specialization for Function1[Char, Int]
95
- assertBoxing(" <init>" , findClass(" Test$ " , dir).methods)
95
+ assertBoxing(" <init>" , findClass(" Test" , dir).methods)
96
96
}
97
97
}
98
98
99
99
@ Test def noBoxingSpecFunction1 = {
100
100
implicit val source : String =
101
- """ |object Test {
101
+ """ |class Test {
102
102
| class Func1 extends Function1[Int, Int] {
103
103
| def apply(i: Int) = i + 1
104
104
| }
@@ -107,13 +107,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
107
107
|}""" .stripMargin
108
108
109
109
checkBCode(source) { dir =>
110
- assertNoBoxing(" <init>" , findClass(" Test$ " , dir).methods)
110
+ assertNoBoxing(" <init>" , findClass(" Test" , dir).methods)
111
111
}
112
112
}
113
113
114
114
@ Test def noBoxingSpecFunction2 = {
115
115
implicit val source : String =
116
- """ |object Test {
116
+ """ |class Test {
117
117
| class Func2 extends Function2[Int, Int, Int] {
118
118
| def apply(i: Int, j: Int) = i + j
119
119
| }
@@ -122,13 +122,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
122
122
|}""" .stripMargin
123
123
124
124
checkBCode(source) { dir =>
125
- assertNoBoxing(" <init>" , findClass(" Test$ " , dir).methods)
125
+ assertNoBoxing(" <init>" , findClass(" Test" , dir).methods)
126
126
}
127
127
}
128
128
129
129
@ Test def boxingFunction2 = {
130
130
implicit val source : String =
131
- """ |object Test {
131
+ """ |class Test {
132
132
| class Func2 extends Function2[Char, Char, Char] {
133
133
| def apply(c1: Char, c2: Char) = c1
134
134
| }
@@ -138,13 +138,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
138
138
139
139
checkBCode(source) { dir =>
140
140
// No specialization for Function2[Char, Char, Char]
141
- assertBoxing(" <init>" , findClass(" Test$ " , dir).methods)
141
+ assertBoxing(" <init>" , findClass(" Test" , dir).methods)
142
142
}
143
143
}
144
144
145
145
@ Test def multipleParentsNoBoxing = {
146
146
implicit val source : String =
147
- """ |object Test {
147
+ """ |class Test {
148
148
| class Func01 extends Function0[Int] with Function1[Int, Int] {
149
149
| def apply(): Int = 0
150
150
| def apply(x: Int): Int = x
@@ -154,13 +154,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
154
154
|}""" .stripMargin
155
155
156
156
checkBCode(source) { dir =>
157
- assertNoBoxing(" <init>" , findClass(" Test$ " , dir).methods)
157
+ assertNoBoxing(" <init>" , findClass(" Test" , dir).methods)
158
158
}
159
159
}
160
160
161
161
@ Test def multipleLevelInheritanceNoBoxing = {
162
162
implicit val source : String =
163
- """ |object Test {
163
+ """ |class Test {
164
164
| class Func1[T](fn: T => Int) extends Function1[T, Int] {
165
165
| def apply(x: T): Int = fn(x)
166
166
| }
@@ -169,25 +169,25 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
169
169
|}""" .stripMargin
170
170
171
171
checkBCode(source) { dir =>
172
- assertNoBoxing(" <init>" , findClass(" Test$ " , dir).methods)
172
+ assertNoBoxing(" <init>" , findClass(" Test" , dir).methods)
173
173
}
174
174
}
175
175
176
176
@ Test def lambdaNoBoxing1 = {
177
177
implicit val source : String =
178
- """ |object Test {
178
+ """ |class Test {
179
179
| val fn = (x: Int) => x + 1
180
180
| fn(2)
181
181
|}""" .stripMargin
182
182
183
183
checkBCode(source) { dir =>
184
- assertNoBoxing(" <init>" , findClass(" Test$ " , dir).methods)
184
+ assertNoBoxing(" <init>" , findClass(" Test" , dir).methods)
185
185
}
186
186
}
187
187
188
188
@ Test def lambdaNoBoxing2 = {
189
189
implicit val source : String =
190
- """ |object Test {
190
+ """ |class Test {
191
191
| def fn[T, U, V](op0: T => U, op1: U => V): T => V = (x: T) => op1(op0(x))
192
192
| val f0: Int => Double = _.toDouble
193
193
| val f1: Double => Int = _.toInt
@@ -196,13 +196,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
196
196
|}""" .stripMargin
197
197
198
198
checkBCode(source) { dir =>
199
- assertNoBoxing(" <init>" , findClass(" Test$ " , dir).methods)
199
+ assertNoBoxing(" <init>" , findClass(" Test" , dir).methods)
200
200
}
201
201
}
202
202
203
203
@ Test def classWithFieldBoxing = {
204
204
implicit val source : String =
205
- """ |object Test {
205
+ """ |class Test {
206
206
| class Func0[T](x: T) extends Function0[T] {
207
207
| def apply(): T = x
208
208
| }
@@ -211,19 +211,19 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
211
211
212
212
checkBCode(source) { dir =>
213
213
// Boxing happens because of the field of `Func0`.
214
- assertBoxing(" <init>" , findClass(" Test$ " , dir).methods)
214
+ assertBoxing(" <init>" , findClass(" Test" , dir).methods)
215
215
}
216
216
}
217
217
218
218
@ Test def passByNameNoBoxing = {
219
219
implicit val source : String =
220
- """ |object Test {
220
+ """ |class Test {
221
221
| def fn(x: => Int): Int = x
222
222
| fn(2)
223
223
|}""" .stripMargin
224
224
225
225
checkBCode(source) { dir =>
226
- assertNoBoxing(" fn" , findClass(" Test$ " , dir).methods)
226
+ assertNoBoxing(" fn" , findClass(" Test" , dir).methods)
227
227
}
228
228
}
229
229
}
0 commit comments