diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-10-13 02:05:30 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-10-13 02:08:12 +0200 |
commit | 6e78c7aff351de5e5c8ccddc319744a4f976d79c (patch) | |
tree | 734fe4470856c936a392b66dedcf8d6dba6eac58 | |
parent | 1c62d0557417612fb90108fd6a3728d7c510f968 (diff) | |
download | dotty-6e78c7aff351de5e5c8ccddc319744a4f976d79c.tar.gz dotty-6e78c7aff351de5e5c8ccddc319744a4f976d79c.tar.bz2 dotty-6e78c7aff351de5e5c8ccddc319744a4f976d79c.zip |
Fix erasure of "def foo[T]: Unit", do not box the return type
-rw-r--r-- | src/dotty/tools/dotc/core/TypeErasure.scala | 2 | ||||
-rw-r--r-- | tests/run/unit_erasure.scala | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala index fd5fcb921..254ea3277 100644 --- a/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/src/dotty/tools/dotc/core/TypeErasure.scala @@ -417,7 +417,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean // See doc comment for ElimByName for speculation how we could improve this. else MethodType(Nil, Nil, eraseResult(rt)) case tp: PolyType => - this(tp.resultType) match { + eraseResult(tp.resultType) match { case rt: MethodType => rt case rt => MethodType(Nil, Nil, rt) } diff --git a/tests/run/unit_erasure.scala b/tests/run/unit_erasure.scala new file mode 100644 index 000000000..51ccf0a16 --- /dev/null +++ b/tests/run/unit_erasure.scala @@ -0,0 +1,16 @@ +class A { + def foo1[T]: Unit = {} + def foo2[T](): Unit = {} + def foo3[T]()(): Unit = {} + def foo4: Unit = {} + def foo5(): Unit = {} + def foo6()(): Unit = {} +} + +object Test { + def main(args: Array[String]): Unit = { + classOf[A].getMethods.toList.filter(_.getName.startsWith("foo")).foreach { m => + assert(m.getGenericReturnType == Void.TYPE, s"Method does not return void: `${m}`") + } + } +}
\ No newline at end of file |