aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/Types.scala8
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala2
3 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 529452c73..6145bdffb 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -906,10 +906,14 @@ object Types {
/** Turn type into a function type.
* @pre this is a non-dependent method type.
+ * @param drop The number of trailing parameters that should be dropped
+ * when forming the function type.
*/
- def toFunctionType(implicit ctx: Context): Type = this match {
+ def toFunctionType(dropLast: Int = 0)(implicit ctx: Context): Type = this match {
case mt @ MethodType(_, formals) if !mt.isDependent =>
- defn.FunctionType(formals mapConserve (_.underlyingIfRepeated(mt.isJava)), mt.resultType)
+ val formals1 = if (dropLast == 0) formals else formals dropRight dropLast
+ defn.FunctionType(
+ formals1 mapConserve (_.underlyingIfRepeated(mt.isJava)), mt.resultType)
}
/** The signature of this type. This is by default NotAMethod,
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index e35dd6c92..5604a607c 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -285,7 +285,9 @@ trait TypeAssigner {
tree.withType(thenp.tpe | elsep.tpe)
def assignType(tree: untpd.Closure, meth: Tree, target: Tree)(implicit ctx: Context) =
- tree.withType(if (target.isEmpty) meth.tpe.widen.toFunctionType else target.tpe)
+ tree.withType(
+ if (target.isEmpty) meth.tpe.widen.toFunctionType(tree.env.length)
+ else target.tpe)
def assignType(tree: untpd.CaseDef, body: Tree)(implicit ctx: Context) =
tree.withType(body.tpe)
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 9c1110dd1..ebd33a6ff 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1273,7 +1273,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
if defn.isFunctionType(wtp) && !defn.isFunctionType(pt) =>
pt match {
case SAMType(meth)
- if wtp <:< meth.info.toFunctionType =>
+ if wtp <:< meth.info.toFunctionType() =>
// was ... && isFullyDefined(pt, ForceDegree.noBottom)
// but this prevents case blocks from implementing polymorphic partial functions,
// since we do not know the result parameter a priori. Have to wait until the