aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-07-19 10:31:56 -0700
committerGitHub <noreply@github.com>2016-07-19 10:31:56 -0700
commit0536d1f3b77fd8332bf696a99cc1aefc82e8bf41 (patch)
treebc3d9f8234b158be0a331435f42d7f7969d0aa72 /src
parent2193100a4617033d75f0b924a5347a02d5e8481d (diff)
parent50c75f0c506799b7805ea0276cc21edfe806abe3 (diff)
downloaddotty-0536d1f3b77fd8332bf696a99cc1aefc82e8bf41.tar.gz
dotty-0536d1f3b77fd8332bf696a99cc1aefc82e8bf41.tar.bz2
dotty-0536d1f3b77fd8332bf696a99cc1aefc82e8bf41.zip
Merge pull request #1402 from dotty-staging/fix-wildcard-protos
Fix wildcard protos
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala6
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
2 files changed, 7 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index ca62827af..bdfce266c 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -96,15 +96,15 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
override def toText(tp: Type): Text = controlled {
def toTextTuple(args: List[Type]): Text =
- "(" ~ toTextGlobal(args, ", ") ~ ")"
+ "(" ~ Text(args.map(argText), ", ") ~ ")"
def toTextFunction(args: List[Type]): Text =
changePrec(GlobalPrec) {
val argStr: Text =
if (args.length == 2 && !defn.isTupleType(args.head))
- atPrec(InfixPrec) { toText(args.head) }
+ atPrec(InfixPrec) { argText(args.head) }
else
toTextTuple(args.init)
- argStr ~ " => " ~ toText(args.last)
+ argStr ~ " => " ~ argText(args.last)
}
homogenize(tp) match {
case AppliedType(tycon, args) =>
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 11a7b6753..df72f0095 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -582,7 +582,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
private def decomposeProtoFunction(pt: Type, defaultArity: Int)(implicit ctx: Context): (List[Type], Type) = pt match {
case _ if defn.isFunctionType(pt) =>
- (pt.dealias.argInfos.init, pt.dealias.argInfos.last)
+ // if expected parameter type(s) are wildcards, approximate from below.
+ // if expected result type is a wildcard, approximate from above.
+ // this can type the greatest set of admissible closures.
+ (pt.dealias.argTypesLo.init, pt.dealias.argTypesHi.last)
case SAMType(meth) =>
val mt @ MethodType(_, paramTypes) = meth.info
(paramTypes, mt.resultType)