summaryrefslogtreecommitdiff
path: root/test/files/neg/t6663.scala
diff options
context:
space:
mode:
authorJan Niehusmann <jan@gondor.com>2012-11-13 22:14:34 +0100
committerJan Niehusmann <jan@gondor.com>2012-11-16 23:54:11 +0100
commitc6569209dab006e74ccecc0ede6ce7815ac8629c (patch)
tree32105de312055560c5e2b2fd8b0a089459d460d5 /test/files/neg/t6663.scala
parent850108886765e99e894f7613f49c1bab3650a0c2 (diff)
downloadscala-c6569209dab006e74ccecc0ede6ce7815ac8629c.tar.gz
scala-c6569209dab006e74ccecc0ede6ce7815ac8629c.tar.bz2
scala-c6569209dab006e74ccecc0ede6ce7815ac8629c.zip
SI-6663: don't ignore type parameter on selectDynamic invocation
Fix mkInvoke to handle selectDynamic calls of the form new C.foo[T].xyz or new C.foo[T].xyz :U (where C extends Dynamic) Without this patch, the type parameter was silently ignored, and possibly inferred to a different. This patch fixes mkInvoke to handle these cases, where ctxTree has the form Select(TypeApply(fun, targs), nme) or Typed(...)
Diffstat (limited to 'test/files/neg/t6663.scala')
-rw-r--r--test/files/neg/t6663.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/neg/t6663.scala b/test/files/neg/t6663.scala
new file mode 100644
index 0000000000..4a358dfbc5
--- /dev/null
+++ b/test/files/neg/t6663.scala
@@ -0,0 +1,19 @@
+import language.dynamics
+
+class C(v: Any) extends Dynamic {
+ def selectDynamic[T](n: String): Option[T] = Option(v.asInstanceOf[T])
+ def applyDynamic[T](n: String)(): Option[T] = Option(v.asInstanceOf[T])
+}
+
+object Test extends App {
+ // this should be converted to
+ // C(42).selectDynamic[String]("foo").get
+ // causing a compile error.
+
+ // but, before fixing SI-6663, became
+ // C(42).selectDynamic("foo").get, ignoring
+ // the [String] type parameter
+ var v = new C(42).foo[String].get :Int
+ println(v)
+}
+