Skip to content

Commit

Permalink
Backport "Reject wildcard types in using clauses" to LTS (#20832)
Browse files Browse the repository at this point in the history
Backports #19459 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 28, 2024
2 parents ea9a722 + f7d07f5 commit c0b8c17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3270,7 +3270,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
Expand Down
14 changes: 14 additions & 0 deletions tests/neg/i19364.scala
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit c0b8c17

Please sign in to comment.