diff options
author | Martin Odersky <odersky@gmail.com> | 2015-03-06 18:38:11 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:14:16 +0100 |
commit | 8e57bc60978e025b8ef5443a19d995c211ea4661 (patch) | |
tree | a59fe0f64baae66537f0842238d2fd4c92b8721d /src/dotty/tools/dotc/typer/Namer.scala | |
parent | 8d370d4a3d6f6b4ad7a658e8d5afac0c771eb968 (diff) | |
download | dotty-8e57bc60978e025b8ef5443a19d995c211ea4661.tar.gz dotty-8e57bc60978e025b8ef5443a19d995c211ea4661.tar.bz2 dotty-8e57bc60978e025b8ef5443a19d995c211ea4661.zip |
Harmonize parameterless constructors between unpickling and namer
Should get an () parameter list in both cases. (In fact, that's pretty annoying,
it woul be better if we did not have this restriction. But in any case it has to
be the same for Namer and Unpickler.)
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 708fb06c1..47375ba39 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -87,6 +87,14 @@ trait NamerContextOps { this: Context => if (sym.name == nme.CONSTRUCTOR) sym.owner.typeRef.appliedTo(typeParams map (_.typeRef)) else given + /** if isConstructor, make sure it has one non-implicit parameter list */ + def normalizeIfConstructor(paramSymss: List[List[Symbol]], isConstructor: Boolean) = + if (isConstructor && + (paramSymss.isEmpty || paramSymss.head.nonEmpty && (paramSymss.head.head is Implicit))) + Nil :: paramSymss + else + paramSymss + /** The method type corresponding to given parameters and result type */ def methodType(typeParams: List[Symbol], valueParamss: List[List[Symbol]], resultType: Type, isJava: Boolean = false)(implicit ctx: Context): Type = { val monotpe = @@ -681,12 +689,7 @@ class Namer { typer: Typer => vparamss foreach completeParams val isConstructor = name == nme.CONSTRUCTOR def typeParams = tparams map symbolOfTree - val paramSymss = { - val pss = vparamss.nestedMap(symbolOfTree) - if (isConstructor && // Make sure constructor has one non-implicit parameter list - (pss.isEmpty || pss.head.nonEmpty && (pss.head.head is Implicit))) Nil :: pss - else pss - } + val paramSymss = ctx.normalizeIfConstructor(vparamss.nestedMap(symbolOfTree), isConstructor) def wrapMethType(restpe: Type): Type = { val restpe1 = // try to make anonymous functions non-dependent, so that they can be used in closures if (name == nme.ANON_FUN) avoid(restpe, paramSymss.flatten) |