1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
scala> :type List[1, 2, 3]
<console>:1: error: identifier expected but integer literal found.
List[1, 2, 3]
^
scala> :type List(1, 2, 3)
List[Int]
scala> :type def foo[T](x: T) = List(x)
[T](x: T)List[T]
scala> :type val bar = List(Set(1))
List[scala.collection.immutable.Set[Int]]
scala> :type lazy val bar = Set(Set(1))
scala.collection.immutable.Set[scala.collection.immutable.Set[Int]]
scala> :type def f[T >: Null, U <: String](x: T, y: U) = Set(x, y)
[T >: Null, U <: String](x: T, y: U)scala.collection.immutable.Set[Any]
scala> :type def x = 1 ; def bar[T >: Null <: AnyRef](xyz: T) = 5
=> Int <and> [T >: Null <: AnyRef](xyz: T)Int
scala>
scala> :type 5
Int
scala> :type val f = 5
Int
scala> :type lazy val f = 5
Int
scala> :type protected lazy val f = 5
<console>:5: error: lazy value f cannot be accessed in object $iw
Access to protected value f not permitted because
enclosing object $eval in package $line13 is not a subclass of
object $iw where target is defined
lazy val $result = f
^
scala> :type def f = 5
=> Int
scala> :type def f() = 5
()Int
scala>
scala> :type def g[T](xs: Set[_ <: T]) = Some(xs.head)
[T](xs: Set[_ <: T])Some[T]
scala>
scala> // verbose!
scala> :type -v List(1,2,3) filter _
// Type signature
(Int => Boolean) => List[Int]
// Internal Type structure
TypeRef(
TypeSymbol(abstract trait Function1[-T1, +R] extends AnyRef)
args = List(
TypeRef(
TypeSymbol(abstract trait Function1[-T1, +R] extends AnyRef)
args = List(
TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
TypeRef(
TypeSymbol(final abstract class Boolean extends AnyVal)
)
)
)
TypeRef(
TypeSymbol(
sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable
)
args = List(
TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
)
)
)
scala> :type -v def f[T >: Null, U <: String](x: T, y: U) = Set(x, y)
// Type signature
[T >: Null, U <: String](x: T, y: U)scala.collection.immutable.Set[Any]
// Internal Type structure
PolyType(
typeParams = List(TypeParam(T >: Null), TypeParam(U <: String))
resultType = MethodType(
params = List(TermSymbol(x: T), TermSymbol(y: U))
resultType = TypeRef(
TypeSymbol(
abstract trait Set[A] extends Iterable[A] with Set[A] with GenericSetTemplate[A,scala.collection.immutable.Set] with SetLike[A,scala.collection.immutable.Set[A]] with Parallelizable[A,scala.collection.parallel.immutable.ParSet[A]]
)
args = List(TypeRef(TypeSymbol(abstract class Any extends )))
)
)
)
scala> :type -v def x = 1 ; def bar[T >: Null <: AnyRef](xyz: T) = 5
// Type signature
=> Int <and> [T >: Null <: AnyRef](xyz: T)Int
// Internal Type structure
OverloadedType(
alts = List(
NullaryMethodType(
TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
PolyType(
typeParams = List(TypeParam(T >: Null <: AnyRef))
resultType = MethodType(
params = List(TermSymbol(xyz: T))
resultType = TypeRef(
TypeSymbol(final abstract class Int extends AnyVal)
)
)
)
)
)
scala> :type -v Nil.combinations _
// Type signature
Int => Iterator[List[Nothing]]
// Internal Type structure
TypeRef(
TypeSymbol(abstract trait Function1[-T1, +R] extends AnyRef)
args = List(
TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
TypeRef(
TypeSymbol(
abstract trait Iterator[+A] extends TraversableOnce[A]
)
args = List(
TypeRef(
TypeSymbol(
sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable
)
args = List(
TypeRef(
TypeSymbol(final abstract class Nothing extends Any)
)
)
)
)
)
)
)
scala> :type -v def f[T <: AnyVal] = List[T]().combinations _
// Type signature
[T <: AnyVal]=> Int => Iterator[List[T]]
// Internal Type structure
PolyType(
typeParams = List(TypeParam(T <: AnyVal))
resultType = NullaryMethodType(
TypeRef(
TypeSymbol(abstract trait Function1[-T1, +R] extends AnyRef)
args = List(
TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
TypeRef(
TypeSymbol(
abstract trait Iterator[+A] extends TraversableOnce[A]
)
args = List(
TypeRef(
TypeSymbol(
sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable
)
args = List(TypeParamTypeRef(TypeParam(T <: AnyVal)))
)
)
)
)
)
)
)
scala> :type -v def f[T, U >: T](x: T, y: List[U]) = x :: y
// Type signature
[T, U >: T](x: T, y: List[U])List[U]
// Internal Type structure
PolyType(
typeParams = List(TypeParam(T), TypeParam(U >: T))
resultType = MethodType(
params = List(TermSymbol(x: T), TermSymbol(y: List[U]))
resultType = TypeRef(
TypeSymbol(
sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable
)
args = List(TypeParamTypeRef(TypeParam(U >: T)))
)
)
)
scala>
scala> // SI-7132 - :type doesn't understand Unit
scala> :type ()
Unit
scala> :type println("side effect!")
Unit
scala> :quit
|