aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2015-09-18 13:11:51 +0100
committerDmitry Petrashko <dark@d-d.me>2015-09-18 13:11:51 +0100
commit6bb62102e0542149a3644819fdcfae40ce08ba9e (patch)
treeefa15934ebcf848e6af38704865427100f29ac61
parentec683c17773ab86782859fdc678d98c34810c1f3 (diff)
parent41b8853ca9a8327c65cb96a8ffccb5491d53edda (diff)
downloaddotty-6bb62102e0542149a3644819fdcfae40ce08ba9e.tar.gz
dotty-6bb62102e0542149a3644819fdcfae40ce08ba9e.tar.bz2
dotty-6bb62102e0542149a3644819fdcfae40ce08ba9e.zip
Merge pull request #798 from dotty-staging/fix-791
Fix 791
-rw-r--r--src/dotty/tools/dotc/core/TypeErasure.scala6
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--tests/run/OrType.scala11
3 files changed, 17 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala
index 0ef31015c..f27b2fd1e 100644
--- a/src/dotty/tools/dotc/core/TypeErasure.scala
+++ b/src/dotty/tools/dotc/core/TypeErasure.scala
@@ -234,7 +234,11 @@ object TypeErasure {
case nil =>
bestSoFar
}
- loop(tp1.baseClasses, defn.ObjectClass).typeRef
+ val t = loop(tp1.baseClasses, defn.ObjectClass)
+ if (t eq defn.AnyValClass)
+ // while AnyVal is a valid common super class for primitives it does not exist after erasure
+ defn.ObjectType
+ else t.typeRef
}
}
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index c45db4ccc..40029c42b 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -1117,7 +1117,7 @@ trait Applications extends Compatibility { self: Typer =>
case cdef: CaseDef => tpd.cpy.CaseDef(cdef)(body = adapt(cdef.body, pt))
case _ => adaptInterpolated(tree, pt, tree)
}
- harmonizeWith(trees)(_.tpe, adapt)
+ if (ctx.isAfterTyper) trees else harmonizeWith(trees)(_.tpe, adapt)
}
/** If all `types` are numeric value types, and they are not all the same type,
diff --git a/tests/run/OrType.scala b/tests/run/OrType.scala
new file mode 100644
index 000000000..9ab805def
--- /dev/null
+++ b/tests/run/OrType.scala
@@ -0,0 +1,11 @@
+class B(val x: Int)
+class C(val x: Double)
+
+object Test{
+ def bar(x: B | C): Int | Double = x.x
+ def main(args: Array[String]): Unit = {
+ val b = new B(1)
+ val c = new C(1)
+ bar(if (b.hashCode > c.hashCode) b else c)
+ }
+}