Skip to content

Commit 40c4fe3

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

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

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

+4-1
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

+10
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
}

tests/neg/closure-args.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ val d = xs // error
1414
.map: x => x.toString + xs.dropWhile:
1515
y => y > 0
1616

17-
val c = List(xs.map: y => y + y) // error // error
17+
val c = List(xs.map: y => y + y) // error // error // error // error
1818
val d2: String = xs // error
1919
.map: x => x.toString + xs.dropWhile: y => y > 0 // error // error
2020
.filter: z => !z.isEmpty // error

tests/neg/i15750.scala

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
val foo = A[B] // error // error
3+
4+
val bar = A[Int] // error

0 commit comments

Comments
 (0)