@@ -1914,11 +1914,26 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1914
1914
.showing(i " desugared fun $tree --> $desugared with pt = $pt" , typr)
1915
1915
}
1916
1916
1917
+ /** Check that the PolyFunction doesn't have by-name parameters.
1918
+ * Return the unchanged tree if it's valid, or EmptyTree otherwise.
1919
+ */
1920
+ private def checkPolyTypeTree (tree : untpd.Tree )(using Context ): untpd.Tree =
1921
+ val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun @ untpd.Function (vparamTypes, res)) = tree : @ unchecked
1922
+ var tree1 = tree
1923
+ vparamTypes.foreach:
1924
+ case t : ByNameTypeTree =>
1925
+ report.error(" By-name parameters are not supported in Polymorphic Functions" , t.srcPos)
1926
+ tree1 = untpd.EmptyTree
1927
+ case _ =>
1928
+ tree1
1917
1929
1918
1930
def typedPolyFunction (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1919
1931
val tree1 = desugar.normalizePolyFunction(tree)
1920
- if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree1), pt)
1921
- else typedPolyFunctionValue(tree1, pt)
1932
+ checkPolyTypeTree(tree1) match
1933
+ case tree2 : untpd.PolyFunction =>
1934
+ if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree2), pt)
1935
+ else typedPolyFunctionValue(tree2, pt)
1936
+ case untpd.EmptyTree => TypeTree (NoType )
1922
1937
1923
1938
def typedPolyFunctionValue (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1924
1939
val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun) = tree : @ unchecked
0 commit comments