@@ -81,26 +81,22 @@ object TypeApplications {
81
81
* `>: L <: H` is substituted for a type lambda parameter `X` only under certain conditions.
82
82
*
83
83
* 1. If Mode.AllowLambdaWildcardApply is set:
84
- * The wildcard argument is substituted only if `X` appears in a toplevel refinement of the form
84
+ * The wildcard argument is substituted only if `X` appears in a toplevel application of the form
85
85
*
86
- * { type A = X }
86
+ * C[..., X, ...]
87
87
*
88
88
* and there are no other occurrences of `X` in the reduced type. In that case
89
89
* the refinement above is replaced by
90
90
*
91
- * { type A >: L <: U }
91
+ * C[..., _ >: L <: H, ...]
92
92
*
93
93
* The `allReplaced` field indicates whether all occurrences of type lambda parameters
94
94
* in the reduced type have been replaced with arguments.
95
95
*
96
96
* 2. If Mode.AllowLambdaWildcardApply is not set:
97
- * All refinements of the form
97
+ * All `X` arguments are replaced by:
98
98
*
99
- * { type A = X }
100
- *
101
- * are replaced by:
102
- *
103
- * { type A >: L <: U }
99
+ * _ >: L <: H
104
100
*
105
101
* Any other occurrence of `X` in `tycon` is replaced by `U`, if the
106
102
* occurrence of `X` in `tycon` is covariant, or nonvariant, or by `L`,
@@ -121,6 +117,12 @@ object TypeApplications {
121
117
p.binder == tycon && args(p.paramNum).isInstanceOf [TypeBounds ]
122
118
def canReduceWildcard (p : TypeParamRef ) =
123
119
! ctx.mode.is(Mode .AllowLambdaWildcardApply ) || available.contains(p.paramNum)
120
+ def atNestedLevel (op : => Type ): Type = {
121
+ val saved = available
122
+ available = Set ()
123
+ try op
124
+ finally available = saved
125
+ }
124
126
125
127
// If this is a reference to a reducable type parameter corresponding to a
126
128
// wildcard argument, return the wildcard argument, otherwise apply recursively.
@@ -129,13 +131,10 @@ object TypeApplications {
129
131
available -= p.paramNum
130
132
args(p.paramNum)
131
133
case _ =>
132
- apply(arg)
134
+ atNestedLevel( apply(arg) )
133
135
}
134
136
135
137
def apply (t : Type ) = t match {
136
- case t @ TypeAlias (p : TypeParamRef ) if hasWildcardArg(p) && canReduceWildcard(p) =>
137
- available -= p.paramNum // @!!! needed in the future?
138
- args(p.paramNum)
139
138
case t @ AppliedType (tycon, args1) if tycon.typeSymbol.isClass =>
140
139
t.derivedAppliedType(apply(tycon), args1.mapConserve(applyArg))
141
140
case p : TypeParamRef if p.binder == tycon =>
@@ -148,10 +147,7 @@ object TypeApplications {
148
147
arg
149
148
}
150
149
case _ : TypeBounds | _ : AppliedType =>
151
- val saved = available
152
- available = Set ()
153
- try mapOver(t)
154
- finally available = saved
150
+ atNestedLevel(mapOver(t))
155
151
case _ =>
156
152
mapOver(t)
157
153
}
0 commit comments