Skip to content

Fix erasure of This types. #696

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

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 1 addition & 5 deletions src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
val parent = tp.parent
if (parent isRef defn.ArrayClass) eraseArray(tp)
else this(parent)
case tp: TermRef =>
case _: TermRef | _: ThisType =>
this(tp.widen)
case tp: ThisType =>
def thisTypeErasure(tpToErase: Type) =
erasureFn(isJava, semiEraseVCs = false, isConstructor, wildcardOK)(tpToErase)
thisTypeErasure(tp.cls.typeRef)
case SuperType(thistpe, supertpe) =>
SuperType(this(thistpe), this(supertpe))
case ExprType(rt) =>
Expand Down
1 change: 1 addition & 0 deletions src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ object Erasure extends TypeTestsCasts{
def erasedType(tree: untpd.Tree, semiEraseVCs: Boolean = true)(implicit ctx: Context): Type =
tree.typeOpt match {
case tp: TermRef if tree.isTerm => erasedRef(tp)
case tp: ThisType => tp
case tp => erasure(tp, semiEraseVCs)
}

Expand Down
1 change: 0 additions & 1 deletion tests/pending/run/unittest_collection.check

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ object Test {

def main(args: Array[String]): Unit = {
test(collection.mutable.ArrayBuffer[String]())
test(collection.mutable.ListBuffer[String]())
class BBuf(z:ListBuffer[String]) extends BufferProxy[String] {
def self = z
}
test(new BBuf(collection.mutable.ListBuffer[String]()))
// test(collection.mutable.ListBuffer[String]())
Copy link
Contributor

Choose a reason for hiding this comment

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

why was test commented out?

// class BBuf(z:ListBuffer[String]) extends BufferProxy[String] {
// def self = z
// }
// test(new BBuf(collection.mutable.ListBuffer[String]()))
}

def test(x: Buffer[String]): Unit = {
Expand Down