Skip to content

Commit

Permalink
Merge pull request scala#15825 from tgodzik/dont-drop-type-params
Browse files Browse the repository at this point in the history
bugfix: Retain partial type params typying information on error
  • Loading branch information
Kordyjan authored Aug 5, 2022
2 parents 44a2f72 + 40c4fe3 commit e560c2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
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

0 comments on commit e560c2d

Please sign in to comment.