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
Activity
scabug commentedon May 22, 2013
Imported From: https://issues.scala-lang.org/browse/SI-7505?orig=1
Reporter: Dan Boitnott (dboitnot)
Affected Versions: 2.10.1
Other Milestones: 2.11.0-M3
Duplicates #7214
Attachments:
scabug commentedon May 31, 2013
@retronym said:
Fixed by #7214 / scala/scala@acd74cae
scabug commentedon May 31, 2013
@retronym said:
Test case: https://github.com/scala/scala/pull/2616/files