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
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ object RefChecks {
def info = self.memberInfo(sym1)
val infoStr =
if (sym1.isAliasType) i", which equals ${info.bounds.hi}"
else if (sym1.isAbstractOrParamType) i" with bounds$info"
else if (sym1.isAbstractOrParamType && info != TypeBounds.empty) i" with bounds$info"
else if (sym1.is(Module)) ""
else if (sym1.isTerm) i" of type $info"
else ""
Expand Down Expand Up @@ -430,6 +430,10 @@ object RefChecks {
// direct overrides were already checked on completion (see Checking.chckWellFormed)
// the test here catches indirect overriddes between two inherited base types.
overrideError("cannot be used here - class definitions cannot be overridden")
else if (other.isOpaqueAlias)
// direct overrides were already checked on completion (see Checking.chckWellFormed)
// the test here catches indirect overriddes between two inherited base types.
overrideError("cannot be used here - opaque type aliases cannot be overridden")
else if (!other.is(Deferred) && member.isClass)
overrideError("cannot be used here - classes can only override abstract types")
else if other.isEffectivelyFinal then // (1.2)
Expand Down
13 changes: 13 additions & 0 deletions tests/neg/i14659.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trait Foo {
opaque type Out = Int
def out1: Out
def out2: Out = out1
}

object Bar extends Foo {
override opaque type Out = String // error
override def out1 = "abc"
}

@main def run() =
val x = Bar.out2