8000 [backport] SI-10071 SI-8786 varargs methods by adriaanm · Pull Request #5630 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

[backport] SI-10071 SI-8786 varargs methods #5630

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 6 commits into from
Jan 11, 2017

Conversation

adriaanm
Copy link
Contributor
@adriaanm adriaanm commented Jan 9, 2017

Backport of the fix in #5556 as well as relevant earlier work in #5262 (which refactors the relevant code parts in UnCurry, backported as de361df).

This PR rebases and slightly reworks @dragos's original backport in #5557 (to make testing work on java 6 and up).

adriaanm and others added 5 commits January 9, 2017 15:30
When generating a varargs forwarder for

    def foo[T](a: T*)

the parameter type of the forwarder needs to be Array[Object]. If we
generate Array[T] in UnCurry, that would be erased to plain Object, and
the method would not be a valid varargs.

Unfortunately, setting the parameter type to Array[Object] lead to
an invalid generic signature - the generic signature should reflect the
real signature.

This change adds an attachment to the parameter symbol in the varargs
forwarder method and special-cases signature generation.

Also cleans up the code to produce the varargs forwarder. For example,
type parameter and parameter symbols in the forwarder's method type were
not clones, but the same symbols from the original method were re-used.

Backported from 0d2760d,
with a small tweak (checkVarargs) to make the test work on Java 6,
as well as later versions.
Make sure that methods annotated with varargs are properly mixed-in. This commit
splits the transformation into an info transformer (that works on all symbols, whether
they come from source or binary) and a tree transformer.

The gist of this is that the symbol-creation part of the code was moved to the UnCurry
info transformer, while tree operations remained in the tree transformer. The newly
created symbol is attached to the original method so that the tree transformer can still
retrieve the symbol.

A few fall outs:

- I removed a local map that was identical to TypeParamsVarargsAttachment
- moved the said attachment to StdAttachments so it’s visible between reflect.internal
  and nsc.transform
- a couple more comments in UnCurry to honour the boy-scout rule
Cloning the original symbol in its entirety, rather than cloning
its type/value parameters individually. `cloneSymbol` takes care of
all the tricky substitutions for us!
@scala-jenkins scala-jenkins added this to the 2.11.9 milestone Jan 9, 2017
@adriaanm adriaanm changed the title [backport] (Rebase of #5557) [backport] SI-10071 SI-8786 varargs methods Jan 9, 2017
@adriaanm
Copy link
Contributor Author

Hrm, spurious failure we've been seeing more recently: !! 496 - run/reflection-mem-typecheck.scala [output differs]

@SethTisue
Copy link
Member

Hrm, spurious failure we've been seeing more recently: !! 496 - run/reflection-mem-typecheck.scala [output differs]

note that on the 2.12.x branch we already nixed that test (in #5480)

(cherry-picking commit a03e7a0)

I have repeatedly seen this fail CI runs, including recently

as the comment in the test itself says: "I'm not sure this is a great
way to test for memory leaks, since we're also testing how good
the JVM's GC is, and this is not easily reproduced between
machines/over time"
@adriaanm
Copy link
Contributor Author

Ah yes, thanks for the reminder!

@adriaanm
Copy link
Contributor Author

/nothingtoseehere -- the earlier failure was in a flaky test that is no longer

@adriaanm
Copy link
Contributor Author

weird, a timeout in scaladoc

@adriaanm
Copy link
Contributor Author

/rebuild

@adriaanm
Copy link
Contributor Author

Weird. Scaladoc hung until the job was aborted again. Could it be because of the info transform changes of 5b972dc?

@adriaanm adriaanm changed the title [backport] SI-10071 SI-8786 varargs methods SI-10071 SI-8786 varargs methods Jan 10, 2017
@adriaanm
Copy link
Contributor Author

/rebuild

@adriaanm adriaanm changed the title SI-10071 SI-8786 varargs methods [backport] SI-10071 SI-8786 varargs methods Jan 10, 2017
@adriaanm
Copy link
Contributor Author

Ok, all seems well.

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.

6 participants
0