Skip to content

Commit c0b8c17

Browse files
Backport "Reject wildcard types in using clauses" to LTS (#20832)
Backports #19459 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents ea9a722 + f7d07f5 commit c0b8c17

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
@@ -3270,7 +3270,7 @@ object Parsers {
32703270
/** ContextTypes ::= FunArgType {‘,’ FunArgType}
32713271
*/
32723272
def contextTypes(paramOwner: ParamOwner, numLeadParams: Int, impliedMods: Modifiers): List[ValDef] =
3273-
val tps = commaSeparated(funArgType)
3273+
val tps = commaSeparated(() => paramTypeOf(toplevelTyp))
32743274
var counter = numLeadParams
32753275
def nextIdx = { counter += 1; counter }
32763276
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)