diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-07-14 16:52:20 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-29 09:52:04 +0200 |
commit | df3689139c4d4bcd2933364d13b8195c3433eb43 (patch) | |
tree | 0e8a6cbf6a870869a4ffac6e1a90be2cbf9f1320 /test/scaladoc | |
parent | a3604707303e4b1f45b6afabccaf00510b281912 (diff) | |
download | scala-df3689139c4d4bcd2933364d13b8195c3433eb43.tar.gz scala-df3689139c4d4bcd2933364d13b8195c3433eb43.tar.bz2 scala-df3689139c4d4bcd2933364d13b8195c3433eb43.zip |
Fields phase expands lazy vals like modules
They remain ValDefs until then.
- remove lazy accessor logic
now that we have a single ValDef for lazy vals,
with the underlying machinery being hidden until the fields phase
leave a `@deprecated def lazyAccessor` for scala-refactoring
- don't skolemize in purely synthetic getters,
but *do* skolemize in lazy accessor during typers
Lazy accessors have arbitrary user code, so have to skolemize.
We exempt the purely synthetic accessors (`isSyntheticAccessor`)
for strict vals, and lazy accessors emitted by the fields phase
to avoid spurious type mismatches due to issues with existentials
(That bug is tracked as https://github.com/scala/scala-dev/issues/165)
When we're past typer, lazy accessors are synthetic,
but before they are user-defined to make this hack less hacky,
we could rework our flag usage to allow for
requiring both the ACCESSOR and the SYNTHETIC bits
to identify synthetic accessors and trigger the exemption.
see also https://github.com/scala/scala-dev/issues/165
ok 7 - pos/existentials-harmful.scala
ok 8 - pos/t2435.scala
ok 9 - pos/existentials.scala
previous attempt: skolemize type of val inside the private[this] val
because its type is only observed from inside the
accessor methods (inside the method scope its existentials are skolemized)
- bean accessors have regular method types, not nullary method types
- must re-infer type for param accessor
some weirdness with scoping of param accessor vals and defs?
- tailcalls detect lazy vals, which are defdefs after fields
- can inline constant lazy val from trait
- don't mix in fields etc for an overridden lazy val
- need try-lift in lazy vals: the assign is not seen in uncurry
because fields does the transform (see run/t2333.scala)
- ensure field members end up final in bytecode
- implicit class companion method: annot filter in completer
- update check: previous error message was tangled up with unrelated
field definitions (`var s` and `val s_scope`),
now it behaves consistently whether those are val/vars or defs
- analyzer plugin check update seems benign, but no way to know...
- error message gen: there is no underlying symbol for a deferred var
look for missing getter/setter instead
- avoid retypechecking valdefs while duplicating for specialize
see pos/spec-private
- Scaladoc uniformly looks to field/accessor symbol
- test updates to innerClassAttribute by Lukas
Diffstat (limited to 'test/scaladoc')
-rw-r--r-- | test/scaladoc/run/t7767.scala | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/test/scaladoc/run/t7767.scala b/test/scaladoc/run/t7767.scala index 6c9ceb511d..433fc5c0c4 100644 --- a/test/scaladoc/run/t7767.scala +++ b/test/scaladoc/run/t7767.scala @@ -4,15 +4,49 @@ import scala.tools.partest.ScaladocModelTest object Test extends ScaladocModelTest { override def code = """ - class Docable extends { /**Doc*/ val foo = 0 } with AnyRef - """ + class CEarly extends { /**CEarly_Doc_foo*/ val foo = 0 } with AnyRef + trait TEarly extends { /**TEarly_Doc_foo*/ val foo = 0 } with AnyRef + class C { + /**C_Doc_sigInferred*/ val sigInferred = 0 + /**C_Doc_const*/ final val const = 0 + /**C_Doc_varr*/ var varr: Any = null + /**C_Doc_abs*/ val abs: Int + /**C_Doc_absVar*/ var absVar: Any + /**C_Doc_lazyValInferred*/ lazy val lazyValInferred = 0 + /**C_Doc_lazyValConst*/ final lazy val lazyValConst = 0 + /**C_Doc_lazyValUnit*/ lazy val lazyValUnit: Unit = println() + /**C_Doc_lazyVal*/ lazy val lazyVal: Int = 0 + } + trait T { + /**T_Doc_sigInferred*/ val sigInferred = 0 + /**T_Doc_const*/ final val const = 0 + /**T_Doc_varr*/ var varr: Any = null + /**T_Doc_abs*/ val abs: Int + /**T_Doc_absVar*/ var absVar: Any + /**T_Doc_lazyValInferred*/ lazy val lazyValInferred = 0 + /**T_Doc_lazyValConst*/ final lazy val lazyValConst = 0 + /**T_Doc_lazyValUnit*/ lazy val lazyValUnit: Unit = println() + /**T_Doc_lazyVal*/ lazy val lazyVal: Int = 0 + }""" // no need for special settings def scaladocSettings = "" + def assertDoc(classEntity: DocTemplateEntity, valName: String) = { + import access._ + val comment = classEntity._value(valName).comment.map(_.body.toString.trim).getOrElse("") + val className = classEntity.name + val marker = s"${className}_Doc_${valName}" + assert(comment.contains(marker), s"Expected $marker in comment for $valName in $className, found: $comment.") + } + def testModel(rootPackage: Package) = { import access._ - val comment = rootPackage._class("Docable")._value("foo").comment.map(_.body.toString.trim).getOrElse("") - assert(comment.contains("Doc"), comment) + assertDoc(rootPackage._class("CEarly"), "foo") + assertDoc(rootPackage._trait("TEarly"), "foo") + + val valNames = List("sigInferred", "const", "varr", "abs", "absVar", "lazyValInferred", "lazyValConst", "lazyValUnit", "lazyVal") + val entities = List(rootPackage._class("C"), rootPackage._trait("T")) + for (e <- entities; vn <- valNames) assertDoc(e, vn) } } |