Skip to content

Commit 1fc9b1b

Browse files
committed
Fix #5720: don't output X <: Long in Java generic signatures
In generic signature generator `jsig`, flag `primitiveOK` remembers if `jsig` is allowed to output primitive types or not; for instance, upper bounds can't contain primitive types. When transforming higher-kinded upper bounds `[X] => T`, `jsig` correctly recurs on `T`, but must remember flag `primitiveOK`. The status of `toplevel` should not change either (since it tracks if are still at the toplevel of the output signature, or instead we have started producing output), so passing it seems safest. Ideally we should test it at least on higher types whose body is a suitable `ClassInfo`; with polymorphic function types, we should also test `PolyType` bodies.
1 parent 82be5ee commit 1fc9b1b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ object GenericSignatures {
283283
jsig(atp, toplevel, primitiveOK)
284284

285285
case hktl: HKTypeLambda =>
286-
jsig(hktl.finalResultType)
286+
jsig(hktl.finalResultType, toplevel, primitiveOK)
287287

288288
case _ =>
289289
val etp = erasure(tp)

tests/pos/i5720.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class A[B[_] <: Long]
2+
object Main {
3+
type C = A[[x] => Long]
4+
type D = A[[x] => Nothing]
5+
}

0 commit comments

Comments
 (0)