Skip to content

Commit 90af6fe

Browse files
committed
bugfix: Retain partial type params typying information on error
Fixes #15750
1 parent 44a2f72 commit 90af6fe

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19931993
typed(tree.tpt, AnyTypeConstructorProto)
19941994
}
19951995
val tparams = tpt1.tpe.typeParams
1996-
if (tparams.isEmpty) {
1996+
if tpt1.tpe.isError then
1997+
val args1 = tree.args.mapconserve(typedType(_))
1998+
assignType(cpy.AppliedTypeTree(tree)(tpt1, args1), tpt1, args1)
1999+
else if (tparams.isEmpty) {
19972000
report.error(TypeDoesNotTakeParameters(tpt1.tpe, tree.args), tree.srcPos)
19982001
tpt1
19992002
}

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,4 +1518,14 @@ class CompletionTest {
15181518
.noCompletions()
15191519
}
15201520

1521+
@Test def badTypeCompletions: Unit = {
1522+
code"""trait Foo
1523+
|object Test:
1524+
| def foo: ArrayBuffer[Fo${m1}] = ???
1525+
"""
1526+
.completion(m1, Set(
1527+
("Foo",Class,"Foo")
1528+
)
1529+
)
1530+
}
15211531
}

0 commit comments

Comments
 (0)