Skip to content

Commit 69af22c

Browse files
committed
Reject wildcard types in using clauses
1 parent 31f837e commit 69af22c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3314,7 +3314,7 @@ object Parsers {
33143314
/** ContextTypes ::= FunArgType {‘,’ FunArgType}
33153315
*/
33163316
def contextTypes(paramOwner: ParamOwner, numLeadParams: Int, impliedMods: Modifiers): List[ValDef] =
3317-
val tps = commaSeparated(funArgType)
3317+
val tps = commaSeparated(() => paramTypeOf(toplevelTyp))
33183318
var counter = numLeadParams
33193319
def nextIdx = { counter += 1; counter }
33203320
val paramFlags = if paramOwner.isClass then LocalParamAccessor else Param

tests/neg/i19364.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
def f(using ?): Unit = {} // error: unbound wildcard type
3+
class C(using ?) {} // error: unbound wildcard type
4+
5+
def f2(using => ?): Unit = {} // error: unbound wildcard type
6+
class C2(using => ?) {} // error: unbound wildcard type
7+
8+
def f3(using ? *): Unit = {} // error: unbound wildcard type // error
9+
class C3(using ? *) {} // error: unbound wildcard type // error
10+
11+
def g(using x: ?): Unit = {} // error: unbound wildcard type
12+
class D(using x: ?) {} // error: unbound wildcard type
13+
14+
val h: (?) ?=> Unit = ??? // ok, but useless (it's a function from Nothing)

0 commit comments

Comments
 (0)