Skip to content
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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
thirdTryNamed(tp2)
else
( (tp1.name eq tp2.name)
&& !sym1.is(Private)
&& tp2.isPrefixDependentMemberRef
&& isSubPrefix(tp1.prefix, tp2.prefix)
&& tp1.signature == tp2.signature
Expand Down
10 changes: 10 additions & 0 deletions tests/neg/i16850.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- [E007] Type Mismatch Error: tests/neg/i16850.scala:7:33 -------------------------------------------------------------
7 | def add(elm: Y): Unit = list = elm :: list // error
| ^^^
| Found: (elm : Y)
| Required: Class.this.Y²
|
| where: Y is a type in class Class
| Y² is a type in trait Trait
|
| longer explanation available when compiling with `-explain`
10 changes: 10 additions & 0 deletions tests/neg/i16850.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

trait Trait :
type Y
var list: List[Y] = Nil

class Class[Y] extends Trait :
def add(elm: Y): Unit = list = elm :: list // error

object Object extends Class[Int] :
add(42)