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

Don't leave underspecified SAM types in the code #19461

Merged
merged 1 commit into from
Jan 16, 2024
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
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 @@ -1738,8 +1738,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
Loading