diff options
author | Paul Phillips <paulp@improving.org> | 2012-07-21 07:11:30 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-07-21 10:52:31 -0700 |
commit | 9fecdfd8cb03816f7992c1577e296854c4dc878b (patch) | |
tree | d8ede036d0e353edc3159188e6cf8bcdfeaa7c7a /test/files/pos/t6117.scala | |
parent | 729aad67224e987849114770b63f81897845f15a (diff) | |
download | scala-9fecdfd8cb03816f7992c1577e296854c4dc878b.tar.gz scala-9fecdfd8cb03816f7992c1577e296854c4dc878b.tar.bz2 scala-9fecdfd8cb03816f7992c1577e296854c4dc878b.zip |
Fix SI-6117, regression involving import ambiguity.
Today I learned that
foo.member("bar") != foo.member("bar")
if bar is overloaded, because each lookup of an overloaded member
creates a new symbol (with equivalent OverloadedTypes.) How should symbols
be compared so these do not appear unequal? Is there a method which
unpacks the alternatives and compares them individually? It seems likely
there are additional bugs which arise from not covering this case.
Since this bug is in the context of importing, if the prefixes are
identical then I can compare the names instead of the symbols and this
issue goes away. But for the rest of the time during which one might
encounter overloaded symbols, that would be a very lossy operation,
since the overloaded symbol might be encoding any subset of the members
with that name.
There are lots of references to "OverloadedSymbol" in the comments of
various methods in Types, but no such class is visible in the history.
If we had such a thing, we could refine its equals method to recognize
equivalent overloads.
Review by @odersky.
Diffstat (limited to 'test/files/pos/t6117.scala')
-rw-r--r-- | test/files/pos/t6117.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/pos/t6117.scala b/test/files/pos/t6117.scala new file mode 100644 index 0000000000..6aca84f72c --- /dev/null +++ b/test/files/pos/t6117.scala @@ -0,0 +1,19 @@ +package test + +trait ImportMe { + def foo(i: Int) = 1 + def foo(s: String) = 2 +} + +class Test(val importMe: ImportMe) { + import importMe._ + import importMe._ + + // A.scala:12: error: reference to foo is ambiguous; + // it is imported twice in the same scope by + // import importMe._ + // and import importMe._ + // println(foo(1)) + // ^ + println(foo(1)) +} |