From b5c3a28f1eabada74827e34743dc264e583f7479 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 12 Feb 2015 15:26:08 +0100 Subject: Fix of the escaping MethodParam problem The issue was in the dependency tracking for MethodTypes. We treated methods with false dependencies as non-dependent (as they should be), but in that case the ResultType could contain orphan MethodParams. --- src/dotty/tools/dotc/typer/ProtoTypes.scala | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/dotty/tools/dotc/typer/ProtoTypes.scala') diff --git a/src/dotty/tools/dotc/typer/ProtoTypes.scala b/src/dotty/tools/dotc/typer/ProtoTypes.scala index 24b4cb423..c0e30b12e 100644 --- a/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -162,9 +162,11 @@ object ProtoTypes { * * [](args): resultType */ - case class FunProto(args: List[untpd.Tree], override val resultType: Type, typer: Typer)(implicit ctx: Context) + case class FunProto(args: List[untpd.Tree], resType: Type, typer: Typer)(implicit ctx: Context) extends UncachedGroundType with ApplyingProto { private var myTypedArgs: List[Tree] = Nil + + override def resultType(implicit ctx: Context) = resType /** A map in which typed arguments can be stored to be later integrated in `typedArgs`. */ private var myTypedArg: SimpleMap[untpd.Tree, Tree] = SimpleMap.Empty @@ -241,8 +243,11 @@ object ProtoTypes { * * []: argType => resultType */ - abstract case class ViewProto(argType: Type, override val resultType: Type) + abstract case class ViewProto(argType: Type, resType: Type) extends CachedGroundType with ApplyingProto { + + override def resultType(implicit ctx: Context) = resType + def isMatchedBy(tp: Type)(implicit ctx: Context): Boolean = ctx.typer.isApplicable(tp, argType :: Nil, resultType) @@ -274,7 +279,10 @@ object ProtoTypes { * * [] [targs] resultType */ - case class PolyProto(targs: List[Type], override val resultType: Type) extends UncachedGroundType with ProtoType { + case class PolyProto(targs: List[Type], resType: Type) extends UncachedGroundType with ProtoType { + + override def resultType(implicit ctx: Context) = resType + override def isMatchedBy(tp: Type)(implicit ctx: Context) = { def isInstantiatable(tp: Type) = tp.widen match { case PolyType(paramNames) => paramNames.length == targs.length @@ -284,8 +292,8 @@ object ProtoTypes { } def derivedPolyProto(targs: List[Type], resultType: Type) = - if ((targs eq this.targs) && (resultType eq this.resultType)) this - else PolyProto(targs, resultType) + if ((targs eq this.targs) && (resType eq this.resType)) this + else PolyProto(targs, resType) def map(tm: TypeMap)(implicit ctx: Context): PolyProto = derivedPolyProto(targs mapConserve tm, tm(resultType)) -- cgit v1.2.3