Skip to content

Commit 042ed56

Browse files
committed
fix #14025: restrict curried HK types in mirrors
1 parent 0d5e2a3 commit 042ed56

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
278278

279279
/** do all parts match the class symbol? */
280280
def acceptable(tp: Type, cls: Symbol): Boolean = tp match
281+
case tp: HKTypeLambda if tp.resultType.isInstanceOf[HKTypeLambda] => false
281282
case tp: TypeProxy => acceptable(tp.underlying, cls)
282283
case OrType(tp1, tp2) => acceptable(tp1, cls) && acceptable(tp2, cls)
283284
case _ => tp.classSymbol eq cls
@@ -330,6 +331,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
330331

331332
def acceptable(tp: Type): Boolean = tp match
332333
case tp: TermRef => false
334+
case tp: HKTypeLambda if tp.resultType.isInstanceOf[HKTypeLambda] => false
333335
case tp: TypeProxy => acceptable(tp.underlying)
334336
case OrType(tp1, tp2) => acceptable(tp1) && acceptable(tp2)
335337
case _ => tp.classSymbol eq cls

tests/neg/i14025.check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Error: tests/neg/i14025.scala:1:88 ----------------------------------------------------------------------------------
2+
1 |val foo = summon[deriving.Mirror.Product { type MirroredType = [X] =>> [Y] =>> (X, Y) }] // error
3+
| ^
4+
|no given instance of type deriving.Mirror.Product{MirroredType[X] = [Y] =>> (X, Y)} was found for parameter x of method summon in object Predef
5+
-- Error: tests/neg/i14025.scala:2:90 ----------------------------------------------------------------------------------
6+
2 |val bar = summon[deriving.Mirror.Sum { type MirroredType = [X] =>> [Y] =>> List[(X, Y)] }] // error
7+
| ^
8+
|no given instance of type deriving.Mirror.Sum{MirroredType[X] = [Y] =>> List[(X, Y)]} was found for parameter x of method summon in object Predef

tests/neg/i14025.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
val foo = summon[deriving.Mirror.Product { type MirroredType = [X] =>> [Y] =>> (X, Y) }] // error
2+
val bar = summon[deriving.Mirror.Sum { type MirroredType = [X] =>> [Y] =>> List[(X, Y)] }] // error

0 commit comments

Comments
 (0)