Skip to content

Commit 2ad6844

Browse files
committed
Port fix for SI-9387
Ideologically the very same issue, but we have a bit different structure of code and data, so I fixed it a bit differently.
1 parent c4979db commit 2ad6844

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
332332
}
333333

334334
genLoadArguments(env, fun.symbol.info.paramTypes map toTypeKind)
335-
genInvokeDynamicLambda(NoSymbol, fun.symbol, env.size, functionalInterface)
335+
generatedType = genInvokeDynamicLambda(NoSymbol, fun.symbol, env.size, functionalInterface)
336336

337337
case app @ Apply(_, _) =>
338338
generatedType = genApply(app, expectedType)
@@ -1379,8 +1379,9 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
13791379
def genSynchronized(tree: Apply, expectedType: BType): BType
13801380
def genLoadTry(tree: Try): BType
13811381

1382-
def genInvokeDynamicLambda(ctor: Symbol, lambdaTarget: Symbol, environmentSize: Int, functionalInterface: Symbol) {
1382+
def genInvokeDynamicLambda(ctor: Symbol, lambdaTarget: Symbol, environmentSize: Int, functionalInterface: Symbol): BType = {
13831383
debuglog(s"Using invokedynamic rather than `new ${ctor.owner}`")
1384+
val generatedType = classBTypeFromSymbol(functionalInterface)
13841385
val invokeStyle =
13851386
if (lambdaTarget.isStaticMember) asm.Opcodes.H_INVOKESTATIC
13861387
else if (lambdaTarget.isPrivate || lambdaTarget.isClassConstructor) asm.Opcodes.H_INVOKESPECIAL
@@ -1400,7 +1401,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
14001401

14011402
// Requires https://github.com/scala/scala-java8-compat on the runtime classpath
14021403
val returnUnit = lambdaTarget.info.resultType.typeSymbol == UnitClass
1403-
val functionalInterfaceDesc: String = classBTypeFromSymbol(functionalInterface).descriptor
1404+
val functionalInterfaceDesc: String = generatedType.descriptor
14041405
val desc = capturedParamsTypes.map(tpe => toTypeKind(tpe)).mkString(("("), "", ")") + functionalInterfaceDesc
14051406
// TODO specialization
14061407
val constrainedType = new MethodBType(lambdaParamTypes.map(p => toTypeKind(p)), toTypeKind(lambdaTarget.tpe.resultType)).toASMType
@@ -1414,6 +1415,8 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
14141415
// boostrap args
14151416
applyN, targetHandle, constrainedType
14161417
)
1418+
1419+
generatedType
14171420
}
14181421
}
14191422
val lambdaMetaFactoryBootstrapHandle =

0 commit comments

Comments
 (0)