Skip to content

Commit

Permalink
Fix overloaded default methods test in RefChecks
Browse files Browse the repository at this point in the history
It used `cls.info` instead of `cls.thisType`, which caused symbols
accessible only through the self type of `cls` to be forgotten.

Fixes scala#18555
  • Loading branch information
odersky committed Apr 18, 2024
1 parent 95a8a9c commit 02533ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object RefChecks {
}}

for (name <- defaultMethodNames) {
val methods = clazz.info.member(name).alternatives.map(_.symbol)
val methods = clazz.thisType.member(name).alternatives.map(_.symbol)
val haveDefaults = methods.filter(_.hasDefaultParams)
if (haveDefaults.length > 1) {
val owners = haveDefaults map (_.owner)
Expand Down
14 changes: 14 additions & 0 deletions tests/pos/i18555.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trait GenericCollectionWithCommands {
self: PackSupport =>

def bar(foo: Int = 1): Any = ???
def bar(writer: GenericCollectionWithCommands.this.pack.Writer[Any]): Any = ???
}

trait PackSupport {
val pack: SerializationPack
}

trait SerializationPack {
type Writer[A]
}

0 comments on commit 02533ed

Please sign in to comment.