diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-12 19:14:46 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-12 19:14:46 -0700 |
commit | 7d0cb1f0e2c254ccc071fcd8a057c67065682a0f (patch) | |
tree | acfeaab79bbcdd3119f7ec7ea5bc55a88505cefd | |
parent | 5f4039f83ea27ed1da88146dc2ffab3d8dd11b29 (diff) | |
parent | 41e3b89c6d636164f48a2c2d8e8867201075cdae (diff) | |
download | scala-7d0cb1f0e2c254ccc071fcd8a057c67065682a0f.tar.gz scala-7d0cb1f0e2c254ccc071fcd8a057c67065682a0f.tar.bz2 scala-7d0cb1f0e2c254ccc071fcd8a057c67065682a0f.zip |
Merge pull request #2230 from retronym/ticket/7233
SI-7233 Account for aliased imports in EtaExpansion / Erasure
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala | 1 | ||||
-rw-r--r-- | test/files/pos/t7233.scala | 14 | ||||
-rw-r--r-- | test/files/pos/t7233b.scala | 8 |
4 files changed, 24 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index cb5268c422..ead6ef288c 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -781,7 +781,7 @@ abstract class Erasure extends AddInterfaces else if (tree.symbol == Any_isInstanceOf) adaptMember(atPos(tree.pos)(Select(qual, Object_isInstanceOf))) else if (tree.symbol.owner == AnyClass) - adaptMember(atPos(tree.pos)(Select(qual, getMember(ObjectClass, name)))) + adaptMember(atPos(tree.pos)(Select(qual, getMember(ObjectClass, tree.symbol.name)))) else { var qual1 = typedQualifier(qual) if ((isPrimitiveValueType(qual1.tpe) && !isPrimitiveValueMember(tree.symbol)) || 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 _ +} diff --git a/test/files/pos/t7233b.scala b/test/files/pos/t7233b.scala new file mode 100644 index 0000000000..927c7fcfd1 --- /dev/null +++ b/test/files/pos/t7233b.scala @@ -0,0 +1,8 @@ +object Test { + // crash + def foo(a: Any) = { import a.{toString => toS}; toS } + + // okay + def ok1(a: String) = { import a.{isInstanceOf => iio}; iio[String] } + def ok2(a: Int) = { import a.{toInt => ti}; ti } +} |