forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#10940 from lrytz/subst-sym-refinement-owner
`substSym` replaces owners of `RefinementClassSymbol`s
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
scala> :power | ||
Power mode enabled. :phase is at typer. | ||
import scala.tools.nsc._, intp.global._, definitions._ | ||
Try :help or completions for vals._ and power._ | ||
|
||
scala> class C { | ||
def f = new { | ||
def g = new { | ||
def h = 1 | ||
} | ||
} | ||
} | ||
class C | ||
|
||
scala> val f = typeOf[C].decl(TermName("f")) | ||
val f: $r.intp.global.Symbol = method f | ||
|
||
scala> val g = f.tpe.resultType.decls.head | ||
val g: $r.intp.global.Symbol = method g | ||
|
||
scala> g.ownerChain.take(4) | ||
val res0: List[$r.intp.global.Symbol] = List(method g, <refinement of AnyRef>, method f, class C) | ||
|
||
scala> g.tpe.resultType.typeSymbol | ||
val res1: $r.intp.global.Symbol = <refinement of AnyRef> | ||
|
||
scala> g.tpe.resultType.typeSymbol.ownerChain.take(4) | ||
val res2: List[$r.intp.global.Symbol] = List(<refinement of AnyRef>, method g, <refinement of AnyRef>, method f) | ||
|
||
scala> :quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import scala.tools.partest.ReplTest | ||
|
||
object Test extends ReplTest { | ||
def code = | ||
""":power | ||
|class C { | ||
| def f = new { | ||
| def g = new { | ||
| def h = 1 | ||
| } | ||
| } | ||
|} | ||
|val f = typeOf[C].decl(TermName("f")) | ||
|val g = f.tpe.resultType.decls.head | ||
|g.ownerChain.take(4) | ||
|g.tpe.resultType.typeSymbol | ||
|g.tpe.resultType.typeSymbol.ownerChain.take(4) | ||
|""".stripMargin | ||
} |