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 @@ -1029,21 +1029,22 @@ class Definitions {
10291029
10301030 /** An extractor for multi-dimensional arrays.
10311031 * Note that this will also extract the high bound if an
1032- * element type is a wildcard. E.g.
1032+ * element type is a wildcard upper-bounded by an array . E.g.
10331033 *
10341034 * Array[? <: Array[? <: Number]]
10351035 *
10361036 * would match
10371037 *
1038- * MultiArrayOf(<Number>, 2)
1038+ * MultiArrayOf(<? <: Number>, 2)
10391039 */
10401040 object MultiArrayOf {
10411041 def apply (elem : Type , ndims : Int )(using Context ): Type =
10421042 if (ndims == 0 ) elem else ArrayOf (apply(elem, ndims - 1 ))
10431043 def unapply (tp : Type )(using Context ): Option [(Type , Int )] = tp match {
10441044 case ArrayOf (elemtp) =>
10451045 def recur (elemtp : Type ): Option [(Type , Int )] = elemtp.dealias match {
1046- case TypeBounds (lo, hi) => recur(hi)
1046+ case tp @ TypeBounds (lo, hi @ MultiArrayOf (finalElemTp, n)) =>
1047+ Some (finalElemTp, n)
10471048 case MultiArrayOf (finalElemTp, n) => Some (finalElemTp, n + 1 )
10481049 case _ => Some (elemtp, 1 )
10491050 }
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