Skip to content

Commit

Permalink
Backport "Don't leave underspecified SAM types in the code" to LTS (#…
Browse files Browse the repository at this point in the history
…20831)

Backports #19461 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 28, 2024
2 parents 724fb71 + 3bc09f3 commit ea9a722
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
// Replace the underspecified expected type by one based on the closure method type
defn.PartialFunctionOf(mt.firstParamTypes.head, mt.resultType)
else
report.error(em"result type of lambda is an underspecified SAM type $samParent", tree.srcPos)
samParent
errorType(em"result type of lambda is an underspecified SAM type $samParent", tree.srcPos)
TypeTree(targetTpe)
case _ =>
if (mt.isParamDependent)
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i15785.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
trait SAMFunction1[-T1, +R]:
def apply(x1: T1): R

def fooSAM[T](foo: SAMFunction1[T, T] = (f: T) => f): Unit = () // error

0 comments on commit ea9a722

Please sign in to comment.