Skip to content

Commit

Permalink
Woraround for scala/scala3#18816
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed Dec 20, 2023
1 parent 4785cc4 commit 37275c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,11 @@ class Scala3Unpickler(
if adapted then tpe.erasedAsReturnType.toString == "void"
else method.returnType.forall(matchType(tpe.erasedAsReturnType, _))
val classOwners = getOwners(binaryClass)
val sourceSpan = removeInlinedLines(method.sourceLines, classOwners).interval
val sourceSpan =
if classOwners.size == 2 && method.allParameters.filter(p => p.name.matches("\\$this\\$\\d+")).nonEmpty then
// workaround of https://github.com/lampepfl/dotty/issues/18816
removeInlinedLines(method.sourceLines, classOwners).maxOption.toSeq
else removeInlinedLines(method.sourceLines, classOwners)
for
classOwner <- classOwners
byNameArg <- collectTrees1(classOwner, sourceSpan)(inlined => {
Expand Down Expand Up @@ -793,7 +797,11 @@ class Scala3Unpickler(
matcher: Boolean => PartialFunction[TermSymbol, BinaryMethodSymbol]
): Seq[BinaryMethodSymbol] =
val owners = getOwners(binaryClass)
val sourceLines = removeInlinedLines(javaMethod.sourceLines, owners)
val sourceLines =
if owners.size == 2 && javaMethod.allParameters.filter(p => p.name.matches("\\$this\\$\\d+")).nonEmpty then
// workaround of https://github.com/lampepfl/dotty/issues/18816
removeInlinedLines(javaMethod.sourceLines, owners).maxOption.toSeq
else removeInlinedLines(javaMethod.sourceLines, owners)
for
owner <- owners
term <- collectTrees1(owner, sourceLines) { inlined =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ class Scala3UnpicklerStats extends munit.FunSuite:

for
cls <- loadClasses(jars, "scala3-compiler_3-3.3.0", binaryClassLoader)
// if cls.name == "dotty.tools.dotc.core.Types$TermLambda"
// if cls.name == "dotty.tools.dotc.transform.ExplicitOuter$OuterOps$"
clsSym <- cls match
case Patterns.LocalClass(_, _, _) => unpickler.tryFind(cls, localClassCounter)
case Patterns.AnonClass(_, _) => unpickler.tryFind(cls, anonClassCounter)
case Patterns.InnerClass(_) => unpickler.tryFind(cls, innerClassCounter)
case _ => unpickler.tryFind(cls, topLevelClassCounter)
method <- cls.declaredMethods
// if method.name == "dotty$tools$dotc$core$Types$TermLambda$$_$compute$1$"
// if method.name == "path$extension$$anonfun$1"
do
method match
case Patterns.AnonFun(_) => unpickler.tryFind(method, anonFunCounter)
case Patterns.AdaptedAnonFun(_) => unpickler.tryFind(method, adaptedAnonFunCounter)
case Patterns.LocalLazyInit(_) => unpickler.tryFind(method, localLazyInitCounter)
case Patterns.LocalMethod(_) => unpickler.tryFind(method, localMethodCounter)
case _ => unpickler.tryFind(method, methodCounter)
localMethodCounter.printNotFound()
anonFunCounter.printNotFound()
methodCounter.printNotFound()
localClassCounter.printReport()
anonClassCounter.printReport()
Expand All @@ -81,8 +81,8 @@ class Scala3UnpicklerStats extends munit.FunSuite:
checkCounter(anonClassCounter, 430)
checkCounter(innerClassCounter, 2409)
checkCounter(topLevelClassCounter, 1505)
checkCounter(localMethodCounter, 2605, expectedAmbiguous = 2, expectedNotFound = 1)
checkCounter(anonFunCounter, 6649, expectedAmbiguous = 331, expectedNotFound = 5)
checkCounter(localMethodCounter, 2606, expectedAmbiguous = 2)
checkCounter(anonFunCounter, 6651, expectedAmbiguous = 331, expectedNotFound = 3)
checkCounter(adaptedAnonFunCounter, 288, expectedAmbiguous = 83)
checkCounter(localLazyInitCounter, 108)
checkCounter(methodCounter, 57744, expectedAmbiguous = 128)
Expand Down

0 comments on commit 37275c3

Please sign in to comment.