Skip to content
This repository
Browse code

SI-7045 reflection now auto-initializes selfType

selfType joins the happy family of flags, annotations and privateWithin,
which automatically trigger initialization, when used within runtime
reflection.
  • Loading branch information...
commit 07bcb6176ac7836e81ec7c849e1140126bb6b327 1 parent bebd62d
Eugene Burmako xeno-by authored
6 src/reflect/scala/reflect/internal/Symbols.scala
@@ -91,10 +91,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
91 91 children
92 92 }
93 93
  94 + def selfType = {
  95 + if (!isCompilerUniverse && needsInitialize(isFlagRelated = false, mask = 0)) initialize
  96 + typeOfThis
  97 + }
  98 +
94 99 def baseClasses = info.baseClasses
95 100 def module = sourceModule
96 101 def thisPrefix: Type = thisType
97   - def selfType: Type = typeOfThis
98 102 def typeSignature: Type = { fullyInitializeSymbol(this); info }
99 103 def typeSignatureIn(site: Type): Type = { fullyInitializeSymbol(this); site memberInfo this }
100 104
2  test/files/run/t7045.check
... ... @@ -0,0 +1,2 @@
  1 +D with C
  2 +D with C
12 test/files/run/t7045.scala
... ... @@ -0,0 +1,12 @@
  1 +import scala.reflect.runtime.universe._
  2 +import scala.reflect.runtime.{currentMirror => cm}
  3 +
  4 +class C
  5 +class D { self: C => }
  6 +
  7 +object Test extends App {
  8 + val d = cm.staticClass("D")
  9 + println(d.selfType)
  10 + d.typeSignature
  11 + println(d.selfType)
  12 +}

1 comment on commit 07bcb61

scala-jenkins
Collaborator

Job pr-rangepos-per-commit failed for 07bcb61 (results):


Took 10 s.
sad kitty
to rebuild, comment "PLS REBUILD/pr-rangepos-per-commit@07bcb61"on PR #2083

Please sign in to comment.
Something went wrong with that request. Please try again.