Skip to content

Fix #3273: Cook raw types #3285

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

Merged
merged 2 commits into from
Oct 8, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ object ClassfileParser {
/** Indicate that there is nothing to unpickle and the corresponding symbols can
* be invalidated. */
object NoEmbedded extends Embedded

/** Replace raw types with wildcard applications */
def cook(implicit ctx: Context) = new TypeMap {
def apply(tp: Type): Type = tp match {
case tp: TypeRef if tp.symbol.typeParams.nonEmpty =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro-optimization: prefer !isEmpty, nonEmpty is a trait method

AppliedType(tp, tp.symbol.typeParams.map(Function.const(TypeBounds.empty)))
case tp @ AppliedType(tycon, args) =>
// disregard tycon itself, but map over it to visit the prefix
tp.derivedAppliedType(mapOver(tycon), args.mapConserve(this))
case _ =>
mapOver(tp)
}
}
}

class ClassfileParser(
Expand Down Expand Up @@ -241,7 +254,7 @@ class ClassfileParser(
addConstructorTypeParams(denot)
}

denot.info = pool.getType(in.nextChar)
denot.info = cook.apply(pool.getType(in.nextChar))
if (isEnum) denot.info = ConstantType(Constant(sym))
if (isConstructor) normalizeConstructorParams()
setPrivateWithin(denot, jflags)
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i3273/Foo_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface Foo_1 {
void foo(java.util.List list);
}
3 changes: 3 additions & 0 deletions tests/pos/i3273/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Test extends Foo_1 {
override def foo(list: java.util.List[_]): Unit = ???
}