Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 07bcb6176ac7836e81ec7c849e1140126bb6b327 1 parent bebd62d
@xeno-by xeno-by authored
View
6 src/reflect/scala/reflect/internal/Symbols.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 }
View
2  test/files/run/t7045.check
@@ -0,0 +1,2 @@
+D with C
+D with C
View
12 test/files/run/t7045.scala
@@ -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

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.