Skip to content
Browse files

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.
  • Loading branch information...
1 parent 696dcdf commit 204b2b45a83cf057b6ece7a25ea4f15ec38b4a3f @retronym retronym committed Feb 26, 2013
Showing with 11 additions and 4 deletions.
  1. +11 −4 src/reflect/scala/reflect/internal/Types.scala
View
15 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
* {{{

0 comments on commit 204b2b4

Please sign in to comment.
Something went wrong with that request. Please try again.