From f8cfaad7b4f026e6be4fa4b86ea1e1864c630eae Mon Sep 17 00:00:00 2001 From: "Kirill A. Korinsky" Date: Sun, 11 Oct 2020 02:42:42 +0200 Subject: [PATCH] Introduced support of JDK15+ `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: https://github.com/scala/bug/issues/12172 --- src/library/scala/collection/mutable/StringBuilder.scala | 6 ++++++ src/reflect/scala/reflect/api/Names.scala | 9 +++++++++ src/reflect/scala/reflect/internal/Names.scala | 6 +++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala index 99421c45e8ed..b73be48cd43a 100644 --- a/src/library/scala/collection/mutable/StringBuilder.scala +++ b/src/library/scala/collection/mutable/StringBuilder.scala @@ -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 { diff --git a/src/reflect/scala/reflect/api/Names.scala b/src/reflect/scala/reflect/api/Names.scala index 8cddc5d6f062..dece857e7394 100644 --- a/src/reflect/scala/reflect/api/Names.scala +++ b/src/reflect/scala/reflect/api/Names.scala @@ -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. diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index b557c4013886..285e5ec0f1e2 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -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