scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Calculation of unbounded generic array level incorrect with refined types as Array elements #7522

Open scabug opened 11 years ago

scabug commented 11 years ago
scala> def level(tp: Type): Int = erasure.asInstanceOf[{def unboundedGenericArrayLevel(tp: Type): Int}].unboundedGenericArrayLevel(tp)
level: (tp: $r.global.Type)Int

scala> level(typeOf[Array[Int]])
res4: Int = 0

scala> level(typeOf[Array[_]])
res5: Int = 1

scala> level(typeOf[Array[Array[_]]])
res6: Int = 2

scala> level(typeOf[Array[_] with String]) // correct since https://github.com/scala/scala/pull/2592 .
res7: Int = 1

scala> level(typeOf[Array[Array[_] with String]]) // still incorrect
res8: Int = 0

I believe the special case added in that PR should be pushed in the GenericArray extractor so that it works at each level of the test, rather than just for the element type of the outermost Array type.

================================== [EDITED]: The old description of the bug isn't too useful without the patch. I'm narrowing the focus of this ticket to the issue that I raised in code review. WAS: There are a ton of bugs; I have a giant patch, from which I have been cutting off slivers; this ticket exists to make sure that after that patch is in, the issues which have been raised along the way have been adequately addressed.

For starters, retronym's comments in https://github.com/scala/scala/pull/2592 .

==================================

scabug commented 11 years ago

Imported From: https://issues.scala-lang.org/browse/SI-7522?orig=1 Reporter: @paulp See #7088