Skip to content

Commit

Permalink
Remap correctly on covariant return and synthetic methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Aug 8, 2020
1 parent fe0f684 commit 06c82ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'io.izzel.arclight'
version '1.7'
version '1.8'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.izzel.arclight.gradle.tasks

import com.google.common.collect.MultimapBuilder
import com.google.common.collect.SetMultimap
import io.izzel.arclight.gradle.Utils
import net.md_5.specialsource.InheritanceMap
import net.md_5.specialsource.Jar
Expand All @@ -10,11 +12,7 @@ import net.md_5.specialsource.provider.JarProvider
import net.md_5.specialsource.provider.JointProvider
import net.md_5.specialsource.transformer.MappingTransformer
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.*
import org.objectweb.asm.Type
import org.objectweb.asm.commons.Remapper

Expand Down Expand Up @@ -73,6 +71,16 @@ class ProcessMappingTask extends DefaultTask {
!it.startsWith('#') && !it.trim().empty
}.collect { it.toString() }
processors.forEach { it.call(csrg, ats, srg) }
def srgMethodAlias = MultimapBuilder.hashKeys().hashSetValues().build() as SetMultimap<String, String>
srg.methods.entrySet().forEach {
def spl = it.key.split(' ')
def srgMethod = it.value
if (srgMethod.startsWith('func_')) {
def i = spl[0].lastIndexOf('/')
def notch = spl[0].substring(i + 1)
srgMethodAlias.put(srgMethod, notch)
}
}
def srgRev = srg.classes.collectEntries { [(it.value): it.key] }
def csrgRev = csrg.classes.collectEntries { [(it.value): it.key] }
def im = new InheritanceMap()
Expand Down Expand Up @@ -195,6 +203,18 @@ class ProcessMappingTask extends DefaultTask {
def csrgCl = notchToCsrgMapper.map(owner)
def csrgDesc = notchToCsrgMapper.mapMethodDesc(desc)
def csrgMethod = ProcessMappingTask.findCsrg(prov, csrgCl, notch, csrgDesc, csrg.methods)
if (csrgMethod == null) {
for (def alias : srgMethodAlias.get(srgMethod)) {
if (alias != notch) {
def find = ProcessMappingTask.findCsrg(prov, csrgCl, alias, csrgDesc, csrg.methods)
if (find != null) {
csrgMethod = find
break
}
}
}
}
if (csrgMethod == null) csrgMethod = notch
writer.println("MD: $csrgCl/$csrgMethod $csrgDesc ${srg.classes.get(owner)}/$srgMethod ${notchToSrgMapper.mapMethodDesc(desc)}")
}
}
Expand All @@ -209,7 +229,7 @@ class ProcessMappingTask extends DefaultTask {
if (csrg) return csrg
}
}
return notch
return null
}

private static List<String> allRet(InheritanceProvider prov, String desc) {
Expand Down

0 comments on commit 06c82ab

Please sign in to comment.