Skip to content

Commit 28cfb1a

Browse files
authored
Merge pull request #3285 from dotty-staging/fix-#3273
Fix #3273: Cook raw types
2 parents 4460551 + 628cc75 commit 28cfb1a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ object ClassfileParser {
2323
/** Indicate that there is nothing to unpickle and the corresponding symbols can
2424
* be invalidated. */
2525
object NoEmbedded extends Embedded
26+
27+
/** Replace raw types with wildcard applications */
28+
def cook(implicit ctx: Context) = new TypeMap {
29+
def apply(tp: Type): Type = tp match {
30+
case tp: TypeRef if tp.symbol.typeParams.nonEmpty =>
31+
AppliedType(tp, tp.symbol.typeParams.map(Function.const(TypeBounds.empty)))
32+
case tp @ AppliedType(tycon, args) =>
33+
// disregard tycon itself, but map over it to visit the prefix
34+
tp.derivedAppliedType(mapOver(tycon), args.mapConserve(this))
35+
case _ =>
36+
mapOver(tp)
37+
}
38+
}
2639
}
2740

2841
class ClassfileParser(
@@ -241,7 +254,7 @@ class ClassfileParser(
241254
addConstructorTypeParams(denot)
242255
}
243256

244-
denot.info = pool.getType(in.nextChar)
257+
denot.info = cook.apply(pool.getType(in.nextChar))
245258
if (isEnum) denot.info = ConstantType(Constant(sym))
246259
if (isConstructor) normalizeConstructorParams()
247260
setPrivateWithin(denot, jflags)

tests/pos/i3273/Foo_1.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface Foo_1 {
2+
void foo(java.util.List list);
3+
}

tests/pos/i3273/Test_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Test extends Foo_1 {
2+
override def foo(list: java.util.List[_]): Unit = ???
3+
}

0 commit comments

Comments
 (0)