-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trees after typer losing information #15750
Comments
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. |
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.
The text was updated successfully, but these errors were encountered: