Skip to content

Commit 876e5ee

Browse files
committed
Don't flag wildcard array arguments for not being sealed
1 parent b50fe54 commit 876e5ee

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Recheck.*
2121
import scala.collection.mutable
2222
import CaptureSet.{withCaptureSetsExplained, IdempotentCaptRefMap, CompareResult}
2323
import StdNames.nme
24-
import NameKinds.DefaultGetterName
24+
import NameKinds.{DefaultGetterName, WildcardParamName}
2525
import reporting.trace
2626

2727
/** The capture checker */
@@ -1316,7 +1316,9 @@ class CheckCaptures extends Recheck, SymTransformer:
13161316
def traverse(t: Type): Unit =
13171317
t match
13181318
case AppliedType(tycon, arg :: Nil) if tycon.typeSymbol == defn.ArrayClass =>
1319-
if !(pos.span.isSynthetic && ctx.reporter.errorsReported) then
1319+
if !(pos.span.isSynthetic && ctx.reporter.errorsReported)
1320+
&& !arg.typeSymbol.name.is(WildcardParamName)
1321+
then
13201322
CheckCaptures.disallowRootCapabilitiesIn(arg, NoSymbol,
13211323
"Array", "have element type",
13221324
"Since arrays are mutable, they have to be treated like variables,\nso their element type must be sealed.",
@@ -1339,10 +1341,11 @@ class CheckCaptures extends Recheck, SymTransformer:
13391341
val lctx = tree match
13401342
case _: DefTree | _: TypeDef if tree.symbol.exists => ctx.withOwner(tree.symbol)
13411343
case _ => ctx
1342-
traverseChildren(tree)(using lctx)
1343-
check(tree)
1344+
trace(i"post check $tree"):
1345+
traverseChildren(tree)(using lctx)
1346+
check(tree)
13441347
def check(tree: Tree)(using Context) = tree match
1345-
case t @ TypeApply(fun, args) =>
1348+
case TypeApply(fun, args) =>
13461349
fun.knownType.widen match
13471350
case tl: PolyType =>
13481351
val normArgs = args.lazyZip(tl.paramInfos).map: (arg, bounds) =>

0 commit comments

Comments
 (0)