Skip to content

Int convert to Double when unnecessary #9935

@scabug

Description

@scabug

The second result type should be Int

def f1(l: Array[Int]): Array[Any] =
      l.map{ x =>
        x match {
        case x if x == 1 => x.toString
        case x if x == 2 => x.toInt
        case _ => x.toDouble
      }    
   } 

f1(Array(1,2,3)).foreach(v => println(s"$v :${v.getClass}"))
1 :class java.lang.String
2.0 :class java.lang.Double
3.0 :class java.lang.Double

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)patmattyper

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions