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
Broken signature for inner case object surrounded by a parametrized class #4820
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4820?orig=1 |
@gkossakowski said: package test
abstract class Test[A] {
object Y
} You'll get following errors: mac-grek:badsigs grek$ rm -rf classes/* && scalac -d classes/ Test.scala && ~/scala/badsigs/badsigs.sh `pwd`/classes
Cleaning up /Users/grek/scala/badsigs/badsigs_working_dir
Checking /Users/grek/tmp/badsigs/classes:
Running Main app (will generate Java files and run ecj)
----------
1. ERROR in /Users/grek/scala/badsigs/badsigs_working_dir/src/C0.java (at line 0)
import test.Test$Y$;
^
Inconsistent classfile encountered: The undefined type parameter A is referenced from within Test$Y$
----------
1 problem (1 error)
----------
1. ERROR in /Users/grek/scala/badsigs/badsigs_working_dir/src/C1.java (at line 0)
import test.Test;
^
The class file Test<A> contains a signature '()Ltest/Test<TA;>.Y;' ill-formed at position 18
----------
1 problem (1 error)
Found 2 errors However, if I use lazy val and inner class: package test
abstract class Test[A] {
class Y
lazy val Y = new Y
} badsigs.sh doesn't report any problems. It turns out that signatures of accessor method Y are in both cases the same (and correct). It's InnerClasses attribute that's broken in first case (object Y is not reported as an inner class). Diff of javap for both cases proves the point: mac-grek:badsigs grek$ diff object_sig lazyval_sig
[...]
> InnerClass:
> public #3= #17 of #13; //Y=class test/Test$Y of class test/Test
[...] |
@paulp said: http://library.epfl.ch/en/theses/?nr=4820 It's a sign from the heavens! |
@gkossakowski said: Do we have any progress on it? |
@paulp said: |
@soc said:
This sounds pretty much like the problem previously uncovered with java reflection and objects. |
Commit Message Bot (anonymous) said: This commit fixes two major problems:
For details it's the best to check #4819, #4820 and First problem mentioned above was straightforward to The second one deserves more attention. From now, classes There's one caveat though: top level objects get two object A { class B } will be compiled into following classes: A, A$, A$B. Since non-top-level objects don't have a mirror class object A { object B { class C } } it's impossible to import C from Java. That's the tradeoff As a nice consequence of this change, we get better way to Fixes #4789 #4819 #4820 #4983 and possibly some Review by extempore, dragos. |
@soc said: I ran the badsigs tool and it doesn't report any errors: Root is /home/soc/Entwicklung/badsigs
Working dir is /tmp/badsigs.VG0Ed
Checking /home/soc/Entwicklung/badsigs/./classes/:
Running Main app (will generate Java files and run ecj) I guess this can be closed? |
@heathermiller said: Heathers-iMac:scala-heather hmiller$ ../badsigs/badsigs.sh ../scala-heather/classes
Root is /Users/hmiller/Dropbox/git-shared/badsigs
Working dir is /tmp/badsigs.vsQMC
Badsigs JAR is /Users/hmiller/Dropbox/git-shared/badsigs/target/badsigs-assembly-0.1-SNAPSHOT.jar
Checking /Users/hmiller/Dropbox/git-shared/badsigs/../scala-heather/classes:
Running Main app (will generate Java files and run ecj)
Heathers-iMac:scala-heather hmiller$ All seems resolved, so I'll be closing this. |
@gkossakowski said: |
Consider following code:
Before r25326, badsigs.sh would report following errors:
By updating compiler to r25326, we get a bit different signatures but still broken:
The text was updated successfully, but these errors were encountered: