Skip to content

Fix #9207: Properly erase self type of classes #9214

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 1 commit into from
Jun 22, 2020
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
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
case nil => nil
}
val erasedDecls = decls.filteredScope(sym => !sym.isType || sym.isClass)
tp.derivedClassInfo(NoPrefix, erasedParents, erasedDecls, erasedRef(tp.selfType))
val selfType1 = if cls.is(Module) then cls.sourceModule.termRef else NoType
tp.derivedClassInfo(NoPrefix, erasedParents, erasedDecls, selfType1)
// can't replace selftype by NoType because this would lose the sourceModule link
}
case _: ErrorType | JavaArrayType(_) =>
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i9207.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Child
class HelloTest {
def simpleTest(): Unit = {
trait Parent {
this: Child =>
final def bar: Int = bar
}
}
}