Please sign in to comment.
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.
- Loading branch information...
Showing with 39 additions and 48 deletions.
- +10 −8 src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
- +4 −18 src/compiler/scala/tools/nsc/javac/JavaParsers.scala
- +2 −2 src/compiler/scala/tools/nsc/typechecker/Typers.scala
- +8 −1 src/reflect/scala/reflect/internal/Printers.scala
- +2 −2 test/files/presentation/callcc-interpreter.check
- +2 −6 test/files/run/analyzerPlugins.check
- +2 −2 test/files/run/macro-typecheck-macrosdisabled.check
- +2 −2 test/files/run/macro-typecheck-macrosdisabled2.check
- +2 −2 test/files/run/reify-each-node-type.check
- +1 −1 test/files/run/reify_ann1a.check
- +1 −1 test/files/run/reify_ann1b.check
- +1 −1 test/files/run/reify_ann2a.check
- +1 −1 test/files/run/reify_ann3.check
- +1 −1 test/scaladoc/run/t5527.check