From ddb3b889b5fa55760167d9995d2f1549e2542b71 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 11 Sep 2012 23:40:11 +0200 Subject: A little cleanup along the Any to AnyRef trail. Followup to 35316be and d3f879a. - Remove obsolete comments and replace them with a test. - Don't emit error addendum unless we know we're dealing with a value class. --- src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 2 +- src/library/scala/runtime/StringAdd.scala | 5 ----- src/library/scala/runtime/StringFormat.scala | 6 ------ 3 files changed, 1 insertion(+), 12 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index b7195b0349..80bb487d2e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -106,7 +106,7 @@ trait ContextErrors { else s"$name extends Any, not AnyRef" ) - if (isPrimitiveValueType(found)) "" else "\n" + + if (isPrimitiveValueType(found) || isTrivialTopType(tp)) "" else "\n" + s"""|Note that $what. |Such types can participate in value classes, but instances |cannot appear in singleton types or in reference comparisons.""".stripMargin diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala index 4693b0bf44..f074b5407e 100644 --- a/src/library/scala/runtime/StringAdd.scala +++ b/src/library/scala/runtime/StringAdd.scala @@ -10,10 +10,5 @@ package scala.runtime /** A wrapper class that adds string concatenation `+` to any value */ final class StringAdd(val self: Any) extends AnyVal { - // Note: The implicit conversion from Any to StringAdd is one of two - // implicit conversions from Any to AnyRef in Predef. It is important to have at least - // two such conversions, so that silent conversions from value types to AnyRef - // are avoided. If StringFormat should become a value class, another - // implicit conversion from Any to AnyRef has to be introduced in Predef def +(other: String) = String.valueOf(self) + other } diff --git a/src/library/scala/runtime/StringFormat.scala b/src/library/scala/runtime/StringFormat.scala index 1f5feec9e1..7d34e82812 100644 --- a/src/library/scala/runtime/StringFormat.scala +++ b/src/library/scala/runtime/StringFormat.scala @@ -11,12 +11,6 @@ package scala.runtime /** A wrapper class that adds a `formatted` operation to any value */ final class StringFormat(val self: Any) extends AnyVal { - // Note: The implicit conversion from Any to StringFormat is one of two - // implicit conversions from Any to AnyRef in Predef. It is important to have at least - // two such conversions, so that silent conversions from value types to AnyRef - // are avoided. If StringFormat should become a value class, another - // implicit conversion from Any to AnyRef has to be introduced in Predef - /** Returns string formatted according to given `format` string. * Format strings are as for `String.format` * (@see java.lang.String.format). -- cgit v1.2.3