Skip to content

Commit 48a2ab3

Browse files
committed
Make hkResult work for curried type lambdas
Ensure that hkResult and typeParams are in sync, except that typeParams work also for classes.
1 parent acb6165 commit 48a2ab3

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

compiler/src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,17 @@ class TypeApplications(val self: Type) extends AnyVal {
178178
if (tsym.isClass) tsym.typeParams
179179
else if (!tsym.isCompleting) tsym.info.typeParams
180180
else Nil
181+
case self: AppliedType =>
182+
if (self.tycon.typeSymbol.isClass) Nil
183+
else self.superType.typeParams
181184
case self: ClassInfo =>
182185
self.cls.typeParams
183186
case self: HKTypeLambda =>
184187
self.typeParams
185-
case self: RefinedType =>
186-
self.parent.typeParams
187-
case self: RecType =>
188-
self.parent.typeParams
189-
case _: SingletonType =>
188+
case _: SingletonType | _: RefinedType | _: RecType =>
190189
Nil
191190
case self: WildcardType =>
192191
self.optBounds.typeParams
193-
case self: AppliedType if self.tycon.typeSymbol.isClass =>
194-
Nil
195192
case self: TypeProxy =>
196193
self.superType.typeParams
197194
case _ =>
@@ -217,15 +214,15 @@ class TypeApplications(val self: Type) extends AnyVal {
217214
/** If self type is higher-kinded, its result type, otherwise NoType */
218215
def hkResult(implicit ctx: Context): Type = self.dealias match {
219216
case self: TypeRef => self.info.hkResult
220-
case self: RefinedType => NoType
221-
case self: AppliedType => NoType
217+
case self: AppliedType =>
218+
if (self.tycon.typeSymbol.isClass) NoType else self.superType.hkResult
222219
case self: HKTypeLambda => self.resultType
223-
case self: SingletonType => NoType
220+
case _: SingletonType | _: RefinedType | _: RecType => NoType
221+
case self: WildcardType => self.optBounds.hkResult
224222
case self: TypeVar =>
225223
// Using `origin` instead of `underlying`, as is done for typeParams,
226224
// avoids having to set ephemeral in some cases.
227225
self.origin.hkResult
228-
case self: WildcardType => self.optBounds.hkResult
229226
case self: TypeProxy => self.superType.hkResult
230227
case _ => NoType
231228
}

0 commit comments

Comments
 (0)