We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4dece74 + 868ad47 commit be50d2cCopy full SHA for be50d2c
compiler/src/dotty/tools/dotc/typer/Namer.scala
@@ -1106,7 +1106,7 @@ class Namer { typer: Typer =>
1106
mdef match {
1107
case mdef: DefDef if mdef.name == nme.ANON_FUN =>
1108
val hygienicType = avoid(rhsType, paramss.flatten)
1109
- if (!(hygienicType <:< tpt.tpe))
+ if (!hygienicType.isValueType || !(hygienicType <:< tpt.tpe))
1110
ctx.error(i"return type ${tpt.tpe} of lambda cannot be made hygienic;\n" +
1111
i"it is not a supertype of the hygienic type $hygienicType", mdef.pos)
1112
//println(i"lifting $rhsType over $paramss -> $hygienicType = ${tpt.tpe}")
tests/neg/i3542a.scala
@@ -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