Skip to content

Commit bf5f629

Browse files
committed
Fix #7811: Harden mapArgs in TypeMap
1 parent 9d759df commit bf5f629

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4599,7 +4599,7 @@ object Types {
45994599

46004600
case tp: AppliedType =>
46014601
def mapArgs(args: List[Type], tparams: List[ParamInfo]): List[Type] = args match {
4602-
case arg :: otherArgs =>
4602+
case arg :: otherArgs if tparams.nonEmpty =>
46034603
val arg1 = arg match {
46044604
case arg: TypeBounds => this(arg)
46054605
case arg => atVariance(variance * tparams.head.paramVariance)(this(arg))

tests/neg/i7811.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
trait A {
2+
type Type[X,] // error
3+
def a[X]: Type[X,] // error
4+
}
5+
class B extends A {
6+
type Type[X]
7+
var a = 1
8+
}

0 commit comments

Comments
 (0)