Skip to content

Commit 52574f2

Browse files
committed
Harden type assignment of lambda trees
Fixes #12456
1 parent 8d3083b commit 52574f2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,12 @@ trait TypeAssigner {
480480
}
481481

482482
def assignType(tree: untpd.LambdaTypeTree, tparamDefs: List[TypeDef], body: Tree)(using Context): LambdaTypeTree =
483-
tree.withType(HKTypeLambda.fromParams(tparamDefs.map(_.symbol.asType), body.tpe))
483+
val validParams = tparamDefs.filterConserve { tdef =>
484+
val ok = tdef.symbol.isType
485+
if !ok then assert(ctx.reporter.errorsReported)
486+
ok
487+
}
488+
tree.withType(HKTypeLambda.fromParams(validParams.map(_.symbol.asType), body.tpe))
484489

485490
def assignType(tree: untpd.MatchTypeTree, bound: Tree, scrutinee: Tree, cases: List[CaseDef])(using Context): MatchTypeTree = {
486491
val boundType = if (bound.isEmpty) defn.AnyType else bound.tpe

tests/neg/i12456.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
object F { type T[G[X] <: X, F <: G[F]] } // error // error

0 commit comments

Comments
 (0)