diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 5467f2e1247f..18294a28b4a1 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3314,7 +3314,7 @@ object Parsers { /** ContextTypes ::= FunArgType {‘,’ FunArgType} */ def contextTypes(paramOwner: ParamOwner, numLeadParams: Int, impliedMods: Modifiers): List[ValDef] = - val tps = commaSeparated(funArgType) + val tps = commaSeparated(() => paramTypeOf(toplevelTyp)) var counter = numLeadParams def nextIdx = { counter += 1; counter } val paramFlags = if paramOwner.isClass then LocalParamAccessor else Param diff --git a/tests/neg/i19364.scala b/tests/neg/i19364.scala new file mode 100644 index 000000000000..ae193e591c2e --- /dev/null +++ b/tests/neg/i19364.scala @@ -0,0 +1,14 @@ + +def f(using ?): Unit = {} // error: unbound wildcard type +class C(using ?) {} // error: unbound wildcard type + +def f2(using => ?): Unit = {} // error: unbound wildcard type +class C2(using => ?) {} // error: unbound wildcard type + +def f3(using ? *): Unit = {} // error: unbound wildcard type // error +class C3(using ? *) {} // error: unbound wildcard type // error + +def g(using x: ?): Unit = {} // error: unbound wildcard type +class D(using x: ?) {} // error: unbound wildcard type + +val h: (?) ?=> Unit = ??? // ok, but useless (it's a function from Nothing)