diff options
author | James Iry <jamesiry@gmail.com> | 2013-02-04 08:23:30 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-02-04 09:30:38 -0800 |
commit | 057417236845b689f29c221037e1d06d2b6e43bb (patch) | |
tree | 2725a1186f0dded8991cf192d3a17274da8a6129 /src/reflect | |
parent | 8d25d05e9bf848d763e7b657d9c7e96ea5cb8daf (diff) | |
download | scala-057417236845b689f29c221037e1d06d2b6e43bb.tar.gz scala-057417236845b689f29c221037e1d06d2b6e43bb.tar.bz2 scala-057417236845b689f29c221037e1d06d2b6e43bb.zip |
SI-5833 Fixes tail-of-Nil problem in RefinedType#normalizeImpl
RefinedType#normalizeImpl was checking to see if the flattened list of
parents had an empty tail then pulling the head if so. But if the list
was empty then boom. This fix makes it check if the whole list has
length 1 instead. Empty lists will flow through to the rest the logic
which has no problems with Nil.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 9d4bdab837..0dd98fb6ae 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1800,7 +1800,7 @@ trait Types extends api.Types { self: SymbolTable => // TODO see comments around def intersectionType and def merge def flatten(tps: List[Type]): List[Type] = tps flatMap { case RefinedType(parents, ds) if ds.isEmpty => flatten(parents) case tp => List(tp) } val flattened = flatten(parents).distinct - if (decls.isEmpty && flattened.tail.isEmpty) { + if (decls.isEmpty && hasLength(flattened, 1)) { flattened.head } else if (flattened != parents) { refinedType(flattened, if (typeSymbol eq NoSymbol) NoSymbol else typeSymbol.owner, decls, NoPosition) @@ -3542,7 +3542,7 @@ trait Types extends api.Types { self: SymbolTable => if (phase.erasedTypes) if (parents.isEmpty) ObjectClass.tpe else parents.head else { - val clazz = owner.newRefinementClass(pos) // TODO: why were we passing in NoPosition instead of pos? + val clazz = owner.newRefinementClass(pos) val result = RefinedType(parents, decls, clazz) clazz.setInfo(result) result |