diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index f95bb3cea351..0195a4ddbf34 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1221,7 +1221,6 @@ class Definitions { /** Creates a refined `PolyFunction` with an `apply` method with the given info. */ def apply(mt: MethodOrPoly)(using Context): Type = - assert(isValidPolyFunctionInfo(mt), s"Not a valid PolyFunction refinement: $mt") RefinedType(PolyFunctionClass.typeRef, nme.apply, mt) /** Matches a refined `PolyFunction` type and extracts the apply info. diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index cb730efbfe89..d65f9a9857e2 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -1829,12 +1829,11 @@ class NotAPath(tp: Type, usage: String)(using Context) extends TypeMsg(NotAPathI if sym.isAllOf(Flags.InlineParam) then i""" |Inline parameters are not considered immutable paths and cannot be used as - |singleton types. - | + |singleton types. + | |Hint: Removing the `inline` qualifier from the `${sym.name}` parameter |may help resolve this issue.""" else "" - class WrongNumberOfParameters(tree: untpd.Tree, foundCount: Int, pt: Type, expectedCount: Int)(using Context) extends SyntaxMsg(WrongNumberOfParametersID) { diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 159ce8354a30..3ed34532aa8f 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1914,7 +1914,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer .showing(i"desugared fun $tree --> $desugared with pt = $pt", typr) } - def typedPolyFunction(tree: untpd.PolyFunction, pt: Type)(using Context): Tree = val tree1 = desugar.normalizePolyFunction(tree) if (ctx.mode is Mode.Type) typed(desugar.makePolyFunctionType(tree1), pt) diff --git a/tests/neg/21538.check b/tests/neg/21538.check index 0e799bef3611..e0bcb43f9356 100644 --- a/tests/neg/21538.check +++ b/tests/neg/21538.check @@ -3,8 +3,8 @@ | ^^^^^^^^^^ | (value : V) is not a valid singleton type, since it is not an immutable path | Inline parameters are not considered immutable paths and cannot be used as - | singleton types. - | + | singleton types. + | | Hint: Removing the `inline` qualifier from the `value` parameter | may help resolve this issue. | diff --git a/tests/neg/i21652.check b/tests/neg/i21652.check new file mode 100644 index 000000000000..6cc024e1bb55 --- /dev/null +++ b/tests/neg/i21652.check @@ -0,0 +1,4 @@ +-- Error: tests/neg/i21652.scala:1:8 ----------------------------------------------------------------------------------- +1 |def k: [A] => (=> A) => A = // error + | ^^^^^^^^^^^^^^^^^ + |Implementation restriction: PolyFunction apply must have exactly one parameter list and optionally type arguments. No by-name nor varags are allowed. diff --git a/tests/neg/i21652.scala b/tests/neg/i21652.scala new file mode 100644 index 000000000000..a49d7f0eb1ce --- /dev/null +++ b/tests/neg/i21652.scala @@ -0,0 +1,2 @@ +def k: [A] => (=> A) => A = // error + [A] => a => a