@@ -21,7 +21,7 @@ import ErrorMessageID._
21
21
import Denotations .SingleDenotation
22
22
import dotty .tools .dotc .ast .Trees
23
23
import dotty .tools .dotc .config .ScalaVersion
24
- import dotty .tools .dotc .core .Flags .{ FlagSet , Mutable }
24
+ import dotty .tools .dotc .core .Flags ._
25
25
import dotty .tools .dotc .core .SymDenotations .SymDenotation
26
26
import scala .util .control .NonFatal
27
27
@@ -203,11 +203,11 @@ object messages {
203
203
val explanation =
204
204
hl """ |Anonymous functions must define a type. For example, if you define a function like this one:
205
205
|
206
- | ${" val f = { case xs @ List(1, 2, 3) => Some(xs) }" }
206
+ | ${" val f = { case x: Int => x + 1 }" }
207
207
|
208
208
|Make sure you give it a type of what you expect to match and help the type inference system:
209
209
|
210
- | ${" val f: Seq[Int] => Option[List[ Int]] = { case xs @ List(1, 2, 3) => Some(xs) }" } """
210
+ | ${" val f: Any => Int = { case x: Int => x + 1 }" } """
211
211
}
212
212
213
213
case class WildcardOnTypeArgumentNotAllowedOnNew ()(implicit ctx : Context )
@@ -2078,23 +2078,14 @@ object messages {
2078
2078
}
2079
2079
2080
2080
case class JavaSymbolIsNotAValue (symbol : Symbol )(implicit ctx : Context ) extends Message (JavaSymbolIsNotAValueID ) {
2081
- val msg = hl " $symbol is not a value "
2082
2081
val kind = " Type Mismatch"
2083
- val explanation = {
2084
- val javaCodeExample = """ class A {public static int a() {return 1;}}"""
2085
-
2086
- val scalaCodeExample =
2087
- """ val objectA = A // This does not compile
2088
- |val aResult = A.a() // This does compile""" .stripMargin
2082
+ val msg = {
2083
+ val kind =
2084
+ if (symbol is Package ) hl " $symbol"
2085
+ else hl " Java defined ${" class " + symbol.name}"
2089
2086
2090
- hl """ Java statics and packages cannot be used as a value.
2091
- |For Java statics consider the following Java example:
2092
- |
2093
- | $javaCodeExample
2094
- |
2095
- |When used from Scala:
2096
- |
2097
- | $scalaCodeExample"""
2087
+ s " $kind is not a value "
2098
2088
}
2089
+ val explanation = " "
2099
2090
}
2100
2091
}
0 commit comments