aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-11-16 14:25:36 +0100
committerMartin Odersky <odersky@gmail.com>2015-11-16 14:25:36 +0100
commitd8c4ab697aa97da509bc2c943a65e4ec78917211 (patch)
tree6f1e677323c948190edc9c1174298b3ec2a0d07d /src/dotty/tools/dotc/typer
parent08b53243bfaadaf8fd590bf0a30a5dfa667ca38e (diff)
downloaddotty-d8c4ab697aa97da509bc2c943a65e4ec78917211.tar.gz
dotty-d8c4ab697aa97da509bc2c943a65e4ec78917211.tar.bz2
dotty-d8c4ab697aa97da509bc2c943a65e4ec78917211.zip
Make secondary constructor type parameters aliases
Make secondary constructor type parameters aliases of the enclosing class parameters. Test case in i941.scala. Observed in the wild when trying to typecheck Streams.scala.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 10bca44bf..936c006fc 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -909,6 +909,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val DefDef(name, tparams, vparamss, tpt, _) = ddef
completeAnnotations(ddef, sym)
val tparams1 = tparams mapconserve (typed(_).asInstanceOf[TypeDef])
+ // for secondary constructors we need to use that their type parameters
+ // are aliases of the class type parameters. See pos/i941.scala
+ if (sym.isConstructor && !sym.isPrimaryConstructor)
+ (sym.owner.typeParams, tparams1).zipped.foreach {(tparam, tdef) =>
+ tdef.symbol.info = TypeAlias(tparam.typeRef)
+ }
+
val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf[ValDef])
if (sym is Implicit) checkImplicitParamsNotSingletons(vparamss1)
val tpt1 = checkSimpleKinded(typedType(tpt))