diff options
author | Martin Odersky <odersky@gmail.com> | 2014-05-16 13:57:21 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-05-30 14:38:13 +0200 |
commit | 20034dd5500815ff04052cbc9a97deddacb3e892 (patch) | |
tree | d8f19ad0950e5c685e5e819068a3553008c569e7 | |
parent | 4a071ad51e4ccc94c34e0fcbea84d48cd8bb214c (diff) | |
download | dotty-20034dd5500815ff04052cbc9a97deddacb3e892.tar.gz dotty-20034dd5500815ff04052cbc9a97deddacb3e892.tar.bz2 dotty-20034dd5500815ff04052cbc9a97deddacb3e892.zip |
Fix of t2660.
Auxiliary constructors need to be wrapped in the type parameters of the primary constructor.
Otherwise they will not take part in type inference.
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 513dee2ff..ba2b62faa 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -241,6 +241,14 @@ object desugar { val constr = cpy.DefDef(constr1, constr1.mods, constr1.name, constrTparams, constrVparamss, constr1.tpt, constr1.rhs) + // Add constructor type parameters to auxiliary constructors + val normalizedBody = body map { + case ddef: DefDef if ddef.name.isConstructorName => + cpy.DefDef(ddef, ddef.mods, ddef.name, constrTparams, ddef.vparamss, ddef.tpt, ddef.rhs) + case stat => + stat + } + val derivedTparams = constrTparams map derivedTypeParam val derivedVparamss = constrVparamss nestedMap derivedTermParam val arity = constrVparamss.head.length @@ -376,7 +384,7 @@ object desugar { } cpy.TypeDef(cdef, mods, name, cpy.Template(impl, constr, parents1, self1, - tparamAccessors ::: vparamAccessors ::: body ::: caseClassMeths)) + tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths)) } // install the watch on classTycon |