Skip to content

Commit 759db09

Browse files
committed
Don't flag wildcard array arguments for not being sealed
1 parent 5fe938d commit 759db09

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 */
@@ -1318,7 +1318,9 @@ class CheckCaptures extends Recheck, SymTransformer:
13181318
def traverse(t: Type): Unit =
13191319
t match
13201320
case AppliedType(tycon, arg :: Nil) if tycon.typeSymbol == defn.ArrayClass =>
1321-
if !(pos.span.isSynthetic && ctx.reporter.errorsReported) then
1321+
if !(pos.span.isSynthetic && ctx.reporter.errorsReported)
1322+
&& !arg.typeSymbol.name.is(WildcardParamName)
1323+
then
13221324
CheckCaptures.disallowRootCapabilitiesIn(arg, NoSymbol,
13231325
"Array", "have element type",
13241326
"Since arrays are mutable, they have to be treated like variables,\nso their element type must be sealed.",
@@ -1341,10 +1343,11 @@ class CheckCaptures extends Recheck, SymTransformer:
13411343
val lctx = tree match
13421344
case _: DefTree | _: TypeDef if tree.symbol.exists => ctx.withOwner(tree.symbol)
13431345
case _ => ctx
1344-
traverseChildren(tree)(using lctx)
1345-
check(tree)
1346+
trace(i"post check $tree"):
1347+
traverseChildren(tree)(using lctx)
1348+
check(tree)
13461349
def check(tree: Tree)(using Context) = tree match
1347-
case t @ TypeApply(fun, args) =>
1350+
case TypeApply(fun, args) =>
13481351
fun.knownType.widen match
13491352
case tl: PolyType =>
13501353
val normArgs = args.lazyZip(tl.paramInfos).map: (arg, bounds) =>

0 commit comments

Comments
 (0)