diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-06 16:38:45 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-24 14:58:37 -0800 |
commit | de2b0c68785afc0f801fbe8d2750366e90c9fa70 (patch) | |
tree | 2104e58922a3953d80646f0b550a2432d8abb8a3 | |
parent | 30b2064080044895bdf6ed0969b5bb001a0ee230 (diff) | |
download | scala-de2b0c68785afc0f801fbe8d2750366e90c9fa70.tar.gz scala-de2b0c68785afc0f801fbe8d2750366e90c9fa70.tar.bz2 scala-de2b0c68785afc0f801fbe8d2750366e90c9fa70.zip |
Renamed a method and made it more available.
We have too many methods called "widen" and/or "normalize".
Renamed one of them to something more instructive. Or in
the words of abe simpson,
Dear Mr. President:
There are too many states nowadays. Please eliminate three.
P.S. I am not a crackpot.
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 14 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 14 |
2 files changed, 15 insertions, 13 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 73f1f3db84..1df60f32d9 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -3266,6 +3266,20 @@ trait Types extends api.Types { self: SymbolTable => mapOver(tp) } } + + /** Type with all top-level occurrences of abstract types replaced by their bounds */ + def abstractTypesToBounds(tp: Type): Type = tp match { // @M don't normalize here (compiler loops on pos/bug1090.scala ) + case TypeRef(_, sym, _) if sym.isAbstractType => + abstractTypesToBounds(tp.bounds.hi) + case TypeRef(_, sym, _) if sym.isAliasType => + abstractTypesToBounds(tp.normalize) + case rtp @ RefinedType(parents, decls) => + copyRefinedType(rtp, parents mapConserve abstractTypesToBounds, decls) + case AnnotatedType(_, underlying, _) => + abstractTypesToBounds(underlying) + case _ => + tp + } // Set to true for A* => Seq[A] // (And it will only rewrite A* in method result types.) diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index b1612f24ef..9db291a306 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1116,19 +1116,7 @@ trait Infer { } } - /** Type with all top-level occurrences of abstract types replaced by their bounds */ - def widen(tp: Type): Type = tp match { // @M don't normalize here (compiler loops on pos/bug1090.scala ) - case TypeRef(_, sym, _) if sym.isAbstractType => - widen(tp.bounds.hi) - case TypeRef(_, sym, _) if sym.isAliasType => - widen(tp.normalize) - case rtp @ RefinedType(parents, decls) => - copyRefinedType(rtp, parents mapConserve widen, decls) - case AnnotatedType(_, underlying, _) => - widen(underlying) - case _ => - tp - } + def widen(tp: Type): Type = abstractTypesToBounds(tp) /** Substitute free type variables <code>undetparams</code> of type constructor * <code>tree</code> in pattern, given prototype <code>pt</code>. |