From 69feaa89167ebeb708535dd4abf3a79a410130f0 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 7 Jan 2017 14:47:18 +0700 Subject: Change scheme to use Selectable Use base types instead of implicits. This is more robust in the presence of type abstraction. --- tests/run/structural.scala | 16 ++++------------ tests/run/structuralNoSuchMethod.scala | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'tests/run') diff --git a/tests/run/structural.scala b/tests/run/structural.scala index 43f008b5f..0f18f4579 100644 --- a/tests/run/structural.scala +++ b/tests/run/structural.scala @@ -1,22 +1,14 @@ -case class Record(elems: (String, Any)*) - -object Record { - - implicit def projector: Projector[Record] = new Projector[Record] { - def get(receiver: Record, name: String): Any = - receiver.elems.find(_._1 == name).get._2 - } - +case class Record(elems: (String, Any)*) extends Selectable { + def selectDynamic(name: String): Any = elems.find(_._1 == name).get._2 } object Test { - import scala.reflect.Projector.reflectiveProjector - import Record.projector + import scala.reflect.Selectable.reflectiveSelectable def f(closeable: { def close(): Unit }) = closeable.close() - type RN = Record { val name: String } + type RN = Record { val name: String; val age: Int } def g(r: RN) = r.name diff --git a/tests/run/structuralNoSuchMethod.scala b/tests/run/structuralNoSuchMethod.scala index 3d33c9d8b..476d7ed82 100644 --- a/tests/run/structuralNoSuchMethod.scala +++ b/tests/run/structuralNoSuchMethod.scala @@ -1,4 +1,4 @@ -import scala.reflect.Projector.reflectiveProjector +import scala.reflect.Selectable.reflectiveSelectable /** Demonstrates limitation of structural method dispatch (in Scala 2.x and dotty). * The method must be defined at exactly the argument types given in the structural type; -- cgit v1.2.3