@@ -130,107 +130,4 @@ package object js {
130
130
" because you tried to run Scala.js binaries on the JVM. Make sure you " +
131
131
" are using the JVM version of the libraries." )
132
132
133
- /** Allows to cast a value to a facade trait in a type-safe way.
134
- *
135
- * Use as follows:
136
- * {{{
137
- * js.use(x).as[MyFacade]
138
- * }}}
139
- *
140
- * Note that the method calls are only syntactic sugar. There is no overhead
141
- * at runtime for such an operation. Using `use(x).as[T]` is strictly
142
- * equivalent to `x.asInstanceOf[T]` if the compile time check does not fail.
143
- *
144
- * This method supports both Scala classes with exports and facade types
145
- * which are structurally equivalent.
146
- *
147
- * == Examples ==
148
- * Given the following facade type:
149
- * {{{
150
- * trait MyFacade extends js.Object {
151
- * def foo(x: Int): String = js.native
152
- * val bar: Int = js.native
153
- * }
154
- * }}}
155
- *
156
- * We show a couple of examples:
157
- * {{{
158
- * class MyClass1 {
159
- * @JSExport
160
- * def foo(x: Int): String = x.toString
161
- *
162
- * @JSExport
163
- * val bar: Int = 1
164
- * }
165
- *
166
- * val x1 = new MyClass1
167
- * js.use(x1).as[MyFacade] // OK
168
- * }}}
169
- *
170
- * Note that JS conventions apply: The `val bar` can be implemented with a
171
- * `def`.
172
- *
173
- * {{{
174
- * class MyClass2 {
175
- * @JSExport
176
- * def foo(x: Int): String = x.toString
177
- *
178
- * @JSExport
179
- * def bar: Int = 1 // def instead of val
180
- * }
181
- *
182
- * val x2 = new MyClass2
183
- * js.use(x2).as[MyFacade] // OK
184
- * }}}
185
- *
186
- * Missing methods or methods with wrong types will cause a compile-time
187
- * failure.
188
- *
189
- * {{{
190
- * class MyClass3 {
191
- * @JSExport
192
- * def foo(x: String): String = x.toString // wrong type signature
193
- *
194
- * // bar is missing
195
- * }
196
- *
197
- * val x3 = new MyClass3
198
- * js.use(x2).as[MyFacade] // Fails: bar is missing and foo has wrong type
199
- * }}}
200
- *
201
- * Methods must be exported, otherwise they are not taken into consideration.
202
- *
203
- * {{{
204
- * class MyClass4 {
205
- * def foo(x: Int): String = x.toString
206
- *
207
- * @JSExport
208
- * def bar: Int = 1 // def instead of val
209
- * }
210
- *
211
- * val x4 = new MyClass4
212
- * js.use(x4).as[MyFacade] // Fails, foo is missing
213
- * }}}
214
- *
215
- * Other facade types can also be used
216
- *
217
- * {{{
218
- * trait MyOtherFacade extends js.Object {
219
- * def foo(x: Any): String = js.native
220
- * val bar: Int = js.native
221
- * def otherMethod(): Unit = js.native
222
- * }
223
- *
224
- * val x5: MyOtherFacade = // ...
225
- * js.use(x5).as[MyFacade] // OK
226
- * }}}
227
- *
228
- * == Restrictions ==
229
- * - Facade types may only be traits and not have any class ancestors
230
- * - Polymorphic methods are currently not supported
231
- * - Facade types defining an apply method cannot used (this is a JavaScript
232
- * restriction).
233
- */
234
- def use [A ](x : A ): Using [A ] = new Using [A ](x)
235
-
236
133
}
0 commit comments