You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ContextProperty.scalapackagescalacbugimportscala.language.implicitConversionsimportscala.language.reflectiveCallsimportscala.math.ScalaNumericAnyConversionscaseclassContextProperty(value: Any, shell: Boolean=false) {
typeHasToInt= { deftoInt:Int }
overridedeftoString:String= value.toString
deftoInt:Int= value match {
casen: ScalaNumericAnyConversions=> n.toInt // Call this out explicitly for efficiency.casen: HasToInt=> n.toInt // Fall back on reflection to find a toIntcases: Any=> s.toString.toInt // Finally, try string conversion
}
}
scalac gives the following error:
$ scalac ContextProperty.scala
ContextProperty.scala:12: error: error during expansion of this match (this is a scalac bug).
The underlying error was: type mismatch;
found : Boolean(true)
required: AnyRef
def toInt: Int = value match {
^
one error found
If I comment line 14:
case n: ScalaNumericAnyConversions => n.toInt // Call this out explicitly for efficiency.
// case n: HasToInt => n.toInt // Fall back on reflection to find a toInt
case s: Any => s.toString.toInt // Finally, try string conversion
The class compiles without error or warning.
The text was updated successfully, but these errors were encountered:
The following code fails to compile:
scalac
gives the following error:If I comment line 14:
The class compiles without error or warning.
The text was updated successfully, but these errors were encountered: