Skip to content
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

bugfix: Retain partial type params typying information on error #15825

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1518,4 +1518,14 @@ class CompletionTest {
.noCompletions()
}

@Test def badTypeCompletions: Unit = {
code"""trait Foo
|object Test:
| def foo: ArrayBuffer[Fo${m1}] = ???
"""
.completion(m1, Set(
("Foo",Class,"Foo")
)
)
}
}
2 changes: 1 addition & 1 deletion tests/neg/closure-args.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ val d = xs // error
.map: x => x.toString + xs.dropWhile:
y => y > 0

val c = List(xs.map: y => y + y) // error // error
val c = List(xs.map: y => y + y) // error // error // error // error
val d2: String = xs // error
.map: x => x.toString + xs.dropWhile: y => y > 0 // error // error
.filter: z => !z.isEmpty // error
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i15750.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

val foo = A[B] // error // error

val bar = A[Int] // error