File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1031,21 +1031,22 @@ class Definitions {
10311031
10321032 /** An extractor for multi-dimensional arrays.
10331033 * Note that this will also extract the high bound if an
1034- * element type is a wildcard. E.g.
1034+ * element type is a wildcard upper-bounded by an array . E.g.
10351035 *
10361036 * Array[? <: Array[? <: Number]]
10371037 *
10381038 * would match
10391039 *
1040- * MultiArrayOf(<Number>, 2)
1040+ * MultiArrayOf(<? <: Number>, 2)
10411041 */
10421042 object MultiArrayOf {
10431043 def apply (elem : Type , ndims : Int )(using Context ): Type =
10441044 if (ndims == 0 ) elem else ArrayOf (apply(elem, ndims - 1 ))
10451045 def unapply (tp : Type )(using Context ): Option [(Type , Int )] = tp match {
10461046 case ArrayOf (elemtp) =>
10471047 def recur (elemtp : Type ): Option [(Type , Int )] = elemtp.dealias match {
1048- case TypeBounds (lo, hi) => recur(hi)
1048+ case tp @ TypeBounds (lo, hi @ MultiArrayOf (finalElemTp, n)) =>
1049+ Some (finalElemTp, n)
10491050 case MultiArrayOf (finalElemTp, n) => Some (finalElemTp, n + 1 )
10501051 case _ => Some (elemtp, 1 )
10511052 }
Original file line number Diff line number Diff line change @@ -65,5 +65,11 @@ object Test {
6565 arr4(x)
6666 arr5(x)
6767 arr6(x)
68+
69+
70+ val str : Any = " "
71+ assert(! str.isInstanceOf [Array [? ]])
72+ assert(! str.isInstanceOf [Array [Array [? ]]])
73+ assert(! str.isInstanceOf [Array [? <: Array [? ]]])
6874 }
6975}
You can’t perform that action at this time.
0 commit comments