Skip to content

Commit 8cdf496

Browse files
committed
add a few comments
1 parent 7f9a0a7 commit 8cdf496

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,8 @@ class Definitions {
740740
@tu lazy val MethodHandlesLookupClass: ClassSymbol = requiredClass("java.lang.invoke.MethodHandles.Lookup")
741741
@tu lazy val VarHandleClass: ClassSymbol = requiredClass("java.lang.invoke.VarHandle")
742742

743-
// from the Java language spec: https://docs.oracle.com/javase/specs/jls/se11/html/jls-15.html#jls-15.12.3
743+
// Java language spec: https://docs.oracle.com/javase/specs/jls/se11/html/jls-15.html#jls-15.12.3
744+
// Scala 2 spec: https://scala-lang.org/files/archive/spec/2.13/06-expressions.html#signature-polymorphic-methods
744745
def isPolymorphicSignature(sym: Symbol) = sym.is(JavaDefined) && {
745746
val owner = sym.maybeOwner
746747
(owner == MethodHandleClass || owner == VarHandleClass)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,10 @@ trait Applications extends Compatibility {
947947
else expectedResultType match
948948
case SelectionProto(nme.asInstanceOf_, PolyProto(_, resTp), _, _) => resTp
949949
case _ => defn.ObjectType
950+
// synthesize a method type based on the types at the call site.
951+
// one can imagine the original signature-polymorphic method as
952+
// being infinitely overloaded, with each individual overload only
953+
// being brought into existence as needed
950954
val info = MethodType(proto.typedArgs().map(_.tpe.widen), resultType)
951955
val fun2 = fun1.withType(funRef.symbol.copy(info = info).termRef)
952956
simpleApply(fun2, proto)

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Standard-Section: "ASTs" TopLevelStat*
8686
IDENT NameRef Type -- Used when term ident’s type is not a TermRef
8787
SELECT possiblySigned_NameRef qual_Term -- qual.name
8888
SELECTin Length possiblySigned_NameRef qual_Term owner_Type -- qual.name, referring to a symbol declared in owner that has the given signature (see note below)
89-
SELECTinPoly Length possiblySigned_NameRef qual_Term owner_Type method_Type -- like SELECTin, but with the method_Type too
89+
SELECTinPoly Length possiblySigned_NameRef qual_Term owner_Type method_Type -- like SELECTin, but with the method_Type too (because signature polymorphic)
9090
QUALTHIS typeIdent_Tree -- id.this, different from THIS in that it contains a qualifier ident with position.
9191
NEW clsType_Term -- new cls
9292
THROW throwableExpr_Term -- throw throwableExpr

0 commit comments

Comments
 (0)