diff options
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/TastyReader.scala | 2 | ||||
-rw-r--r-- | tests/pos/pickleOK/unions.scala | 33 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TastyReader.scala b/src/dotty/tools/dotc/core/pickling/TastyReader.scala index e0f3be84e..0385e9adb 100644 --- a/src/dotty/tools/dotc/core/pickling/TastyReader.scala +++ b/src/dotty/tools/dotc/core/pickling/TastyReader.scala @@ -88,7 +88,7 @@ class TastyReader(val bytes: Array[Byte], start: Int, end: Int, val base: Int = /** Read a long integer number in 2's complement big endian format, base 128. */ def readLongInt(): Long = { var b = bytes(bp) - var x = (b << 1).toByte >> 1 // sign extend with bit 6. + var x: Long = (b << 1).toByte >> 1 // sign extend with bit 6. bp += 1 while ((b & 0x80) == 0) { b = bytes(bp) diff --git a/tests/pos/pickleOK/unions.scala b/tests/pos/pickleOK/unions.scala new file mode 100644 index 000000000..22e6391e3 --- /dev/null +++ b/tests/pos/pickleOK/unions.scala @@ -0,0 +1,33 @@ +object unions { + + class A { + def f: String = "abc" + + def g(x: Int): Int = x + def g(x: Double): Double = x + } + + class B { + def f: String = "bcd" + + def g(x: Int) = -x + def g(x: Double): Double = -x + } + + val x: A | B = if (true) new A else new B + def y: B | A = if (true) new A else new B + println(x.f) + println(x.g(2)) + println(y.f) + println(y.g(1.0)) + println(y.g(1.0f)) + + class C { + private def foo = 0 + class D extends C { + private def foo = 1 + def test(cd: C | D, dc: D | C) = (cd.foo, dc.foo) + } + } + +} |