diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-10-28 10:27:13 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-10-31 22:30:16 -0700 |
commit | 4959e9f11c459e1c1eaa6cc168a4b9f2e784ffdf (patch) | |
tree | e070f4a89d557551f73da5c362a689df3e4c87ee | |
parent | 9e1de6ee81e9eaf9d8ac59446bc97c79b5ff0cb6 (diff) | |
download | scala-4959e9f11c459e1c1eaa6cc168a4b9f2e784ffdf.tar.gz scala-4959e9f11c459e1c1eaa6cc168a4b9f2e784ffdf.tar.bz2 scala-4959e9f11c459e1c1eaa6cc168a4b9f2e784ffdf.zip |
SI-6734 Comment
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 3 | ||||
-rw-r--r-- | test/files/pos/t6734.scala | 24 |
2 files changed, 11 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a92c190805..cca6f280e3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3140,13 +3140,14 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper // SI-5877 The decls of a package include decls of the package object. But we don't want to add // the corresponding synthetics to the package class, only to the package object class. // SI-6734 Locality test below is meaningless if we're not even in the correct tree. + // For modules that are synthetic case companions, check that case class is defined here. def shouldAdd(sym: Symbol): Boolean = { def shouldAddAsModule: Boolean = sym.moduleClass.attachments.get[ClassForCaseCompanionAttachment] match { case Some(att) => val cdef = att.caseClass stats.exists { - case t @ ClassDef(_, _, _, _) => t.symbol == cdef.symbol + case t @ ClassDef(_, _, _, _) => t.symbol == cdef.symbol // cdef ne t case _ => false } case _ => true diff --git a/test/files/pos/t6734.scala b/test/files/pos/t6734.scala index f8fed0a27a..88932cd2cc 100644 --- a/test/files/pos/t6734.scala +++ b/test/files/pos/t6734.scala @@ -1,23 +1,17 @@ -//single file badimp.scala -// adding package object gives not found: type SortedMap -package object badimp +// desugars to package p { object `package` } +// previously, synthetic p.C was incorrectly added to this tree +// This only matters because synthetics are not hygienic +package object p -package badimp { - - // move before package object works - import scala.collection.immutable.SortedMap - - case class Nodal private[badimp] (value: String, children: SortedMap[String, Int]) - - // adding target object restores sanity - // but adding it before the import does not - //object Nodal +package p { + import scala.concurrent.Future + case class C private[p] (value: Future[Int]) // private to avoid rewriting C.apply to new C } package client { trait X { - import scala.collection.immutable.SortedMap - def f = badimp.Nodal("test", SortedMap[String, Int]()) // ensure Nodal.apply was created + import scala.concurrent.Future + def f = p.C(Future(42)(null)) // ensure synthetics were generated, i.e., p.C.apply } } |