Skip to content

Commit be50d2c

Browse files
authored
Merge pull request #3727 from dotty-staging/fi-#3542
Fix #3542: Avoid comparisons between method types and typevars
2 parents 4dece74 + 868ad47 commit be50d2c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ class Namer { typer: Typer =>
11061106
mdef match {
11071107
case mdef: DefDef if mdef.name == nme.ANON_FUN =>
11081108
val hygienicType = avoid(rhsType, paramss.flatten)
1109-
if (!(hygienicType <:< tpt.tpe))
1109+
if (!hygienicType.isValueType || !(hygienicType <:< tpt.tpe))
11101110
ctx.error(i"return type ${tpt.tpe} of lambda cannot be made hygienic;\n" +
11111111
i"it is not a supertype of the hygienic type $hygienicType", mdef.pos)
11121112
//println(i"lifting $rhsType over $paramss -> $hygienicType = ${tpt.tpe}")

tests/neg/i3542a.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Foo {
2+
def f()()(implicit ctx: String): Int = ???
3+
def at[T](op: () => T): Unit = ()
4+
at(() => f()) // error: missing ()
5+
}

0 commit comments

Comments
 (0)