diff options
author | Paul Phillips <paulp@improving.org> | 2013-04-19 15:01:46 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-04-20 15:25:53 -0700 |
commit | c29405dfe1a24419ce4ce10500b5e8d05c581bee (patch) | |
tree | dca5ea3a915101613b6d007831d9240596b685f5 /test/files | |
parent | d506bedc5ab83bf9af8cc0240e61a0c691f8508b (diff) | |
download | scala-c29405dfe1a24419ce4ce10500b5e8d05c581bee.tar.gz scala-c29405dfe1a24419ce4ce10500b5e8d05c581bee.tar.bz2 scala-c29405dfe1a24419ce4ce10500b5e8d05c581bee.zip |
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.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/presentation/callcc-interpreter.check | 4 | ||||
-rw-r--r-- | test/files/run/analyzerPlugins.check | 8 | ||||
-rw-r--r-- | test/files/run/macro-typecheck-macrosdisabled.check | 4 | ||||
-rw-r--r-- | test/files/run/macro-typecheck-macrosdisabled2.check | 4 | ||||
-rw-r--r-- | test/files/run/reify-each-node-type.check | 4 | ||||
-rw-r--r-- | test/files/run/reify_ann1a.check | 2 | ||||
-rw-r--r-- | test/files/run/reify_ann1b.check | 2 | ||||
-rw-r--r-- | test/files/run/reify_ann2a.check | 2 | ||||
-rw-r--r-- | test/files/run/reify_ann3.check | 2 |
9 files changed, 14 insertions, 18 deletions
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) diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index 297bd36bae..641fbfff6b 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -25,13 +25,13 @@ pluginsPt(?, Trees$Assign) [7] pluginsPt(?, Trees$Block) [4] pluginsPt(?, Trees$ClassDef) [2] pluginsPt(?, Trees$DefDef) [14] -pluginsPt(?, Trees$Ident) [51] +pluginsPt(?, Trees$Ident) [50] pluginsPt(?, Trees$If) [2] pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [52] +pluginsPt(?, Trees$Select) [48] pluginsPt(?, Trees$Super) [2] pluginsPt(?, Trees$This) [20] pluginsPt(?, Trees$TypeApply) [4] @@ -112,7 +112,6 @@ pluginsTyped(<notype>, Trees$DefDef) [14] pluginsTyped(<notype>, Trees$PackageDef) [1] pluginsTyped(<notype>, Trees$TypeDef) [1] pluginsTyped(<notype>, Trees$ValDef) [21] -pluginsTyped(<root>, Trees$Ident) [1] pluginsTyped(=> Boolean @testAnn, Trees$Select) [1] pluginsTyped(=> Double, Trees$Select) [4] pluginsTyped(=> Int, Trees$Select) [5] @@ -151,7 +150,6 @@ pluginsTyped(List[Any], Trees$Apply) [1] pluginsTyped(List[Any], Trees$Select) [1] pluginsTyped(List[Any], Trees$TypeTree) [3] pluginsTyped(Nothing, Trees$Return) [1] -pluginsTyped(Nothing, Trees$Select) [2] pluginsTyped(Object, Trees$Apply) [1] pluginsTyped(String @testAnn, Trees$Ident) [1] pluginsTyped(String @testAnn, Trees$Select) [1] @@ -185,8 +183,6 @@ pluginsTyped(scala.annotation.TypeConstraint, Trees$TypeTree) [2] pluginsTyped(scala.collection.immutable.List.type, Trees$Select) [2] pluginsTyped(scala.collection.immutable.StringOps, Trees$ApplyImplicitView) [2] pluginsTyped(scala.collection.mutable.WrappedArray[Any], Trees$Apply) [1] -pluginsTyped(scala.type, Trees$Ident) [1] -pluginsTyped(scala.type, Trees$Select) [1] pluginsTyped(str.type, Trees$Ident) [3] pluginsTyped(testAnn, Trees$Apply) [5] pluginsTyped(testAnn, Trees$Ident) [5] diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check index 29a881f8b1..e0e880ab66 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.check +++ b/test/files/run/macro-typecheck-macrosdisabled.check @@ -7,7 +7,7 @@ $treecreator1.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.Literal.apply($u.Constant.apply(2)) @@ -20,7 +20,7 @@ $typecreator2.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.ConstantType.apply($u.Constant.apply(2)) diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check index 75fd693722..347dfec1dc 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2.check +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -7,7 +7,7 @@ $treecreator1.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) @@ -20,7 +20,7 @@ $typecreator2.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) diff --git a/test/files/run/reify-each-node-type.check b/test/files/run/reify-each-node-type.check index af6fd13a7b..afc65add7a 100644 --- a/test/files/run/reify-each-node-type.check +++ b/test/files/run/reify-each-node-type.check @@ -15,7 +15,7 @@ 15 { def f(x: Any): Unit = (); () } EmptyTree 16 (null: r.D with r.E) CompoundTypeTree 17 { type T = Int; () } TypeDef -18 { type CC[T >: Nothing <: r.D] = r.C[T]; () } TypeBoundsTree +18 { type CC[T <: r.D] = r.C[T]; () } TypeBoundsTree 19 try { 0 } finally Predef.println("") Try 20 ((x: Int) => x) Function 21 { var v = 1; v = 2 } Assign @@ -24,7 +24,7 @@ 24 0: @unchecked Annotated 25 (null: r.Outer#Inner) SelectFromTypeTree 26 (null: Nil.type) SingletonTypeTree -27 (null: T forSome { type T >: Nothing <: Any }) ExistentialTypeTree +27 (null: T forSome { type T }) ExistentialTypeTree 28 { import r.{A, B=>C}; () } Import 29 { def f: Int = return 0; () } Return 30 { object x extends AnyRef { def <init>() = { super.<init>(); ModuleDef diff --git a/test/files/run/reify_ann1a.check b/test/files/run/reify_ann1a.check index 99a966f38b..71841ff83b 100644 --- a/test/files/run/reify_ann1a.check +++ b/test/files/run/reify_ann1a.check @@ -1,5 +1,5 @@ { - @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T] extends AnyRef { @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); diff --git a/test/files/run/reify_ann1b.check b/test/files/run/reify_ann1b.check index 6a5f32a492..bc046a7455 100644 --- a/test/files/run/reify_ann1b.check +++ b/test/files/run/reify_ann1b.check @@ -1,5 +1,5 @@ { - @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T >: Nothing <: Any] extends AnyRef { + @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T] extends AnyRef { @new ann(bar = "3a") @new ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4a") @ann(bar = "4b") = _; def <init>(@new ann(bar = "3a") @new ann(bar = "3b") x: T @ann(bar = "4a") @ann(bar = "4b")) = { super.<init>(); diff --git a/test/files/run/reify_ann2a.check b/test/files/run/reify_ann2a.check index ccbcb4c31e..a26fa42045 100644 --- a/test/files/run/reify_ann2a.check +++ b/test/files/run/reify_ann2a.check @@ -6,7 +6,7 @@ () } }; - @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T] extends AnyRef { @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); diff --git a/test/files/run/reify_ann3.check b/test/files/run/reify_ann3.check index 8caceb2696..d4cf660758 100644 --- a/test/files/run/reify_ann3.check +++ b/test/files/run/reify_ann3.check @@ -1,5 +1,5 @@ { - class Tree[A >: Nothing <: Any, B >: Nothing <: Any] extends AnyRef { + class Tree[A, B] extends AnyRef { @new inline @getter() final <paramaccessor> val key: A = _; def <init>(key: A) = { super.<init>(); |