Skip to content

Commit 14a80fd

Browse files
SethTisuedwijnand
authored andcommitted
add a few comments
1 parent f6a7900 commit 14a80fd

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
@@ -946,6 +946,10 @@ trait Applications extends Compatibility {
946946
else expectedResultType match
947947
case SelectionProto(nme.asInstanceOf_, PolyProto(_, resTp), _, _) => resTp
948948
case _ => defn.ObjectType
949+
// synthesize a method type based on the types at the call site.
950+
// one can imagine the original signature-polymorphic method as
951+
// being infinitely overloaded, with each individual overload only
952+
// being brought into existence as needed
949953
val info = MethodType(proto.typedArgs().map(_.tpe.widen), resultType)
950954
val fun2 = fun1.withType(funRef.symbol.copy(info = info).termRef)
951955
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)