Skip to content

Commit 2ad2ef9

Browse files
committed
SI-5990 u.build now correctly invokes missing symbol hooks
1 parent bc2e6fe commit 2ad2ef9

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

src/reflect/scala/reflect/internal/BuildUtils.scala

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ trait BuildUtils extends base.BuildUtils { self: SymbolTable =>
77

88
class BuildImpl extends BuildBase {
99

10-
def selectType(owner: Symbol, name: String): TypeSymbol = {
11-
val result = owner.info.decl(newTypeName(name))
12-
if (result ne NoSymbol) result.asTypeSymbol
13-
else MissingRequirementError.notFound("type %s in %s".format(name, owner.fullName))
14-
}
10+
def selectType(owner: Symbol, name: String): TypeSymbol =
11+
select(owner, newTypeName(name)).asTypeSymbol
1512

1613
def selectTerm(owner: Symbol, name: String): TermSymbol = {
17-
val sym = owner.info.decl(newTermName(name))
18-
val result =
19-
if (sym.isOverloaded) sym.suchThat(!_.isMethod)
20-
else sym
21-
if (result ne NoSymbol) result.asTermSymbol
22-
else MissingRequirementError.notFound("term %s in %s".format(name, owner.fullName))
14+
val result = select(owner, newTermName(name)).asTermSymbol
15+
if (result.isOverloaded) result.suchThat(!_.isMethod).asTermSymbol
16+
else result
17+
}
18+
19+
private def select(owner: Symbol, name: Name): Symbol = {
20+
val result = owner.info decl name
21+
if (result ne NoSymbol) result
22+
else
23+
mirrorThatLoaded(owner).tryMissingHooks(owner, name) orElse
24+
MissingRequirementError.notFound("%s %s in %s".format(if (name.isTermName) "term" else "type", name, owner.fullName))
2325
}
2426

2527
def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol = {

src/reflect/scala/reflect/internal/Mirrors.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ trait Mirrors extends api.Mirrors {
4141
if (result != NoSymbol) result
4242
else {
4343
if (settings.debug.value) { log(sym.info); log(sym.info.members) }//debug
44-
mirrorMissingHook(owner, name) orElse symbolTableMissingHook(owner, name) orElse {
44+
tryMissingHooks(owner, name) orElse {
4545
MissingRequirementError.notFound((if (path.isTermName) "object " else "class ")+path+" in "+thisMirror)
4646
}
4747
}
@@ -51,6 +51,8 @@ trait Mirrors extends api.Mirrors {
5151

5252
protected def symbolTableMissingHook(owner: Symbol, name: Name): Symbol = self.missingHook(owner, name)
5353

54+
private[reflect] def tryMissingHooks(owner: Symbol, name: Name): Symbol = mirrorMissingHook(owner, name) orElse symbolTableMissingHook(owner, name)
55+
5456
/** If you're looking for a class, pass a type name.
5557
* If a module, a term name.
5658
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Any
2+
AnyVal
3+
AnyRef
4+
Null
5+
Nothing
6+
List[Any]
7+
List[AnyVal]
8+
List[AnyRef]
9+
List[Null]
10+
List[Nothing]
11+
AnyRef{def foo(x: Int): Int}
12+
Int* => Unit
13+
=> Int => Unit
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import scala.reflect.runtime.universe._
2+
3+
object Test extends App {
4+
println(typeOf[Any])
5+
println(typeOf[AnyVal])
6+
println(typeOf[AnyRef])
7+
println(typeOf[Null])
8+
println(typeOf[Nothing])
9+
println(typeOf[List[Any]])
10+
println(typeOf[List[AnyVal]])
11+
println(typeOf[List[AnyRef]])
12+
println(typeOf[List[Null]])
13+
println(typeOf[List[Nothing]])
14+
println(typeOf[{def foo(x: Int): Int}])
15+
println(typeOf[(Int*) => Unit])
16+
println(typeOf[(=> Int) => Unit])
17+
}

0 commit comments

Comments
 (0)