Skip to content
This repository has been archived by the owner. It is now read-only.

Fixes #4467, #4490. #19

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -238,7 +238,7 @@ class Function(val i: Int) extends Group("Function") with Arity {
curryComment +
" def curried: %s => R = {\n %s\n }\n".format(
targs mkString " => ", body
) + """ @deprecated("Use 'curried' instead", "2.8.0")""" + "\n def curry = curried\n"
) + """ @deprecated("Use `curried` instead", "2.8.0")""" + "\n def curry = curried\n"
}

override def moreMethods = curryMethod + tupleMethod
@@ -13,8 +13,8 @@ import util.Statistics._
/** A base type sequence (BaseTypeSeq) is an ordered sequence spanning all the base types
* of a type. It characterized by the following two laws:
*
* (1) Each element of `tp.baseTypeSeq' is a basetype of `tp'
* (2) For each basetype `bt1' of `tp' there is an element `bt' in `tp.baseTypeSeq' such that
* (1) Each element of `tp.baseTypeSeq` is a basetype of `tp`
* (2) For each basetype `bt1` of `tp` there is an element `bt` in `tp.baseTypeSeq` such that
*
* bt.typeSymbol = bt1.typeSymbol
* bt <: bt1
@@ -96,16 +96,16 @@ trait BaseTypeSeqs {
new BaseTypeSeq(parents, arr)
}

/** Compute new base type sequence with `tp' prepended to this sequence */
/** Compute new base type sequence with `tp` prepended to this sequence */
def prepend(tp: Type): BaseTypeSeq = copy(tp, 1)

/** Compute new base type sequence with `tp' replacing the head of this sequence */
/** Compute new base type sequence with `tp` replacing the head of this sequence */
def updateHead(tp: Type): BaseTypeSeq = copy(tp, 0)

