From c2d5246bdb33d60d3eaff62a539d01368124d859 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 7 May 2014 14:50:56 +0200 Subject: More systematic treatment of prototypes. There's a delicate balance about how much of a prototype should be passed down the tree when typechecking. Passing little can cause ambiguity errors (both in overloading and in implicit search). Passing too much can cause spurious errors because implicit conversions "down the road" that apply to some tree continaing the result might not be considered. Symptoms of the problems wree that we could not handle the tests included in this commit before. The new scheme is as follows: we always keep all available information in a prototype, but hide nested prototypes behined a `IgnoredProto` wall. These trees will not be considered for conformity checking. When type checking hits an ambiguity, it tries again with a prototype that's one level deeper (has fewer Ignore links) than the previous one. This continues until there are no more Ignore links to unwrap. We also generalize the scheme for wrapping qualifiers of select nodes from realApply to all instances where we compare against a FunProto. Finally, there are some fixes that avoid assertion violations that were provoked by the new typechecking scheme. --- src/dotty/tools/dotc/printing/RefinedPrinter.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/dotty/tools/dotc/printing/RefinedPrinter.scala') diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index dd8f04d92..c20598bb3 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -7,7 +7,7 @@ import Contexts.Context, Scopes.Scope, Denotations._, Annotations.Annotation import StdNames.nme import ast.{Trees, untpd} import typer.Namer -import typer.ProtoTypes.{SelectionProto, ViewProto, FunProto} +import typer.ProtoTypes.{SelectionProto, ViewProto, FunProto, IgnoredProto} import Trees._ import scala.annotation.switch @@ -108,10 +108,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } return (toTextLocal(tycon) ~ "[" ~ Text(args map argText, ", ") ~ "]").close } - case tp: SelectionProto => - return toText(RefinedType(WildcardType, tp.name, tp.memberProto)) - case tp: ViewProto => - return toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType) case tp: TypeRef => if ((tp.symbol is TypeParam | TypeArgument) && !ctx.phase.erasedTypes) { return tp.info match { @@ -121,8 +117,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } case ExprType(result) => return "=> " ~ toText(result) + case tp: SelectionProto => + return toText(RefinedType(WildcardType, tp.name, tp.memberProto)) + case tp: ViewProto => + return toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType) case FunProto(args, resultType, _) => return "funproto(" ~ toTextGlobal(args, ", ") ~ "):" ~ toText(resultType) + case tp: IgnoredProto => + return "?" case _ => } super.toText(tp) -- cgit v1.2.3