diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Fields.scala | 2 | ||||
-rw-r--r-- | test/files/pos/shapeless-regression.scala | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Fields.scala b/src/compiler/scala/tools/nsc/transform/Fields.scala index a383b65192..0c7bc742d9 100644 --- a/src/compiler/scala/tools/nsc/transform/Fields.scala +++ b/src/compiler/scala/tools/nsc/transform/Fields.scala @@ -694,7 +694,7 @@ abstract class Fields extends InfoTransform with ast.TreeDSL with TypingTransfor // drop the val for (a) constant (pure & not-stored) and (b) not-stored (but still effectful) fields case ValDef(mods, _, _, rhs) if (rhs ne EmptyTree) && !excludedAccessorOrFieldByFlags(statSym) - && fieldMemoizationIn(statSym, currOwner).constantTyped => + && currOwner.isClass && fieldMemoizationIn(statSym, currOwner).constantTyped => EmptyThicket case ModuleDef(_, _, impl) => diff --git a/test/files/pos/shapeless-regression.scala b/test/files/pos/shapeless-regression.scala new file mode 100644 index 0000000000..f3a1ed1ba0 --- /dev/null +++ b/test/files/pos/shapeless-regression.scala @@ -0,0 +1,16 @@ +class W[T <: AnyRef](val t: T) { + val v: T {} = t +} + +object W { + def apply[T <: AnyRef](t: T) = new W[t.type](t) +} + +object RightAssoc { + def ra_:[T](t: T): Unit = () +} + +object Boom { + W("fooo").v ra_: RightAssoc +} + |