Skip to content

Scalac fills irrelevant type parameters for applyDynamic in curried calls #10307

Open
@Atry

Description

@Atry
Welcome to Scala 2.12.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala> import scala.language._
import scala.language._

scala> def getManifest[A] = new Dynamic {
     |   def applyDynamic[B: Manifest](method: String)(b: B) = manifest[B]
     | } 
getManifest: [A]=> Dynamic{def applyDynamic[B](method: String)(b: B)(implicit evidence$1: Manifest[B]): Manifest[B]}

scala> getManifest[AnyRef]("text")
res0: Manifest[AnyRef] = Object

scala> getManifest[Int]("text")
<console>:16: error: type mismatch;
 found   : String("text")
 required: Int
       getManifest[Int]("text")
                        ^

scala> getManifest[Int].apply("text")
res2: Manifest[String] = java.lang.String

I expect all the three calls compile and return Manifest[String]. However getManifest[AnyRef]("text") incorrectly returns Manifest[AnyRef] and getManifest[Int]("text") does not compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions