aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/Phases.scala5
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Phases.scala b/src/dotty/tools/dotc/core/Phases.scala
index 5eb8cd920..53c193994 100644
--- a/src/dotty/tools/dotc/core/Phases.scala
+++ b/src/dotty/tools/dotc/core/Phases.scala
@@ -200,6 +200,11 @@ object Phases {
*/
def checkPostCondition(tree: tpd.Tree)(implicit ctx: Context): Unit = ()
+ /** If set, allow missing or superfluous arguments in applications
+ * and type applications.
+ */
+ def relaxedTyping: Boolean = false
+
def exists: Boolean = true
private var myPeriod: Period = Periods.InvalidPeriod
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index c23b820e4..e35dd6c92 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -246,7 +246,7 @@ trait TypeAssigner {
def assignType(tree: untpd.Apply, fn: Tree, args: List[Tree])(implicit ctx: Context) = {
val ownType = fn.tpe.widen match {
case fntpe @ MethodType(_, ptypes) =>
- if (sameLength(ptypes, args)) fntpe.instantiate(args.tpes)
+ if (sameLength(ptypes, args) || ctx.phase.prev.relaxedTyping) fntpe.instantiate(args.tpes)
else errorType(i"wrong number of parameters for ${fn.tpe}; expected: ${ptypes.length}", tree.pos)
case t =>
errorType(i"${err.exprStr(fn)} does not take parameters", tree.pos)
@@ -258,7 +258,7 @@ trait TypeAssigner {
val ownType = fn.tpe.widen match {
case pt: PolyType =>
val argTypes = args.tpes
- if (sameLength(argTypes, pt.paramNames)) pt.instantiate(argTypes)
+ if (sameLength(argTypes, pt.paramNames)|| ctx.phase.prev.relaxedTyping) pt.instantiate(argTypes)
else errorType(d"wrong number of type parameters for ${fn.tpe}; expected: ${pt.paramNames.length}", tree.pos)
case _ =>
errorType(i"${err.exprStr(fn)} does not take type parameters", tree.pos)