|
| 1 | +/* |
| 2 | + * Scala (https://www.scala-lang.org) |
| 3 | + * |
| 4 | + * Copyright EPFL and Lightbend, Inc. dba Akka |
| 5 | + * |
| 6 | + * Licensed under Apache License 2.0 |
| 7 | + * (http://www.apache.org/licenses/LICENSE-2.0). |
| 8 | + * |
| 9 | + * See the NOTICE file distributed with this work for |
| 10 | + * additional information regarding copyright ownership. |
| 11 | + */ |
| 12 | + |
| 13 | +// DO NOT EDIT, CHANGES WILL BE LOST |
| 14 | +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". |
| 15 | +// Afterwards, running "sbt generateSources" regenerates this source file. |
| 16 | + |
| 17 | +package scala |
| 18 | + |
| 19 | +import scala.language.`2.13` |
| 20 | +import scala.scalajs.js |
| 21 | +import scala.annotation.nowarn |
| 22 | + |
| 23 | +/** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type |
| 24 | + * `Unit`, `()`, and it is not represented by any object in the underlying |
| 25 | + * runtime system. A method with return type `Unit` is analogous to a Java |
| 26 | + * method which is declared `void`. |
| 27 | + */ |
| 28 | +final abstract class Unit private extends AnyVal { |
| 29 | + // Provide a more specific return type for Scaladoc |
| 30 | + override def getClass(): Class[Unit] = ??? |
| 31 | +} |
| 32 | + |
| 33 | +@scala.annotation.compileTimeOnly("`Unit` companion object is not allowed in source; instead, use `()` for the unit value") |
| 34 | +object Unit extends AnyValCompanion { |
| 35 | + |
| 36 | + /** Transforms a value type into a boxed reference type. |
| 37 | + * |
| 38 | + * This method is not intended for use in source code. |
| 39 | + * The runtime representation of this value is platform specific. |
| 40 | + * |
| 41 | + * @param x the Unit to be boxed |
| 42 | + * @return a scala.runtime.BoxedUnit offering `x` as its underlying value. |
| 43 | + */ |
| 44 | + def box(x: Unit): scala.runtime.BoxedUnit = scala.runtime.BoxedUnit.UNIT |
| 45 | + |
| 46 | + /** Transforms a boxed type into a value type. Note that this |
| 47 | + * method is not typesafe: it accepts any Object, but will throw |
| 48 | + * an exception if the argument is not a scala.runtime.BoxedUnit. |
| 49 | + * |
| 50 | + * This method is not intended for use in source code. |
| 51 | + * The result of successfully unboxing a value is `()`. |
| 52 | + * |
| 53 | + * @param x the scala.runtime.BoxedUnit to be unboxed. |
| 54 | + * @throws ClassCastException if the argument is not a scala.runtime.BoxedUnit |
| 55 | + * @return the Unit value () |
| 56 | + */ |
| 57 | + def unbox(x: java.lang.Object): Unit = x.asInstanceOf[scala.runtime.BoxedUnit] |
| 58 | + |
| 59 | + /** The String representation of the scala.Unit companion object. */ |
| 60 | + override def toString = "object scala.Unit" |
| 61 | + |
| 62 | + // The companion of `js.|` defines an implicit conversions from |
| 63 | + // `A | Unit` to `js.UndefOrOps[A]`. To keep this conversion in scope |
| 64 | + // in Scala 3, where we re-interpret `js.|` as a real union, we inject |
| 65 | + // it in the scope of `Unit`. |
| 66 | + @nowarn("cat=deprecation") |
| 67 | + implicit def unitOrOps[A](x: A | Unit): js.UndefOrOps[A] = |
| 68 | + js.internal.UnitOps.unitOrOps[A](x) |
| 69 | + |
| 70 | +} |
| 71 | + |
0 commit comments