diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-09-14 15:14:41 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-11-07 11:42:51 +1000 |
commit | a9182fbeaf018c1aa0f88f0aee7b921383b746f2 (patch) | |
tree | 01801890071c5cef286638721bf074ed0302ac8d /test/files/run/t8575c.scala | |
parent | c12a9b7bf8dc423783dd02eb0e4c477c86de96df (diff) | |
download | scala-a9182fbeaf018c1aa0f88f0aee7b921383b746f2.tar.gz scala-a9182fbeaf018c1aa0f88f0aee7b921383b746f2.tar.bz2 scala-a9182fbeaf018c1aa0f88f0aee7b921383b746f2.zip |
SI-8575 Fix subtyping transitivity with aliases, compound types
Thanks to @b-studios and @Blaisorblade for investigation into this
bug.
`RefinedType#normalize` is responsible for flattening nested
compound types to a flat representation.
Types are normalized during `=:=` in search of a successful
result.
This means that `((A with B) with C) =:= (A with B with C)`.
However, if we introduce a type alias for `A with B` on the LHS,
the attempt at flattening is thwarted.
This commit changes normalization of refined types. If a parent is
an alias for another refined type, it is dealiased during the
flattening process.
Two tests are included. The first demonstrates a symptom of this
problem: failure to install a bridge method resulted in a linkage
error.
The second test uses the reflection API to directly show transitivity
of subtyping now holds.
Targetting at 2.12, as bug fixes in subtyping usually can be shown
to lead to binary incompatibilities between code using the old and
new compilers.
Diffstat (limited to 'test/files/run/t8575c.scala')
-rw-r--r-- | test/files/run/t8575c.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/files/run/t8575c.scala b/test/files/run/t8575c.scala new file mode 100644 index 0000000000..8219952299 --- /dev/null +++ b/test/files/run/t8575c.scala @@ -0,0 +1,23 @@ +class C + +trait TypeMember { + type X + type Y + type Z +} + +object Test extends TypeMember { + type A = X with Y + type B = Z with A + type F = A with B + + def main(args: Array[String]) { + import reflect.runtime.universe._ + val t1 = typeOf[F with C] + val t2 = typeOf[(A with B) with C] + val t3 = typeOf[A with B with C] + assert(t1 =:= t2) + assert(t2 =:= t3) + assert(t3 =:= t1) + } +} |