summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-02-26 17:11:43 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-02-26 17:11:43 +0100
commit204b2b45a83cf057b6ece7a25ea4f15ec38b4a3f (patch)
tree4137c4b2f300295ee10a7c94baa91293b28e43ad
parent696dcdfcdb40ee3dbd2ba63f8281b87cde787a00 (diff)
downloadscala-204b2b45a83cf057b6ece7a25ea4f15ec38b4a3f.tar.gz
scala-204b2b45a83cf057b6ece7a25ea4f15ec38b4a3f.tar.bz2
scala-204b2b45a83cf057b6ece7a25ea4f15ec38b4a3f.zip
SI-7126 Eliminate a source of malformed types.
The kind-polymorphic nature of Nothing and Any in concert with type argument inference could lead to types like `T[T]` (where `type T=Any`). Compensatory action is taken later on to recover; see the usages of `TypeRef#typeParamsMatchArgs`. But this these types have a nasty property, they can dealias to themselves. Callers recursing through types who fail to account for this hit an infinite recursion, as was reported in SI-7126. This commit simply dealiases `T` when registering the type bound in `unifySimple`. We should try to weed out additional sources of these types.
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index fb493fabd8..7299b439f8 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -3183,12 +3183,19 @@ trait Types extends api.Types { self: SymbolTable =>
* ?TC[?T] <: Any
* }}}
*/
- def unifySimple = (
- (params.isEmpty || tp.typeSymbol == NothingClass || tp.typeSymbol == AnyClass) && {
+ def unifySimple = {
+ val sym = tp.typeSymbol
+ if (sym == NothingClass || sym == AnyClass) { // kind-polymorphic
+ // SI-7126 if we register some type alias `T=Any`, we can later end
+ // with malformed types like `T[T]` during type inference in
+ // `handlePolymorphicCall`. No such problem if we register `Any`.
+ addBound(sym.tpe)
+ true
+ } else if (params.isEmpty) {
addBound(tp)
true
- }
- )
+ } else false
+ }
/** Full case: involving a check of the form
* {{{