diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 5 | ||||
-rw-r--r-- | tests/neg/t2660.scala | 47 | ||||
-rw-r--r-- | tests/pos/t2660.scala | 25 |
3 files changed, 48 insertions, 29 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 5ceab475e..3a1f0a98b 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -632,10 +632,7 @@ class Namer { typer: Typer => completeParams(tparams) vparamss foreach completeParams val isConstructor = name == nme.CONSTRUCTOR - val isSecondaryConstructor = isConstructor && sym != sym.owner.primaryConstructor - def typeParams = - if (isSecondaryConstructor) sym.owner.primaryConstructor.typeParams - else tparams map symbolOfTree + def typeParams = tparams map symbolOfTree def wrapMethType(restpe: Type): Type = { var paramSymss = vparamss.nestedMap(symbolOfTree) // Make sure constructor has one non-implicit parameter list 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) + } +} + + diff --git a/tests/pos/t2660.scala b/tests/pos/t2660.scala deleted file mode 100644 index 94a40f740..000000000 --- a/tests/pos/t2660.scala +++ /dev/null @@ -1,25 +0,0 @@ -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) - } -} |