Skip to content

Commit ab68632

Browse files
committed
Use member lookup for Names
1 parent 87463bd commit ab68632

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ object StdNames {
839839

840840
final val Uninstantiated: TypeName = "?$"
841841

842+
val Names: TypeName = "Names"
843+
842844
val JFunctionPrefix: Seq[TypeName] = (0 to 2).map(i => s"scala.runtime.java8.JFunction${i}")
843845
val JProcedure: Seq[TypeName] = (0 to 22).map(i => s"scala.runtime.function.JProcedure${i}")
844846
}

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,19 +1389,18 @@ trait Applications extends Compatibility {
13891389

13901390
val resTypeOfUnapplyFn = unapplyFn.tpe.widen.asInstanceOf[MethodType].resType
13911391

1392-
val typeInfoOfGetMethod: Type =
1392+
val names: SingleDenotation =
13931393
resTypeOfUnapplyFn.member(nme.get).info
13941394
.orElse(resTypeOfUnapplyFn)
1395-
1396-
val names = typeInfoOfGetMethod
1397-
.memberDenots(typeNameFilter, (name, buf) => if (name.toString == "Names") buf += typeInfoOfGetMethod.member(name).asSingleDenotation)
1398-
.headOption
1395+
.member(tpnme.Names)
1396+
// TODO: Is it possible to get something else than a SingleDenotation?
1397+
.asSingleDenotation
13991398

14001399
val positionOfStringNames: Map[String, Int] =
1401-
if names.isDefined then
1400+
if names.exists then
14021401
// TODO: Don't use regular expression to deconstruct tuples
14031402
val reg = "\"([^\"]+)\"".r
1404-
reg.findAllMatchIn(names.get.showDcl)
1403+
reg.findAllMatchIn(names.showDcl)
14051404
.map(_.group(1))
14061405
.zipWithIndex
14071406
.toMap

0 commit comments

Comments
 (0)