Skip to content

Commit 03fdd37

Browse files
oderskytgodzik
authored andcommitted
Guard against invalid prefixes in argForParam
Fixes scala#23504
1 parent 599a015 commit 03fdd37

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,8 +2682,11 @@ object Types extends TypeUtils {
26822682
while (tparams.nonEmpty && args.nonEmpty) {
26832683
if (tparams.head.eq(tparam))
26842684
return args.head match {
2685-
case _: TypeBounds if !widenAbstract => TypeRef(pre, tparam)
2686-
case arg => arg.boxedUnlessFun(tycon)
2685+
case _: TypeBounds if !widenAbstract =>
2686+
if !NamedType.validPrefix(pre) then
2687+
throw TypeError(em"invalid prefix $pre cannot replace parameter $tparam in result of selection")
2688+
TypeRef(pre, tparam)
2689+
case arg => arg
26872690
}
26882691
tparams = tparams.tail
26892692
args = args.tail

tests/neg/i23504.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test =
2+
Seq.empty[[T] =>> () => ?].head() // error

0 commit comments

Comments
 (0)