Skip to content

Commit

Permalink
Merge pull request scala#4519 from dotty-staging/fix-4496-part1
Browse files Browse the repository at this point in the history
Selectable: catch correct exception when the field isn't found
  • Loading branch information
nicolasstucki authored May 12, 2018
2 parents 2136fc1 + b077695 commit 83735d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/src/scala/reflect/Selectable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Selectable(val receiver: Any) extends AnyVal with scala.Selectable {
fld.get(receiver)
}
catch {
case ex: NoSuchFieldError =>
case ex: NoSuchFieldException =>
selectDynamicMethod(name).asInstanceOf[() => Any]()
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/run/i4496a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import scala.reflect.Selectable.reflectiveSelectable
class Foo1 { val a: Int = 10 }
class Foo2 { def a: Int = 10 }
class Foo3 { var a: Int = 10 }
object Test {
def main(args: Array[String]): Unit = {
assert((new Foo1 : {val a: Int}).a == 10)
assert((new Foo2 : {val a: Int}).a == 10)
assert((new Foo3 : {val a: Int}).a == 10)
}
}

0 comments on commit 83735d2

Please sign in to comment.