diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-05 17:41:45 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:01 +0200 |
commit | e36a36a5aea93c19aa133ffb215bc05787378375 (patch) | |
tree | 2cbcaadc76d35b1557f78f43f520d84bd0414e52 /src/dotty/tools/dotc/core/TypeApplications.scala | |
parent | c35f817f43a776b567acef3816405b5373097842 (diff) | |
download | dotty-e36a36a5aea93c19aa133ffb215bc05787378375.tar.gz dotty-e36a36a5aea93c19aa133ffb215bc05787378375.tar.bz2 dotty-e36a36a5aea93c19aa133ffb215bc05787378375.zip |
Fix typeParams for abstract types under completion
Their type parameters are not the type parameters in the completer,
but hk type parameters with the same variances.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 0de951c31..be0eb9230 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -47,19 +47,20 @@ object TypeApplications { def variancesConform(syms1: List[MemberBinding], syms2: List[MemberBinding])(implicit ctx: Context) = syms1.corresponds(syms2)(varianceConforms) - def fallbackTypeParams(n: Int)(implicit ctx: Context): List[MemberBinding] = { - def memberBindings(n: Int): Type = - if (n == 0) NoType - else + def fallbackTypeParams(variances: List[Int])(implicit ctx: Context): List[MemberBinding] = { + def memberBindings(vs: List[Int]): Type = vs match { + case Nil => NoType + case v :: vs1 => RefinedType( - memberBindings(n - 1), - tpnme.hkArg(n - 1), - TypeBounds.empty.withBindingKind(NonvariantBinding)) + memberBindings(vs1), + tpnme.hkArg(vs1.length), + TypeBounds.empty.withBindingKind(BindingKind.fromVariance(v))) + } def decompose(t: Type, acc: List[MemberBinding]): List[MemberBinding] = t match { case t: RefinedType => decompose(t.parent, t :: acc) case NoType => acc } - decompose(memberBindings(n), Nil) + decompose(memberBindings(variances), Nil) } /** Extractor for @@ -343,7 +344,7 @@ class TypeApplications(val self: Type) extends AnyVal { else tsym.infoOrCompleter match { case completer: TypeParamsCompleter => val tparams = completer.completerTypeParams(tsym) - if (Config.newHK) tparams + if (Config.newHK) fallbackTypeParams(tparams.map(_.variance)) else defn.LambdaTraitOBS(tparams.map(_.variance)).typeParams case _ => if (!tsym.isCompleting || tsym.isAliasType) tsym.info.typeParams @@ -861,7 +862,7 @@ class TypeApplications(val self: Type) extends AnyVal { case self: TypeRef if !self.symbol.isClass && self.symbol.isCompleting => // This happens when unpickling e.g. scala$collection$generic$GenMapFactory$$CC ctx.warning(i"encountered F-bounded higher-kinded type parameters for ${self.symbol}; assuming they are invariant") - if (Config.newHK) fallbackTypeParams(args.length) + if (Config.newHK) fallbackTypeParams(args map alwaysZero) else defn.LambdaTraitOBS(args map alwaysZero).typeParams case _ => typeParams |