diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-03-10 09:11:50 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-03-10 10:10:42 +0100 |
commit | 33b499cd04342a49bd5c4f5bf0e2fab88b69069c (patch) | |
tree | a5aff002f2d3255322cf9dac6c63a826f984e285 | |
parent | 889020dfab9f99a3198528fedb699c061027acab (diff) | |
download | scala-33b499cd04342a49bd5c4f5bf0e2fab88b69069c.tar.gz scala-33b499cd04342a49bd5c4f5bf0e2fab88b69069c.tar.bz2 scala-33b499cd04342a49bd5c4f5bf0e2fab88b69069c.zip |
SI-7233 Account for aliased imports in eta expansion.
Buggy:
treeCopy.Select(sel, sel.qual, sel.name) setSymbol null
Select(sel, sel.qual, sel.name)
Okay:
treeCopy.Select(sel, sel.qual, sel.name)
Select(sel, sel.qual, sel.symbol.name) // but doesn't copyAttrs!
It is an easy mistake to make, I've found one more occurance:
def foo(a: Any) = { import a.{toString => toS}; toS }
error: uncaught exception during compilation: scala.reflect.internal.FatalError
scala.reflect.internal.FatalError: class Object does not have a member toS
at scala.reflect.internal.Definitions$DefinitionsClass.scala$reflect$internal$Definitions$DefinitionsClass$$fatalMissingSymbol(Definitions.scala:1028)
A followup commit will address that problem.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala | 1 | ||||
-rw-r--r-- | test/files/pos/t7233.scala | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index bbba7e0435..57b9dfe3e4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -101,6 +101,7 @@ trait EtaExpansion { self: Analyzer => case TypeApply(fn, args) => treeCopy.TypeApply(tree, liftoutPrefix(fn), args) setType null case Select(qual, name) => + val name = tree.symbol.name // account for renamed imports, SI-7233 treeCopy.Select(tree, liftout(qual, false), name) setSymbol NoSymbol setType null case Ident(name) => tree diff --git a/test/files/pos/t7233.scala b/test/files/pos/t7233.scala new file mode 100644 index 0000000000..ae15c08c35 --- /dev/null +++ b/test/files/pos/t7233.scala @@ -0,0 +1,14 @@ +object Foo { + def bar(i: Int) = i + + def ol(i: Int) = i + def ol(i: String) = i +} +object Test { + import Foo.{ bar => quux, toString => bar, ol => olRenamed} + + val f1 = quux _ + val f1Typed: (Int => Int) = f1 + + val f2: String => String = olRenamed _ +} |