diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-23 10:06:50 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-23 10:06:50 -0800 |
commit | 841389bc6f879031a8d36a5ffcca5e3c0e1fdcef (patch) | |
tree | 898ac7b039c94779f1e52a7d8d0ebaccf2537c01 /src/compiler | |
parent | a0b11b32aca74a4c3aee2e8c70356a29cd937727 (diff) | |
parent | 467872999e4940e06f2da811d1ae2d8278639126 (diff) | |
download | scala-841389bc6f879031a8d36a5ffcca5e3c0e1fdcef.tar.gz scala-841389bc6f879031a8d36a5ffcca5e3c0e1fdcef.tar.bz2 scala-841389bc6f879031a8d36a5ffcca5e3c0e1fdcef.zip |
Merge pull request #4139 from retronym/ticket/7965
SI-7965 Support calls to MethodHandle.{invoke,invokeExact}
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 6671183ff0..5719a9e358 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3281,6 +3281,22 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } handleOverloaded + case _ if isPolymorphicSignature(fun.symbol) => + // Mimic's Java's treatment of polymorphic signatures as described in + // https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.12.3 + // + // One can think of these methods as being infinitely overloaded. We create + // a ficticious new cloned method symbol for each call site that takes on a signature + // governed by a) the argument types and b) the expected type + val args1 = typedArgs(args, forArgMode(fun, mode)) + val pts = args1.map(_.tpe.deconst) + val clone = fun.symbol.cloneSymbol + val cloneParams = pts map (pt => clone.newValueParameter(currentUnit.freshTermName()).setInfo(pt)) + val resultType = if (isFullyDefined(pt)) pt else ObjectTpe + clone.modifyInfo(mt => copyMethodType(mt, cloneParams, resultType)) + val fun1 = fun.setSymbol(clone).setType(clone.info) + doTypedApply(tree, fun1, args1, mode, resultType).setType(resultType) + case mt @ MethodType(params, _) => val paramTypes = mt.paramTypes // repeat vararg as often as needed, remove by-name |