-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
NoSuchMethodError when pattern matching on inner class (no outer accessor) #13096
Comments
This was referenced Jul 17, 2021
Make it work, IMO. Looks like it's in one of posttyper's phases (oh, probably |
compilation of the test code fails under
|
SethTisue
added a commit
to SethTisue/dotty
that referenced
this issue
Jul 21, 2021
fixes scala#13096 Co-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
PR: #13124 |
dwijnand
added a commit
to SethTisue/dotty
that referenced
this issue
Jul 27, 2021
TryCatchPatterns is similar in spirit, so keep it with its buddy. Fixes scala#13096 Co-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
tanishiking
pushed a commit
to tanishiking/scala3
that referenced
this issue
Aug 10, 2021
TryCatchPatterns is similar in spirit, so keep it with its buddy. Fixes scala#13096 Co-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tested on both 3.0.0 and 3.0.1-RC2
originally reported by Scala book author @cayhorstmann at scala/scala-xml#541
Minimized code
Output
which occurs because
C2
simply doesn't have an outer accessor method.C2
s constructor accepts an outer reference, but doesn't do anything with it:Expectation
The runtime error occurs regardless of whether
C2
is declaredprivate[this]
or merelyprivate
. It stops occurring if you declareC2
to beprivate[C1]
. (Perhaps theprivate
version fails because of the Scala 3 behavior where plainprivate
sometimes meansprivate[this]
and sometimes meansprivate[C1]
?)Ironically, Scala 2 does the reverse: for
private[this]
it givesC2
an outer accessor, but then the pattern match inC1
's constructor does not call it...!So, what would the correct behavior — keep the check and make it work, or omit it? I don't know offhand, especially once you start considering the nuances of the different access levels the inner class might have. But I see there is a lot of previous lore in this area: #2156, scala/bug#4440, scala/bug#1419, maybe others...?
The text was updated successfully, but these errors were encountered: