Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java generic signatures can't refer to type members #15093

Merged
merged 1 commit into from May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala
Expand Up @@ -9,7 +9,7 @@ import core.Definitions
import core.Flags._
import core.Names.Name
import core.Symbols._
import core.TypeApplications.TypeParamInfo
import core.TypeApplications.{EtaExpansion, TypeParamInfo}
import core.TypeErasure.{erasedGlb, erasure, isGenericArrayElement}
import core.Types._
import core.classfile.ClassfileConstants
Expand Down Expand Up @@ -166,6 +166,7 @@ object GenericSignatures {
// a type parameter or similar) must go through here or the signature is
// likely to end up with Foo<T>.Empty where it needs Foo<T>.Empty$.
def fullNameInSig(sym: Symbol): Unit = {
assert(sym.isClass)
val name = atPhase(genBCodePhase) { sanitizeName(sym.fullName).replace('.', '/') }
builder.append('L').nn.append(name)
}
Expand All @@ -183,11 +184,10 @@ object GenericSignatures {
boxedSig(bounds.lo)
}
else builder.append('*')
case PolyType(_, res) =>
builder.append('*') // scala/bug#7932
case EtaExpansion(tp) =>
argSig(tp)
case _: HKTypeLambda =>
fullNameInSig(tp.typeSymbol)
builder.append(';')
builder.append('*')
case _ =>
boxedSig(tp)
}
Expand Down
4 changes: 4 additions & 0 deletions tests/run/t7932.check
@@ -1,9 +1,13 @@
public Category C.category()
public Category C.category1()
public abstract Category<?> M2.category3()
public abstract Category<java.lang.Object> M2.category2()
public default Category<F> M1.category()
public default Category<scala.Tuple2> M1.category1()
public static Category M1.category$(M1)
public static Category M1.category1$(M1)
public abstract Category<?> M2.category3()
public abstract Category<java.lang.Object> M2.category2()
public default Category<F> M2.category()
public default Category<scala.Tuple2> M2.category1()
public static Category M2.category$(M2)
Expand Down
4 changes: 4 additions & 0 deletions tests/run/t7932.scala
Expand Up @@ -13,6 +13,10 @@ trait M1[F] {
trait M2[F] { self: M1[F] =>
override def category: Category[X] = null
override def category1: Category[Tuple2] = null

type T[A, B]
def category2: Category[T]
def category3: Category[[A, B] =>> T[B, A]]
}

abstract class C extends M1[Float] with M2[Float]
Expand Down