diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-21 14:40:41 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-11 08:24:36 +0200 |
commit | ce81244e6c4fc7b5b8ccc70ad32290045a591739 (patch) | |
tree | 8f62951a0e1e07963a33d1a199e74e2de3f1a83f /tests/neg | |
parent | d9a911c43bbedcae8a787eafb91bb6889a8ff461 (diff) | |
download | dotty-ce81244e6c4fc7b5b8ccc70ad32290045a591739.tar.gz dotty-ce81244e6c4fc7b5b8ccc70ad32290045a591739.tar.bz2 dotty-ce81244e6c4fc7b5b8ccc70ad32290045a591739.zip |
Fix handling of type params in secondary constructors
Params are already added by Desugar. No special treatment needed here.
Besides primaryConstructor.typeParams is always empty, because term symbols
do not have type parameters.
The fix turns t2660.scala into an error. I believe the error is correct, hence
the test was moved with a comment to neg.
Diffstat (limited to 'tests/neg')
-rw-r--r-- | tests/neg/t2660.scala | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/neg/t2660.scala b/tests/neg/t2660.scala new file mode 100644 index 000000000..85e318915 --- /dev/null +++ b/tests/neg/t2660.scala @@ -0,0 +1,47 @@ +// Dotty deviation. The calls here now are classified as ambiguous. + +package hoho + +class G + +class H extends G + +class A[T](x: T) { + + def this(y: G, z: T) = { + this(z) + print(1) + } + + def this(z: H, h: T) = { + this(h) + print(2) + } +} + +object T { + def main(args: Array[String]): Unit = { + implicit def g2h(g: G): H = new H + new A[Int](new H, 23) + // in the context here, either secondary constructor is applicable + // to the other, due to the implicit in scope. So the call is ambiguous. + } +} + + +// A version of t2660 which does not use constructors + +object X { + def f[T](x: T) = ??? + def f[T](y: G, z: T) = ??? + def f[T](z: H, h: T) = ??? +} + +object T2 { + def main(args: Array[String]): Unit = { + implicit def g2h(g: G): H = new H + X.f(new H, 23) + } +} + + |