Closed tgodzik closed 2 years ago
Something like this should do the trick:
--- compiler/src/dotty/tools/dotc/typer/Typer.scala
+++ compiler/src/dotty/tools/dotc/typer/Typer.scala
@@ -1993,7 +1993,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
typed(tree.tpt, AnyTypeConstructorProto)
}
val tparams = tpt1.tpe.typeParams
- if (tparams.isEmpty) {
+ if tpt1.tpe.isError then
+ val args1 = tree.args.mapconserve(typedType(_))
+ assignType(cpy.AppliedTypeTree(tree)(tpt1, args1), tpt1, args1)
+ else if (tparams.isEmpty) {
report.error(TypeDoesNotTakeParameters(tpt1.tpe, tree.args), tree.srcPos)
tpt1
}
Looks like this is exactly what I am looking for, thanks! I can take a look and try and raise a PR with fix or would you want to do it?
All yours - I got curious to try, but not curious enough to babysit the PR into main. 😄
I invite you to take a look at the problem this issue has caused in Metals, for the detection of existing type parameters, so that an extra type bracket is not inserted upon type completion. https://github.com/scalameta/metals/pull/4174#discussion_r930605632
@dwijnand Seems like that did the trick! Thanks! https://github.com/lampepfl/dotty/pull/15825
Compiler version
3.1.3
Minimized code
ArrayBuffer
is missing from imports.Output
Parser tree
Notice
tpt = AppliedTypeTree(tpt = Ident(name = ArrayBuffer), args = List(Ident(name = Int))),
<- AppliedTypeTree is available.Typed tree though:
Notice that the tpt of the DefDef is
tpt = Ident(name = ArrayBuffer),
Seems that if the type is not available then we are missing TypeApply, which is useful for the IDE to figure out if we need to insert
[]
Expectation
TypeApply should still be available in tpt of DefDef. It might be an error type, but it should be available there.