Skip to content

Fix generic signature for type params bounded by primitive #16442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 14, 2022

Conversation

dwijnand
Copy link
Member

Fixes #15385

@dwijnand dwijnand force-pushed the java-generic-bounds branch from 054dd3d to c7e88c2 Compare November 30, 2022 22:29
@dwijnand dwijnand marked this pull request as ready for review December 1, 2022 12:33
@dwijnand dwijnand requested a review from jan-pieter December 1, 2022 12:33
@dwijnand dwijnand requested review from nicolasstucki and removed request for jan-pieter December 1, 2022 12:34
Copy link
Contributor

@jan-pieter jan-pieter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import core.Types._
import core.classfile.ClassfileConstants
import SymUtils._
import TypeUtils._
import config.Printers.transforms
import reporting.trace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports w.r.t. debugging can be dropped

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to never have to import them, so this is 1 more file that won't have to happen...


class Foo:
def testNoParam[A <: Int]: A = 1.asInstanceOf[A]
def testSingleParam[A <: Int](a: A): A = 2.asInstanceOf[A] // <A:Ljava/lang/Object;>(I)I
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we drop the generic signature here entirely? In the end it's just int => int

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a matter of taste a this point. From Java, there's no more link between any passed type argument and the term argument, but maybe there is still a type argument you can provide - so that's why I kept it, as well as it being easier to implement it this way. Unless we have a real reason to drop it, I think this is good.

@dwijnand
Copy link
Member Author

@dwijnand Can we now drop the check at main/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala#L850-L854 as well?

I think I tried earlier and it failed (and I didn't look more into it at the time) but, good shout, because it looks like we can now.

This reverts commit 5cdb001.

Breaks in CI, here's a snippet:

    [info] Test dotty.tools.dotc.BootstrappedOnlyCompilationTests.posWithCompiler started
    -- Error: compiler/src/dotty/tools/dotc/transform/CapturedVars.scala:31:20 ---------------------------------------------
    31 |  private[this] var Captured: Store.Location[util.ReadOnlySet[Symbol]] = _
       |                    ^
       |compiler bug: created invalid generic signature for variable Captured in dotty.tools.dotc.transform.CapturedVars
       |signature: I
       |if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
       |
@dwijnand dwijnand force-pushed the java-generic-bounds branch from c4fe39d to be10979 Compare December 13, 2022 14:31
@dwijnand dwijnand assigned smarter and unassigned nicolasstucki Dec 13, 2022
@dwijnand dwijnand requested review from smarter and removed request for nicolasstucki and smarter December 13, 2022 23:45
@smarter smarter merged commit 2e409c6 into scala:main Dec 14, 2022
@dwijnand dwijnand deleted the java-generic-bounds branch December 14, 2022 17:46
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid generic signature for type params bounded by primitive
5 participants