You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Java 8, when an interface overrides a method from another interface and narrows the method's return type, additional bridge method with original return type is generated.
This bridge method doesn't seem to be properly filtered by Scala reflection API, e.g. Symbol's overrides method.
Example:
public interface DynamicGetter {
public Object get(String property);
}
public interface BaseextendsDynamicGetter {
@Override
public Base get(String property);
}
public classKlass implements Base {
@Override
public Klass get(String property) {
returnthis;
}
}
Manifestation:
$ scala
Welcome to Scala version 2.11.5 (JavaHotSpot(TM) 64-BitServerVM, Java1.8.0_25).
Type in expressions to have them evaluated.
Type:help for more information.
scala>:power
**PowerUser mode enabled -BEEPWHIRGYVE****:phase has been set to 'typer'. **** scala.tools.nsc._ has been imported **** global._, definitions._ also imported ****Try:help, :vals, power.<tab> **
scala>valg= typeOf[Klass].member(TermName("get"))
g: $r.intp.global.Symbol= method get
scala> g.overrides
res0:List[$r.intp.global.Symbol] =List(value get, method get)
scala> g.overrides.head.alternatives.map(_.typeSignature)
res2:List[$r.intp.global.Type] =List((x$1: String)Base, (x$1: String)Object)
scala> typeOf[Base].member(TermName("get"))
res3: $r.intp.global.Symbol= method get
In Java 8, when an interface overrides a method from another interface and narrows the method's return type, additional bridge method with original return type is generated.
This bridge method doesn't seem to be properly filtered by Scala reflection API, e.g.
Symbol
'soverrides
method.Example:
Manifestation:
Original discussion: https://groups.google.com/forum/?fromgroups=#!topic/scala-user/IeD2siVXyss
The text was updated successfully, but these errors were encountered: