Skip to content

Commit e2fde11

Browse files
committed
Avoid "value of type <notype> does not take parameters" errors
1 parent 6f9d50c commit e2fde11

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ object ErrorReporting {
9696

9797
def exprStr(tree: Tree): String = refStr(tree.tpe)
9898

99+
def takesNoParamsStr(tree: Tree, kind: String) =
100+
if (tree.tpe.widen.exists)
101+
i"${exprStr(tree)} does not take ${kind}parameters"
102+
else
103+
i"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString}"
104+
99105
def patternConstrStr(tree: Tree): String = ???
100106

101107
def typeMismatch(tree: Tree, pt: Type, implicitFailure: SearchFailure = NoImplicitMatches): Tree =

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ trait TypeAssigner {
340340
else
341341
errorType(i"wrong number of arguments for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.pos)
342342
case t =>
343-
errorType(i"${err.exprStr(fn)} does not take parameters", tree.pos)
343+
errorType(err.takesNoParamsStr(fn, ""), tree.pos)
344344
}
345345
tree.withType(ownType)
346346
}
@@ -396,7 +396,7 @@ trait TypeAssigner {
396396
else wrongNumberOfTypeArgs(fn.tpe, pt.typeParams, args, tree.pos)
397397
}
398398
case _ =>
399-
errorType(i"${err.exprStr(fn)} does not take type parameters", tree.pos)
399+
errorType(err.takesNoParamsStr(fn, "type "), tree.pos)
400400
}
401401

402402
tree.withType(ownType)

0 commit comments

Comments
 (0)