Permalink
Browse files

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...
1 parent bebd62d commit 07bcb6176ac7836e81ec7c849e1140126bb6b327 @xeno-by xeno-by committed Feb 7, 2013
Showing with 19 additions and 1 deletion.
  1. +5 −1 src/reflect/scala/reflect/internal/Symbols.scala
  2. +2 −0 test/files/run/t7045.check
  3. +12 −0 test/files/run/t7045.scala
@@ -91,10 +91,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
children
}
+ def selfType = {
+ if (!isCompilerUniverse && needsInitialize(isFlagRelated = false, mask = 0)) initialize
+ typeOfThis
+ }
+
def baseClasses = info.baseClasses
def module = sourceModule
def thisPrefix: Type = thisType
- def selfType: Type = typeOfThis
def typeSignature: Type = { fullyInitializeSymbol(this); info }
def typeSignatureIn(site: Type): Type = { fullyInitializeSymbol(this); site memberInfo this }
@@ -0,0 +1,2 @@
+D with C
+D with C
@@ -0,0 +1,12 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+class C
+class D { self: C => }
+
+object Test extends App {
+ val d = cm.staticClass("D")
+ println(d.selfType)
+ d.typeSignature
+ println(d.selfType)
+}

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.