Skip to content

Commit

Permalink
Introduced support of JDK15+
Browse files Browse the repository at this point in the history
`java.lang.CharSequence` has `isEmpty` method since JDK 15 that makes impossibly
to compile scala by JDK15.

Fix it on the way that allows to compiled with JDK15 and before JDK15.

Link to the issue: scala/bug#12172
  • Loading branch information
catap committed Oct 11, 2020
1 parent 8b9858e commit f8cfaad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/library/scala/collection/mutable/StringBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ final class StringBuilder(val underlying: java.lang.StringBuilder) extends Abstr
* @return the last applicable index where target occurs, or -1 if not found.
*/
def lastIndexOf(str: String, fromIndex: Int): Int = underlying.lastIndexOf(str, fromIndex)

/** Tests whether this builder is empty.
*
* @return `true` if this builder contains nothing, `false` otherwise.
*/
override def isEmpty: Boolean = underlying.length() == 0
}

object StringBuilder {
Expand Down
9 changes: 9 additions & 0 deletions src/reflect/scala/reflect/api/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ trait Names {
/** The encoded name, still represented as a name.
*/
def encodedName: Name

/** The length of this name. */
def length: Int

/** Tests whether this name is empty. */
def isEmpty: Boolean

/** Tests whether this name is not empty. */
def nonEmpty: Boolean
}

/** Create a new term name.
Expand Down
6 changes: 3 additions & 3 deletions src/reflect/scala/reflect/internal/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ trait Names extends api.Names {
def next: Name with ThisNameType

/** The length of this name. */
final def length: Int = len
final def isEmpty = length == 0
final def nonEmpty = !isEmpty
override final def length: Int = len
override final def isEmpty: Boolean = length == 0
override final def nonEmpty: Boolean = !isEmpty

def nameKind: String
def isTermName: Boolean
Expand Down

0 comments on commit f8cfaad

Please sign in to comment.