@@ -10,6 +10,7 @@ import util.common._
10
10
import Names ._
11
11
import Flags ._
12
12
import util .Positions .Position
13
+ import config .Printers ._
13
14
import collection .mutable
14
15
15
16
object TypeApplications {
@@ -195,13 +196,32 @@ class TypeApplications(val self: Type) extends AnyVal {
195
196
NoType
196
197
}
197
198
198
- /** The base type including all type arguments of this type.
199
+ /** The base type including all type arguments and applicable refinements
200
+ * of this type. Refinements are applicable if they refine a member of
201
+ * the parent type which furthermore is not a name-mangled type parameter.
199
202
* Existential types in arguments are returned as TypeBounds instances.
200
203
*/
201
- final def baseTypeWithArgs (base : Symbol )(implicit ctx : Context ): Type = self.dealias match {
202
- case AndType (tp1, tp2) => tp1.baseTypeWithArgs(base) & tp2.baseTypeWithArgs(base)
203
- case OrType (tp1, tp2) => tp1.baseTypeWithArgs(base) | tp2.baseTypeWithArgs(base)
204
- case _ => self.baseTypeRef(base).appliedTo(baseArgInfos(base))
204
+ final def baseTypeWithArgs (base : Symbol )(implicit ctx : Context ): Type = ctx.traceIndented(s " btwa ${self.show} wrt $base" , core, show = true ) {
205
+ def default = self.baseTypeRef(base).appliedTo(baseArgInfos(base))
206
+ self match {
207
+ case tp : TypeRef =>
208
+ tp.info match {
209
+ case TypeBounds (_, hi) => hi.baseTypeWithArgs(base)
210
+ case _ => default
211
+ }
212
+ case tp @ RefinedType (parent, name) if ! tp.member(name).symbol.is(ExpandedTypeParam ) =>
213
+ val pbase = parent.baseTypeWithArgs(base)
214
+ if (pbase.member(name).exists) RefinedType (pbase, name, tp.refinedInfo)
215
+ else pbase
216
+ case tp : TermRef =>
217
+ tp.underlying.baseTypeWithArgs(base)
218
+ case AndType (tp1, tp2) =>
219
+ tp1.baseTypeWithArgs(base) & tp2.baseTypeWithArgs(base)
220
+ case OrType (tp1, tp2) =>
221
+ tp1.baseTypeWithArgs(base) | tp2.baseTypeWithArgs(base)
222
+ case _ =>
223
+ default
224
+ }
205
225
}
206
226
207
227
/** Translate a type of the form From[T] to To[T], keep other types as they are.
0 commit comments