/** Compute new base type sequence where every element is mapped
* with function `f'. Lazy types are mapped but not evaluated */
* with function `f`. Lazy types are mapped but not evaluated */
def map(f: Type => Type): BaseTypeSeq = {
// inlined `elems map f' for performance
// inlined `elems map f` for performance
val len = length
var arr = new Array[Type](len)
var i = 0
@@ -139,7 +139,7 @@ trait BaseTypeSeqs {
d
}

/** The maximum depth of type `tp' */
/** The maximum depth of type `tp` */
protected def maxDpth(tp: Type): Int = tp match {
case TypeRef(pre, sym, args) =>
max(maxDpth(pre), maxDpth(args) + 1)
@@ -159,7 +159,7 @@ trait BaseTypeSeqs {
1
}

/** The maximum depth of all types `tps' */
/** The maximum depth of all types `tps` */
private def maxDpth(tps: Seq[Type]): Int = {
var d = 0
for (tp <- tps) d = max(d, maxDpth(tp))
@@ -94,13 +94,13 @@ trait NameManglers {
name.endChar == '=' && name.startChar != '=' && isOperatorPart(name.startChar)
}

/** The expanded setter name of `name' relative to this class `base`
/** The expanded setter name of `name` relative to this class `base`
*/
def expandedSetterName(name: TermName, base: Symbol): TermName =
expandedName(name, base, separator = TRAIT_SETTER_SEPARATOR_STRING)

/** If `name' is an expandedName name, the original name.
* Otherwise `name' itself.
/** If `name` is an expandedName name, the original name.
* Otherwise `name` itself.
*/
def originalName(name: Name): Name = {
var i = name.length
@@ -25,21 +25,17 @@ trait Names /*extends reflect.generic.Names*/ {

final val nameDebug = false

/** memory to store all names sequentially
*/
/** Memory to store all names sequentially. */
var chrs: Array[Char] = new Array[Char](NAME_SIZE)
private var nc = 0

/** hashtable for finding term names quickly
*/
/** Hashtable for finding term names quickly. */
private val termHashtable = new Array[TermName](HASH_SIZE)

/** hashtable for finding type names quickly
*/
/** Hashtable for finding type names quickly. */
private val typeHashtable = new Array[TypeName](HASH_SIZE)

/** the hashcode of a name
*/
/** The hashcode of a name. */
private def hashValue(cs: Array[Char], offset: Int, len: Int): Int =
if (len > 0)
(len * (41 * 41 * 41) +
@@ -58,8 +54,7 @@ trait Names /*extends reflect.generic.Names*/ {
i == len
}

/** enter characters into chrs array
*/
/** Enter characters into chrs array. */
private def enterChars(cs: Array[Char], offset: Int, len: Int) {
var i = 0
while (i < len) {
@@ -75,8 +70,7 @@ trait Names /*extends reflect.generic.Names*/ {
else nc = nc + len
}

/** Create a term name from the characters in cs[offset..offset+len-1].
*/
/** Create a term name from the characters in cs[offset..offset+len-1]. */
def newTermName(cs: Array[Char], offset: Int, len: Int): TermName = {
val h = hashValue(cs, offset, len) & HASH_MASK
var n = termHashtable(h)
@@ -89,28 +83,23 @@ trait Names /*extends reflect.generic.Names*/ {
n
}

/** create a term name from string
*/
/** Create a term name from string. */
def newTermName(s: String): TermName =
newTermName(s.toCharArray(), 0, s.length())

/** Create a term name from the UTF8 encoded bytes in bs[offset..offset+len-1].
*/
/** Create a term name from the UTF8 encoded bytes in bs[offset..offset+len-1]. */
def newTermName(bs: Array[Byte], offset: Int, len: Int): TermName =
newTermName(Codec fromUTF8 bs.slice(offset, offset + len) mkString)

/** Create a type name from the characters in cs[offset..offset+len-1].
*/
/** Create a type name from the characters in cs[offset..offset+len-1]. */
def newTypeName(cs: Array[Char], offset: Int, len: Int): TypeName =
newTermName(cs, offset, len).toTypeName

/** Create a type name from string
*/
/** Create a type name from string. */
def newTypeName(s: String): TypeName =
newTermName(s).toTypeName

/** Create a type name from the UTF8 encoded bytes in bs[offset..offset+len-1].
*/
/** Create a type name from the UTF8 encoded bytes in bs[offset..offset+len-1]. */
def newTypeName(bs: Array[Byte], offset: Int, len: Int): TypeName =
newTermName(bs, offset, len).toTypeName

@@ -122,8 +111,7 @@ trait Names /*extends reflect.generic.Names*/ {
def nameChars: Array[Char] = chrs
@deprecated("", "2.9.0") def view(s: String): TermName = newTermName(s)

/** An implicit conversion from names to term names
*/
/** An implicit conversion from names to term names. */
implicit def promoteTermNamesAsNecessary(name: Name): TermName = mkTermName(name)


@@ -134,12 +122,10 @@ trait Names /*extends reflect.generic.Names*/ {
/** Index into name table */
def start: Int = index

/** next name in the same hash bucket
*/
/** The next name in the same hash bucket. */
def next: Name

/** return the length of this name
*/
/** The length of this name. */
final def length: Int = len
final def isEmpty = length == 0
final def nonEmpty = !isEmpty
@@ -151,26 +137,23 @@ trait Names /*extends reflect.generic.Names*/ {
def companionName: Name
def bothNames: List[Name] = List(toTermName, toTypeName)

/** Copy bytes of this name to buffer cs, starting at position `offset`.
*/
/** Copy bytes of this name to buffer cs, starting at position `offset`. */
final def copyChars(cs: Array[Char], offset: Int) =
compat.Platform.arraycopy(chrs, index, cs, offset, len)

/** return the ascii representation of this name
*/
/** @return the ascii representation of this name */
final def toChars: Array[Char] = {
val cs = new Array[Char](len)
copyChars(cs, 0)
cs
}

/** return the string representation of this name
*/
/** @return the string representation of this name */
final override def toString(): String = new String(chrs, index, len)
def debugString() = NameTransformer.decode(toString) + (if (isTypeName) "!" else "")

/** Write to UTF8 representation of this name to given character array.
* Start copying to index `to'. Return index of next free byte in array.
* Start copying to index `to`. Return index of next free byte in array.
* Array must have enough remaining space for all bytes
* (i.e. maximally 3*length bytes).
*/
@@ -180,8 +163,7 @@ trait Names /*extends reflect.generic.Names*/ {
offset + bytes.length
}

/** return the hash value of this name
*/
/** @return the hash value of this name */
final override def hashCode(): Int = index

// Presently disabled.
@@ -207,17 +189,16 @@ trait Names /*extends reflect.generic.Names*/ {
false
}

/** return the i'th Char of this name
*/
/** @return the i'th Char of this name */
final def apply(i: Int): Char = chrs(index + i)

/** return the index of first occurrence of char c in this name, length if not found */
/** @return the index of first occurrence of char c in this name, length if not found */
final def pos(c: Char): Int = pos(c, 0)

/** return the index of first occurrence of char c in this name, length if not found */
/** @return the index of first occurrence of char c in this name, length if not found */
final def pos(s: String): Int = pos(s, 0)

/** return the index of the first occurrence of character c in
/** Returns the index of the first occurrence of character c in
* this name from start, length if not found.
*
* @param c the character
@@ -230,7 +211,7 @@ trait Names /*extends reflect.generic.Names*/ {
i
}

/** return the index of the first occurrence of nonempty string s
/** Returns the index of the first occurrence of nonempty string s
* in this name from start, length if not found.
*
* @param s the string
@@ -250,7 +231,7 @@ trait Names /*extends reflect.generic.Names*/ {
len
}

/** return the index of last occurrence of char c in this
/** Returns the index of last occurrence of char c in this
* name, -1 if not found.
*
* @param c the character
@@ -260,7 +241,7 @@ trait Names /*extends reflect.generic.Names*/ {

final def lastPos(s: String): Int = lastPos(s, len - s.length)

/** return the index of the last occurrence of char c in this
/** Returns the index of the last occurrence of char c in this
* name from start, -1 if not found.
*
* @param c the character
@@ -273,7 +254,7 @@ trait Names /*extends reflect.generic.Names*/ {
i
}

/** return the index of the last occurrence of string s in this
/** Returns the index of the last occurrence of string s in this
* name from start, -1 if not found.
*
* @param s the string
@@ -293,12 +274,10 @@ trait Names /*extends reflect.generic.Names*/ {
-s.length()
}

/** does this name start with prefix?
*/
/** Does this name start with prefix? */
final def startsWith(prefix: Name): Boolean = startsWith(prefix, 0)

/** does this name start with prefix at given start index?
*/
/** Does this name start with prefix at given start index? */
final def startsWith(prefix: Name, start: Int): Boolean = {
var i = 0
while (i < prefix.length && start + i < len &&
@@ -307,12 +286,10 @@ trait Names /*extends reflect.generic.Names*/ {
i == prefix.length
}

/** does this name end with suffix?
*/
/** Does this name end with suffix? */
final def endsWith(suffix: Name): Boolean = endsWith(suffix, len)

/** does this name end with suffix just before given end index?
*/
/** Does this name end with suffix just before given end index? */
final def endsWith(suffix: Name, end: Int): Boolean = {
var i = 1
while (i <= suffix.length && i <= end &&
@@ -345,8 +322,7 @@ trait Names /*extends reflect.generic.Names*/ {

def lastIndexOf(ch: Char) = toChars lastIndexOf ch

/** Return the subname with characters from start to end-1.
*/
/** Return the subname with characters from start to end-1. */
def subName(from: Int, to: Int): Name

/** Replace all occurrences of `from` by `to` in
@@ -363,8 +339,7 @@ trait Names /*extends reflect.generic.Names*/ {
newTermName(cs, 0, len)
}

/** Replace operator symbols by corresponding $op_name.
*/
/** Replace operator symbols by corresponding $op_name. */
def encode: Name = {
val str = toString()
val res = NameTransformer.encode(str)
@@ -376,8 +351,7 @@ trait Names /*extends reflect.generic.Names*/ {
def append(suffix: String): Name
def append(suffix: Name): Name

/** Replace $op_name by corresponding operator symbol.
*/
/** Replace $op_name by corresponding operator symbol. */
def decode: String = (
NameTransformer.decode(toString()) +
(if (nameDebug && isTypeName) "!" else ""))//debug
ProTip! Use n and p to navigate between commits in a pull request.