Skip to content

Conversation

@som-snytt
Copy link
Contributor

typedIdent converts repeated params as required,
and typedSelect should do the same.

There is a more generic issue in scala/bug#6929

Fixes scala/bug#8923

@scala-jenkins scala-jenkins added this to the 2.12.5 milestone Oct 2, 2017
@som-snytt som-snytt closed this Oct 2, 2017
@som-snytt som-snytt reopened this Oct 2, 2017
@som-snytt
Copy link
Contributor Author

The first cut failed because accessors were star-typed, or star-crossed.

scala> class C(val xs: Int*) { def f = xs }
defined class C

scala> val c = new C(1,2,3)
c: C = C@7ddd84b5

scala> c.f //print
   $line4.$read.$iw.$iw.c.f // : Seq[Int]

scala> c.xs //print
   $line4.$read.$iw.$iw.c.xs // : Int*


I tested bootstrap build locally thanks to @lrytz instructions on another PR, maybe he can also say how far off base this tweak is. I didn't follow type completers in namers far enough to get a sense of it.

@som-snytt
Copy link
Contributor Author

som-snytt commented Oct 2, 2017

The tweak probably isn't tweaky enough, but one test failure is because it relies on previous star in function:

val testAllS: (Int, =>Int, Int*) => Int = testAll _
test("all s", 8, testAllS(1, 5, 78, 89))

It also re-broke varargs in ctors. I guess that relies on the accessors having star type.

@som-snytt som-snytt closed this Oct 2, 2017
@som-snytt som-snytt reopened this Oct 2, 2017
@retronym retronym self-requested a review January 12, 2018 05:32
@retronym retronym self-assigned this Jan 12, 2018
@retronym
Copy link
Member

retronym commented Jan 12, 2018

This area fills me with dread, but I've been here before so I'll assign myself to this ticket. Let's move the PR to 2.13.x though.

@SethTisue SethTisue added the WIP label Feb 22, 2018
@SethTisue SethTisue modified the milestones: 2.12.5, 2.13.0-M4, 2.13.0-RC1 Feb 22, 2018
@adriaanm adriaanm modified the milestones: 2.13.0-RC1, 2.13.0-M5 Jun 1, 2018
@som-snytt som-snytt removed the WIP label Jun 26, 2018
@som-snytt som-snytt closed this Jun 26, 2018
@som-snytt som-snytt reopened this Jun 26, 2018
@som-snytt som-snytt changed the base branch from 2.12.x to 2.13.x June 26, 2018 22:00
@som-snytt som-snytt changed the title No illegal stars in typed select No illegal stars in typed select [ci:last-only] Jun 28, 2018
@som-snytt som-snytt changed the title No illegal stars in typed select [ci:last-only] No illegal stars in typed select Jun 28, 2018
@SethTisue
Copy link
Member

ping @retronym

@lrytz
Copy link
Member

lrytz commented Aug 8, 2018

hmm i don't see it, which part of the diff fixes the bug?

@SethTisue SethTisue removed this from the 2.13.0-M5 milestone Aug 9, 2018
@SethTisue SethTisue added this to the 2.13.0-RC1 milestone Aug 9, 2018
@som-snytt
Copy link
Contributor Author

I see the fix allows star in the signature, but requires Seq in the application. Essentially, instead of disallowing it, the star becomes a kind of alternative syntax for Seq. The spec language would say that the star type means Seq everywhere except in a method application.

Probably that made more sense back in the days of -Yeta-expand-keeps-star. But since that is no longer an option (literally), it should be disallowed except for method parameters.

I kind of like the current fix, but it's rather eccentric.

`typedIdent` converts repeated params as required,
and `typedSelect` should do the same.

Also accessors, should be converted to Seq. The type
completer is set up in `Namers`.

Restore test for super param
In the old days, eta expansion would preserve
repeatedness of parameters. Instead, disallow
`T*` except for methods and constructors.

In function types, it should be expressed with
`Seq`, including for the expected type of an
eta expansion.
@som-snytt
Copy link
Contributor Author

som-snytt commented Aug 10, 2018

Added a commit that disallows T* in (T*) => U.

Maybe that should be deprecated until -Xsource:2.14?

The previous commit still does something, compare to last year:

$ skala
Welcome to Scala 2.13.0 (OpenJDK 64-Bit Server VM 1.8.0_181)

scala> class C(val xs: Int*) { def f = xs }
defined class C

scala> val c = new C(1,2,3)
c: C = C@7cea0110

scala> c.f //print
   c.f // : Seq[Int]

scala> c.xs //print
   c.xs // : Seq[Int]

The original report, that import X.f ; f(1,2,3) fails but X.f(1,2,3) succeeds, is fixed by stripping star in typedSelect. But with the parser change, the star type is not expressible, so you can't import something of star type. The print-tab in REPL might see it if I reverted that change; I haven't tried that yet.

It's probably the aliasing bit that retronym found dreadful. I don't see a new test, and I don't remember which tests fail without that change, which I'll have to puzzle over a minute.

You may have noticed 38 Down in the Friday NY Times crossword, "rotary phone", @retronym so-called. I wonder if "compiler engineer" could be considered a retronym. Then is retronym a compiler engineer or the other way around?

@SethTisue
Copy link
Member

closing for inactivity, can be revived & reopened whenever

@som-snytt
Copy link
Contributor Author

Since retronym is dreadfully hung up, I moved the other commits to separate PRs.

@SethTisue
Copy link
Member

new PR: #7399

@SethTisue SethTisue removed this from the 2.13.0-RC1 milestone Feb 22, 2019
@som-snytt som-snytt deleted the issue/8923 branch December 20, 2020 01:04
@som-snytt som-snytt changed the title No illegal stars in typed select [SUPERSEDED] No illegal stars in typed select Nov 9, 2024
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.

imported function forgets varargness

6 participants