From c29405dfe1a24419ce4ce10500b5e8d05c581bee Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 19 Apr 2013 15:01:46 -0700 Subject: Simplify type bounds. I started out looking to limit the noise from empty type bounds, i.e. the endless repetition of class A[T >: _root_.scala.Nothing <: _root_.scala.Any] This led me to be reminded of all the unnecessary and in fact damaging overreaches which are performed during parsing. Why should a type parameter for which no bounds are specified be immediately encoded with this giant tree: TypeBounds( Select(Select(Ident(nme.ROOTPKG), tpnme.scala_), tpnme.Nothing), Select(Select(Ident(nme.ROOTPKG), tpnme.scala_), tpnme.Any) ) ...which must then be manually recognized as empty type bounds? Truly, this is madness. - It deftly eliminates the possibility of recognizing whether the user wrote "class A[T]" or "class A[T >: Nothing]" or "class A[T <: Any]" or specified both bounds. The fact that these work out the same internally does not imply the information should be exterminated even before parsing completes. - It burdens everyone who must recognize type bounds trees, such as this author - It is far less efficient than the obvious encoding - It offers literally no advantage whatsoever Encode empty type bounds as TypeBounds(EmptyTree, EmptyTree) What could be simpler. --- test/files/presentation/callcc-interpreter.check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/files/presentation/callcc-interpreter.check') diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index af0154fe60..804b365101 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -69,13 +69,13 @@ retrieved 63 members askType at CallccInterpreter.scala(14,21) ================================================================================ [response] askTypeAt at (14,21) -def unitM[A >: Nothing <: Any](a: A): callccInterpreter.M[A] = callccInterpreter.this.M.apply[A](((c: A => callccInterpreter.Answer) => c.apply(a))) +def unitM[A](a: A): callccInterpreter.M[A] = callccInterpreter.this.M.apply[A](((c: A => callccInterpreter.Answer) => c.apply(a))) ================================================================================ askType at CallccInterpreter.scala(16,12) ================================================================================ [response] askTypeAt at (16,12) -def id[A >: Nothing <: Any]: A => A = ((x: A) => x) +def id[A]: A => A = ((x: A) => x) ================================================================================ askType at CallccInterpreter.scala(17,25) -- cgit v1.2.3